[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/speedrect 7390122e49 75/90: calc-grab: improve with cal
From: |
ELPA Syncer |
Subject: |
[elpa] externals/speedrect 7390122e49 75/90: calc-grab: improve with calc-top, avoid brackets/truncation |
Date: |
Fri, 6 Dec 2024 18:59:17 -0500 (EST) |
branch: externals/speedrect
commit 7390122e4959663950fa369e80357c20a5f91f14
Author: JD Smith <93749+jdtsmith@users.noreply.github.com>
Commit: JD Smith <93749+jdtsmith@users.noreply.github.com>
calc-grab: improve with calc-top, avoid brackets/truncation
---
speedrect.el | 42 ++++++++++++++++++++----------------------
1 file changed, 20 insertions(+), 22 deletions(-)
diff --git a/speedrect.el b/speedrect.el
index c20cc15ce4..257a9c9b9d 100644
--- a/speedrect.el
+++ b/speedrect.el
@@ -183,34 +183,32 @@ RECT (a list of strings)."
START and END are the interactively-defined region beginning and
end. The (matrix) value at the top of the calc stack is used,
and must have the same number of rows as the height of the marked
-rectangle. To avoid copying brackets and commas, v [ and v , may
-be used in calc. A minimum of one padding space is preserved on
-each side of the inserted text."
+rectangle. Brackets are not copied and short vectors are
+expanded. To avoid copying commas, `v ,' may be used in calc,
+and `d n' with a prefix arg changes the displayed precision. A
+minimum of one padding space is preserved on each side of the
+inserted text."
(interactive "r")
(if-let ((rectangle-mark-mode)
(buf (get-buffer "*Calculator*")))
- (let* ((b (region-beginning))
+ (let* ((lines (with-current-buffer buf
+ (string-lines
+ (let ((calc-vector-brackets nil)
+ (calc-full-vectors t))
+ (math-format-value (calc-top))))))
+ (b (region-beginning))
(e (region-end))
- (height (+ (count-lines b e)
- (if (eq (char-before e) ?\n) 1 0)))
- crect lr)
- (with-current-buffer buf
- (let* ((cstart (progn (calc-cursor-stack-index 1)
- (if (and calc-line-numbering (looking-at
"[0-9]+: "))
- (match-end 0)
- (point))))
- (cend (progn (calc-cursor-stack-index 0) (line-end-position
0))))
- (setq crect (extract-rectangle cstart cend))))
- (if (eq (length crect) height)
- (progn
- (setq lr (speedrect--lr-space crect))
- (push nil crect) ; dummy, for consuming in apply-on-rectangle
+ (height (+ (count-lines b e) (if (eq (char-before e) ?\n) 1 0))))
+ (if (eq (length lines) height)
+ (let* ((lr (speedrect--lr-space lines))
+ (low (max 0 (1- (car lr))))
+ (high (- (1- (cdr lr)))))
+ (when (>= high 0) (setq high nil))
+ (push nil lines) ; dummy, for consuming lines in
apply-on-rectangle
(apply-on-rectangle 'speedrect--replace-with-rect
- start end crect
- (max 0 (1- (car lr)))
- (min 0 (- (1- (cdr lr))))))
+ start end lines low high))
(user-error "Row count of calc matrix (%d) does not match rectangle
height (%d)"
- (length crect) height)))
+ (length lines) height)))
(user-error "Calc rectangle yank not possible here")))
(declare-function mc/edit-lines "mc-edit-lines")
- [elpa] externals/speedrect 64c68ebdf3 85/90: Add NEWS.org, (continued)
- [elpa] externals/speedrect 64c68ebdf3 85/90: Add NEWS.org, ELPA Syncer, 2024/12/06
- [elpa] externals/speedrect b101eaea01 48/90: calc-yank: no save-excursion needed, ELPA Syncer, 2024/12/06
- [elpa] externals/speedrect f96b01863e 50/90: README: explain restart and add more calc detail, ELPA Syncer, 2024/12/06
- [elpa] externals/speedrect 94d6c643cb 51/90: README: improve calc section, ELPA Syncer, 2024/12/06
- [elpa] externals/speedrect 3120746026 56/90: Update README.md, ELPA Syncer, 2024/12/06
- [elpa] externals/speedrect e37d89acc6 63/90: wrap-command: ensure buffer is restored on re-running command, ELPA Syncer, 2024/12/06
- [elpa] externals/speedrect 94c125f60f 68/90: fill-text: use height of rect as line count limit, ELPA Syncer, 2024/12/06
- [elpa] externals/speedrect 5da3d70805 74/90: delete-rest: save rectangle after command, ELPA Syncer, 2024/12/06
- [elpa] externals/speedrect 16e79924ed 82/90: Prepare for ELPA, ELPA Syncer, 2024/12/06
- [elpa] externals/speedrect 2782b03be2 38/90: Update README.md, ELPA Syncer, 2024/12/06
- [elpa] externals/speedrect 7390122e49 75/90: calc-grab: improve with calc-top, avoid brackets/truncation,
ELPA Syncer <=
- [elpa] externals/speedrect 4b79f0109d 88/90: README: document new `speedrect-mode' config, ELPA Syncer, 2024/12/06
- [elpa] externals/speedrect 43a89af9f7 52/90: allow rectangle-mark-mode-hook to operate on continue, ELPA Syncer, 2024/12/06
- [elpa] externals/speedrect c47e5e4e7b 43/90: move commands: use rectangle-right/next-line, ELPA Syncer, 2024/12/06
- [elpa] externals/speedrect 6363a7ba6d 47/90: yank-rectangle-dwim: exchange point and mark before yank if needed, ELPA Syncer, 2024/12/06
- [elpa] externals/speedrect 9be7569c70 70/90: shift-right: use rectangle point-mark exchange for line ends, ELPA Syncer, 2024/12/06