Emacs: Use helm-do-grep-ag on untracked git files

master
Pierre Neidhardt 2016-10-12 09:13:03 +05:30
parent 17f2455b34
commit a3566d548c
1 changed files with 5 additions and 2 deletions

View File

@ -21,10 +21,13 @@
(setq helm-grep-ag-command "pt -S --hidden --color --nogroup %s %s %s")
(defun helm-grep-git-or-ag (arg)
"Run `helm-grep-do-git-grep' if possible; fallback to `helm-do-grep-ag' otherwise."
"Run `helm-grep-do-git-grep' if possible; fallback to `helm-do-grep-ag' otherwise.
Requires `call-process-to-string' from `functions'."
(interactive "P")
(require 'vc)
(if (vc-find-root default-directory ".git")
(require 'functions)
(if (and (vc-find-root default-directory ".git")
(or arg (split-string (call-process-to-string "git" "ls-files" "-z") "\0" t)))
(helm-grep-do-git-grep arg)
(helm-do-grep-ag arg)))