Thanks Luca.
I see that the folding of quotes is indeed brittle when applied to quote
pairs such as "\enquote{" and "}", for the reason you say, that closing
brackets "}" appear in many more places than just quotes.
Perhaps it would be more robust to restrict quote folding to the
standard pairs by default. After all, one can always fold \enquote{...}
macros directly, by customizing TeX-fold-macro-spec-list.
I'll confess that I wasn't familiar with the sorts of settings people
might use for quotes. Are there popular options besides ("``", "''")
and ("\\enquote", "}")? If not, then I'm inclined to install the
attached patch to avoid issues like what Luca encountered. Any thoughts
welcome.
Paul
>From e1ec2edf909b0426b50c220d1b13c52aef59c929 Mon Sep 17 00:00:00 2001
From: Paul Nelson <[email protected]>
Date: Mon, 29 Sep 2025 12:07:47 +0100
Subject: [PATCH] Simplify quote character handling in TeX-fold-quotes
* tex-fold.el (TeX-fold-quotes): Hardcode standard quote
characters instead of calling TeX-get-quote-characters to avoid
excessive folding when using \enquote{...}.
---
tex-fold.el | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/tex-fold.el b/tex-fold.el
index 20c8d27a..0ef1d7e1 100644
--- a/tex-fold.el
+++ b/tex-fold.el
@@ -1486,7 +1486,7 @@ Consulted by `TeX-insert-quote'."
Replaces opening and closing quotes with `TeX-fold-open-quote' and
`TeX-fold-close-quote', respectively, except in math environments,
verbatim contexts and comments."
- (pcase-let ((`(,open-quote ,close-quote _) (TeX-get-quote-characters)))
+ (pcase-let ((`(,open-quote ,close-quote _) '("``" "''")))
(save-excursion
(goto-char start)
(let ((regexp (regexp-opt (list open-quote close-quote))))
--
2.39.5 (Apple Git-154)