emacs-elpa-diffs
[Top][All Lists]
Advanced

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

[elpa] externals/tempel 0aa4e8c37f 63/82: Only erase default value if th


From: ELPA Syncer
Subject: [elpa] externals/tempel 0aa4e8c37f 63/82: Only erase default value if the point is at the beginning or end
Date: Sun, 9 Jan 2022 20:58:45 -0500 (EST)

branch: externals/tempel
commit 0aa4e8c37fbc96e90ae4eafcc33c7583a056c29c
Author: Daniel Mendler <mail@daniel-mendler.de>
Commit: Daniel Mendler <mail@daniel-mendler.de>

    Only erase default value if the point is at the beginning or end
---
 tempel.el | 12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)

diff --git a/tempel.el b/tempel.el
index 74aba08daf..cee3ec646e 100644
--- a/tempel.el
+++ b/tempel.el
@@ -153,12 +153,10 @@ WIDTH, SEP and ELLIPSIS configure the formatting."
 AFTER is non-nil after the modification.
 BEG and END are the boundaries of the modification."
   (cond
-   ;; Overwrite default before modification
-   ((and (not after) (eq 'tempel-default (overlay-get ov 'face)))
-    (setq beg (overlay-start ov) end (overlay-end ov))
-    (goto-char beg)
-    (overlay-put ov 'face 'tempel-field)
-    (delete-region beg end))
+   ;; Erase default before modification if at beginning or end
+   ((and (not after) (eq 'tempel-default (overlay-get ov 'face))
+         (or (= beg (overlay-start ov)) (= end (overlay-end ov))))
+    (delete-region (overlay-start ov) (overlay-end ov)))
    ;; Update field after modification
    (after
     (let ((st (overlay-get ov 'tempel--state)))
@@ -170,6 +168,8 @@ BEG and END are the boundaries of the modification."
                (overlay-start ov) (overlay-end ov))))
       (unless undo-in-progress
         (template--synchronize-fields st ov)))))
+  (when (eq 'tempel-default (overlay-get ov 'face))
+    (overlay-put ov 'face 'tempel-field))
   (tempel--update-mark ov))
 
 (defun template--synchronize-fields (st current)



reply via email to

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