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

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

[elpa] master cf2c7bc 067/272: Modify "M-n" prediction when region is ac


From: Oleh Krehel
Subject: [elpa] master cf2c7bc 067/272: Modify "M-n" prediction when region is active
Date: Mon, 25 Apr 2016 10:13:17 +0000

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

    Modify "M-n" prediction when region is active
    
    * ivy.el (ivy--reset-state): When the region is active and "M-n" is
      called, insert the region contents into the minibuffer and deactivate
      the region. The region deactivation is done for `swiper', to make it
      easier to search for multiple words or a subword.
---
 ivy.el |   14 ++++++++++----
 1 file changed, 10 insertions(+), 4 deletions(-)

diff --git a/ivy.el b/ivy.el
index a5da026..f44dbdf 100644
--- a/ivy.el
+++ b/ivy.el
@@ -1312,10 +1312,16 @@ This is useful for recursive `ivy-read'."
                                   coll)))
                           0))))
     (setq ivy-exit nil)
-    (setq ivy--default (or
-                        (thing-at-point 'url)
-                        (thing-at-point 'symbol)
-                        ""))
+    (setq ivy--default
+          (if (region-active-p)
+              (prog1 (buffer-substring
+                      (region-beginning)
+                      (region-end))
+                (deactivate-mark))
+            (or
+             (thing-at-point 'url)
+             (thing-at-point 'symbol)
+             "")))
     (setq ivy--prompt
           (cond ((string-match "%.*d" prompt)
                  prompt)



reply via email to

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