[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/tempel fcfb19e134 47/82: Improve undo
From: |
ELPA Syncer |
Subject: |
[elpa] externals/tempel fcfb19e134 47/82: Improve undo |
Date: |
Sun, 9 Jan 2022 20:58:44 -0500 (EST) |
branch: externals/tempel
commit fcfb19e134bcb5f8b89d2ba03a21d6206095d863
Author: Daniel Mendler <mail@daniel-mendler.de>
Commit: Daniel Mendler <mail@daniel-mendler.de>
Improve undo
---
tempel.el | 33 ++++++++++++++++++++-------------
1 file changed, 20 insertions(+), 13 deletions(-)
diff --git a/tempel.el b/tempel.el
index 8a92d50846..7733634297 100644
--- a/tempel.el
+++ b/tempel.el
@@ -255,15 +255,17 @@ INIT is the optional initial input."
"Insert template NAME given the list of TEMPLATES and the current REGION."
(when-let* ((name (intern-soft name))
(template (cdr (assoc name templates))))
- (tempel--activate template region)))
+ (tempel--enable template region)))
-(defun tempel--activate (template region)
- "Activate TEMPLATE given the current REGION."
- (setf (alist-get 'tempel--active minor-mode-overriding-map-alist) tempel-map)
+(defun tempel--enable (template region)
+ "Enable TEMPLATE given the current REGION."
+ ;; TODO do we want to have the ability to reactivate snippets?
(unless (eq buffer-undo-list t)
- (push (list 'apply #'tempel-done) buffer-undo-list))
+ (push (list 'apply #'tempel--disable) buffer-undo-list))
+ (setf (alist-get 'tempel--active minor-mode-overriding-map-alist) tempel-map)
(save-excursion
;; Split existing overlays, do not expand within existing field.
+ ;; TODO This will be causing issues. Think more about nested expansion.
(dolist (st tempel--active)
(dolist (ov (car st))
(when (and (<= (overlay-start ov) (point)) (>= (overlay-end ov)
(point)))
@@ -340,7 +342,7 @@ INIT is the optional initial input."
(defun tempel-abort ()
"Abort template insertion."
(interactive)
- ;; TODO quit only the topmost template?
+ ;; TODO abort only the topmost template?
(when tempel--active
(let ((beg (cl-loop for st in tempel--active minimize
(cl-loop for ov in (car st) minimize (overlay-start
ov))))
@@ -349,16 +351,20 @@ INIT is the optional initial input."
(tempel-done)
(delete-region beg end))))
+(defun tempel--disable ()
+ "Disable last template."
+ (when-let (st (pop tempel--active))
+ (mapc #'delete-overlay (car st))
+ (unless tempel--active
+ (setq minor-mode-overriding-map-alist
+ (delq (assq-delete-all 'tempel--active
minor-mode-overriding-map-alist)
+ minor-mode-overriding-map-alist)))))
+
(defun tempel-done ()
"Template completion is done."
(interactive)
;; TODO disable only the topmost template?
- (dolist (st tempel--active)
- (mapc #'delete-overlay (car st)))
- (setq tempel--active nil
- minor-mode-overriding-map-alist
- (delq (assq-delete-all 'tempel--active minor-mode-overriding-map-alist)
- minor-mode-overriding-map-alist)))
+ (while tempel--active (tempel--disable)))
;;;###autoload
(defun tempel-expand (&optional interactive)
@@ -383,7 +389,8 @@ If INTERACTIVE is nil the function acts like a capf."
(tempel--insert templates name region))
:annotation-function
(and tempel-expand-annotation
- (apply-partially #'tempel--annotate templates
tempel-expand-annotation nil " ")))))))
+ (apply-partially #'tempel--annotate
+ templates tempel-expand-annotation nil "
")))))))
;;;###autoload
(defun tempel-insert ()
- [elpa] externals/tempel bdf04d8c48 05/82: Improved field movement, (continued)
- [elpa] externals/tempel bdf04d8c48 05/82: Improved field movement, ELPA Syncer, 2022/01/09
- [elpa] externals/tempel 76a5ab120b 15/82: Add customization variables, ELPA Syncer, 2022/01/09
- [elpa] externals/tempel f7990f528b 11/82: README update, ELPA Syncer, 2022/01/09
- [elpa] externals/tempel 5807ca4d28 33/82: Use remappings, ELPA Syncer, 2022/01/09
- [elpa] externals/tempel 9291904a84 24/82: Simplify overlay updates, ELPA Syncer, 2022/01/09
- [elpa] externals/tempel 5e1a864123 68/82: Add tempel-abbrev to define an abbrev, ELPA Syncer, 2022/01/09
- [elpa] externals/tempel 6c288c32a2 80/82: README: Document Capf setup (Fix #14), ELPA Syncer, 2022/01/09
- [elpa] externals/tempel b5cea7ac67 03/82: Add template markers, ELPA Syncer, 2022/01/09
- [elpa] externals/tempel 545b929a28 45/82: README: Fix formatting, ELPA Syncer, 2022/01/09
- [elpa] externals/tempel 1ef2d76dd1 35/82: Add screenshots, ELPA Syncer, 2022/01/09
- [elpa] externals/tempel fcfb19e134 47/82: Improve undo,
ELPA Syncer <=
- [elpa] externals/tempel 36a7977702 62/82: Use cyan color for default values, ELPA Syncer, 2022/01/09
- [elpa] externals/tempel bcf135f993 66/82: Bind lexical environment for prompt eval, ELPA Syncer, 2022/01/09
- [elpa] externals/tempel 7a7813e531 26/82: Maintain list of active templates, ELPA Syncer, 2022/01/09
- [elpa] externals/tempel 934bf35f4b 37/82: Set deleted overlays to nil, ELPA Syncer, 2022/01/09
- [elpa] externals/tempel a5dde06576 75/82: Add tempel-abbrev-mode and tempel-global-abbrev-mode, ELPA Syncer, 2022/01/09
- [elpa] externals/tempel 49ba6e795e 79/82: README update, ELPA Syncer, 2022/01/09
- [elpa] externals/tempel 72a31055cc 41/82: Fix movement commands, ELPA Syncer, 2022/01/09
- [elpa] externals/tempel 29ca4b424d 13/82: README formatting, ELPA Syncer, 2022/01/09
- [elpa] externals/tempel 931ea613cb 49/82: Remove faces, reduce visual noise, ELPA Syncer, 2022/01/09
- [elpa] externals/tempel 49f779027c 38/82: Minor corrections, ELPA Syncer, 2022/01/09