Subject: Re: bug#11646: 23.2; latex-close-block indenting \end{verbatim} incorrectly

From: Stefan Monnier <[email-masked]>
Date: Wed, 13 Jun 2012 09:57:47 -0400

>     C-x C-f /tmp/foo.text

I presume you meant "foo.tex" ;-)

> Enter
>     \begin{verbatim} RET SPC SPC SPC hello RET C-c C-e
> and the resulting \end{verbatim} is indented three spaces instead of in
> column 0 as it should be.
> The problem does not manifest with \begin{quote}.

Yes, verbatim is special in LaTeX, and hence so it is in latex-mode.
The bug actually seems to require you be at EOB when hitting C-c C-e.
I've installed the patch below which seems to fix the root cause.

        Stefan

=== modified file 'lisp/textmodes/tex-mode.el'
--- lisp/textmodes/tex-mode.el	2012-04-16 23:57:09 +0000
+++ lisp/textmodes/tex-mode.el	2012-06-13 13:55:17 +0000
@@ -2686,7 +2686,9 @@
   "Syntax table used while computing indentation.")
 
 (defun latex-indent (&optional arg)
-  (if (and (eq (get-text-property (line-beginning-position) 'face)
+  (if (and (eq (get-text-property (if (and (eobp) (bolp))
+                                      (max (point-min) (1- (point)))
+                                    (line-beginning-position)) 'face)
 	       'tex-verbatim))
       'noindent
     (with-syntax-table tex-latex-indent-syntax-table