[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/tempel d9efb707b3 20/82: Improve undo behavior
From: |
ELPA Syncer |
Subject: |
[elpa] externals/tempel d9efb707b3 20/82: Improve undo behavior |
Date: |
Sun, 9 Jan 2022 20:58:42 -0500 (EST) |
branch: externals/tempel
commit d9efb707b31db4765ac3bb47101279d66d6dd540
Author: Daniel Mendler <mail@daniel-mendler.de>
Commit: Daniel Mendler <mail@daniel-mendler.de>
Improve undo behavior
---
tempel.el | 32 +++++++++++++++++---------------
1 file changed, 17 insertions(+), 15 deletions(-)
diff --git a/tempel.el b/tempel.el
index f5d6996c3e..6ca4637500 100644
--- a/tempel.el
+++ b/tempel.el
@@ -113,8 +113,7 @@ WIDTH, SEP and ELLIPSIS configure the formatting."
(defun tempel--replace-field (ov str)
"Replace OV content with STR."
- (let ((inhibit-modification-hooks t)
- (beg (overlay-start ov)))
+ (let ((beg (overlay-start ov)))
(goto-char beg)
(delete-char (- (overlay-end ov) beg))
(insert str)
@@ -125,19 +124,20 @@ WIDTH, SEP and ELLIPSIS configure the formatting."
AFTER is non-nil after the modification.
BEG and END are the boundaries of the modification."
(when (and after (>= beg (overlay-start ov)) (<= beg (overlay-end ov)))
- (move-overlay ov (overlay-start ov) (max end (overlay-end ov)))
- (when-let (name (overlay-get ov 'tempel--name))
- (let ((state (overlay-get ov 'tempel--state))
- (str (buffer-substring-no-properties (overlay-start ov)
(overlay-end ov))))
- (setf (alist-get name (cddr state)) str)
- (save-excursion
- ;; Update overlays
- (dolist (other (alist-get name (car state)))
- (unless (eq other ov)
- (tempel--replace-field other str)))
- ;; Update forms
- (dolist (other (cadr state))
- (tempel--replace-field other (eval (overlay-get other
'tempel--form) (cddr state)))))))))
+ (save-excursion
+ (with-silent-modifications
+ (move-overlay ov (overlay-start ov) (max end (overlay-end ov)))
+ (when-let (name (overlay-get ov 'tempel--name))
+ (let ((state (overlay-get ov 'tempel--state))
+ (str (buffer-substring-no-properties (overlay-start ov)
(overlay-end ov))))
+ (setf (alist-get name (cddr state)) str)
+ ;; Update overlays
+ (dolist (other (alist-get name (car state)))
+ (unless (eq other ov)
+ (tempel--replace-field other str)))
+ ;; Update forms
+ (dolist (other (cadr state))
+ (tempel--replace-field other (eval (overlay-get other
'tempel--form) (cddr state))))))))))
(defun tempel--field (&optional face)
"Create template field with FACE."
@@ -214,6 +214,8 @@ BEG and END are the boundaries of the modification."
(when-let* ((name (intern-soft name))
(template (cdr (assoc name templates))))
(setf (alist-get 'tempel--overlays minor-mode-overriding-map-alist)
tempel-map)
+ (unless (eq buffer-undo-list t)
+ (push (list 'apply #'tempel-done) buffer-undo-list))
(save-excursion
;; Split existing overlays, do not expand within existing field.
(dolist (ov tempel--overlays)
- [elpa] externals/tempel 01e7430343 27/82: Add docstrings, (continued)
- [elpa] externals/tempel 01e7430343 27/82: Add docstrings, ELPA Syncer, 2022/01/09
- [elpa] externals/tempel a03c36c8dd 02/82: Improve behavior when templates are nested, ELPA Syncer, 2022/01/09
- [elpa] externals/tempel db6847a7f9 56/82: Make temple-key a macro, ELPA Syncer, 2022/01/09
- [elpa] externals/tempel 0e618cd169 23/82: Do not sort overlays, ELPA Syncer, 2022/01/09
- [elpa] externals/tempel 04d4f6c055 55/82: Use named key function, ELPA Syncer, 2022/01/09
- [elpa] externals/tempel 91f6978ddd 60/82: Use Tempo PROMPT as default value, ELPA Syncer, 2022/01/09
- [elpa] externals/tempel e20f982dc5 25/82: Remove global variable tempel--state, ELPA Syncer, 2022/01/09
- [elpa] externals/tempel fa99fb7f96 34/82: README: Update keybindings, ELPA Syncer, 2022/01/09
- [elpa] externals/tempel c4cd6e0f69 73/82: Rename tempel-expand -> tempel-complete, add tempel-expand (Fix #13), ELPA Syncer, 2022/01/09
- [elpa] externals/tempel 8f8588985a 04/82: Simplify template markers, ELPA Syncer, 2022/01/09
- [elpa] externals/tempel d9efb707b3 20/82: Improve undo behavior,
ELPA Syncer <=
- [elpa] externals/tempel 4bc75c1aba 52/82: Use the more subtle face colors from Modus, ELPA Syncer, 2022/01/09
- [elpa] externals/tempel 52d8556c05 57/82: Improve annotation function, ELPA Syncer, 2022/01/09
- [elpa] externals/tempel 675e759bde 64/82: Add special prompt treatment, ELPA Syncer, 2022/01/09
- [elpa] externals/tempel e6aa1892af 14/82: README: Simplify template, ELPA Syncer, 2022/01/09
- [elpa] externals/tempel 2ba940809a 42/82: Add temple-abort (Fix #2), ELPA Syncer, 2022/01/09
- [elpa] externals/tempel 5521546f48 10/82: README: Add header, ELPA Syncer, 2022/01/09
- [elpa] externals/tempel d2d5566282 65/82: Improve description of PROMPT/DEFAULT value, ELPA Syncer, 2022/01/09
- [elpa] externals/tempel e529887d5d 70/82: tempel-expand: Fix exit function, ELPA Syncer, 2022/01/09
- [elpa] externals/tempel 349e9735ac 08/82: Remove global temple-region variable, ELPA Syncer, 2022/01/09
- [elpa] externals/tempel bdf04d8c48 05/82: Improved field movement, ELPA Syncer, 2022/01/09