从“grep-find”运行时,ack不起作用在Windows上的Emacs [英] ack does not work when run from "grep-find" in Emacs on Windows
问题描述
我正在尝试使用 ack-grep 作为Windows上Emacs中的grep + find的替代品,但是ack-grep立即(成功)退出,不打印任何匹配。我已经尝试了命令行参数与ack-grep的每一个可想到的组合,但似乎没有任何效果。
I'm trying to use ack-grep as a replacement for grep + find in Emacs on Windows, but ack-grep exits immediately (successfully) without printing any matches. I've tried just about every conceivable combination of command-line parameters to ack-grep, but nothing seems to work.
M-x grep-find
输入ack html来搜索包含html的文件。 Ack立即退出,不打印:
Enter "ack html" to search for files containing "html". Ack exits immediately, printing nothing:
-*- mode: grep; default-directory: "c:/" -*-
Grep started at Tue Feb 23 23:50:52
ack html
Grep finished (matches found) at Tue Feb 23 23:50:52
执行相同的命令ack html在 cmd.exe
正常工作(显示包含字符串html的各种文件。
Executing the same command "ack html" in cmd.exe
works fine (showing lots of various files containing the string "html".
任何想法? >
Any ideas?
推荐答案
在Windows下的Emacs下运行ack时,我发现有时候是否应该搜索文件或从STDIN读取,这是我使用的函数调用ack(使用 Mx ack
),您可以将其放在 .emacs
中。
When running ack under Emacs in Windows, I found it sometimes got confused about whether it was supposed to search files or read from STDIN. Here's the function I use to call ack (use M-x ack
). You can put this in .emacs
.
(defvar ack-command "ack --nogroup --nocolor ")
(defvar ack-history nil)
(defvar ack-host-defaults-alist nil)
(defun ack ()
"Like grep, but using ack-command as the default"
(interactive)
; Make sure grep has been initialized
(if (>= emacs-major-version 22)
(require 'grep)
(require 'compile))
; Close STDIN to keep ack from going into filter mode
(let ((null-device (format "< %s" null-device))
(grep-command ack-command)
(grep-history ack-history)
(grep-host-defaults-alist ack-host-defaults-alist))
(call-interactively 'grep)
(setq ack-history grep-history
ack-host-defaults-alist grep-host-defaults-alist)))
这篇关于从“grep-find”运行时,ack不起作用在Windows上的Emacs的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!