bug#73302: TeX-find-closing-brace and verbatim macros

2024-09-21 Thread Arash Esbati
Ikumi Keita  writes:

>> Paul Nelson  writes:
>> As a fix, we could either:
>
>> (i) Do (save-restriction (widen) ...) in TeX-fold-macro-nth-arg before
>> (TeX-verbatim-p).
>
>> (ii) Do (save-restriction (widen) ...) in LaTeX-verbatim-p.
>
>> The advantage of (ii) is that it arguably fixes the root cause rather
>> than just patching it at the source.  The disadvantage is that I don't
>> know off hand whether this would affect other calls to
>> LaTeX-verbatim-p in an undesired way.  I lean in favor of (i) for now,
>> and have updated my patch accordingly, but would welcome other
>> feedback.
>
> I don't have particular preference,

I think we should go with (i) and let the caller decide.

> so I think we can install your change, provided that no objection is
> raised.

@Paul: How does you change work in a file like this:

--8<---cut here---start->8---
\documentclass{article}

\usepackage{fvextra}

\begin{document}

Vanilla \verb|LaTeX|

With \Verb|fvextra|, or \Verb[fontsize=\scriptsize]|fvextra|.

With \Verb{fvextra}, or \Verb[fontsize=\scriptsize]{fvextra}.

\end{document}

%%% Local Variables:
%%% mode: latex
%%% TeX-master: t
%%% End:
--8<---cut here---end--->8---

> Thank you for your contribution!

+1.

Best, Arash



___
bug-auctex mailing list
bug-auctex@gnu.org
https://lists.gnu.org/mailman/listinfo/bug-auctex


bug#73302: TeX-find-closing-brace and verbatim macros

2024-09-21 Thread Paul Nelson
> @Paul: How does you change work in a file like this:
>
> --8<---cut here---start->8---
> \documentclass{article}
>
> \usepackage{fvextra}
>
> \begin{document}
>
> Vanilla \verb|LaTeX|
>
> With \Verb|fvextra|, or \Verb[fontsize=\scriptsize]|fvextra|.
>
> With \Verb{fvextra}, or \Verb[fontsize=\scriptsize]{fvextra}.
>
> \end{document}
>
> %%% Local Variables:
> %%% mode: latex
> %%% TeX-master: t
> %%% End:
> --8<---cut here---end--->8---


One issue that shows up when attempting to fold these examples via a
string display spec is that (TeX-find-macro-end), called with point at
the beginning of \Verb|LaTeX|, returns the end of \Verb rather than
the complete macro.  As a result, using tex-fold with a string display
spec never folds the complete macro, but instead just the part
appearing before the first "|".  Perhaps this should be changed?  In
any event, it's an issue orthogonal to my patch.

Modulo this issue, I think everything in the example you provided
works as intended.  For example, with the spec ("[1]:{1}!||{1}@||[1]#"
("Verb"), the tex code

\Verb[fontsize=\scriptsize]{fvextra}
\Verb{fvextra}
\Verb[fontsize=\scriptsize]|fvextra|

folds to something that looks like

fontsize=\scriptsize:fvextra!
fvextra@
fontsize=\scriptsize#|fvextra|

which I think is the expected behavior, modulo the oddity that in the
third example, "|fvextra|" appears at the end, due to the behavior of
(TeX-find-macro-end) noted above.

Note that the string display specs in tex-fold don't support "|...|"
arguments.  I do provide folding support for "\verb|...|" in
https://github.com/ultronozm/czm-tex-fold.el, but it's done there
using a function display spec, ultimately using the regexp
"verb|\\([^|]*\\)|" rather than anything built-in.  I guess I
could extend it to work also with \Verb.

Alternatively, one could view the contents of "|...|" as a "required
argument" and extend the string display spec folding to work with
"|...|" in addition to "{...}", but I don't see the immediate payoff
from doing so.



___
bug-auctex mailing list
bug-auctex@gnu.org
https://lists.gnu.org/mailman/listinfo/bug-auctex


bug#73302: TeX-find-closing-brace and verbatim macros

2024-09-21 Thread Paul Nelson
On an unrelated note, I did encounter another issue with this change:
it sporadically breaks some of the folding carried out by my package
https://github.com/ultronozm/czm-tex-mint.el, due to a weird bug that
I'm having trouble diagnosing.

The issue concerns detecting verbatim macros in code immediately after
moving out of an mmm-mode block in a LaTeX buffer.  Specifically, with
point at the beginning of the final line of such a block, evaluating

  (progn (forward-line) (TeX-verbatim-p))

returns non-nil, but should instead return nil.  For instance, if we
interactively do (forward-line) followed by (TeX-verbatim-p), then we
get nil.

As a result, (TeX-verbatim-p) returns t in cases where
(LaTeX-verbatim-macro-boundaries) doesn't return anything useful, and
so TeX-fold-macro-nth-arg fails to detect arguments.

The issue really boils down to

  (progn (forward-line) (syntax-propertize (point)) (nth 3 (syntax-ppss)))

The issue disappears when tested via edebug, which makes it a bit
tricky for me to debug further.  I've noticed that the issue does NOT
arise with

  (progn (forward-line) (mmm-update-submode-region) (syntax-propertize
(point)) (nth 3 (syntax-ppss)))

but DOES still arise when putting the same lines in my code (rather
than running it via M-:).

Any quick thoughts/suggestions?

Is there some function that "very forcefully" updates whatever
internals (syntax-propertize (point)) (nth 3 (syntax-ppss)) depend
upon?

Is one forced to resort to idle timer trickery?  That would be a bit
painful in the case I'm considering.



___
bug-auctex mailing list
bug-auctex@gnu.org
https://lists.gnu.org/mailman/listinfo/bug-auctex


bug#73302: TeX-find-closing-brace and verbatim macros

2024-09-21 Thread Ikumi Keita
Hi Paul,

> Paul Nelson  writes:
> The issue concerns detecting verbatim macros in code immediately after
> moving out of an mmm-mode block in a LaTeX buffer.

There is a TODO entry in syntax.el which says
;; - interaction with mmm-mode.
, so maybe syntax-related facilities including syntax-ppss and
syntax-propertize-function have something incompatible with mmm-mode.

However, I don't know anything concrete with respect to such conflict.

Regards,
Ikumi Keita
#StandWithUkraine #StopWarInUkraine
#Gaza #StopMassiveKilling #CeasefireNOW



___
bug-auctex mailing list
bug-auctex@gnu.org
https://lists.gnu.org/mailman/listinfo/bug-auctex