bug-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

bug#23632: 25.1.50; Gratuitous undo boundary in latex-insert-block


From: Chong Yidong
Subject: bug#23632: 25.1.50; Gratuitous undo boundary in latex-insert-block
Date: Fri, 27 May 2016 23:11:21 +0800

In GNU Emacs 25.1.50.1 (x86_64-unknown-linux-gnu, GTK+ Version 3.18.9)

1. emacs -Q foo.tex

2. C-c C-o RET

   The buffer now contains an `enumerate' skeleton:

\begin{enumerate}
\item 
\end{enumerate}

3. C-/

   After this undo command, the buffer now contains

\begin{

   Expected behavior: C-/ should undo the entire effects of C-c C-o, so
   the buffer should contain nothing at all.  You shouldn't need another
   C-/ to get rid of the "\begin{".

This happens because latex-insert-block uses skeleton-insert, in which
the "interactor" specified for reading a string is lazily invoked only
when the string appears in the skeleton.  Hence, the "\begin{" is
inserted into the buffer first, and then completing-read is called to
ask for the LaTeX block name.  The completing-read adds an undo
boundary, in the midst of the changes by latex-insert-block.

The attached patch, which gets rid of the undo boundary, seems to fix
this:


--- a/lisp/textmodes/tex-mode.el
+++ b/lisp/textmodes/tex-mode.el
@@ -1539,7 +1539,8 @@ 'tex-latex-block
 (define-skeleton latex-insert-block
   "Create a matching pair of lines \\begin{NAME} and \\end{NAME} at point.
 Puts point on a blank line between them."
-  (let ((choice (completing-read (format "LaTeX block name [%s]: "
+  (let* ((buffer-undo-list t) ; Don't add an undo boundary
+         (choice (completing-read (format "LaTeX block name [%s]: "
                                         latex-block-default)
                                  (latex-complete-envnames)
                                 nil nil nil nil latex-block-default)))





reply via email to

[Prev in Thread] Current Thread [Next in Thread]