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
;;* 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\"."
(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