[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/latex-table-wizard 1f4effedfa 59/70: NOCYCLE argument a
|
From: |
ELPA Syncer |
|
Subject: |
[elpa] externals/latex-table-wizard 1f4effedfa 59/70: NOCYCLE argument added to movement commands |
|
Date: |
Sat, 13 May 2023 08:59:14 -0400 (EDT) |
branch: externals/latex-table-wizard
commit 1f4effedfa3d601a4cbf6989e23c5f337ddd02e7
Author: Enrico Flor <enrico@eflor.net>
Commit: Enrico Flor <enrico@eflor.net>
NOCYCLE argument added to movement commands
---
NEWS | 5 ++-
latex-table-wizard.el | 94 +++++++++++++++++++++++++++++++++++++--------------
2 files changed, 73 insertions(+), 26 deletions(-)
diff --git a/NEWS b/NEWS
index 38141af4d7..1874e595a0 100644
--- a/NEWS
+++ b/NEWS
@@ -13,7 +13,10 @@
aliased to new command "latex-table-wizard-kill-column-content"
*** latex-table-wizard-kill-row
aliased to new command "latex-table-wizard-kill-row-content"
-
+*** latex-table-wizard-right, latex-table-wizard-left,
latex-table-wizard-down, latex-table-wizard-up
+added a second optional argument NOCYCLE that makes the command return
+nil (instead of moving point), in case the movement in the chosen
+direction hits the boundaries of the table.
* 1.2.0 <2022-12-20 Tue>
** New user option: latex-table-wizard-allow-detached-args
diff --git a/latex-table-wizard.el b/latex-table-wizard.el
index 0fef2c4d7e..84fad56f23 100644
--- a/latex-table-wizard.el
+++ b/latex-table-wizard.el
@@ -743,7 +743,38 @@ plists."
(lambda (x y) (> (plist-get x other-prop)
(plist-get y other-prop))))))))
-(defun latex-table-wizard--jump (dir &optional absolute count same-line)
+(defsubst latex-table-wizard--shift (dir cell table)
+ "Given a CELL and a list of cells TABLE, return one of TABLE.
+
+The cell returned is the one whose coordinates correspond to
+having CELL shifted in direction DIR (whose value is either
+\\='next\\=', \\='previous\\=', \\='forward\\=' or
+\\='backward\\='). If no such cell is found in TABLE, return
+nil."
+ (let (target ; cons cell column . row
+ output)
+ (cond ((eq dir 'next)
+ (setq target (cons (plist-get cell :column)
+ (1+ (plist-get cell :row)))))
+ ((eq dir 'previous)
+ (setq target (cons (plist-get cell :column)
+ (1- (plist-get cell :row)))))
+ ((eq dir 'forward)
+ (setq target (cons (1+ (plist-get cell :column))
+ (plist-get cell :row))))
+ ((eq dir 'backward)
+ (setq target (cons (1- (plist-get cell :column))
+ (plist-get cell :row)))))
+ (catch 'found
+ (dolist (c table)
+ (when (and (= (plist-get c :column) (car target))
+ (= (plist-get c :row) (cdr target)))
+ (setq output c)
+ (throw 'found t))))
+ output))
+
+(defun latex-table-wizard--jump (dir &optional absolute
+ count same-line nocycle)
"Move point to the beginning of a cell in the table.
DIR is either \\='next\\=', \\='previous\\=', \\='forward\\=' or
@@ -757,7 +788,12 @@ or column (depending on the value of DIR) point is
currently in.
COUNT is a positive integer that determines how many steps in
direction DIR to take.
-If SAME-LINE is non-nil, never leave current column or row."
+If SAME-LINE is non-nil, never leave current column or row.
+
+If NOCYCLE is non-nil, do not move and return nil in case the
+jump would move point to a different column (if DIR is either
+\\='forward\\=' or \\='backward\\=') or to a different row (if
+DIR is either \\='next\\=', \\='previous\\=')."
(unless (ignore-errors (save-excursion (LaTeX-find-matching-begin)))
(user-error "Not in a LaTeX environment"))
(let* ((message-log-max 0)
@@ -769,14 +805,17 @@ If SAME-LINE is non-nil, never leave current column or
row."
(let ((sorted (latex-table-wizard--sort cells t dir)))
(if (memq dir '(previous backward))
(car sorted)
- (car (last sorted)))))))
+ (car (last sorted))))))
+ (stop (and nocycle (not (latex-table-wizard--shift dir curr cells)))))
(latex-table-wizard--remove-overlays cells)
- (goto-char (plist-get target :start))
- (latex-table-wizard--hl-cells `(,target))
- (latex-table-wizard--hl-cells latex-table-wizard--selection)
- (message "Col X Row (%d,%d)"
- (plist-get target :column)
- (plist-get target :row))))
+ (unless stop
+ ;; (goto-char (plist-get curr :start))
+ (goto-char (plist-get target :start))
+ (latex-table-wizard--hl-cells `(,target))
+ (latex-table-wizard--hl-cells latex-table-wizard--selection)
+ (message "Col X Row (%d,%d)"
+ (plist-get target :column)
+ (plist-get target :row)))))
@@ -1017,46 +1056,51 @@ Leave point at the beginning of the cell.
If N is nil, move one cell to the right.
-If there is no cell to the right of where point is, move to the
-leftmost cell of the row below where point is."
+If there is no cell to the right of where point is, and NOCYCLE
+is nil, move to the leftmost cell of the row below where point
+is. If NOCYCLE is non-nil, do not move and return nil in that
+case."
(interactive "p")
- (latex-table-wizard--jump 'forward nil n))
+ (latex-table-wizard--jump 'forward nil nil n))
-(defun latex-table-wizard-left (&optional n)
+(defun latex-table-wizard-left (&optional n nocycle)
"Move point N cells to the left.
Leave point at the beginning of the cell.
If N is nil, move one cell to the left.
-If there is no cell to the left of where point is, move to the
-rightmost cell of the row above where point is."
+If there is no cell to the left of where point is, and NOCYCLE is
+nil, move to the rightmost cell of the row above where point is.
+If NOCYCLE is non-nil, do not move and return nil in that case."
(interactive "p")
- (latex-table-wizard--jump 'backward nil n))
+ (latex-table-wizard--jump 'backward nil n nil nocycle))
-(defun latex-table-wizard-down (&optional n)
+(defun latex-table-wizard-down (&optional n nocycle)
"Move point N cells down.
Leave point at the beginning of the cell.
If N is nil, move one row down.
-If there is no row below where point is, move to the top cell of
-the column to the right of where point is."
+If there is no row below where point is, and NOCYCLE is nil, move
+to the top cell of the column to the right of where point is. If
+NOCYCLE is non-nil, do not move and return nil in that case."
(interactive "p")
- (latex-table-wizard--jump 'next nil n))
+ (latex-table-wizard--jump 'next nil n nil nocycle))
-(defun latex-table-wizard-up (&optional n)
+(defun latex-table-wizard-up (&optional n nocycle)
"Move point N cells up.
Leave point at the beginning of the cell.
If N is nil, move one row up.
-If there is no row above where point is, move to the bottom cell
-of the column to the left of where point is."
+If there is no row above where point is, and NOCYCLE is nil, move
+to the bottom cell of the column to the left of where point is.
+If NOCYCLE is non-nil, do not move and return nil in that case."
(interactive "p")
- (latex-table-wizard--jump 'previous nil n))
+ (latex-table-wizard--jump 'previous nil n nil nocycle))
(defun latex-table-wizard-end-of-row ()
"Move point to the rightmost cell in current row."
@@ -1642,7 +1686,7 @@ If non-nil TABLE is a list of cells."
(envs (latex-table-wizard--get-env-ends tab))
(out t))
(dolist (c latex-table-wizard--selection)
- (unless (< (car envs) (plist-get c :start) (cdr envs))
+ (unless (<= (car envs) (plist-get c :start) (cdr envs))
(setq out nil)))
out)))
- [elpa] externals/latex-table-wizard 9ce3165694 32/70: Add center and right alignment, (continued)
- [elpa] externals/latex-table-wizard 9ce3165694 32/70: Add center and right alignment, ELPA Syncer, 2023/05/13
- [elpa] externals/latex-table-wizard e3553c7759 34/70: Add feedback about cell jumps, ELPA Syncer, 2023/05/13
- [elpa] externals/latex-table-wizard 13359e40f6 44/70: rename readme, ELPA Syncer, 2023/05/13
- [elpa] externals/latex-table-wizard f290f87949 45/70: add empty changelog file, ELPA Syncer, 2023/05/13
- [elpa] externals/latex-table-wizard 3bafcbefeb 49/70: Update commentary section, ELPA Syncer, 2023/05/13
- [elpa] externals/latex-table-wizard 36e68b0fd8 48/70: Add .elpaignore, ELPA Syncer, 2023/05/13
- [elpa] externals/latex-table-wizard 85af90dac4 52/70: Use TeX-comment-forward, ELPA Syncer, 2023/05/13
- [elpa] externals/latex-table-wizard ff8c832ad0 53/70: Version 1.1.0, ELPA Syncer, 2023/05/13
- [elpa] externals/latex-table-wizard 71b7b2c252 55/70: Update copyright year and fix bug, ELPA Syncer, 2023/05/13
- [elpa] externals/latex-table-wizard 2544236eb3 57/70: New commands to kill row and column content, ELPA Syncer, 2023/05/13
- [elpa] externals/latex-table-wizard 1f4effedfa 59/70: NOCYCLE argument added to movement commands,
ELPA Syncer <=
- [elpa] externals/latex-table-wizard d5494445cf 62/70: Fix latex-table-wizard--comment-thing for multiline cells, ELPA Syncer, 2023/05/13
- [elpa] externals/latex-table-wizard c496237fa1 64/70: Minor bug fix in latex-table-wizard-right, ELPA Syncer, 2023/05/13
- [elpa] externals/latex-table-wizard 04b3d59de7 65/70: Four new commands added to edit cell content, ELPA Syncer, 2023/05/13
- [elpa] externals/latex-table-wizard e61e1c1f0f 69/70: Fix parsing when whole table is inside certain macros, ELPA Syncer, 2023/05/13
- [elpa] externals/latex-table-wizard 9d779a2d9b 42/70: Correct conditional in mode startup, ELPA Syncer, 2023/05/13
- [elpa] externals/latex-table-wizard f2f2efeed4 50/70: New alignment commands and bug fixes, ELPA Syncer, 2023/05/13
- [elpa] externals/latex-table-wizard c315f144a6 47/70: Add short description file, ELPA Syncer, 2023/05/13
- [elpa] externals/latex-table-wizard bb8c0e04f1 58/70: Two commands to comment out cells added, ELPA Syncer, 2023/05/13
- [elpa] externals/latex-table-wizard c3b1802c1e 29/70: Syntax-quote lists, ELPA Syncer, 2023/05/13
- [elpa] externals/latex-table-wizard 4b5670e397 33/70: Collapse align and compress whitespace commands, ELPA Syncer, 2023/05/13