Subject: bug#78693: 14.0.9; Folding of math macros with a function spec is broken

From: "Paul D. Nelson" <[email-masked]>
Date: Sat, 07 Jun 2025 20:32:53 +0200

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