Subject: Re: bug#35284: 12.1.1; new verbatim environment wrongly commented out

From: Ikumi Keita <[email-masked]>
Date: Tue, 16 Apr 2019 21:47:19 +0900

Hi Jean,

>>>>> jfbu <[email-masked]> writes:

> But isn't there a bug even for the use case one wants the verbatim to
> be inserted inside the comment?

> (which wasn't my case)

> Look at commented out last line, and at the added blank line.

> \documentclass{article}

> \begin{document}
> % \begin{verbatim}
> % This is a comment
> \def\foo#1{foo}
> % another comment

> % \end{verbatim}
> % \end{document}

Thanks for your comments.  I agree that the current behavior is not
totally satisfactory, and expect the attatched patch would crudely
resolve this particular issue.  However, the relevant codes must be
involved in a lot, lot of different cases, so it might not be valid for
some other cases.  I'm not sure currently.

Regards,
Ikumi Keita

diff --git a/latex.el b/latex.el
index 898eec8d..58bf6157 100644
--- a/latex.el
+++ b/latex.el
@@ -699,6 +699,9 @@ environment just inserted, the buffer position just before
 	       (newline)
 	       (beginning-of-line 0))
 	      (t
+	       (when (bolp)
+		 (backward-char 1)
+		 (set-marker (mark-marker) (point)))
 	       (delete-horizontal-space)
 	       (insert-before-markers "\n")
 	       (newline)