[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/tempel cdc4eaa199 2/3: Make the conditions more toleran
From: |
ELPA Syncer |
Subject: |
[elpa] externals/tempel cdc4eaa199 2/3: Make the conditions more tolerant, save match data, excursion, restriction |
Date: |
Sun, 16 Jan 2022 16:57:44 -0500 (EST) |
branch: externals/tempel
commit cdc4eaa199cbe5671d9216e0c2f06f96c36c51e2
Author: Daniel Mendler <mail@daniel-mendler.de>
Commit: Daniel Mendler <mail@daniel-mendler.de>
Make the conditions more tolerant, save match data, excursion, restriction
---
README.org | 6 +-----
tempel.el | 9 ++++++---
2 files changed, 7 insertions(+), 8 deletions(-)
diff --git a/README.org b/README.org
index 25e805a475..8f1ecb663d 100644
--- a/README.org
+++ b/README.org
@@ -149,11 +149,7 @@ the template. Behind the name, the Tempo syntax elements
follow.
(class "public class " (p (file-name-base (or (buffer-file-name)
(buffer-name)))) " {" n> r> n "}")
- c-mode
- :condition
- (save-match-data
- (save-excursion
- (re-search-backward "^\\w*$" (line-beginning-position) 'noerror)))
+ c-mode :condition (re-search-backward "^\\w*$" (line-beginning-position)
'noerror)
(inc "#include <" (p (concat (file-name-base (or (buffer-file-name)
(buffer-name))) ".h")) ">")
(incc "#include \"" (p (concat (file-name-base (or (buffer-file-name)
(buffer-name))) ".h")) "\"")
diff --git a/tempel.el b/tempel.el
index c5c6585d9b..e78e0e8183 100644
--- a/tempel.el
+++ b/tempel.el
@@ -379,9 +379,12 @@ PROMPT is the optional prompt/default value."
(setq tempel--file-templates (tempel--file-read tempel-file)
tempel--file-modified mod)))
(cl-loop for (mode plist . templates) in tempel--file-templates
- if (or (derived-mode-p mode) (eq mode #'fundamental-mode))
- if (or (not (plist-member plist :condition))
- (eval (plist-get plist :condition) 'lexical))
+ if (and (or (derived-mode-p mode) (eq mode #'fundamental-mode))
+ (or (not (plist-member plist :condition))
+ (save-excursion
+ (save-restriction
+ (save-match-data
+ (eval (plist-get plist :condition) 'lexical))))))
append templates))
(defun tempel--templates ()