GNU bug report logs -
#78693
14.0.9; Folding of math macros with a function spec is broken
Previous Next
To reply to this bug, email your comments to 78693 AT debbugs.gnu.org.
Toggle the display of automated, internal messages from the tracker.
Report forwarded
to
bug-auctex <at> gnu.org
:
bug#78693
; Package
auctex
.
(Wed, 04 Jun 2025 08:49:04 GMT)
Full text and
rfc822 format available.
Acknowledgement sent
to
Rahguzar <rahguzar <at> mailbox.org>
:
New bug report received and forwarded. Copy sent to
bug-auctex <at> gnu.org
.
(Wed, 04 Jun 2025 08:49:04 GMT)
Full text and
rfc822 format available.
Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):
[Message part 1 (text/plain, inline)]
Dear AucTeX maintainers,
The commits
d0a57d8d Fix math macro folding to not consume subsequent brackets
33f9eb07 Fix TeX macro end detection in some edge cases
break the folding of math macros with a function spec.
E.g. evaluate
(setq TeX-fold-math-spec-list `((,(lambda (text) (propertize text 'face '(underline))) ("underline"))))
and open the attached file. Do `M-x TeX-fold-mode RET` followed by `M-x
TeX-fold-buffer RET`. This results in
[Error: no content or function found]
getting displayed instead of \underline.
My config has many folding specs which are functions and all of them
exhibit the same behavior.
Reverting the commits above fixes the issue.
Thanks,
Rahguzar
Emacs : GNU Emacs 30.1 (build 1, aarch64-redhat-linux-gnu, GTK+ Version 3.24.49, cairo version 1.18.2)
of 2025-04-08
Package: 14.0.9
current state:
==============
(setq
window-system 'pgtk
LaTeX-version "2e"
TeX-style-path '("/home/azeem/.local/state/emacs/auctex/" "/home/azeem/.local/state/emacs/elpaca/builds/auctex/style" "/home/azeem/.local/state/emacs/auctex/auto"
"/home/azeem/.local/state/emacs/auctex/style" "auto" "style")
TeX-auto-save nil
TeX-parse-self nil
TeX-master t
TeX-command-list '(("TeX" "%(PDF)%(tex) %(file-line-error) %`%(extraopts) %S%(PDFout)%(mode)%' %(output-dir) %t" TeX-run-TeX nil (plain-TeX-mode AmSTeX-mode Texinfo-mode) :help "Run plain TeX")
("LaTeX" "%`%l%(mode)%' %T" TeX-run-TeX nil (LaTeX-mode docTeX-mode) :help "Run LaTeX")
("Makeinfo" "makeinfo %(extraopts) %(o-dir) %t" TeX-run-compile nil (Texinfo-mode) :help "Run Makeinfo with Info output")
("Makeinfo HTML" "makeinfo %(extraopts) %(o-dir) --html %t" TeX-run-compile nil (Texinfo-mode) :help "Run Makeinfo with HTML output")
("AmSTeX" "amstex %(PDFout) %`%(extraopts) %S%(mode)%' %(output-dir) %t" TeX-run-TeX nil (AmSTeX-mode) :help "Run AMSTeX")
("ConTeXt" "%(cntxcom) --once %(extraopts) %(execopts)%t" TeX-run-TeX nil (ConTeXt-mode) :help "Run ConTeXt once")
("ConTeXt Full" "%(cntxcom) %(extraopts) %(execopts)%t" TeX-run-TeX nil (ConTeXt-mode) :help "Run ConTeXt until completion")
("BibTeX" "bibtex %(O?aux)" TeX-run-BibTeX nil (plain-TeX-mode LaTeX-mode docTeX-mode AmSTeX-mode Texinfo-mode ConTeXt-mode) :help "Run BibTeX")
("Biber" "biber %(output-dir) %s" TeX-run-Biber nil (plain-TeX-mode LaTeX-mode docTeX-mode AmSTeX-mode Texinfo-mode) :help "Run Biber")
("Texindex" "texindex %s.??" TeX-run-command nil (Texinfo-mode) :help "Run Texindex")
("Texi2dvi" "%(PDF)texi2dvi %t" TeX-run-command nil (Texinfo-mode) :help "Run Texi2dvi or Texi2pdf") ("View" "%V" TeX-run-discard-or-function t t :help "Run Viewer")
("Print" "%p" TeX-run-command t t :help "Print the file") ("Queue" "%q" TeX-run-background nil t :help "View the printer queue" :visible TeX-queue-command)
("File" "%(o?)dvips %d -o %f " TeX-run-dvips t (plain-TeX-mode LaTeX-mode docTeX-mode AmSTeX-mode Texinfo-mode) :help "Generate PostScript file")
("Dvips" "%(o?)dvips %d -o %f " TeX-run-dvips nil (plain-TeX-mode LaTeX-mode docTeX-mode AmSTeX-mode Texinfo-mode) :help "Convert DVI file to PostScript")
("Dvipdfmx" "dvipdfmx -o %(O?pdf) %d" TeX-run-dvipdfmx nil (plain-TeX-mode LaTeX-mode docTeX-mode AmSTeX-mode Texinfo-mode) :help "Convert DVI file to PDF with dvipdfmx")
("Ps2pdf" "ps2pdf %f %(O?pdf)" TeX-run-ps2pdf nil (plain-TeX-mode LaTeX-mode docTeX-mode AmSTeX-mode Texinfo-mode) :help "Convert PostScript file to PDF")
("LaTeXMk" "latexmk %(latexmk-out) %(file-line-error) %(output-dir) %`%(extraopts) %S%(mode)%' %t" TeX-run-TeX nil (LaTeX-mode docTeX-mode) :help "Run LaTeXMk")
("Glossaries" "makeglossaries %(d-dir) %s" TeX-run-command nil (plain-TeX-mode LaTeX-mode docTeX-mode AmSTeX-mode Texinfo-mode) :help
"Run makeglossaries to create glossary file")
("Index" "makeindex %(O?idx)" TeX-run-index nil (plain-TeX-mode LaTeX-mode docTeX-mode AmSTeX-mode Texinfo-mode) :help "Run makeindex to create index file")
("upMendex" "upmendex %(O?idx)" TeX-run-index t (plain-TeX-mode LaTeX-mode docTeX-mode AmSTeX-mode Texinfo-mode) :help "Run upmendex to create index file")
("Xindy" "texindy %s" TeX-run-command nil (plain-TeX-mode LaTeX-mode docTeX-mode AmSTeX-mode Texinfo-mode) :help "Run xindy to create index file")
("Check" "lacheck %s" TeX-run-compile nil (LaTeX-mode) :help "Check LaTeX file for correctness")
("ChkTeX" "chktex -v6 %s" TeX-run-compile nil (LaTeX-mode) :help "Check LaTeX file for common mistakes")
("Spell" "(TeX-ispell-document \"\")" TeX-run-function nil t :help "Spell-check the document")
("Clean" "TeX-clean" TeX-run-function nil t :help "Delete generated intermediate files")
("Clean All" "(TeX-clean t)" TeX-run-function nil t :help "Delete generated intermediate and output files") ("Other" "" TeX-run-command t t :help "Run an arbitrary command"))
)
[test.tex (application/x-tex, attachment)]
Information forwarded
to
bug-auctex <at> gnu.org
:
bug#78693
; Package
auctex
.
(Wed, 04 Jun 2025 10:33:01 GMT)
Full text and
rfc822 format available.
Message #8 received at submit <at> debbugs.gnu.org (full text, mbox):
Thanks Raghuzar. The issue is the result of this change:
--8<---------------cut here---------------start------------->8---
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)))))
--8<---------------cut here---------------end--------------->8---
The intent here was that "math macros" built-in to tex-fold don't take
arguments, but this is not the case for the custom one you provide.
> (setq TeX-fold-math-spec-list `((,(lambda (text) (propertize text 'face '(underline))) ("underline"))))
Is there a reason to prefer this vs. the same with
TeX-fold-macro-spec-list in place of TeX-fold-math-spec-list?
Paul
Information forwarded
to
bug-auctex <at> gnu.org
:
bug#78693
; Package
auctex
.
(Fri, 06 Jun 2025 09:40:01 GMT)
Full text and
rfc822 format available.
Message #11 received at 78693 <at> debbugs.gnu.org (full text, mbox):
Hi Raghuzar, thanks for your suggestions.
Regarding (1) and (2), I searched my shared tex projects and found
examples that those approaches would not fold correctly:
> 1) Assume that there is no white-space between the macro name and the
> brackets enclosing the arguments. This is probably not how TeX syntax
> works but I think (not too sure about this) it is the usual style. This
> behavior can be controlled by a custom variable.
"\in[0,1]"
I also worry that style like
\includegraphics
[width=0.8\textwidth]
{result.pdf}
is not too uncommon.
> 2) Since the problem is with optional arguments we can allow { after the
> macro name but not [.
"\in{\rm SL}_2"
> 3) Another option can be to introduce a new spec alist for macros
> without optional args.
Maybe call it TeX-fold-unargumented-spec-list. Then, we would have:
TeX-fold-macro-spec-list
TeX-fold-math-spec-list
TeX-fold-env-spec-list
TeX-fold-unargumented-spec-list
The defaults for *math* would move to *unargumented* and *macro*/*math*
would behave identically. This seems a bit complicated.
Moreover, none of the above solutions address related (but rarer) issues
with argumented macros. For instance, if one includes \mathbf in
*macro*/*math*, then the following folds incorrectly:
$\mathbf{text} [0,1]$
(I feel like I've seen similar examples occur organically over the
years, but can't quickly think of one.)
----------------------------------------------------------------------
Here's a proposed solution that seems more robust to me. Recall that
*macro*/*math* are lists consisting of items
(SPEC (M1 M2 ...)),
where SPEC is a display specification (an integer, a string or a
function) and M1, M2, ... are macro names as strings. We could enhance
the display specification to allow
((SPEC . SIG) (M1 M2 ...)),
where SIG is a "signature" that restricts the number of args:
- nil means no restriction,
- an integer n means at most n total args (so 0 means unargumented), and
- a cons cell (p . q) means at most p optional and q required args.
With that enhancement, we could revert d0a57d8d and tag the defaults for
LaTeX-fold-math-spec-list with "0", e.g.,
("∈" ("in")) -> (("∈" . 0) ("in"))
That would fix the original "\in [0,1]" issue as well as the issue
raised by Raghuzar. It would also make it easy to fix related issues,
like the one with \mathbf noted above. Thoughts?
----------------------------------------------------------------------
I also thought I'd link the original proposal [1] for TeX-fold
math-spec-list. My reading is that the purpose of the *macro*/*math*
split was just to better organize the defaults.
[1]
https://lists.gnu.org/archive/html/auctex-devel/2007-01/msg00078.html
----------------------------------------------------------------------
Finally, I noticed that we've been CC'ing bug-auctex rather than the
specific bug number, which is generating duplicated bugs at
https://lists.gnu.org/archive/html/bug-auctex/2025-06/threads.html.
I've tried to fix that here.
Information forwarded
to
bug-auctex <at> gnu.org
:
bug#78693
; Package
auctex
.
(Sat, 07 Jun 2025 17:34:03 GMT)
Full text and
rfc822 format available.
Message #14 received at 78693 <at> debbugs.gnu.org (full text, mbox):
Hi Paul,
"Paul D. Nelson" <ultrono <at> gmail.com> writes:
> Here's a proposed solution that seems more robust to me. Recall that
> *macro*/*math* are lists consisting of items
>
> (SPEC (M1 M2 ...)),
>
> where SPEC is a display specification (an integer, a string or a
> function) and M1, M2, ... are macro names as strings. We could enhance
> the display specification to allow
>
> ((SPEC . SIG) (M1 M2 ...)),
>
> where SIG is a "signature" that restricts the number of args:
>
> - nil means no restriction,
>
> - an integer n means at most n total args (so 0 means unargumented), and
>
> - a cons cell (p . q) means at most p optional and q required args.
>
> With that enhancement, we could revert d0a57d8d and tag the defaults for
> LaTeX-fold-math-spec-list with "0", e.g.,
>
> ("∈" ("in")) -> (("∈" . 0) ("in"))
>
> That would fix the original "\in [0,1]" issue as well as the issue
> raised by Raghuzar. It would also make it easy to fix related issues,
> like the one with \mathbf noted above. Thoughts?
I like this proposal. It is backward compatible I think it should also
allow us to deal with optional arguments in a function spec. Currently
if the spec is a function it only receives the mandatory arguments. If
the number of arguments is part of the spec we can allow it to receive
up to p+q args without breaking existing code.
> Finally, I noticed that we've been CC'ing bug-auctex rather than the
> specific bug number, which is generating duplicated bugs at
> https://lists.gnu.org/archive/html/bug-auctex/2025-06/threads.html.
> I've tried to fix that here.
Thanks for catching this. I was surprised by emails about those new bugs.
Rahguzar
Information forwarded
to
bug-auctex <at> gnu.org
:
bug#78693
; Package
auctex
.
(Sat, 07 Jun 2025 18:34:02 GMT)
Full text and
rfc822 format available.
Message #17 received at 78693 <at> debbugs.gnu.org (full text, mbox):
Hi Raghuzar,
> I like this proposal. It is backward compatible I think it should also
> allow us to deal with optional arguments in a function spec.
OK, great. I'll try fleshing it out when I get the chance.
> Currently if the spec is a function it only receives the mandatory
> arguments. If the number of arguments is part of the spec we can allow
> it to receive up to p+q args without breaking existing code.
Regarding optional arguments, I am in the habit of extracting those
using TeX-fold-macro-nth-arg. This is possible because (with recent
enough AUCTeX) the function display spec is always called with point at
the beginning of the macro to be folded. See for instance the
implementation of TeX-fold-cite-display.
For this reason, I'm inclined to first implement the proposal without
changing how optional args are used - we could change that later, if
desired.
Thanks, best,
Paul
Information forwarded
to
bug-auctex <at> gnu.org
:
bug#78693
; Package
auctex
.
(Mon, 09 Jun 2025 18:04:01 GMT)
Full text and
rfc822 format available.
Message #20 received at 78693 <at> debbugs.gnu.org (full text, mbox):
Hi Paul,
"Paul D. Nelson" <ultrono <at> gmail.com> writes:
> Hi Raghuzar,
>
>> Currently if the spec is a function it only receives the mandatory
>> arguments. If the number of arguments is part of the spec we can allow
>> it to receive up to p+q args without breaking existing code.
>
> Regarding optional arguments, I am in the habit of extracting those
> using TeX-fold-macro-nth-arg. This is possible because (with recent
> enough AUCTeX) the function display spec is always called with point at
> the beginning of the macro to be folded. See for instance the
> implementation of TeX-fold-cite-display.
>
> For this reason, I'm inclined to first implement the proposal without
> changing how optional args are used - we could change that later, if
> desired.
I think the difference between passing optional arg now vs later would
be backward compatibility. Since the the signature part of spec is new
there are no backward compatibility concerns. However if people start
using the feature assuming no optional arguments are passed to the
function and we start passing them later there can be breakage.
I think passing the arguments directly to the function is more user
friendly. However, I think documenting TeX-fold-macro-nth-arg as the way
to access optional arguments is also good enough.
>
> Thanks, best,
> Paul
Best,
Rahguzar
Information forwarded
to
bug-auctex <at> gnu.org
:
bug#78693
; Package
auctex
.
(Wed, 11 Jun 2025 07:34:01 GMT)
Full text and
rfc822 format available.
Message #23 received at submit <at> debbugs.gnu.org (full text, mbox):
forcemerge 78693 78696 78698
thanks
Rahguzar via bug-auctex via Bug reporting list for AUCTeX <bug-auctex <at> gnu.org> writes:
> Dear AucTeX maintainers,
>
> The commits
>
> d0a57d8d Fix math macro folding to not consume subsequent brackets
> 33f9eb07 Fix TeX macro end detection in some edge cases
>
> break the folding of math macros with a function spec.
Gents,
somehow 3 bug reports where opened for this report which I'm merging
now. Please try to avoid this in future. TIA.
Best, Arash
Information forwarded
to
bug-auctex <at> gnu.org
:
bug#78693
; Package
auctex
.
(Wed, 11 Jun 2025 07:34:02 GMT)
Full text and
rfc822 format available.
Forcibly Merged 78693 78696 78698.
Request was from
Arash Esbati <arash <at> gnu.org>
to
control <at> debbugs.gnu.org
.
(Wed, 11 Jun 2025 07:34:02 GMT)
Full text and
rfc822 format available.
Information forwarded
to
bug-auctex <at> gnu.org
:
bug#78693
; Package
auctex
.
(Wed, 11 Jun 2025 07:37:02 GMT)
Full text and
rfc822 format available.
Message #31 received at 78693 <at> debbugs.gnu.org (full text, mbox):
Arash Esbati <arash <at> gnu.org> writes:
> somehow 3 bug reports where opened for this report which I'm merging
> now. Please try to avoid this in future. TIA.
Thanks. For future reference, the issue is that I was CC'd on the
original bug (and responded to that message, causing a cascade of new
bugs), but the correct approach (as I've now learned) is to use the
X-Debbugs-CC pseudo-header (https://www.debian.org/Bugs/Reporting).
Information forwarded
to
bug-auctex <at> gnu.org
:
bug#78693
; Package
auctex
.
(Wed, 11 Jun 2025 07:37:03 GMT)
Full text and
rfc822 format available.
Information forwarded
to
bug-auctex <at> gnu.org
:
bug#78693
; Package
auctex
.
(Sun, 15 Jun 2025 10:30:02 GMT)
Full text and
rfc822 format available.
Message #37 received at 78693 <at> debbugs.gnu.org (full text, mbox):
[Message part 1 (text/plain, inline)]
Hi Raghuzar and all,
Please see the attached patch which implements signature support for
macro folds, following the plan outlined in my earlier email. This
should address both the issue in your report and that in my earlier bug.
We also need to update the manual, but I'll do that later once the
general shape of the proposal is agreed upon. If you get the chance,
please let me know what you think.
Thanks, best,
Paul
[0001-Add-signature-support-for-macro-folding.patch (text/x-patch, attachment)]
This bug report was last modified 1 day ago.
Previous Next
GNU bug tracking system
Copyright (C) 1999 Darren O. Benham,
1997,2003 nCipher Corporation Ltd,
1994-97 Ian Jackson.