Hi again,
Folding $x \in [0,1]$ doesn't work as intended: [0,1] gets folded as if it
were an optional argument to \in.
The issue is that, when called on 'math macros, TeX-fold-item-end calls
TeX-find-macro, which skips past any {...} or [...].
The attached patch makes an expection in TeX-fold-item-end for 'math
macros, so that only the macro name itself (e.g., "\in") is folded.
This only affects the folding of macros in the list
TeX-fold-math-spec-list-internal, and looking through that list, I
didn't spot any for which this change would have an undesired effect.
Any feedback welcome.
Thanks, best,
Paul
>From 83db375da4ea71b5abae3c010f2160f87086e850 Mon Sep 17 00:00:00 2001
From: Paul Nelson <[email protected]>
Date: Sun, 25 May 2025 17:54:15 +0200
Subject: [PATCH] Fix math macro folding to not consume subsequent brackets
* tex-fold.el (TeX-fold-item-end): Add special handling for math
macros to only fold the macro name itself, not following
arguments. For instance, in "$x \in [0,1]$", this prevents
folding [0,1] as an optional argument to \in.
---
tex-fold.el | 6 ++++++
1 file changed, 6 insertions(+)
diff --git a/tex-fold.el b/tex-fold.el
index 766270ef..78e5b822 100644
--- a/tex-fold.el
+++ b/tex-fold.el
@@ -901,6 +901,12 @@ TYPE can be either `env' for environments, `macro' for macros or
(goto-char (1+ start))
(LaTeX-find-matching-end)
(point))
+ ((eq type 'math)
+ (goto-char (1+ start))
+ (if (zerop (skip-chars-forward "A-Za-z@"))
+ (forward-char)
+ (skip-chars-forward "*"))
+ (point))
(t
(goto-char start)
(TeX-find-macro-end)))))
--
2.39.3 (Apple Git-145)
_______________________________________________
bug-auctex mailing list
[email protected]
https://lists.gnu.org/mailman/listinfo/bug-auctex