summaryrefslogtreecommitdiff
path: root/helm-grep.el
diff options
context:
space:
mode:
authorThierry Volpiatto <thierry.volpiatto@gmail.com>2020-06-16 15:16:42 +0200
committerThierry Volpiatto <thierry.volpiatto@gmail.com>2020-06-16 15:29:22 +0200
commita9bc75235f51687772e6f9f6e61c5c4f849d1aaf (patch)
treebd83dcfdf2eb4b8f36b3a966b78c507c8c8ecb62 /helm-grep.el
parentfb63cd6f05f842b21458076cf28cf79ded35846f (diff)
Fix rg pipe command when color is never (#2313)
Without this, with multi matches, first pattern matched is not colorized because ansi is used only on next matches. Try to extract the info from helm-grep-ag-command --color= parameter. With this patch both --color=always and --color=never should work properly.
Diffstat (limited to 'helm-grep.el')
-rw-r--r--helm-grep.el15
1 files changed, 10 insertions, 5 deletions
diff --git a/helm-grep.el b/helm-grep.el
index 95413b89..2323e4e3 100644
--- a/helm-grep.el
+++ b/helm-grep.el
@@ -1451,9 +1451,11 @@ And to customize colors (always for ripgrep) use something like this:
\--smart-case --no-heading --line-number %s %s %s
This will change color for matched items from foreground red (the
-default) to a yellow background with a black foreground. For more
-enhanced settings of ansi colors see
-https://github.com/emacs-helm/helm/issues/2313.
+default) to a yellow background with a black foreground. Note
+that your color settings for RG will not work properly with
+multiples pattern if you have configured colors in rg config file
+instead of command line. For more enhanced settings of ansi
+colors see https://github.com/emacs-helm/helm/issues/2313
You must use an output format that fit with helm grep, that is:
@@ -1504,8 +1506,11 @@ returns if available with current AG version."
(pipe-cmd (helm-acase (helm-grep--ag-command)
(("ag" "pt")
(format "%s -S --color%s" it (concat " " pipe-switches)))
- ("rg" (format "rg -N -S --color=always%s"
- (concat " " pipe-switches)))))
+ ("rg" (format "rg -N -S --color=%s%s"
+ (when (string-match "--color=\\([a-z]+\\) "
+ helm-grep-ag-command)
+ (match-string 1 helm-grep-ag-command))
+ (concat " " pipe-switches)))))
(cmd (format helm-grep-ag-command
(mapconcat 'identity type " ")
(shell-quote-argument (car patterns))