]> code.delx.au - gnu-emacs-elpa/commitdiff
counsel-ag: Fix escaping problem
authorjustbur <justin@burkett.cc>
Mon, 7 Mar 2016 01:59:14 +0000 (20:59 -0500)
committerjustbur <justin@burkett.cc>
Mon, 7 Mar 2016 01:59:14 +0000 (20:59 -0500)
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

index 0d062c1c2eb87a35632df9e133a893ae712fb02c..f1ede40921897541305cded5822f818b8e0de086 100644 (file)
@@ -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