更改emacs中的默认find-grep命令

Joe*_*oey 5 linux emacs fish

当我find-grep在emacs中执行命令时find . -type f -exec grep -nH -e {} +,由于要使用fish shell作为默认shell,因此我必须执行该命令find . -type f -exec grep -nH -e \{\} +

我试图修改emacs源代码,以下是我的更改:

/usr/share/emacs/24.4/lisp/ldefs-boot.el 12669行: If `exec-plus' use `find -exec \{\} +'.

/usr/share/emacs/24.4/lisp/loaddefs.el 12669行: If `exec-plus' use `find -exec \{\} +'.

但它并没有任何意义,当我执行find-grep仍显示find . -type f -exec grep -nH -e {} +。谁能告诉我我在哪里做错了,或者我应该如何解决?

tri*_*eee 5

您更改的文本看起来不像可执行代码。可能您只是更改了一个文档字符串(实际上,谷歌搜索显示这是在 的文档字符串中grep-find-use-xargs)。但是 Emacs 是非常可定制的;您所要做的就是将 的值设置grep-find-template为更适合您个人,您自己.emacs/init.el或类似的东西。

(setq grep-find-template
      "find <D> <X> -type f <F> -exec grep <C> -nH -e <R> \\{\\} +")
Run Code Online (Sandbox Code Playgroud)

请参阅手册以获取更多文档,当然还有内置文档 ( ctrl-h v grep-find-template RET)。

实际的源代码在http://git.savannah.gnu.org/cgit/emacs.git/tree/lisp/progmodes/grep.el#n174但你真的,真的,真的不想编辑源代码. 无需更改代码的用户级可定制性是 Emacs 的基础设计之一。学习使用这个设施。

  • 不,不要修改文件。只需覆盖您需要在您自己的个人 init 文件中覆盖的内容。对源的任何更改都将随着下一次升级而丢失,并且在多用户系统上,您正在破坏其他所有人。 (2认同)

小智 5

(grep-apply-setting 'grep-find-command '("find . -type f -exec grep -nH -e  \\{\\} +" . 34))
Run Code Online (Sandbox Code Playgroud)

将把光标放在-e