]> code.delx.au - gnu-emacs-elpa/commitdiff
Modify "M-n" prediction when region is active
authorOleh Krehel <ohwoeowho@gmail.com>
Mon, 1 Feb 2016 17:38:57 +0000 (18:38 +0100)
committerOleh Krehel <ohwoeowho@gmail.com>
Mon, 1 Feb 2016 17:38:57 +0000 (18:38 +0100)
* 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

diff --git a/ivy.el b/ivy.el
index a5da0264a54a94d8b9ecf99a4aa6c4fa8b092c7f..f44dbdfef3d49465611731d826812e72ba506cb8 100644 (file)
--- 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)