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

From: Werner LEMBERG <[email-masked]>
Date: Sat, 13 May 2023 07:30:37 +0000 (UTC)

>> It seems that the presence of a `@xxx` command within a macro
>> causes hiccups, but as `englishref` shows, other factors seem to
>> play a role, too.
> 
> I'm not sure if I understand this part.  Can you please give me a hint
> where to look in that file and what to do in order to understand this
> issue better?

I was confused.  Having never tried folding mode for Texinfo before, I
interpreted `[r]` as the contents of a macro.  However, this is the
visual indicator for a reference.

>> Finally, I have a wish: It would be extremely helpful to have two
>> more commands for folding
>>
>> * conditional blocks like `@iffoo ... @end iffoo`, and
>>
>> * format-specific blocks like `@html ... @end html` or `@tex
>>   ... @end tex`.
> 
> You can put this in your init file (and adjust it accordingly):
> 
> (setq Texinfo-fold-env-spec-list
>       '(("[html]"  ("html"))
>         ("[TeX]"   ("tex"))))
> 
> and then load your .texi file and activate folding.  Maybe that helps
> already.

Aaah, completely undocumented :-) 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?

* 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?

* `Texinfo-fold-type-list` is missing – or not documented.

* In combination with the last item, it seems that there are no
  folding defaults for Texinfo mode.  Maybe it makes sense to have the
  same default as with other TeX modes, i.e., folding macros and
  environments.

    Werner