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

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

[elpa] master 6a5a688 201/272: counsel.el: Improve counsel-grep


From: Oleh Krehel
Subject: [elpa] master 6a5a688 201/272: counsel.el: Improve counsel-grep
Date: Mon, 25 Apr 2016 10:13:25 +0000

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

    counsel.el: Improve counsel-grep
---
 counsel.el |   38 +++++++++++++++++++++++---------------
 1 file changed, 23 insertions(+), 15 deletions(-)

diff --git a/counsel.el b/counsel.el
index 6afdbbc..59926e3 100644
--- a/counsel.el
+++ b/counsel.el
@@ -1371,6 +1371,8 @@ This uses `counsel-ag' with `counsel-pt-base-command' 
replacing
         (re-search-forward (ivy--regex ivy-text t) (line-end-position) t)
         (unless (eq ivy-exit 'done)
           (swiper--cleanup)
+          (isearch-range-invisible (line-beginning-position)
+                                   (line-end-position))
           (swiper--add-overlays (ivy--regex ivy-text)))))))
 
 ;;;###autoload
@@ -1378,21 +1380,27 @@ This uses `counsel-ag' with `counsel-pt-base-command' 
replacing
   "Grep for a string in the current file."
   (interactive)
   (setq counsel--git-grep-dir (buffer-file-name))
-  (ivy-read "grep: " 'counsel-grep-function
-            :dynamic-collection t
-            :preselect (format "%d:%s"
-                               (line-number-at-pos)
-                               (buffer-substring-no-properties
-                                (line-beginning-position)
-                                (line-end-position)))
-            :history 'counsel-git-grep-history
-            :update-fn (lambda ()
-                         (counsel-grep-action ivy--current))
-            :action #'counsel-grep-action
-            :unwind (lambda ()
-                      (counsel-delete-process)
-                      (swiper--cleanup))
-            :caller 'counsel-grep))
+  (let ((init-point (point))
+        res)
+    (unwind-protect
+         (setq res (ivy-read "grep: " 'counsel-grep-function
+                             :dynamic-collection t
+                             :preselect (format "%d:%s"
+                                                (line-number-at-pos)
+                                                (buffer-substring-no-properties
+                                                 (line-beginning-position)
+                                                 (line-end-position)))
+                             :history 'counsel-git-grep-history
+                             :update-fn (lambda ()
+                                          (counsel-grep-action ivy--current))
+                             :action #'counsel-grep-action
+                             :unwind (lambda ()
+                                       (counsel-delete-process)
+                                       (swiper--cleanup))
+                             :caller 'counsel-grep))
+      (unless res
+        (goto-char init-point)))))
+
 ;;** `counsel-recoll'
 (defun counsel-recoll-function (string)
   "Grep in the current directory for STRING."



reply via email to

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