diff options
author | Thierry Volpiatto <thierry.volpiatto@gmail.com> | 2017-01-04 07:50:56 +0100 |
---|---|---|
committer | Thierry Volpiatto <thierry.volpiatto@gmail.com> | 2017-01-04 07:55:13 +0100 |
commit | 8f91682a46f236279b70e103f08f368eb35875ad (patch) | |
tree | a1e11ad547d64812e816da99123a18afb61b6953 /helm-locate.el | |
parent | add846c1d07a6d7b0713be50d1a436f4d1656058 (diff) |
Match only on basename in locate when fuzzy enabled.
Allow customizing which sort fn to use for fuzzy.
* helm-locate.el (helm-locate-fuzzy-sort-fn): New.
(helm-locate-with-db): Do it.
(helm-locate-init): Use helm-locate-fuzzy-sort-fn.
Diffstat (limited to 'helm-locate.el')
-rw-r--r-- | helm-locate.el | 16 |
1 files changed, 13 insertions, 3 deletions
diff --git a/helm-locate.el b/helm-locate.el index 4f2acc7b..ced45dc6 100644 --- a/helm-locate.el +++ b/helm-locate.el @@ -90,6 +90,12 @@ the opposite of \"locate\" command." :group 'helm-locate :type 'boolean) +(defcustom helm-locate-fuzzy-sort-fn + #'helm-fuzzy-matching-default-sort-fn-1 + "Default fuzzy matching sort function for locate." + :group 'helm-locate + :type 'boolean) + (defcustom helm-locate-project-list nil "A list of directories, your projects. When set, allow browsing recursively files in all @@ -230,7 +236,8 @@ See also `helm-locate'." (if db (replace-regexp-in-string "locate" - (format "locate -d %s" + (format (if helm-locate-fuzzy-match + "locate -b -d %s" "locate -d %s") (mapconcat 'identity ;; Remove eventually ;; marked directories by error. @@ -238,7 +245,10 @@ See also `helm-locate'." unless (file-directory-p i) collect i) ":")) helm-locate-command) - helm-locate-command))) + (if helm-locate-fuzzy-match + (replace-regexp-in-string + "locate" "locate -b" helm-locate-command) + helm-locate-command)))) (setq helm-file-name-history (mapcar 'helm-basename file-name-history)) (helm :sources 'helm-source-locate :buffer "*helm locate*" @@ -292,7 +302,7 @@ See also `helm-locate'." cmd))))) ((string= event "finished\n") (when helm-locate-fuzzy-match - (helm-redisplay-buffer 'helm-fuzzy-matching-default-sort-fn-1)) + (helm-redisplay-buffer helm-locate-fuzzy-sort-fn)) (with-helm-window (setq mode-line-format '(" " mode-line-buffer-identification " " |