[英]Interactive Elisp Function to Directly Search File Names with `emacs-helm-ag` (-g option)
我使用emacs-helm-ag搜索项目中的文件内容和文件名。 我的emacs-helm-ag
配置为:
; Helm Ag mode
(add-to-list 'load-path "~/.emacs.d/emacs-helm-ag")
(require 'helm-ag)
(custom-set-variables
'(helm-ag-base-command "ag --nocolor --nogroup")
'(helm-ag-command-option "--hidden --ignore *~ --ignore .git --ignore .idea"))
(global-set-key (kbd "M-s s") 'helm-do-ag-project-root)
要搜索文件内容 (所有项目文件中的单词),请按Ms s
并键入要搜索的单词。
要搜索文件名 (项目所有文件列表中的文件),请按Ms s
键,然后键入-g
(我想自动执行此步骤),然后键入要搜索的文件名。
问题 。 请您帮我提供一个elisp
交互功能,该功能可以通过自动插入-g
命令行选项直接搜索项目中的文件名(最好重用emacs-helm-ag
包中的helm-do-ag-project-root
),并且仅要求最终用户键入文件名。 我希望有一个交互式功能来搜索项目中的文件名,并能够使用其他键绑定来调用该功能。 类似于:
(global-set-key (kbd "M-s f") 'helm-do-ag-project-root-file-names)
根据DasEwigeLicht在Reddit上的建议,我创建了一个函数,该函数可以根据我的问题要求使用ag -g <pattern>
在项目中搜索文件名。 该函数是:
(defun helm-do-ag-project-root-search-file-names ()
"Searches file names in a project using ag -g <pattern> command line tool"
(interactive)
(let ((helm-ag-command-option (concat helm-ag-command-option " -g")))
(helm-do-ag-project-root)))
(global-set-key (kbd "M-s f") 'helm-do-ag-project-root-search-file-names)
非常感谢DasEwigeLicht的有用建议!
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.