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

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

[elpa] master a041429 62/78: avy.el (avy-copy-region): Obey avy-line-ins


From: Oleh Krehel
Subject: [elpa] master a041429 62/78: avy.el (avy-copy-region): Obey avy-line-insert-style
Date: Sat, 23 Jan 2016 14:00:18 +0000

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

    avy.el (avy-copy-region): Obey avy-line-insert-style
    
    Re #117
---
 avy.el |   30 ++++++++++++++++++------------
 1 files changed, 18 insertions(+), 12 deletions(-)

diff --git a/avy.el b/avy.el
index 165087c..2d4b5a0 100644
--- a/avy.el
+++ b/avy.el
@@ -1138,18 +1138,24 @@ ARG lines can be used."
   "Select two lines and copy the text between them here."
   (interactive)
   (avy-with avy-copy-region
-    (let ((beg (avy--line))
-          (end (avy--line))
-          (pad (if (bolp) "" "\n")))
-      (move-beginning-of-line nil)
-      (save-excursion
-        (insert
-         (buffer-substring-no-properties
-          beg
-          (save-excursion
-            (goto-char end)
-            (line-end-position)))
-         pad)))))
+    (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'"))))))
 
 ;;;###autoload
 (defun avy-setup-default ()



reply via email to

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