avy.el (avy-copy-region): Fix for multi-buffer use

Fixes #119
This commit is contained in:
Oleh Krehel 2015-12-07 11:01:52 +01:00
parent 54074c764d
commit fa6d1e1242

17
avy.el
View File

@ -1143,17 +1143,22 @@ ARG lines can be used."
(user-error "Unexpected `avy-line-insert-style'")))))) (user-error "Unexpected `avy-line-insert-style'"))))))
;;;###autoload ;;;###autoload
(defun avy-copy-region () (defun avy-copy-region (arg)
"Select two lines and copy the text between them here." "Select two lines and copy the text between them to point.
(interactive)
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 (avy-with avy-copy-region
(let* ((beg (avy--line)) (let* ((beg (avy--line arg))
(end (avy--line)) (end (avy--line arg))
(str (buffer-substring-no-properties (str (buffer-substring-no-properties
beg beg
(save-excursion (save-excursion
(goto-char end) (goto-char end)
(line-end-position))))) (line-end-position)))))
(select-window initial-window)
(cond ((eq avy-line-insert-style 'above) (cond ((eq avy-line-insert-style 'above)
(beginning-of-line) (beginning-of-line)
(save-excursion (save-excursion
@ -1164,7 +1169,7 @@ ARG lines can be used."
(save-excursion (save-excursion
(insert str))) (insert str)))
(t (t
(user-error "Unexpected `avy-line-insert-style'")))))) (user-error "Unexpected `avy-line-insert-style'")))))))
;;;###autoload ;;;###autoload
(defun avy-setup-default () (defun avy-setup-default ()