avy.el (avy-transpose-lines-in-region): Add

Fixes #317
Fixes #310
This commit is contained in:
lWarne 2020-12-23 14:58:17 +00:00 committed by Oleh Krehel
parent bbf1e7339e
commit e92cb37457

16
avy.el
View File

@ -2176,6 +2176,22 @@ The window scope is determined by `avy-all-windows' (ARG negates it)."
(error
(set-mark-command 4)))))
;;;###autoload
(defun avy-transpose-lines-in-region ()
"Transpose lines in the active region."
(interactive)
(when (and (use-region-p) (> (count-lines (region-beginning) (region-end)) 1))
(let ((avy-all-windows nil)
(fst-line-point (avy--line nil (region-beginning) (region-end))))
(when fst-line-point
(let ((snd-line-point (avy--line nil (region-beginning) (region-end))))
(when snd-line-point
(save-mark-and-excursion
(push-mark fst-line-point)
(goto-char snd-line-point)
(transpose-lines 0))
(avy-transpose-lines-in-region)))))))
;; ** Org-mode
(defvar org-reverse-note-order)
(declare-function org-refile "org")