branch: externals/tempel
commit 0aa4e8c37fbc96e90ae4eafcc33c7583a056c29c
Author: Daniel Mendler <[email protected]>
Commit: Daniel Mendler <[email protected]>
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)