diff options
author | Thierry Volpiatto <thierry.volpiatto@gmail.com> | 2013-10-12 09:09:08 +0200 |
---|---|---|
committer | Thierry Volpiatto <thierry.volpiatto@gmail.com> | 2013-10-12 09:09:08 +0200 |
commit | 1ed08c4370d43eb435e2974dca251a684f6251a9 (patch) | |
tree | 7797a20c95d64b7ed3d5aa18fa85d2d02679e601 /helm-locate.el | |
parent | b905d7740c21b8f1dc2172e4882c09c6db60880a (diff) |
* helm-locate.el (helm-locate-pattern-transformer): New, pattern transformer for locate.
(helm-source-locate): Use it, avoid failing miserably when user enter multiple patterns,
though it will fail to match with inversed pattern, but without error.
Diffstat (limited to 'helm-locate.el')
-rw-r--r-- | helm-locate.el | 16 |
1 files changed, 14 insertions, 2 deletions
diff --git a/helm-locate.el b/helm-locate.el index 150304eb..0c3ea796 100644 --- a/helm-locate.el +++ b/helm-locate.el @@ -212,8 +212,8 @@ See also `helm-locate'." (defun helm-locate-init () "Initialize async locate process for `helm-source-locate'." - (let* ((locate-is-es (string-match "^es" helm-locate-command)) - (real-locate (string-match "^locate" helm-locate-command)) + (let* ((locate-is-es (string-match "\\`es" helm-locate-command)) + (real-locate (string-match "\\`locate" helm-locate-command)) (case-sensitive-flag (if locate-is-es "-i" "")) (ignore-case-flag (if (or locate-is-es (not real-locate)) "" "-i")) @@ -254,10 +254,22 @@ See also `helm-locate'." (helm-log "Error: Locate %s" (replace-regexp-in-string "\n" "" event)))))))) +(defun helm-locate-pattern-transformer (pattern) + "Replace spaces in PATTERN with \".*\". +Don't affect space at end of PATTERN preceding a possible locate option. +Do nothing when `helm-locate-command' is 'es'." + (if (and (string-match + " " (replace-regexp-in-string + " -[a-z]\\'" "" pattern)) + (not (string-match-p "\\`es" helm-locate-command))) + (replace-match ".*" nil t pattern) + pattern)) + (defvar helm-source-locate `((name . "Locate") (init . helm-locate-set-command) (candidates-process . helm-locate-init) + (pattern-transformer . helm-locate-pattern-transformer) (type . file) (requires-pattern . 3) (history . ,'helm-file-name-history) |