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

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

[elpa] externals/speedrect 1935a0266a 06/12: kill-rectangle: new option


From: ELPA Syncer
Subject: [elpa] externals/speedrect 1935a0266a 06/12: kill-rectangle: new option to preserve space on kill with prefix
Date: Mon, 16 Dec 2024 12:59:28 -0500 (EST)

branch: externals/speedrect
commit 1935a0266ac289c87f013d3e29f5102b79d73f6c
Author: JD Smith <93749+jdtsmith@users.noreply.github.com>
Commit: JD Smith <93749+jdtsmith@users.noreply.github.com>

    kill-rectangle: new option to preserve space on kill with prefix
---
 speedrect.el | 14 ++++++++++++--
 1 file changed, 12 insertions(+), 2 deletions(-)

diff --git a/speedrect.el b/speedrect.el
index 5af56232f5..4ef6f740f1 100644
--- a/speedrect.el
+++ b/speedrect.el
@@ -152,6 +152,16 @@ Note that point and mark will not move beyond the end of 
text on their lines."
   (interactive)
   (let ((mark-active nil)) (undo)))
 
+(defun speedrect-kill-rectangle (start end &optional preserve-width)
+  "Kill rectangle between START and END.
+If PRESERVE-WIDTH is non-nil, preserves width."
+  (interactive "*r\nP")
+  (if preserve-width
+      (progn
+       (copy-rectangle-as-kill start end)
+       (clear-rectangle start end))
+    (kill-rectangle start end)))
+
 (defun speedrect-yank-rectangle-dwim ()
   "Yank rectangle, but first swap mark and point if needed."
   (interactive)
@@ -378,7 +388,7 @@ Insertion:
   [o] open      open rectangle with tabs/spaces, shifting text right
   [t] string    replace rectangle with string\n
 Killing:\n
-  [k] kill      kill and save rectangle for yanking
+  [k] kill      kill and save rectangle for yanking (keep space, with prefix)
   [d] delete    kill rectangle without saving
   [SPC] del-ws  delete all whitespace from left (right, with prefix)
   [c] clear     clear rectangle area by overwriting with spaces
@@ -447,7 +457,7 @@ rectangle after the command runs, otherwise, stash it 
before."
   (cl-loop
    for (key def wrap) in
    '(;; Rectangle basics
-     ("k" kill-rectangle after)
+     ("k" speedrect-kill-rectangle t)
      ("t" string-rectangle after)
      ("o" open-rectangle t)
      ("w" copy-rectangle-as-kill t)



reply via email to

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