代码之家  ›  专栏  ›  技术社区  ›  JesperE

在Windows上的Emacs中从“grep find”运行时,ACK不工作

  •  4
  • JesperE  · 技术社区  · 15 年前

    我想用 ack-grep 作为Windows Emacs中grep+find的替代,但ack grep会立即(成功)退出,而不打印任何匹配项。我尝试过将所有可能的命令行参数组合成ACKgrep,但似乎没有任何效果。

    M-x grep-find
    

    输入“ack html”搜索包含“html”的文件。ACK立即退出,不打印任何内容:

    -*- 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”的许多不同文件)。

    有什么想法吗?

    3 回复  |  直到 12 年前
        1
  •  8
  •   cjm    15 年前

    在Windows的Emacs下运行ACK时,我发现它有时会对是否应该搜索文件或从stdin读取感到困惑。这是我用来调用ACK的函数(使用 M-x ack )你可以把这个放进去 .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)))
    
        2
  •  0
  •   Denis Howe    12 年前

    (setq grep-find-command "ack <nul -i ")

        3
  •  0
  •   Tom Gruff    12 年前

    我也有类似的问题 ack-and-a-half 模块,关闭stdin也完成了这个技巧。Github上有一个问题: https://github.com/jhelwig/ack-and-a-half/issues/23

    推荐文章