[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
LaTeX-find-matching-{begin,end} and LaTeX-current-environment
From: |
Ikumi Keita |
Subject: |
LaTeX-find-matching-{begin,end} and LaTeX-current-environment |
Date: |
Sun, 11 Dec 2022 16:48:34 +0900 |
Hi all,
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, 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?
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? 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.)
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?
[1] https://debbugs.gnu.org/cgi/bugreport.cgi?bug=19281
Regards,
Ikumi Keita
#StandWithUkraine #StopWarInUkraine
0001-Support-starred-variant-name.patch
Description: include asterisk
- LaTeX-find-matching-{begin,end} and LaTeX-current-environment,
Ikumi Keita <=