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

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

[elpa] master fa6d1e1 66/78: avy.el (avy-copy-region): Fix for multi-buf


From: Oleh Krehel
Subject: [elpa] master fa6d1e1 66/78: avy.el (avy-copy-region): Fix for multi-buffer use
Date: Sat, 23 Jan 2016 14:00:21 +0000

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

    avy.el (avy-copy-region): Fix for multi-buffer use
    
    Fixes #119
---
 avy.el |   49 +++++++++++++++++++++++++++----------------------
 1 files changed, 27 insertions(+), 22 deletions(-)

diff --git a/avy.el b/avy.el
index 524c127..bd04228 100644
--- a/avy.el
+++ b/avy.el
@@ -1143,28 +1143,33 @@ ARG lines can be used."
              (user-error "Unexpected `avy-line-insert-style'"))))))
 
 ;;;###autoload
-(defun avy-copy-region ()
-  "Select two lines and copy the text between them here."
-  (interactive)
-  (avy-with avy-copy-region
-    (let* ((beg (avy--line))
-           (end (avy--line))
-           (str (buffer-substring-no-properties
-                 beg
-                 (save-excursion
-                   (goto-char end)
-                   (line-end-position)))))
-      (cond ((eq avy-line-insert-style 'above)
-             (beginning-of-line)
-             (save-excursion
-               (insert str "\n")))
-            ((eq avy-line-insert-style 'below)
-             (end-of-line)
-             (newline)
-             (save-excursion
-               (insert str)))
-            (t
-             (user-error "Unexpected `avy-line-insert-style'"))))))
+(defun avy-copy-region (arg)
+  "Select two lines and copy the text between them to point.
+
+The window scope is determined by `avy-all-windows' or
+`avy-all-windows-alt' when ARG is non-nil."
+  (interactive "P")
+  (let ((initial-window (selected-window)))
+    (avy-with avy-copy-region
+      (let* ((beg (avy--line arg))
+             (end (avy--line arg))
+             (str (buffer-substring-no-properties
+                   beg
+                   (save-excursion
+                     (goto-char end)
+                     (line-end-position)))))
+        (select-window initial-window)
+        (cond ((eq avy-line-insert-style 'above)
+               (beginning-of-line)
+               (save-excursion
+                 (insert str "\n")))
+              ((eq avy-line-insert-style 'below)
+               (end-of-line)
+               (newline)
+               (save-excursion
+                 (insert str)))
+              (t
+               (user-error "Unexpected `avy-line-insert-style'")))))))
 
 ;;;###autoload
 (defun avy-setup-default ()



reply via email to

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