branch: externals/counsel commit b68f91beec3eb1e2afa0dc6dd0d9a751dab7ac8e Author: Daanturo <daant...@gmail.com> Commit: Basil L. Contovounesios <conto...@tcd.ie>
counsel-locate: honor locate-command * counsel.el (counsel-locate-cmd-default) (counsel-locate-cmd-noregex): Use `locate-command` from `locate.el` instead of hard-coding "locate" (#2859). (counsel-locate): Load `locate.el` for this. --- counsel.el | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/counsel.el b/counsel.el index e6c2c43..6655a6c 100644 --- a/counsel.el +++ b/counsel.el @@ -2617,18 +2617,23 @@ string - the full shell command to run." "Use `dired-jump' on X." (dired-jump nil x)) +(defvar locate-command) + (defun counsel-locate-cmd-default (input) "Return a `locate' shell command based on regexp INPUT." - (counsel-require-program "locate") - (format "locate -i --regex %s" + (counsel-require-program locate-command) + (format "%s -i --regex %s" + locate-command (shell-quote-argument (counsel--elisp-to-pcre (ivy--regex input))))) (defun counsel-locate-cmd-noregex (input) "Return a `locate' shell command based on INPUT." - (counsel-require-program "locate") - (format "locate -i %s" (shell-quote-argument input))) + (counsel-require-program locate-command) + (format "%s -i %s" + locate-command + (shell-quote-argument input))) (defun counsel-locate-cmd-mdfind (input) "Return a `mdfind' shell command based on INPUT." @@ -2684,6 +2689,8 @@ string - the full shell command to run." "Call a \"locate\" style shell command. INITIAL-INPUT can be given as the initial minibuffer input." (interactive) + ;; For `locate-command', which is honored in some options of `counsel-locate-cmd'. + (require 'locate) (counsel--locate-updatedb) (ivy-read "Locate: " #'counsel-locate-function :initial-input initial-input