gpt4 book ai didi

git - magit-grep,如何包含或排除文件扩展名?

转载 作者:太空狗 更新时间:2023-10-29 13:30:50 28 4
gpt4 key购买 nike

我想给 magit-grep 一些选项

使用选项 foo 运行它会导致

git --no-pager grep -n foo

我想给它一个选项

git --no-pager grep -n foo (options to include *.html and exclude *.py, etc)

不一定是magit-grep,emacs中最好的git grep解决方案是什么?


魔术师

(magit-define-command grep (&optional pattern)
(interactive)
(let ((pattern (or pattern
(read-string "git grep: "
(shell-quote-argument (grep-tag-default))))))
(with-current-buffer (generate-new-buffer "*Magit Grep*")
(let ((default-directory (magit-get-top-dir)))
(insert magit-git-executable " "
(mapconcat 'identity magit-git-standard-options " ")
" grep -n "
(shell-quote-argument pattern) "\n\n")
(magit-git-insert (list "grep" "--line-number" pattern))
(grep-mode)
(pop-to-buffer (current-buffer))))))

最佳答案

我已经删除了 magit-grep,因为它只是 rgrep 的严重损坏版本。 vc-git-grep 实际上是一个改进,所以你应该使用它。 (如今 magit-grep 被定义为 vc 命令的别名,以避免打扰以前使用过 magit 变体的任何人。“通过查看其他地方已经存在的内容添加功能然后删除我们的功能”的经典案例代码”:-)

关于git - magit-grep,如何包含或排除文件扩展名?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17735829/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com