From 79f9cdab81526246018642421b3b0f144991b1d6 Mon Sep 17 00:00:00 2001 From: justbur Date: Sun, 6 Mar 2016 20:59:14 -0500 Subject: [PATCH] counsel-ag: Fix escaping problem Before this it is not possible to pass the string "string1\|string2" to ag, because inputing string1\|string2 gets translated into "string1\\|string2" via %S. Instead I use %s and shell-quote-argument to take care of escaping for the command line, which fixes the issue for me. Please test. Also see https://github.com/syl20bnr/spacemacs/issues/5378 --- counsel.el | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/counsel.el b/counsel.el index 0d062c1c2..f1ede4092 100644 --- a/counsel.el +++ b/counsel.el @@ -1185,7 +1185,7 @@ INITIAL-INPUT can be given as the initial minibuffer input." ;;* Grep ;;** `counsel-ag' -(defcustom counsel-ag-base-command "ag --vimgrep %S" +(defcustom counsel-ag-base-command "ag --vimgrep %s" "Format string to use in `cousel-ag-function' to construct the command. %S will be replaced by the regex string. The default is \"ag --vimgrep %S\"." @@ -1201,7 +1201,7 @@ command. %S will be replaced by the regex string. The default is (setq ivy--old-re (ivy--regex string))))) (counsel--async-command - (format counsel-ag-base-command regex)) + (format counsel-ag-base-command (shell-quote-argument regex))) nil))) ;;;###autoload -- 2.39.2