emacs中grep-find的默认字符串

Zit*_*rax 7 emacs grep dot-emacs

我经常在emacs中使用命令grep-find来搜索我的源文件,但是它总是在临时文件和备份文件中找到匹配项等等.grep-find的默认命令是:

find . -type f -print0 | xargs -0 -e grep -nH -e
Run Code Online (Sandbox Code Playgroud)

我知道我可以在运行之前对其进行修改以满足我的需求,但是如何更改它以使其在启动时正确?

Tre*_*son 8

grep软件包预先计算了一堆默认值(但不一定在包加载时).所以你想要让它发生,然后重新定义find命令.就像是:

(grep-compute-defaults)
(setq grep-find-command "find . ! -name \"*~\" ! -name \"#*#\" -type f -print0 | xargs -0 -e grep -nH -e ")
Run Code Online (Sandbox Code Playgroud)

  • 我不得不在Emacs 24中使用`grep-apply-setting`:`(grep-apply-setting'grep-find-command"find.!-name \"*〜\"!-name \"#*#\" -type f -print0 | xargs -0 -e grep -nH -e")` (4认同)

san*_*inc 7

如果使用lgrep或rgrep而不是grep-find,则可以提前设置忽略的文件/目录:

(eval-after-load "grep"
  '(progn
    (add-to-list 'grep-find-ignored-files "*.tmp")
    (add-to-list 'grep-find-ignored-directories "_darcs")))
Run Code Online (Sandbox Code Playgroud)