auctex-devel
[Top][All Lists]
Advanced

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

Re: [PATCH] * tex.el (TeX-insert-macro): Use 'atomic-change-group'


From: Philip Kaludercic
Subject: Re: [PATCH] * tex.el (TeX-insert-macro): Use 'atomic-change-group'
Date: Mon, 29 Aug 2022 09:14:36 +0000

Arash Esbati <arash@gnu.org> writes:

>
> Tassilo Horn <tsdh@gnu.org> writes:
>
>> Philip Kaludercic <philipk@posteo.net> writes:
>>
>>> Hi, I'd like to propose the following patch:
>>
>> Accepted, thanks! :-)
>
> The question now is: Can we have this also for environments, please?  I
> think `LaTeX-insert-environment' is the right candidate :)

IIRC environments are usually inserted in one go, so the atomic change
group wouldn't make much of a difference, or am I mistaken?

If so, this patch should do the job:

>From 4e25d3ba7ee1b6399d544cc32d9e10a63ab6a1d7 Mon Sep 17 00:00:00 2001
From: Philip Kaludercic <philipk@posteo.net>
Date: Sun, 28 Aug 2022 14:14:04 +0200
Subject: [PATCH] * tex.el (TeX-insert-macro): Use 'atomic-change-group'

If the user aborts the command, we avoid keeping behind a partial
state by reverting all changes that might have made.
---
 tex.el | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/tex.el b/tex.el
index e7a1fd0f..3a8cd140 100644
--- a/tex.el
+++ b/tex.el
@@ -3337,8 +3337,9 @@ is called with \\[universal-argument]."
                                    'TeX-macro-history TeX-default-macro))))
   (when (called-interactively-p 'any)
     (setq TeX-default-macro symbol))
-  (TeX-parse-macro symbol (cdr-safe (assoc symbol (TeX-symbol-list))))
-  (run-hooks 'TeX-after-insert-macro-hook))
+  (atomic-change-group
+    (TeX-parse-macro symbol (cdr-safe (assoc symbol (TeX-symbol-list))))
+    (run-hooks 'TeX-after-insert-macro-hook)))
 
 (defvar TeX-electric-macro-map
   (let ((map (make-sparse-keymap)))
-- 
2.37.2

> Best, Arash

reply via email to

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