[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/tempel 349e9735ac 08/82: Remove global temple-region va
From: |
ELPA Syncer |
Subject: |
[elpa] externals/tempel 349e9735ac 08/82: Remove global temple-region variable |
Date: |
Sun, 9 Jan 2022 20:58:41 -0500 (EST) |
branch: externals/tempel
commit 349e9735ac2ed7d65f449936136cc06e1f6549ec
Author: Daniel Mendler <mail@daniel-mendler.de>
Commit: Daniel Mendler <mail@daniel-mendler.de>
Remove global temple-region variable
---
tempel.el | 27 ++++++++++++---------------
1 file changed, 12 insertions(+), 15 deletions(-)
diff --git a/tempel.el b/tempel.el
index bb773b16c0..ac147ee7b1 100644
--- a/tempel.el
+++ b/tempel.el
@@ -39,7 +39,6 @@
(eval-when-compile (require 'subr-x))
(defvar tempel-file (expand-file-name "templates" user-emacs-directory))
-(defvar tempel-region nil)
(defvar tempel--templates nil)
(defvar tempel--modified nil)
(defvar tempel--history nil)
@@ -147,8 +146,8 @@ BEG and END are the boundaries of the modification."
"Read input with PROMPT and assign to NAME."
(setf (alist-get name (cddr tempel--state)) (read-string prompt)))
-(defun tempel--element (element)
- "Insert template ELEMENT."
+(defun tempel--element (element region)
+ "Insert template ELEMENT given the REGION."
(pcase element
('nil)
('n (insert "\n"))
@@ -159,15 +158,15 @@ BEG and END are the boundaries of the modification."
(insert "\n")))
('% (unless (or (eolp) (save-excursion (re-search-forward "\\=\\s-*$" nil
t)))
(insert "\n")))
- ('o (unless (or tempel-region (eolp)
+ ('o (unless (or region (eolp)
(save-excursion (re-search-forward "\\=\\s-*$" nil t)))
(open-line 1)))
('p (tempel--field))
- ((or 'r `(r . ,_)) (if tempel-region (goto-char (cdr tempel-region))
(tempel--field)))
+ ((or 'r `(r . ,_)) (if region (goto-char (cdr region)) (tempel--field)))
((or 'r> `(r> . ,_))
- (if (not tempel-region) (tempel--field)
- (goto-char (cdr tempel-region))
- (indent-region (car tempel-region) (cdr tempel-region) nil)))
+ (if (not region) (tempel--field)
+ (goto-char (cdr region))
+ (indent-region (car region) (cdr region) nil)))
(`(,(or 'p 'P) ,prompt . ,rest) ;; Tempo legacy, use i, s, or plain p
instead
(cond
((cadr rest) (tempel--query prompt (car rest)))
@@ -177,8 +176,8 @@ BEG and END are the boundaries of the modification."
(`(s ,name) (tempel--named name))
(_ (tempel--form element))))
-(defun tempel--insert (templates name)
- "Insert template NAME given the list of TEMPLATES."
+(defun tempel--insert (templates name region)
+ "Insert template NAME given the list of TEMPLATES and the REGION."
(when-let* ((name (intern-soft name))
(template (cdr (assoc name templates))))
(setf (alist-get 'tempel--overlays minor-mode-overriding-map-alist)
tempel-map)
@@ -191,7 +190,7 @@ BEG and END are the boundaries of the modification."
(push (make-overlay (point) (point)) tempel--overlays)
(let ((tempel--state (list nil nil))
(inhibit-modification-hooks t))
- (mapc #'tempel--element template))
+ (dolist (x template) (tempel--element x region)))
;; End marker
(push (make-overlay (point) (point)) tempel--overlays))
(setq tempel--overlays (sort tempel--overlays (lambda (x y) (<
(overlay-start x) (overlay-start y)))))
@@ -271,8 +270,7 @@ If INTERACTIVE is nil the function acts like a capf."
:exclusive 'no
:exit-function (lambda (name _status)
(delete-region (max (point-min) (- (point)
(length name))) (point))
- (let ((tempel-region region))
- (tempel--insert templates name)))
+ (tempel--insert templates name region))
:annotation-function (apply-partially #'tempel--annotate
templates " "))))))
;;;###autoload
@@ -286,8 +284,7 @@ If INTERACTIVE is nil the function acts like a capf."
(apply-partially #'tempel--annotate templates
#(" " 1 2 (display (space :align-to (+ left
20)))))))
(name (completing-read "Template: " templates nil t nil
'tempel--history)))
- (let ((tempel-region (tempel--region)))
- (tempel--insert templates name))))
+ (tempel--insert templates name (tempel--region))))
(provide 'tempel)
;;; tempel.el ends here
- [elpa] externals/tempel 8f8588985a 04/82: Simplify template markers, (continued)
- [elpa] externals/tempel 8f8588985a 04/82: Simplify template markers, ELPA Syncer, 2022/01/09
- [elpa] externals/tempel d9efb707b3 20/82: Improve undo behavior, ELPA Syncer, 2022/01/09
- [elpa] externals/tempel 4bc75c1aba 52/82: Use the more subtle face colors from Modus, ELPA Syncer, 2022/01/09
- [elpa] externals/tempel 52d8556c05 57/82: Improve annotation function, ELPA Syncer, 2022/01/09
- [elpa] externals/tempel 675e759bde 64/82: Add special prompt treatment, ELPA Syncer, 2022/01/09
- [elpa] externals/tempel e6aa1892af 14/82: README: Simplify template, ELPA Syncer, 2022/01/09
- [elpa] externals/tempel 2ba940809a 42/82: Add temple-abort (Fix #2), ELPA Syncer, 2022/01/09
- [elpa] externals/tempel 5521546f48 10/82: README: Add header, ELPA Syncer, 2022/01/09
- [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 <=
- [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