[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/tempel 7dd3360af1 3/3: Add modification hook to range o
From: |
ELPA Syncer |
Subject: |
[elpa] externals/tempel 7dd3360af1 3/3: Add modification hook to range overlay, templates can be deleted (Fix #37) |
Date: |
Fri, 11 Feb 2022 09:57:49 -0500 (EST) |
branch: externals/tempel
commit 7dd3360af1a390747632eb9a87be75b79d38cec0
Author: Daniel Mendler <mail@daniel-mendler.de>
Commit: Daniel Mendler <mail@daniel-mendler.de>
Add modification hook to range overlay, templates can be deleted (Fix #37)
---
tempel.el | 9 +++++++++
1 file changed, 9 insertions(+)
diff --git a/tempel.el b/tempel.el
index 343f74cc2c..2c63f27ead 100644
--- a/tempel.el
+++ b/tempel.el
@@ -177,6 +177,13 @@ REGION are the current region bouns"
(tempel--delete-word name)
(tempel--insert template region))))
+(defun tempel--range-modified (ov &rest _)
+ "Range overlay OV modified."
+ (when (= (overlay-start ov) (overlay-end ov))
+ (let ((st (overlay-get ov 'tempel--range)))
+ (setq tempel--active (cons st (delq st tempel--active)))
+ (tempel--disable))))
+
(defun tempel--field-modified (ov after beg end &optional _len)
"Update field overlay OV.
AFTER is non-nil after the modification.
@@ -340,6 +347,8 @@ PROMPT is the optional prompt/default value."
(while (and template (not (keywordp (car template))))
(tempel--element st region (pop template)))
(push (make-overlay beg (point) nil t) (car st))
+ (overlay-put (caar st) 'modification-hooks (list
#'tempel--range-modified))
+ (overlay-put (caar st) 'tempel--range st)
;;(overlay-put (caar st) 'face 'region) ;; TODO debug
(push st tempel--active)))
(cond