[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/tempel b5cea7ac67 03/82: Add template markers
From: |
ELPA Syncer |
Subject: |
[elpa] externals/tempel b5cea7ac67 03/82: Add template markers |
Date: |
Sun, 9 Jan 2022 20:58:37 -0500 (EST) |
branch: externals/tempel
commit b5cea7ac6783111f63d81c998eddd6c26a582349
Author: Daniel Mendler <mail@daniel-mendler.de>
Commit: Daniel Mendler <mail@daniel-mendler.de>
Add template markers
---
README.org | 5 +++--
tempel.el | 21 +++++++++++++++++++--
2 files changed, 22 insertions(+), 4 deletions(-)
diff --git a/README.org b/README.org
index 4862790dbf..15a6a8b1ce 100644
--- a/README.org
+++ b/README.org
@@ -19,8 +19,9 @@ provides a modernized UI on top of Tempo, in the form of two
commands:
(Capf). You may want to use my [[https://github.com/minad/corfu][Corfu]]
completion at point UI.
+ ~tempel-insert~: Select a template by name and insert it into the current
buffer.
-After inserting a template you can move between the template markers with keys
-~M-up/down~ as defined in the ~tempel-map~ keymap.
+After inserting a template you can move between the visible template markers
+with keys ~M-left/right~ as defined in the ~tempel-map~ keymap. As soon as you
move
+before (behind) the first (last) marker, the markers will be removed.
Note that this package is not a competitor to the mature and widely used
YASnippet library. Try Tempel only if your snippet and templating requirements
diff --git a/tempel.el b/tempel.el
index c024d3a22b..92a7b520e2 100644
--- a/tempel.el
+++ b/tempel.el
@@ -43,6 +43,7 @@
(defvar tempel--modified nil)
(defvar tempel--current nil)
(defvar tempel--history nil)
+(defvar-local tempel--overlays nil)
(defvar tempel-map
(let ((map (make-sparse-keymap)))
@@ -91,8 +92,22 @@
(when-let* ((name (intern-soft name))
(template (cdr (assoc name templates))))
(setf (alist-get 'tempo-marks minor-mode-overriding-map-alist) tempel-map)
- (let ((tempel--current template))
- (tempo-insert-template 'tempel--current region))))
+ (let ((tempel--current template)
+ (old-point (point))
+ (split-overlays nil)
+ (old-marks (copy-sequence tempo-marks)))
+ (dolist (ov tempel--overlays)
+ (when (and (<= (overlay-start ov) old-point) (>= (overlay-end ov)
old-point))
+ (push ov split-overlays)))
+ (tempo-insert-template 'tempel--current region)
+ (dolist (ov split-overlays)
+ (setf (overlay-end ov) old-point))
+ (dolist (x tempo-marks)
+ (unless (member x old-marks)
+ (let ((ov (make-overlay x x nil nil t)))
+ (overlay-put ov 'face '(:underline t))
+ (overlay-put ov 'before-string #(" " 0 1 (face highlight display
(space :width (1)))))
+ (push ov tempel--overlays)))))))
(defun tempel--save ()
"Save Tempo file buffer."
@@ -127,7 +142,9 @@
"Template completion is done."
(interactive)
(dolist (mark tempo-marks) (set-marker mark nil))
+ (mapc #'delete-overlay tempel--overlays)
(setq tempo-marks nil
+ tempel--overlays nil
minor-mode-overriding-map-alist
(delq (assq-delete-all 'tempo-marks minor-mode-overriding-map-alist)
minor-mode-overriding-map-alist)))
- [elpa] externals/tempel d2d5566282 65/82: Improve description of PROMPT/DEFAULT value, (continued)
- [elpa] externals/tempel d2d5566282 65/82: Improve description of PROMPT/DEFAULT value, ELPA Syncer, 2022/01/09
- [elpa] externals/tempel e529887d5d 70/82: tempel-expand: Fix exit function, ELPA Syncer, 2022/01/09
- [elpa] externals/tempel 349e9735ac 08/82: Remove global temple-region variable, ELPA Syncer, 2022/01/09
- [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 <=
- [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, 2022/01/09
- [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