emacs-elpa-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[elpa] externals/tempel 7cf25bd795 71/82: Simplify templates data struct


From: ELPA Syncer
Subject: [elpa] externals/tempel 7cf25bd795 71/82: Simplify templates data structure at load time
Date: Sun, 9 Jan 2022 20:58:46 -0500 (EST)

branch: externals/tempel
commit 7cf25bd795f14a01e234257cccd2f18c7813e5e1
Author: Daniel Mendler <mail@daniel-mendler.de>
Commit: Daniel Mendler <mail@daniel-mendler.de>

    Simplify templates data structure at load time
---
 tempel.el | 19 +++++++++++--------
 1 file changed, 11 insertions(+), 8 deletions(-)

diff --git a/tempel.el b/tempel.el
index 8e164e2024..227653f3b6 100644
--- a/tempel.el
+++ b/tempel.el
@@ -120,7 +120,11 @@ may be named with `tempel--name' or carry an evaluatable 
Lisp expression
     (goto-char (point-max))
     (insert "\n)")
     (goto-char (point-min))
-    (read (current-buffer))))
+    (let ((templates (read (current-buffer))) result)
+      (while (and templates (symbolp (car templates)))
+        (push (cons (car templates) (seq-take-while #'consp (cdr templates))) 
result)
+        (setq templates (seq-drop-while #'consp (cdr templates))))
+      result)))
 
 (defun tempel--print-element (elt)
   "Return string representation of template ELT."
@@ -324,16 +328,15 @@ PROMPT is the optional prompt/default value."
 
 (defun tempel--templates ()
   "Return templates for current mode."
-  (let ((mod (file-attribute-modification-time (file-attributes tempel-file))))
+  (let ((mod (time-convert (file-attribute-modification-time
+                            (file-attributes tempel-file))
+                           'integer)))
     (unless (equal tempel--modified mod)
       (setq tempel--templates (tempel--load tempel-file)
             tempel--modified mod)))
-  (let (result (templates tempel--templates))
-    (while (and templates (symbolp (car templates)))
-      (when (derived-mode-p (car templates))
-        (push (seq-take-while #'consp (cdr templates)) result))
-      (setq templates (seq-drop-while #'consp (cdr templates))))
-    (apply #'append result)))
+  (cl-loop for x in tempel--templates
+           if (derived-mode-p (car x))
+           append (cdr x)))
 
 (defun tempel--region ()
   "Return region bounds."



reply via email to

[Prev in Thread] Current Thread [Next in Thread]