From 11b8ee55a1310d2bc8e7cced52ac447d38a27990 Mon Sep 17 00:00:00 2001 From: Henrik Lissner Date: Wed, 15 Aug 2018 19:44:09 +0200 Subject: [PATCH] Use helm-do-ag instead of helm-ag #805 Fixes project search matching against the leading file name. And ensures modeline remains disabled. --- modules/completion/helm/autoload/helm.el | 18 ++++++------------ modules/completion/helm/config.el | 12 ++++++++---- 2 files changed, 14 insertions(+), 16 deletions(-) diff --git a/modules/completion/helm/autoload/helm.el b/modules/completion/helm/autoload/helm.el index c9d8162d2..ea0c874c4 100644 --- a/modules/completion/helm/autoload/helm.el +++ b/modules/completion/helm/autoload/helm.el @@ -153,18 +153,12 @@ order. ('grep (+helm--grep-search directory query prompt all-files recursive) (cl-return t)))) (helm-ag-base-command (string-join command " "))) - (if (and (eq engine 'ag) - (equal query "")) - (helm-do-ag directory) - (setq helm-ag--last-query query) - (helm-attrset 'search-this-file nil helm-ag-source) - (helm-attrset 'name (helm-ag--helm-header helm-ag--default-directory) helm-ag-source) - (helm :sources '(helm-ag-source) - :input query - :prompt prompt - :buffer "*helm-ag*" - :keymap helm-ag-map - :history 'helm-ag--helm-history)))) + (when (> (length query) 0) + (setcdr (assq 'requires-pattern helm-source-do-ag) 1)) + (cl-letf (((symbol-function 'helm-ag--marked-input) (lambda (_escape) query))) + (helm-do-ag directory) + ;; restore default + (setcdr (assq 'requires-pattern helm-source-do-ag) 3)))) (defun +helm--get-command (format) (cl-loop for tool in (cl-remove-duplicates +helm-project-search-engines :from-end t) diff --git a/modules/completion/helm/config.el b/modules/completion/helm/config.el index 9490b9f74..c30bbd0a9 100644 --- a/modules/completion/helm/config.el +++ b/modules/completion/helm/config.el @@ -114,10 +114,14 @@ be negative.") plist))) (advice-add #'helm :filter-args #'+helm*replace-prompt) - (defun +helm*hide-mode-line (&rest _) - (unless helm-mode-line-string - (hide-mode-line-mode +1))) - (advice-add #'helm-display-mode-line :override #'+helm*hide-mode-line) + ;; Hide the modeline + (defun +helm|hide-mode-line (&rest _) + (with-current-buffer (helm-buffer-get) + (unless helm-mode-line-string + (hide-mode-line-mode +1)))) + (add-hook 'helm-after-initialize-hook #'+helm|hide-mode-line) + (advice-add #'helm-display-mode-line :override #'+helm|hide-mode-line) + (advice-add #'helm-ag-show-status-default-mode-line :override #'ignore) (defun +helm*hide-minibuffer-maybe () "Hide minibuffer in Helm session if we use the header line as input field."