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

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

[elpa] externals/tempel 2cff879181 30/82: Do not call modification hooks


From: ELPA Syncer
Subject: [elpa] externals/tempel 2cff879181 30/82: Do not call modification hooks from forms
Date: Sun, 9 Jan 2022 20:58:43 -0500 (EST)

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

    Do not call modification hooks from forms
---
 tempel.el | 22 ++++++++++++----------
 1 file changed, 12 insertions(+), 10 deletions(-)

diff --git a/tempel.el b/tempel.el
index a2f4a5a4bc..f817473f70 100644
--- a/tempel.el
+++ b/tempel.el
@@ -153,12 +153,11 @@ BEG and END are the boundaries of the modification."
                 (insert str)
                 (move-overlay other (overlay-start other) (point))))))))))
 
-(defun tempel--field (st &optional face)
-  "Add template field with FACE to ST."
+(defun tempel--field (st)
+  "Add template field to ST."
   (let ((ov (make-overlay (point) (point))))
-    (setq face (or face 'tempel-field))
-    (overlay-put ov 'face face)
-    (overlay-put ov 'before-string (propertize " " 'face face 'display '(space 
:width (1))))
+    (overlay-put ov 'face 'tempel-field)
+    (overlay-put ov 'before-string #(" " 0 1 (display (space :width (1)) face 
tempel-field)))
     (overlay-put ov 'modification-hooks (list #'tempel--update-field))
     (overlay-put ov 'insert-behind-hooks (list #'tempel--update-field))
     (overlay-put ov 'tempel--state st)
@@ -175,13 +174,16 @@ BEG and END are the boundaries of the modification."
 
 (defun tempel--form (st form)
   "Add new template field evaluating FORM to ST."
-  (let ((ov (tempel--field st 'tempel-form)))
-    (overlay-put ov 'tempel--form form)
-    ;; Ignore variable errors, since some variables may not be defined yet.
+  (let ((beg (point)))
     (condition-case nil
         (insert (eval form (cdr st)))
+      ;; Ignore errors since some variables may not be defined yet.
       (void-variable nil))
-    (move-overlay ov (overlay-start ov) (point))))
+    (let ((ov (make-overlay beg (point) nil t)))
+      (overlay-put ov 'face 'tempel-form)
+      (overlay-put ov 'before-string #(" " 0 1 (display (space :width (1)) 
face tempel-form)))
+      (overlay-put ov 'tempel--form form)
+      (push ov (car st)))))
 
 (defun tempel--query (st prompt name)
   "Read input with PROMPT and assign to binding NAME in ST."
@@ -243,7 +245,7 @@ BEG and END are the boundaries of the modification."
           (inhibit-modification-hooks t))
       (push (make-overlay (point) (point)) (car st))
       (dolist (x template) (tempel--element st x region))
-      (push (make-overlay (point) (point) nil nil t) (car st))
+      (push (make-overlay (point) (point)) (car st))
       (push st tempel--active)))
   ;; Jump to first field
   (tempel-next 1))



reply via email to

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