emacs - 如何在Emacs中的git grep命令中使用M-x rgrep?

标签 emacs grep elisp

我希望能够使用常规的M-x rgrep工作流程(输入路径,模式并在*grep*缓冲区中显示链接的结果),但要使用git grep而不是常规的find命令:

find . -type f -exec grep -nH -e  {} +

我尝试直接设置grep-find-command变量:
(setq grep-find-command "git grep")

并使用grep-apply-setting
(grep-apply-setting 'grep-find-command "git grep")

但似乎都行不通。当我运行M-x rgrep时,它只使用与以前相同的find命令。

实际上,我现在很确定rgrep甚至不使用grep-find-command变量,但是我不知道它的命令存储在哪里。

最佳答案

M-x vc-git-grep(C-x v f)呢?那不是您所需要的吗?

它会提示您:

  • 搜索模式(默认值:点或区域处的标记)
  • 文件名模式(默认值:当前文件后缀)
  • 基本搜索目录(默认,当前目录)

  • 对我来说很好。

    关于emacs - 如何在Emacs中的git grep命令中使用M-x rgrep?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25633490/

    相关文章:

    emacs - org-mode 不喜欢 c++-mode

    c - 防止 CEDET 语义解析某些文件类型

    emacs - 在批处理模式下使用 emacs 转储带有语法突出显示的文件?

    linux - ls -l 和 grep 不能一起工作

    emacs - 如何用Emacs Calendar在Lisp中实现二十四节气

    emacs - elisp中如何管理底层接口(interface)的变化

    linux - Grep 查找文件中的双正斜杠和星号

    grep 中的正则表达式用于包含 A、B、C...但不包含 Z 的文件

    Emacs 口齿不清 "shell-command-on-region"

    emacs - 为什么 elisp 函数不起作用(如我所料)?