emacs-elpa-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[elpa] master c9235c8 04/54: counsel-locate should use '' for the regex


From: Oleh Krehel
Subject: [elpa] master c9235c8 04/54: counsel-locate should use '' for the regex
Date: Tue, 29 Sep 2015 14:09:47 +0000

branch: master
commit c9235c8b765998894e4f6756671bd9247ba99c95
Author: Oleh Krehel <address@hidden>
Commit: Oleh Krehel <address@hidden>

    counsel-locate should use '' for the regex
    
    * counsel.el (counsel-unquote-regex-parens): New defun.
    (counsel-locate-function): Update.
    (counsel-ag-function): Update.
    
    Fixes #194
---
 counsel.el |   21 ++++++++++++---------
 1 files changed, 12 insertions(+), 9 deletions(-)

diff --git a/counsel.el b/counsel.el
index 0d75da1..2d41766 100644
--- a/counsel.el
+++ b/counsel.el
@@ -470,14 +470,21 @@ Skip some dotfiles unless `ivy-text' requires them."
  '(("x" counsel-locate-action-extern "xdg-open")
    ("d" counsel-locate-action-dired "dired")))
 
+(defun counsel-unquote-regex-parens (str)
+  (replace-regexp-in-string
+   "\\\\)" ")"
+   (replace-regexp-in-string
+    "\\\\(" "("
+    str)))
+
 (defun counsel-locate-function (str &rest _u)
   (if (< (length str) 3)
       (counsel-more-chars 3)
     (counsel--async-command
-     (concat "locate "
-            (mapconcat #'identity counsel-locate-options " ")
-            " "
-            (ivy--regex str)))
+     (format "locate %s '%s'"
+             (mapconcat #'identity counsel-locate-options " ")
+             (counsel-unquote-regex-parens
+              (ivy--regex str))))
     '("" "working...")))
 
 ;;;###autoload
@@ -872,11 +879,7 @@ Usable with `ivy-resume', `ivy-next-line-and-call' and
   "Grep in the current directory for STRING."
   (if (< (length string) 3)
       (counsel-more-chars 3)
-    (let ((regex (replace-regexp-in-string
-                  "\\\\)" ")"
-                  (replace-regexp-in-string
-                   "\\\\(" "("
-                   (ivy--regex string)))))
+    (let ((regex (counsel-unquote-regex-parens (ivy--regex string))))
       (counsel--async-command
        (format "ag --noheading --nocolor %S" regex))
       nil)))



reply via email to

[Prev in Thread] Current Thread [Next in Thread]