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

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

[elpa] master 4147453 212/399: swiper.el (swiper-isearch-thing-at-point)


From: Oleh Krehel
Subject: [elpa] master 4147453 212/399: swiper.el (swiper-isearch-thing-at-point): Add
Date: Sat, 20 Jul 2019 14:57:25 -0400 (EDT)

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

    swiper.el (swiper-isearch-thing-at-point): Add
    
    Re #2027
---
 swiper.el | 19 +++++++++++++------
 1 file changed, 13 insertions(+), 6 deletions(-)

diff --git a/swiper.el b/swiper.el
index b49a85f..b643756 100644
--- a/swiper.el
+++ b/swiper.el
@@ -1268,7 +1268,7 @@ come back to the same place as when \"a\" was initially 
entered.")
           (swiper--add-cursor-overlay)))
     (swiper--cleanup)))
 
-(defun swiper-isearch-symbol-at-point ()
+(defun swiper-isearch-thing-at-point ()
   "Insert `symbol-at-point' into the minibuffer of `swiper-isearch'.
 When not running `swiper-isearch' already, start it."
   (interactive)
@@ -1280,15 +1280,22 @@ When not running `swiper-isearch' already, start it."
         (setq swiper--isearch-point-history
               (list (cons "" (car bnd))))
         (insert str))
-    (let ((bnd (bounds-of-thing-at-point 'symbol)))
-      (when bnd
-        (goto-char (car bnd))
-        (swiper-isearch (buffer-substring-no-properties (car bnd) (cdr 
bnd)))))))
+    (let (thing)
+      (if (use-region-p)
+          (progn
+            (goto-char (region-beginning))
+            (setq thing (ivy-thing-at-point))
+            (deactivate-mark))
+        (let ((bnd (bounds-of-thing-at-point 'symbol)))
+          (when bnd
+            (goto-char (car bnd)))
+          (setq thing (ivy-thing-at-point))))
+      (swiper-isearch thing))))
 
 (defvar swiper-isearch-map
   (let ((map (make-sparse-keymap)))
     (set-keymap-parent map swiper-map)
-    (define-key map (kbd "M-n") 'swiper-isearch-symbol-at-point)
+    (define-key map (kbd "M-n") 'swiper-isearch-thing-at-point)
     map)
   "Keymap for `swiper-isearch'.")
 



reply via email to

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