emacs-elpa-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[elpa] master 2e3c2f7 013/110: Add new command `avy-move-region'


From: Oleh Krehel
Subject: [elpa] master 2e3c2f7 013/110: Add new command `avy-move-region'
Date: Sat, 11 May 2019 10:15:34 -0400 (EDT)

branch: master
commit 2e3c2f7c88e226eaa74b64180c4dd68c1b83581e
Author: York Zhao <address@hidden>
Commit: Oleh Krehel <address@hidden>

    Add new command `avy-move-region'
    
    Fixes #75
---
 avy.el | 18 ++++++++++++++++++
 1 file changed, 18 insertions(+)

diff --git a/avy.el b/avy.el
index 496dfd5..1e5ee1a 100644
--- a/avy.el
+++ b/avy.el
@@ -82,6 +82,7 @@ in the avy overlays."
                      (const avy-copy-line)
                      (const avy-copy-region)
                      (const avy-move-line)
+                     (const avy-move-region)
                      (function :tag "Other command"))
           :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-region)
                      (const avy-move-line)
+                     (const avy-move-region)
                      (function :tag "Other command"))
           :value-type (choice
                        (const :tag "Pre" pre)
@@ -1254,6 +1256,22 @@ The window scope is determined by `avy-all-windows' or
                (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
 (defun avy-setup-default ()
   "Setup the default shortcuts."
   (eval-after-load "isearch"



reply via email to

[Prev in Thread] Current Thread [Next in Thread]