From a3566d548c8e40493d2a4367d86293fa33ace713 Mon Sep 17 00:00:00 2001 From: Pierre Neidhardt Date: Wed, 12 Oct 2016 09:13:03 +0530 Subject: [PATCH] Emacs: Use helm-do-grep-ag on untracked git files --- .emacs.d/lisp/tool-helm.el | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/.emacs.d/lisp/tool-helm.el b/.emacs.d/lisp/tool-helm.el index 7c98d1a5..954c53ac 100644 --- a/.emacs.d/lisp/tool-helm.el +++ b/.emacs.d/lisp/tool-helm.el @@ -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)))