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 ;;;###autoload
(defun avy-move-region () (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) (interactive)
(avy-with avy-move-region (avy-with avy-move-region
(let* ((initial-window (selected-window)) (let* ((initial-window (selected-window))
(beg (avy--line)) (beg (avy--line))
(end (save-excursion (end (avy--line))
(goto-char (avy--line)) text)
(forward-line) (when (> beg end)
(point))) (cl-rotatef beg end))
(text (buffer-substring beg end)) (setq end (save-excursion
(pad (if (bolp) "" "\n"))) (goto-char end)
(1+ (line-end-position))))
(setq text (buffer-substring beg end))
(move-beginning-of-line nil) (move-beginning-of-line nil)
(delete-region beg end) (delete-region beg end)
(select-window initial-window) (select-window initial-window)
(insert text pad)))) (insert text))))
;;;###autoload ;;;###autoload
(defun avy-kill-region (arg) (defun avy-kill-region (arg)