Subject: Re: bug#21154: 24.5.50; LaTeX mode complains about mismatched parentheses on end commands

From: Marcin Borkowski <[email-masked]>
Date: Mon, 02 May 2016 12:32:19 +0200

On 2016-04-30, at 14:13, Marcin Borkowski <[email-masked]> wrote:

> On 2015-07-28, at 20:43, Jeff Clough <[email-masked]> wrote:
>
>> When writing LaTeX, typing the closing curly brace of an end
>> command (\end{document} for instance) causes a "Mismatched parentheses"
>> complaint to appear in the minibuffer, even when this seems to be false.
>>
>> Steps to reproduce:
>>
>> Create a new ".tex" file with the following contents (note the missing
>> curly brace at the very end...
>>
>> \documentclass{article}
>> \begin{document}
>> \end{document
>>
>> Watch the minibuffer, type the closing curly brace, and witness the
>> complaint. The only ever appears to happen on an end command, and it
>> happens on every single end command no matter where it appears.
>
> Confirmed on GNU Emacs 25.1.50.9 (commit a3b46e0).  I'll try to
> investigate it.

Here's my conjecture: the problematic message is displayed by
`blink-matching-open'.  After cursory examination, it seems that the
problem is caused by the fact that `forward-sexp-function' in tex-mode
is trying to be smart and jumps to the beginning of the environment when
after "\end{...}".  Since there is no opening brace there,
`blink-matching-open' thinks there's a mismatch.

I'll try to come up with a patch.

Incidentally, AUC-TeX does not have this problem.

Best,

-- 
Marcin