[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/tex-parens 78a261d2e3 22/62: make all user-facing comma
From: |
ELPA Syncer |
Subject: |
[elpa] externals/tex-parens 78a261d2e3 22/62: make all user-facing commands accept ARG for repetition |
Date: |
Thu, 6 Jun 2024 04:00:57 -0400 (EDT) |
branch: externals/tex-parens
commit 78a261d2e338fa72664ca7f2f545bf1623fc66c0
Author: Paul Nelson <ultrono@gmail.com>
Commit: Paul Nelson <ultrono@gmail.com>
make all user-facing commands accept ARG for repetition
especially convenient for tp-down-list, which can now called with the
prefix argument "-" to go backwards
---
tex-parens.el | 201 +++++++++++++++++++++++++++++++++++++++++-----------------
1 file changed, 144 insertions(+), 57 deletions(-)
diff --git a/tex-parens.el b/tex-parens.el
index 9259257a3f..a860392256 100644
--- a/tex-parens.el
+++ b/tex-parens.el
@@ -379,7 +379,27 @@ terminates `\left{'), so we do not treat it as an error."
(unless (equal other stack-top)
(message "Mismatched delimiters: %s %s" stack-top delim))))
-(defun tp-forward-list (&optional bound)
+(defun tp-forward-list (&optional arg)
+ "Move forward across one balanced group.
+With ARG, do it that many times. Negative arg -N means move
+backward across N balanced groups."
+ (interactive "^p")
+ (or arg (setq arg 1))
+ (while (> arg 0)
+ (tp--forward-list-1)
+ (setq arg (1- arg)))
+ (while (< arg 0)
+ (tp-backward-list)
+ (setq arg (1+ arg))))
+
+(defun tp-backward-list (&optional arg)
+ "Move backward across one balanced group.
+With ARG, do it that many times. Negative
+arg -N means move forward across N balanced groups."
+ (interactive "^p")
+ (tp-forward-list (- arg)))
+
+(defun tp--forward-list-1 (&optional bound)
"Move forward across one balanced group.
Search up to BOUND."
(interactive)
@@ -405,7 +425,7 @@ Search up to BOUND."
(when tp--debug
(message "Unmatched delimiters: %s" (car stack))))))
-(defun tp-backward-list (&optional bound)
+(defun tp--backward-list-1 (&optional bound)
"Move backward across one balanced group.
Search up to BOUND."
(interactive)
@@ -431,51 +451,37 @@ Search up to BOUND."
(when tp--debug
(message "Unmatched delimiters: %s" (car stack))))))
-(defun tp-backward-up-list (&optional bound)
- "Move backward out of one balanced group.
-Search up to BOUND."
- (interactive)
- (unless bound (setq bound (tp--backward-bound)))
- (let ((start (point))
- success
- (delim (tp--backward-delim bound))
- (stack ()))
- (while delim
- (if (tp--backward-search-found-close delim)
- (push delim stack)
- (if stack
- (progn
- (tp--check-match delim (tp--close-of-open delim) (car stack))
- (pop stack))
- (setq success t)))
- (setq delim (and (not success) (tp--backward-delim bound))))
- (unless success
- (goto-char start))))
+(defun tp-forward-sexp (&optional arg)
+ "Move forward across one balanced expression (sexp).
+If `forward-sexp' does not take us past the starting point of the
+next delimiter, then do that. Otherwise, do
+`tp-forward-list'.
-(defun tp-up-list (&optional bound)
- "Move forward out of one balanced group.
-Search up to BOUND."
- (interactive)
- (unless bound (setq bound (tp--forward-bound)))
- (let ((start (point))
- success
- (delim (tp--forward-delim bound))
- (stack ()))
- (while delim
- (if (tp--forward-search-found-open delim)
- (push delim stack)
- (if stack
- (progn
- (tp--check-match delim (tp--open-of-close delim) (car stack))
- (pop stack))
- (setq success t)))
- (setq delim (and (not success) (tp--forward-delim bound))))
- (unless success
- (goto-char start))))
+With ARG, do it that many times. Negative arg -N means move
+backward across N balanced expressions."
+ (interactive "^p")
+ (or arg (setq arg 1))
+ (while (> arg 0)
+ (tp--forward-sexp-1)
+ (setq arg (1- arg)))
+ (while (< arg 0)
+ (tp--backward-sexp-1)
+ (setq arg (1+ arg))))
+
+(defun tp-backward-sexp (&optional arg)
+ "Move forward across one balanced expression (sexp).
+If `forward-sexp' does not take us past the starting point of the
+next delimiter, then do that. Otherwise, do
+`tp-forward-list'.
+
+With ARG, do it that many times. Negative arg -N means move
+backward across N balanced expressions."
+ (interactive "^p")
+ (tp-forward-sexp (- arg)))
(defun tp--forward-sexp-1 ()
"Move forward across one balanced expression (sexp).
-Helper function for `tp-backward-sexp'."
+Helper function for `tp-forward-sexp'."
(let ((delim-beg (save-excursion
(tp--forward-delim)
(match-beginning 0)))
@@ -484,10 +490,10 @@ Helper function for `tp-backward-sexp'."
(point))))
(if (and delim-beg
(> vanilla delim-beg))
- (tp-forward-list)
+ (tp--forward-list-1)
(goto-char vanilla))))
-(defun tp-backward-sexp ()
+(defun tp--backward-sexp-1 ()
"Move backward across one balanced expression (sexp).
If `backward-sexp' does not take us beyond the ending point of
the previous delimiter, then do that. Otherwise, do
@@ -503,27 +509,92 @@ the previous delimiter, then do that. Otherwise, do
(point))))
(if (and delim-end
(< vanilla delim-end))
- (tp-backward-list)
+ (tp--backward-list-1)
(goto-char vanilla))))
-(defun tp-forward-sexp (&optional arg)
- "Move forward across one balanced expression (sexp).
-If `forward-sexp' does not take us past the starting point of the
-next delimiter, then do that. Otherwise, do
-`tp-forward-list'.
+(defun tp-up-list (&optional arg)
+ "Move forward out of one balanced group.
+With ARG, do it that many times. Negative arg -N means move
+backward out of N balanced groups."
+ (interactive "^p")
+ (or arg (setq arg 1))
+ (while (> arg 0)
+ (tp--up-list-1)
+ (setq arg (1- arg)))
+ (while (< arg 0)
+ (tp--backward-up-list-1)
+ (setq arg (1+ arg))))
+(defun tp-backward-up-list (&optional arg)
+ "Move backward out of one balanced group.
With ARG, do it that many times. Negative arg -N means move
-backward across N balanced expressions."
+forward out of N balanced groups."
+ (interactive "^p")
+ (tp-up-list (- arg)))
+
+(defun tp--up-list-1 (&optional bound)
+ "Move forward out of one balanced group.
+Search up to BOUND."
+ (interactive)
+ (unless bound (setq bound (tp--forward-bound)))
+ (let ((start (point))
+ success
+ (delim (tp--forward-delim bound))
+ (stack ()))
+ (while delim
+ (if (tp--forward-search-found-open delim)
+ (push delim stack)
+ (if stack
+ (progn
+ (tp--check-match delim (tp--open-of-close delim) (car stack))
+ (pop stack))
+ (setq success t)))
+ (setq delim (and (not success) (tp--forward-delim bound))))
+ (unless success
+ (goto-char start))))
+
+(defun tp--backward-up-list-1 (&optional bound)
+ "Move backward out of one balanced group.
+Search up to BOUND."
+ (interactive)
+ (unless bound (setq bound (tp--backward-bound)))
+ (let ((start (point))
+ success
+ (delim (tp--backward-delim bound))
+ (stack ()))
+ (while delim
+ (if (tp--backward-search-found-close delim)
+ (push delim stack)
+ (if stack
+ (progn
+ (tp--check-match delim (tp--close-of-open delim) (car stack))
+ (pop stack))
+ (setq success t)))
+ (setq delim (and (not success) (tp--backward-delim bound))))
+ (unless success
+ (goto-char start))))
+
+(defun tp-down-list (&optional arg)
+ "Move forward into one balanced group.
+With ARG, do it that many times. Negative arg -N means move
+backward into N balanced groups."
(interactive "^p")
(or arg (setq arg 1))
(while (> arg 0)
- (tp--forward-sexp-1)
+ (tp--down-list-1)
(setq arg (1- arg)))
(while (< arg 0)
- (tp-backward-sexp)
+ (tp--backward-down-list-1)
(setq arg (1+ arg))))
-(defun tp-down-list (&optional bound)
+(defun tp-backward-down-list (&optional arg)
+ "Move backward into one balanced group.
+With ARG, do it that many times. Negative arg -N means move
+forward into N balanced groups."
+ (interactive "^p")
+ (tp-down-list (- arg)))
+
+(defun tp--down-list-1 (&optional bound)
"Move forward into one balanced group.
Search up to BOUND. Return t if successful, nil otherwise."
(interactive)
@@ -540,13 +611,29 @@ Search up to BOUND. Return t if successful, nil
otherwise."
(preview-move-point))
success))
+(defun tp--backward-down-list-1 (&optional bound)
+ "Move backward into one balanced group.
+Search up to BOUND. Return t if successful, nil otherwise."
+ (interactive)
+ (unless bound (setq bound (tp--backward-bound)))
+ (let ((start (point))
+ (delim (tp--backward-delim bound))
+ success)
+ (when (and delim
+ (tp--backward-search-found-close delim))
+ (setq success t))
+ (unless success
+ (goto-char start))
+ (when (fboundp 'preview-move-point)
+ (preview-move-point))
+ success))
+
(defun tp-delete-pair (&optional bound)
"Delete a balanced pair of delimiters that follow point.
Push a mark at the end of the contents of the pair.
Search up to BOUND."
(interactive)
- (unless bound (setq bound (tp--forward-bound)))
- (when (tp-down-list bound)
+ (when (tp--down-list-1)
(save-excursion
(tp-up-list)
(let ((q (point)))
- [elpa] externals/tex-parens 53bf2e5c4f 44/62: change comment detection, (continued)
- [elpa] externals/tex-parens 53bf2e5c4f 44/62: change comment detection, ELPA Syncer, 2024/06/06
- [elpa] externals/tex-parens 5e94f47595 45/62: add #'pop-to-mark-command to auto-reveal list for preview/TeX-fold, ELPA Syncer, 2024/06/06
- [elpa] externals/tex-parens 15b106f6ea 47/62: fix bug in tp-forward-sexp, ELPA Syncer, 2024/06/06
- [elpa] externals/tex-parens 13eea1b412 48/62: fix TeX-fold-auto-reveal setup, ELPA Syncer, 2024/06/06
- [elpa] externals/tex-parens e4c941a350 49/62: turn a bug into a feature, ELPA Syncer, 2024/06/06
- [elpa] externals/tex-parens 147de81a27 53/62: revertsomechanges, ELPA Syncer, 2024/06/06
- [elpa] externals/tex-parens 548c6743f9 52/62: change tp to tex-parens in README, ELPA Syncer, 2024/06/06
- [elpa] externals/tex-parens 2d2e467d1d 58/62: Tweak commentary, ELPA Syncer, 2024/06/06
- [elpa] externals/tex-parens 1b1ba96a09 56/62: change to new auto reveal customization, ELPA Syncer, 2024/06/06
- [elpa] externals/tex-parens b427ee42af 61/62: add some variant commands, ELPA Syncer, 2024/06/06
- [elpa] externals/tex-parens 78a261d2e3 22/62: make all user-facing commands accept ARG for repetition,
ELPA Syncer <=
- [elpa] externals/tex-parens ea1260bc27 28/62: fix some beginning of buffer bug, ELPA Syncer, 2024/06/06
- [elpa] externals/tex-parens 6f5e8328ee 55/62: change tp- to tex-parens-p in auto-reveal customizations, ELPA Syncer, 2024/06/06
- [elpa] externals/tex-parens 79c263f2e6 37/62: account for name change of tp--math-face, clarify doc strings, ELPA Syncer, 2024/06/06
- [elpa] externals/tex-parens aa11f6c222 42/62: fix bug for detection of comments and quotes in math, ELPA Syncer, 2024/06/06
- [elpa] externals/tex-parens 10a25a3e3e 59/62: remove (interactive) from some internal functions, ELPA Syncer, 2024/06/06
- [elpa] externals/tex-parens b38d8c8ffc 30/62: add mention of latex-extra, ELPA Syncer, 2024/06/06
- [elpa] externals/tex-parens acf5524a26 31/62: Make tp-down-list auto-reveal folds from TeX-fold-mode, ELPA Syncer, 2024/06/06
- [elpa] externals/tex-parens 6d5ee64608 62/62: address issue involving optional begin{...} arguments, ELPA Syncer, 2024/06/06