[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/speedrect 629e9d935b 42/90: add move up/down commands a
From: |
ELPA Syncer |
Subject: |
[elpa] externals/speedrect 629e9d935b 42/90: add move up/down commands and [M-]S-<up>/<down> |
Date: |
Fri, 6 Dec 2024 18:59:13 -0500 (EST) |
branch: externals/speedrect
commit 629e9d935b64e0c6e7f6c9124de5966ed7998bae
Author: JD Smith <93749+jdtsmith@users.noreply.github.com>
Commit: JD Smith <93749+jdtsmith@users.noreply.github.com>
add move up/down commands and [M-]S-<up>/<down>
---
README.md | 18 ++++++++++++++++++
speedrect.el | 57 +++++++++++++++++++++++++++++++++++++++++++++++----------
2 files changed, 65 insertions(+), 10 deletions(-)
diff --git a/README.md b/README.md
index 9e95e0843e..d3c0eed0aa 100644
--- a/README.md
+++ b/README.md
@@ -62,33 +62,51 @@ You don't have to be in the same `mark-rectangle-mode`
session to yank a matrix
```
SpeedRect Rectangle Mark Mode Commands
============================================================================
+
Insertion:
+
[o] open fill rectangle with tabs/spaces, moving adjacent text right
[t] string replace rectangle with prompt string
+
Killing:
+
[k] kill kill and save rectangle for yanking
[d] delete kill rectangle without saving
[SPC] del-ws delete all whitespace, starting from left column
[c] clear clear rectangle area by overwriting with spaces
[r] rest delete the rest of the columns, keeping the marked rectangle
+
Change Rectangle:
+
[n] new start a new rectangle from this location
[l] last restore the last used rectangle position, if possible
+
Shift Rectangle (can use numeric prefixes):
+
[S-left] move the rectangle left
[S-right] move the rectangle right
+ [S-up] move the rectangle up
+ [S-down] move the rectangle down
[M-S-left] move the rectangle left 5 columns
[M-S-right] move the rectangle right 5 columns
+ [M-S-up] move the rectangle up 5 columns
+ [M-S-down] move the rectangle down 5 lines
+
Copy/Yank:
+
[w] copy copy rectangle for future yanking
[y] yank yank rectangle, inserting at point
+
Numerical:
+
[N] numbers fill the rectangle with numbers (prefix to set start)
[#] grab grab the rectangle as a matrix in calc
[_] across sum across rows and grab result in calc as a vector
[:] down sum down the columns and grab result in calc
[m] yank-mat yank matrix from top of calc stack, overwriting selected rect
+
Etc:
+
[?] help view this Help buffer
[q] quit exit rectangle-mark-mode
```
diff --git a/speedrect.el b/speedrect.el
index 1823514976..3227b1d267 100644
--- a/speedrect.el
+++ b/speedrect.el
@@ -75,7 +75,7 @@ rect and exit `rectangle-mark-mode'."
(interactive)
(set-mark (point)))
-(defun speedrect-shift (columns)
+(defun speedrect-shift-right (columns)
"Shift the current speedrect by COLUMNS (negative to the left, default 1).
Note that point and mark will not move beyond the end of text on their lines."
(interactive "P")
@@ -83,25 +83,54 @@ Note that point and mark will not move beyond the end of
text on their lines."
(pcol (current-column))
(columns (or columns 1))
(mcol (progn (goto-char (mark)) (current-column))))
- (move-to-column (+ mcol columns))
+ (move-to-column (max 0 (+ mcol columns)))
(set-mark (point))
(goto-char p)
- (move-to-column (+ pcol columns))))
+ (move-to-column (max 0 (+ pcol columns)))))
-(defun speedrect-shift-fast (columns)
+(defun speedrect-shift-right-fast (columns)
"Shift the current speedrect left by COLUMNS (default 5)."
(interactive "P")
- (speedrect-shift (or columns 5)))
+ (speedrect-shift-right (or columns 5)))
(defun speedrect-shift-left (columns)
"Shift the current speedrect left by COLUMNS (default 1)."
(interactive "P")
- (speedrect-shift (- (or columns 1))))
+ (speedrect-shift-right (- (or columns 1))))
(defun speedrect-shift-left-fast (columns)
"Shift the current speedrect left by COLUMNS (default 5)."
(interactive "P")
- (speedrect-shift (- (or columns 5))))
+ (speedrect-shift-right (- (or columns 5))))
+
+(defun speedrect-shift-down (lines)
+ "Shift rectangle down by LINES."
+ (interactive "P")
+ (let ((p (point))
+ (pcol (current-column))
+ (lines (or lines 1))
+ (mcol (progn (goto-char (mark)) (current-column))))
+ (forward-line lines)
+ (move-to-column mcol)
+ (set-mark (point))
+ (goto-char p)
+ (forward-line lines)
+ (move-to-column pcol)))
+
+(defun speedrect-shift-down-fast (lines)
+ "Shift the current speedrect down by LINES (default 5)."
+ (interactive "P")
+ (speedrect-shift-down (or lines 5)))
+
+(defun speedrect-shift-up (lines)
+ "Shift the current speedrect up by LINES (default 1)."
+ (interactive "P")
+ (speedrect-shift-down (- (or lines 1))))
+
+(defun speedrect-shift-up-fast (lines)
+ "Shift the current speedrect up by LINES (default 5)."
+ (interactive "P")
+ (speedrect-shift-down (- (or lines 5))))
(defun speedrect-delete-rest (start end)
"Keep rectangle between START and END, deleting the rest of the affected
lines."
@@ -189,8 +218,12 @@ each side of the inserted text."
"Shift Rectangle (can use numeric prefixes):\n\n"
" [S-left] move the rectangle left\n"
" [S-right] move the rectangle right\n"
+ " [S-up] move the rectangle up\n"
+ " [S-down] move the rectangle down\n"
" [M-S-left] move the rectangle left 5 columns\n"
- " [M-S-right] move the rectangle right 5 columns\n\n"
+ " [M-S-right] move the rectangle right 5 columns\n"
+ " [M-S-up] move the rectangle up 5 columns\n"
+ " [M-S-down] move the rectangle down 5 lines\n\n"
"Copy/Yank:\n\n"
" [w] copy copy rectangle for future yanking\n"
" [y] yank yank rectangle, inserting at point\n\n"
@@ -223,10 +256,14 @@ prior to deactivating mark."
("d" delete-rectangle) ("N" rectangle-number-lines)
("r" speedrect-delete-rest) ("SPC" delete-whitespace-rectangle)
;; Shift rect
- ("S-<right>" speedrect-shift)
+ ("S-<right>" speedrect-shift-right)
("S-<left>" speedrect-shift-left)
- ("M-S-<right>" speedrect-shift-fast)
+ ("M-S-<right>" speedrect-shift-right-fast)
("M-S-<left>" speedrect-shift-left-fast)
+ ("S-<up>" speedrect-shift-up)
+ ("S-<down>" speedrect-shift-down)
+ ("M-S-<up>" speedrect-shift-up-fast)
+ ("M-S-<down>" speedrect-shift-down-fast)
;; Calc commands
("_" calc-grab-sum-across) (":" calc-grab-sum-down) ("#"
calc-grab-rectangle)
("m" speedrect-yank-from-calc)
- [elpa] externals/speedrect 0ea0dba568 20/90: more doc tweaks, (continued)
- [elpa] externals/speedrect 0ea0dba568 20/90: more doc tweaks, ELPA Syncer, 2024/12/06
- [elpa] externals/speedrect 2aac618746 26/90: speedrect-yank-from-calc: added, ELPA Syncer, 2024/12/06
- [elpa] externals/speedrect f0de893e1a 14/90: kill-rest: added on "r", ELPA Syncer, 2024/12/06
- [elpa] externals/speedrect 1e9b598017 21/90: Update README.md, ELPA Syncer, 2024/12/06
- [elpa] externals/speedrect 952899587f 24/90: doc: extend bar, ELPA Syncer, 2024/12/06
- [elpa] externals/speedrect 395c578693 25/90: doc tweaks, ELPA Syncer, 2024/12/06
- [elpa] externals/speedrect 496f6e7473 31/90: Update README.md, ELPA Syncer, 2024/12/06
- [elpa] externals/speedrect 0d899fc06d 34/90: Update README.md, ELPA Syncer, 2024/12/06
- [elpa] externals/speedrect 7abd0d9337 33/90: Update README.md, ELPA Syncer, 2024/12/06
- [elpa] externals/speedrect bb9d61cba6 39/90: Update README.md, ELPA Syncer, 2024/12/06
- [elpa] externals/speedrect 629e9d935b 42/90: add move up/down commands and [M-]S-<up>/<down>,
ELPA Syncer <=
- [elpa] externals/speedrect f81a17461d 53/90: Update README.md, ELPA Syncer, 2024/12/06
- [elpa] externals/speedrect d4d89acb50 27/90: yank-from-calc: preserve at least one space padding each side, ELPA Syncer, 2024/12/06
- [elpa] externals/speedrect a8b179b738 41/90: Remove superfluous \n, ELPA Syncer, 2024/12/06
- [elpa] externals/speedrect 1ffb2c76ca 30/90: Update README.md, ELPA Syncer, 2024/12/06
- [elpa] externals/speedrect 3cab9dfcc5 35/90: Update README.md, ELPA Syncer, 2024/12/06
- [elpa] externals/speedrect d9d7f79977 36/90: calc-grab-sum-down/across: switch to `_` and `:` to mirror calc, ELPA Syncer, 2024/12/06
- [elpa] externals/speedrect 1e732a5b35 44/90: bump version, ELPA Syncer, 2024/12/06
- [elpa] externals/speedrect a9086d65e5 45/90: speedrect-right-char: correct rectangle-right logic, ELPA Syncer, 2024/12/06
- [elpa] externals/speedrect 6867945e0b 54/90: Update README.md, ELPA Syncer, 2024/12/06
- [elpa] externals/speedrect 2a4d4f0bcd 59/90: Properly handle point/mark crutches for saving rects, ELPA Syncer, 2024/12/06