avy.el (avy-move-region): Update

Fixes #188
This commit is contained in:
Oleh Krehel 2017-04-02 21:14:29 +02:00
parent 3980c03f6c
commit 54bce2cfb0

18
avy.el
View File

@ -1481,21 +1481,23 @@ The window scope is determined by `avy-all-windows' or
;;;###autoload
(defun avy-move-region ()
"Select two lines and move the text between them here."
"Select two lines and move the text between them above the current line."
(interactive)
(avy-with avy-move-region
(let* ((initial-window (selected-window))
(beg (avy--line))
(end (save-excursion
(goto-char (avy--line))
(forward-line)
(point)))
(text (buffer-substring beg end))
(pad (if (bolp) "" "\n")))
(end (avy--line))
text)
(when (> beg end)
(cl-rotatef beg end))
(setq end (save-excursion
(goto-char end)
(1+ (line-end-position))))
(setq text (buffer-substring beg end))
(move-beginning-of-line nil)
(delete-region beg end)
(select-window initial-window)
(insert text pad))))
(insert text))))
;;;###autoload
(defun avy-kill-region (arg)