0

我正在使用 igrep.el 包并喜欢它。不过有一件事让我很困扰。在 igrep 结果页面中,第一行和最后一行作为编译的一部分被突出显示,因此使用 next-error 循环遍历结果最终会在没有相应文件的情况下命中这两行。

这些是第一个和最后一个文件的格式:

Igrep started at Thu Aug  1 15:15:23

finished (matches found) at Thu Aug  1 15:15:27

我相信这是负责将这些行一起显示的代码。如何禁用这些行在 grep 结果中显示或至少不将它们作为结果的一部分突出显示:

(if igrep-find
(setq command
      (igrep-format-find-command command files)))
(cond ((eq igrep-save-buffers t) (save-some-buffers t))
  (igrep-save-buffers (save-some-buffers)))
(if (fboundp 'compilation-start)    ; Emacs 22
    (let ((compilation-process-setup-function 'grep-process-setup))
      (or (fboundp 'igrep-mode)
          (define-derived-mode igrep-mode grep-mode "Igrep"))
      (compilation-start command
                         'igrep-mode
                         nil
                         (cond ((eq compilation-highlight-regexp t))
                               (compilation-highlight-regexp
                                (if (eq program "fgrep")
                                    (regexp-quote regex)
                                  regex)))))
  (compile-internal command (format "No more %s matches" program)
                    "Igrep" nil grep-regexp-alist))))
4

1 回答 1

1

问题是这些行的正则表达式需要“Grep”,而不是“Igrep”。作为一个快速破解,您可以用“Grep”替换那段代码的两个“Igrep”字符串。

一个不那么 hacky 的解决方案是添加到grep-mode-font-lock-keywords这些正则表达式的表达式中。这很容易:只需查看该 var 的当前值,并将以“^Grep”开头的正则表达式复制到以“^Igrep”开头的类似表达式

于 2013-08-02T07:07:44.207 回答