Display search command & directory in helm header

Displays the full command (minus formatting options) and target
directory rather than the unhelpful "The Silver Searcher", even if we're
using ripgrep or pt.
This commit is contained in:
Henrik Lissner 2018-08-17 03:56:45 +02:00
parent 7a578eb242
commit 1a6519aa45
No known key found for this signature in database
GPG key ID: 5F6C0EA160557395

View file

@ -44,18 +44,20 @@ workspace."
;; ;;
(defun +helm-ag-search-args (all-files-p recursive-p) (defun +helm-ag-search-args (all-files-p recursive-p)
(list "ag -S" (list (concat "ag " (if IS-WINDOWS "--vimgrep" "--nocolor --nogroup"))
(if IS-WINDOWS "--vimgrep" "--nocolor --nogroup") "-S"
(if all-files-p "-z -a") (if all-files-p "-z -a")
(unless recursive-p "--depth 1"))) (unless recursive-p "--depth 1")))
(defun +helm-rg-search-args (all-files-p recursive-p) (defun +helm-rg-search-args (all-files-p recursive-p)
(list "rg -S --no-heading --line-number --color never" (list "rg --no-heading --line-number --color never"
"-S"
(when all-files-p "-z -uu") (when all-files-p "-z -uu")
(unless recursive-p "--maxdepth 1"))) (unless recursive-p "--maxdepth 1")))
(defun +helm-pt-search-args (all-files-p recursive-p) (defun +helm-pt-search-args (all-files-p recursive-p)
(list "pt -S --nocolor --nogroup -e" (list "pt --nocolor --nogroup -e"
"-S"
(if all-files-p "-z -a") (if all-files-p "-z -a")
(unless recursive-p "--depth 1"))) (unless recursive-p "--depth 1")))
@ -153,6 +155,12 @@ order.
('grep (+helm--grep-search directory query prompt all-files recursive) ('grep (+helm--grep-search directory query prompt all-files recursive)
(cl-return t)))) (cl-return t))))
(helm-ag-base-command (string-join command " "))) (helm-ag-base-command (string-join command " ")))
;; TODO Define our own sources instead
(helm-attrset 'name (format "[%s %s] Searching %s"
engine
(string-join (delq nil (cdr command)) " ")
(abbreviate-file-name directory))
helm-source-do-ag)
(cl-letf ((+helm-global-prompt prompt) (cl-letf ((+helm-global-prompt prompt)
((symbol-function 'helm-do-ag--helm) ((symbol-function 'helm-do-ag--helm)
(lambda () (helm :sources '(helm-source-do-ag) (lambda () (helm :sources '(helm-source-do-ag)