branch: externals/ivy-hydra
commit 5f1d9ce04599c52818244c2cb8cb066a601610b8
Author: Oleh Krehel <[email protected]>
Commit: Oleh Krehel <[email protected]>
counsel.el (counsel--grep-smart-case-flag): Extract
Fixes #2392
---
counsel.el | 11 ++++++++---
1 file changed, 8 insertions(+), 3 deletions(-)
diff --git a/counsel.el b/counsel.el
index d556d6c..57ec13c 100644
--- a/counsel.el
+++ b/counsel.el
@@ -2958,6 +2958,13 @@ Works for `counsel-git-grep', `counsel-ag', etc."
(ivy-quit-and-run
(funcall (ivy-state-caller ivy-last) input new-dir))))
+(defun counsel--grep-smart-case-flag ()
+ (if (ivy--case-fold-p ivy-text)
+ " -i "
+ (if (string-match-p "\\`pt" counsel-ag-base-command)
+ " -S "
+ " -s ")))
+
(defun counsel-grep-like-occur (cmd-template)
(unless (eq major-mode 'ivy-occur-grep-mode)
(ivy-occur-grep-mode)
@@ -2972,9 +2979,7 @@ Works for `counsel-git-grep', `counsel-ag', etc."
(regex (counsel--grep-regex (cdr command-args)))
(switches (concat (car command-args)
(counsel--ag-extra-switches regex)
- (if (ivy--case-fold-p ivy-text)
- " -i "
- " -s "))))
+ (counsel--grep-smart-case-flag))))
(format cmd-template
(concat
switches