我正在使用 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))))