Subject: Re: bug#63444: folding mode for Texinfo doesn't work reliably

From: Ralf Angeli <[email-masked]>
Date: Sun, 14 May 2023 13:38:07 +0200

[Sorry for the last mail which was unfinished. Now I know that C-RET 
does not insert a linebreak with quoting in Thunderbird. Duh. %-)]

On 13/05/2023 21.02, Arash Esbati wrote:

>    The variables TeX-fold-macro-spec-list, TeX-fold-env-spec-list, and
>    TeX-fold-math-spec-list apply to any AUCTeX mode.  If you want to make
>    settings which are only applied to LaTeX mode, you can use the
>    mode-specific variables LaTeX-fold-macro-spec-list,
>    LaTeX-fold-env-spec-list, and LaTeX-fold-math-spec-list
> 
> So users should deduce from this that there is also
> `Texinfo-fold-env-spec-list', which is, optimistic.

I don't tend to add riddles to manuals. ;-) I guess I only mentioned the 
LaTeX-mode-specific variables because those are the only ones 
implemented as custom variables. Why the other ones are not, 
unfortunately I don't remember. It's not just the ones for Texinfo mode 
but also for ConTeXt, docTeX and so on. Perhaps I didn't have enough 
trust in the folding support for other modes than LaTeX. The latter is 
the only one which received much testing and usage.

> But before fixing
> the manual, I wonder what the idea behind the implementation is: The
> variables are not custom variables, so in order to make
> `Texinfo-fold-env-spec-list' for example to work, one has to setq it.
> I'm CC'ing Ralf who wrote the code, maybe he can remember the idea
> behind it.

As hinted at above, it could be that this was a way to let people in the 
knowing test a feature that was still experimental. They could setq the 
variables and assess the results whereas regular users would not 
directly see them.

>> This helps, thanks.  However, there are some issues.
>>
>> * I tried to set
>>
>>    ```
>>    (setq Texinfo-fold-env-spec-list
>>          '(("[macro]"  ("macro"))
>>            ...
>>    ```
>>
>>    This converts
>>
>>    ```
>>    @macro foo {bar, baz}
>>      ...
>>    @end macro
>>    ```
>>
>>    into
>>
>>    ```
>>    [macro]
>>    ```
>>
>>    which is not very helpful.  Is there a way to get
>>
>>    ```
>>    [macro foo]
>>    ```
>>
>>    instead?
> 
> Does something like
> 
>     (setq Texinfo-fold-env-spec-list
>           '((1  ("macro"))
>             ...
> 
> helps (which I didn't test)?

I just tested it and you just get an ellipsis (...) when a macro is 
folded. Without looking at the code, it seems that it does not consider 
the first thing behind @macro to be an argument. This could be a missing 
feature. As mentioned above, Texinfo mode was not the focus of 
development and usage, which is the likely reason for this.

>> * There is no example for
>>
>>      If the first element is a function symbol, the function will be
>>      called with all mandatory arguments of the macro and the result of
>>      the function call will be used as a replacement for the macro.
>>
>>    Additionally, this documentation paragraph confuses me: Are the
>>    'mandatory arguments' passed as plain strings arguments?  Or a list
>>    of strings?  Or something else?
> 
> I'd like to pass this question to Ralf as well; otherwise I have to read
> and understand the code (which I've never used for any mode in my life).
It's a list of strings, see `TeX-fold-hide-item'. Inside of ((functionp 
spec)...) you can see the list `arg-list' being built and then used to 
call the function behind `spec'.

-- 
Ralf