[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/speedrect 85b281d045 61/90: f - fill-text in rectangle
From: |
ELPA Syncer |
Subject: |
[elpa] externals/speedrect 85b281d045 61/90: f - fill-text in rectangle |
Date: |
Fri, 6 Dec 2024 18:59:15 -0500 (EST) |
branch: externals/speedrect
commit 85b281d045d50c75bdb4060d62b99a394ce521cc
Author: JD Smith <93749+jdtsmith@users.noreply.github.com>
Commit: JD Smith <93749+jdtsmith@users.noreply.github.com>
f - fill-text in rectangle
---
speedrect.el | 41 +++++++++++++++++++++++++++++++++++++++--
1 file changed, 39 insertions(+), 2 deletions(-)
diff --git a/speedrect.el b/speedrect.el
index 95961efd5d..cbffce02e4 100644
--- a/speedrect.el
+++ b/speedrect.el
@@ -145,6 +145,12 @@ Note that point and mark will not move beyond the end of
text on their lines."
(if (< (mark) (point)) (exchange-point-and-mark))
(call-interactively #'yank-rectangle))
+(defun speedrect-copy-rectangle-dwim ()
+ "Copy rectangle, but first swap mark and point if needed."
+ (interactive)
+ (if (< (mark) (point)) (exchange-point-and-mark))
+ (call-interactively #'copy-rectangle-as-kill))
+
(defun speedrect-delete-rest (start end)
"Keep rectangle between START and END, deleting the rest of the affected
lines."
(interactive "r")
@@ -220,6 +226,35 @@ each side of the inserted text."
(move-to-column col)
(mc/edit-lines)))))
+(defun speedrect-fill-text (width)
+ "Fill text in the rectangle to the given WIDTH."
+ (interactive
+ (list (cond ((null current-prefix-arg)
+ (car (rectangle-dimensions (point) (mark))))
+ ((consp current-prefix-arg)
+ (read-number "Fill width: "))
+ (t (prefix-numeric-value current-prefix-arg)))))
+ (when (<= width 0) (user-error "Fill width must be >0"))
+ (let ((rect (apply #'delete-extract-rectangle
+ (if (< (point) (mark))
+ (list (point) (mark))
+ (list (mark) (point))))))
+ (with-temp-buffer
+ (dolist (line rect) (insert line " "))
+ (message "GOT %S" (buffer-string))
+ (let ((fill-column (point-max)))
+ (fill-region (point-min) (point-max)))
+ (let ((fill-column width))
+ (fill-region (point-min) (point-max) nil 'nosqueeze))
+ (message "THEN %S" (buffer-string))
+ (goto-char (point-min))
+ (set-mark (point))
+ (goto-char (point-max))
+ (beginning-of-line)
+ (rectangle-forward-char width)
+ (speedrect-copy-rectangle-dwim))
+ (speedrect-yank-rectangle-dwim)))
+
(defun speedrect-transient-map-info ()
"Documentation window for speedrect."
(interactive)
@@ -228,8 +263,8 @@ each side of the inserted text."
(l '("SpeedRect Rectangle Mark Mode Commands\n"
"============================================================================\n\n"
"Insertion:\n\n"
- " [o] open fill rectangle with tabs/spaces, moving adjacent
text right\n"
- " [t] string replace rectangle with prompt string\n\n"
+ " [o] open open rectangle with tabs/spaces, shifting text
right\n"
+ " [t] string replace rectangle with string\n\n"
"Killing:\n\n"
" [k] kill kill and save rectangle for yanking\n"
" [d] delete kill rectangle without saving\n"
@@ -259,6 +294,7 @@ each side of the inserted text."
" [:] down sum down the columns and grab result in calc\n"
" [m] yank-mat yank matrix from top of calc stack, overwriting
selected rect\n\n"
"Etc:\n\n"
+ " [f] fill text within rectangle (prefix to prompt fill width)\n"
" [M] multiple-cursors add cursors at current column\n"
" [?] help view this Help buffer\n"
" [q] quit exit rectangle-mark-mode"))
@@ -316,6 +352,7 @@ prior to deactivating mark."
("m" speedrect-yank-from-calc after)
;; Special
("n" speedrect-restart) ("l" speedrect-recall-last)
+ ("f" speedrect-fill-text after)
("M" speedrect-multiple-cursors)
("?" speedrect-transient-map-info) ("q" speedrect-quit))
for bind = (if wrap (speedrect--wrap-command def (eq wrap 'after)) def)
- [elpa] externals/speedrect 6dc047f54b 64/90: bump version, (continued)
- [elpa] externals/speedrect 6dc047f54b 64/90: bump version, ELPA Syncer, 2024/12/06
- [elpa] externals/speedrect 4321fef672 40/90: Mention phi-rectangle, ELPA Syncer, 2024/12/06
- [elpa] externals/speedrect 4f9d3020e2 32/90: Update README.md, ELPA Syncer, 2024/12/06
- [elpa] externals/speedrect 0fa8964ce2 46/90: wrap commands for stash and restart, ELPA Syncer, 2024/12/06
- [elpa] externals/speedrect e7c0ca81cc 49/90: Bump version, ELPA Syncer, 2024/12/06
- [elpa] externals/speedrect 540dc4e790 58/90: Update README.md, ELPA Syncer, 2024/12/06
- [elpa] externals/speedrect 0f00af4c67 62/90: docstring tweak, ELPA Syncer, 2024/12/06
- [elpa] externals/speedrect 6982a08d25 11/90: doc: open uses tabs/spaces, ELPA Syncer, 2024/12/06
- [elpa] externals/speedrect 7bb4633c90 29/90: Update README.md, ELPA Syncer, 2024/12/06
- [elpa] externals/speedrect b743b42208 55/90: Add x:corners and M:multiple-cursors support, ELPA Syncer, 2024/12/06
- [elpa] externals/speedrect 85b281d045 61/90: f - fill-text in rectangle,
ELPA Syncer <=
- [elpa] externals/speedrect 6886e5c604 66/90: Update README.md, ELPA Syncer, 2024/12/06
- [elpa] externals/speedrect 932d983f02 65/90: Document fill, ELPA Syncer, 2024/12/06
- [elpa] externals/speedrect 1e1b713d65 57/90: Update README.md, ELPA Syncer, 2024/12/06
- [elpa] externals/speedrect 3e981896f1 71/90: Bump version, require Emacs v29.1, ELPA Syncer, 2024/12/06
- [elpa] externals/speedrect 1e897cc0d5 76/90: copy-rectangle-as-text, ELPA Syncer, 2024/12/06
- [elpa] externals/speedrect a8015aea6f 79/90: Bump version, ELPA Syncer, 2024/12/06
- [elpa] externals/speedrect c068c528e3 69/90: Update README.md, ELPA Syncer, 2024/12/06
- [elpa] externals/speedrect ed85814e48 72/90: help: correct typo, ELPA Syncer, 2024/12/06
- [elpa] externals/speedrect 94ed5cbc6c 80/90: README NEWS, ELPA Syncer, 2024/12/06
- [elpa] externals/speedrect 874f0be40c 81/90: calc: allow mismatched rect/vector heights with warning + format, ELPA Syncer, 2024/12/06