diff options
author | Thierry Volpiatto <thierry.volpiatto@gmail.com> | 2016-10-15 23:00:26 +0200 |
---|---|---|
committer | Thierry Volpiatto <thierry.volpiatto@gmail.com> | 2016-10-15 23:00:26 +0200 |
commit | 9867cf605496dc7de5502a5c0ff538968865254c (patch) | |
tree | ea2355dbb792f07d0aaea529c4743af1e2543e24 | |
parent | 894b69edc3a2a0d72d5edad9f84beb2133d73744 (diff) |
Fix issue #1618 for ag as well.
* helm-grep.el (helm-grep--prepare-cmd-line): Ensure end space is removed when needed.
(helm-grep-ag-prepare-cmd-line): Do it, use --smart-case.
-rw-r--r-- | helm-grep.el | 27 |
1 files changed, 18 insertions, 9 deletions
diff --git a/helm-grep.el b/helm-grep.el index bb73a3b1..bdebca34 100644 --- a/helm-grep.el +++ b/helm-grep.el @@ -417,10 +417,12 @@ It is intended to use as a let-bound variable, DON'T set this globaly.") ;; we need to pass an empty string ;; to types to avoid error. (or include ""))) - (smartcase (if (helm-grep-use-ack-p) "" - (unless (let ((case-fold-search nil)) - (string-match-p - "[[:upper:]]" helm-pattern)) "i"))) + (smartcase (if (helm-grep-use-ack-p) + "" + (unless (let ((case-fold-search nil)) + (string-match-p + "[[:upper:]]" helm-pattern)) + "i"))) (helm-grep-default-command (concat helm-grep-default-command " %m")) ; `%m' like multi. (patterns (split-string helm-pattern)) @@ -429,8 +431,10 @@ It is intended to use as a let-bound variable, DON'T set this globaly.") (cl-loop with pipcom = (pcase (helm-grep-command) ;; Use grep for GNU regexp based tools. ((or "grep" "zgrep" "git-grep") - (format "grep --color=always %s" - (if smartcase "-i" ""))) + (replace-regexp-in-string + "\\s-\\'" "" + (format "grep --color=always %s" + (if smartcase "-i" "")))) ;; Use ack-grep for PCRE based tools. ;; Sometimes ack-grep cmd is ack only. ((and (pred (string-match-p "ack")) ack) @@ -1321,9 +1325,14 @@ Ripgrep (rg) types are also supported if this backend is used." When TYPE is specified it is one of what returns `helm-grep-ag-get-types' if available with current AG version." (let* ((patterns (split-string pattern)) - (pipe-cmd (cond ((executable-find "ack") "ack --color") - ((executable-find "ack-grep") "ack-grep --color") - (t "grep --perl-regexp --color=always"))) + (smartcase (let ((case-fold-search nil)) + (string-match-p + "[[:upper:]]" helm-pattern))) + (pipe-cmd (cond ((executable-find "ack") "ack --smart-case --color") + ((executable-find "ack-grep") "ack-grep --smart-case --color") + (t (replace-regexp-in-string + "\\s-\\'" "" (format "grep --perl-regexp --color=always %s" + (if smartcase "-i" "")))))) (cmd (format helm-grep-ag-command (mapconcat 'identity type " ") (shell-quote-argument (car patterns)) |