avy.el (avy-copy-region): Obey avy-line-insert-style

Re #117
This commit is contained in:
Oleh Krehel 2015-12-02 09:37:57 +01:00
parent 54fb4d65e1
commit a0414291f1

22
avy.el
View File

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