auctex-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: LaTeX-find-matching-{begin,end} and LaTeX-current-environment


From: Arash Esbati
Subject: Re: LaTeX-find-matching-{begin,end} and LaTeX-current-environment
Date: Mon, 12 Dec 2022 12:39:56 +0100
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/30.0.50

Hi Keita,

Ikumi Keita <ikumi@ikumi.que.jp> writes:

> I have some minor issues with respect to `LaTeX-find-matching-begin',
> `LaTeX-find-matching-end' and `LaTeX-current-environment', which I'd
> like to discuss.
>
> 1. I noticed that `LaTeX-find-matching-{begin,end}' doesn't work
>    correctly when the point is just after the asterisk of "\end{foo*}".
>    To confirm, put the point at "!" in the following example and
>    type M-: (LaTeX-find-matching-begin) RET or M-:
>    (LaTeX-find-matching-end) RET
> ----------------------------------------------------------------------
> \documentclass{article}
> \begin{document}
>
> \begin{equation*}
>   abc = xyz
> \end{equation*!}
>
> \end{document}
> ----------------------------------------------------------------------
>    The attached patch fixes the starred variant case, 

Thanks for this.  As a coincidence, I was bitten by this issue shortly
and wanted to look at as well :-)

> but, as stated in the FIXME comment, this simple fix doesn't yet work
> for the case discussed in bug#19281[1]; When the point is after "\bar"
> of "\end{\bar}", neither `LaTeX-find-matching-begin' nor
> `LaTeX-find-matching-end' find the correct position. Should we handle
> such exceptional cases, too?

I'm not sure how realistic this case is: Searching source2e.pdf for
'\end{\' returns 11 occurrences mostly with \end{\@currenvir}.  So I
think this case isn't that much on user-level but on programming level.
So I wouldn't cater for it.

> 2. `LaTeX-current-environment' has special support for macrocode*?
>    environments, but that support is absent in
>    `LaTeX-find-matching-{begin,end}':
> ----------------------------------------------------------------------
>                   ;; macrocode*? in docTeX-mode is special since we
>                   ;; have also regular code lines not starting with a
>                   ;; comment-prefix.  Hence, the next check just looks
>                   ;; if we're inside such a group and returns t to
>                   ;; recognize such a situation.
>                   (and (eq major-mode 'doctex-mode)
>                        (member (match-string-no-properties 2)
>                                '("macrocode" "macrocode*"))))
> ----------------------------------------------------------------------
>    Is this intentional?

No, it was just me adding code to `LaTeX-current-environment' and
missing the others :-[

> Or should we add similar codes to `LaTeX-find-matching-{begin,end}' as
> well? (I have little experience with doctex mode, so am not sure what
> to do.)

I'd say we should cater for this.

> 3. The regexp used in `LaTeX-current-environment' is
> ----------------------------------------------------------------------
>                   (re-search-backward
>                    "\\\\\\(begin\\|end\\) *{\\([^}]+\\)}" nil t))
> ----------------------------------------------------------------------
>    so it doesn't handle the exceptional cases of bug#19281, namely
>    "\begin{\bar{xyz}}" and "\end{\bar{xyz}}". Should we cater for such
>    cases?

See above.

Best, Arash



reply via email to

[Prev in Thread] Current Thread [Next in Thread]