Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/ssis/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Emacs rgrep自定义_Emacs_Elisp - Fatal编程技术网

Emacs rgrep自定义

Emacs rgrep自定义,emacs,elisp,Emacs,Elisp,我在~/.emacs中有以下自定义函数: (defun xi-rgrep (term) (grep-compute-defaults) (interactive "sSearch Term: ") (rgrep term "*.[ch]*" "../")) 这个函数只是针对我感兴趣的文件/目录中输入的术语运行rgrep。但是,我想匹配原始的rgrep功能,即让默认搜索词成为该点上的单词(我认为这就是术语?)。我如何做到这一点?我尝试过几件事,包括运行(grep read r

我在~/.emacs中有以下自定义函数:

(defun xi-rgrep (term)
  (grep-compute-defaults)
    (interactive "sSearch Term: ")
    (rgrep term "*.[ch]*" "../"))
这个函数只是针对我感兴趣的文件/目录中输入的术语运行rgrep。但是,我想匹配原始的rgrep功能,即让默认搜索词成为该点上的单词(我认为这就是术语?)。我如何做到这一点?我尝试过几件事,包括运行(grep read regexp),但都没有成功。

您可以像这样使用该软件包:

(require 'thingatpt)
(defun xi-rgrep (term)
   (interactive (list (completing-read "Search Term: " nil nil nil (thing-at-point 'word))))
  (grep-compute-defaults)
  (rgrep term "*.[ch]*" "../"))

下面是另一种不需要包并使用(grep read regexp)的方法:

我更喜欢这样,因为如果您想用符号(例如下划线)来表示单词,则需要设置边界,这通常是变量的情况

(defun xi-rgrep ()
  (interactive)
  (grep-compute-defaults)
  (rgrep (grep-read-regexp) "*.[ch]*" "../"))