4

Before I send this on to the developers, I'd like to know if others can confirm this problem. Consider these two environments:

\begin{flalign*}
sdfsdf  
\end{flalign*}

\begin{flalign*}
   && A \rightarrow \End_{B}(M) && {; B=\End_{A}(M)}
\end{flalign*}

If I set the cursor in the first one and execute LaTeX-mark-environment (C-c .), then I get the expected result, i.e. marked the flalign* environment, including the \begin/end lines.

However if I do the same in the other one, it never covers the env. What ever is marked depends on where the cursor is. It is clearly having an issue with the \End, presumably because it is ignoring case.

Can others confirm?

(LaTeX-mark-environment together with narrow-to-region is a really nice feature to have when writing macros).

4

The problem is that the LaTeX-find-matching-end performs case insensitive searches. To make the search for the \end case sensitive, you have to bind the case-fold-search variable to nil. To do that you can advice the LaTeX-find-matching-end function. This will fix your problem but won't work if there is an \end inside the environment (think about a verbatim environment).

(defadvice LaTeX-find-matching-end
  (around LaTeX-find-matching-end-case-sensitive activate)
  "Perform case-sensitive search."
  (let ((case-fold-search nil))
    ad-do-it))

PS development version of AUCTeX has a new function to narrow to an environment (LaTeX-narrow-to-environment), so you'll need a single key binding (C-x n e) instead of C-c . C-x n r


(daleif addition), one also need to change add to LaTeX-find-matching-begin:

(defadvice LaTeX-find-matching-begin
  (around LaTeX-find-matching-begin-case-sensitive activate)
  "Perform case-sensitive search."
  (let ((case-fold-search nil))
   ad-do-it))
  • They already mention thecverbatim in latex.el but nothing about case insensitivity. And \End is a perfectly reasonable mathematical operator – daleif Jan 10 '14 at 7:58
  • 2
    Now the bug has been fixed directly in the development version of AUCTeX. – giordano Jan 10 '14 at 23:25
  • Slightly off topic, will the development version also carry execution hooks for when one changes an env? The is a hook that is executed when a new env is inserted but not when an environment is changed into another. Would be handy when cleaning other people's code – daleif Jan 11 '14 at 8:49
  • 1
    I've added the corresponding fix for LaTeX-find-matching-begin without it C-u C-c C-e fails to find the start of the environment – daleif Jan 11 '14 at 10:29
  • @daleif Regarding the post environment change hook, I advise you to suggest this improvement to the auctex-devel mailing list ;-). – giordano Jan 11 '14 at 13:49

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.