Add new command `avy-move-region'

Fixes #75
This commit is contained in:
York Zhao 2015-07-06 15:46:57 -04:00 committed by Oleh Krehel
parent 85a384a151
commit 2e3c2f7c88

18
avy.el
View File

@ -82,6 +82,7 @@ in the avy overlays."
(const avy-copy-line) (const avy-copy-line)
(const avy-copy-region) (const avy-copy-region)
(const avy-move-line) (const avy-move-line)
(const avy-move-region)
(function :tag "Other command")) (function :tag "Other command"))
:value-type (repeat :tag "Keys" character))) :value-type (repeat :tag "Keys" character)))
@ -111,6 +112,7 @@ If the commands isn't on the list, `avy-style' is used."
(const avy-copy-line) (const avy-copy-line)
(const avy-copy-region) (const avy-copy-region)
(const avy-move-line) (const avy-move-line)
(const avy-move-region)
(function :tag "Other command")) (function :tag "Other command"))
:value-type (choice :value-type (choice
(const :tag "Pre" pre) (const :tag "Pre" pre)
@ -1253,6 +1255,22 @@ The window scope is determined by `avy-all-windows' or
(t (t
(user-error "Unexpected `avy-line-insert-style'"))))))) (user-error "Unexpected `avy-line-insert-style'")))))))
;;;###autoload
(defun avy-move-region ()
"Select two lines and move the text between them here."
(interactive)
(avy-with avy-move-region
(let* ((beg (avy--line))
(end (save-excursion
(goto-char (avy--line))
(forward-line)
(point)))
(text (buffer-substring beg end))
(pad (if (bolp) "" "\n")))
(move-beginning-of-line nil)
(delete-region beg end)
(insert text pad))))
;;;###autoload ;;;###autoload
(defun avy-setup-default () (defun avy-setup-default ()
"Setup the default shortcuts." "Setup the default shortcuts."