From 19ef37e1fd4ce5ff004822e35717f365d825b360 Mon Sep 17 00:00:00 2001 From: Steven Allen Date: Sun, 26 Jan 2025 13:34:11 -0800 Subject: [PATCH] Defer elpaca form as a lambda This lets the byte-compiler process it. It won't matter for users who don't byte-compile their init files, but it provides a noticeable speedup for those of us that do. --- elpaca.el | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/elpaca.el b/elpaca.el index 1f12b12d..6ceaf7df 100644 --- a/elpaca.el +++ b/elpaca.el @@ -729,9 +729,9 @@ Optional ARGS are passed to `elpaca--signal', which see." (when-let* ((forms (nreverse (elpaca-q<-forms q)))) (with-current-buffer (get-buffer-create " *elpaca--finalize-queue*") (setq-local lexical-binding t) - (cl-loop for (id . body) in forms + (cl-loop for (id . cb) in forms do (condition-case-unless-debug err - (eval `(progn ,@body) t) + (funcall cb) ((error) (warn "Config Error %s: %S" id err))))) (setf (elpaca-q<-forms q) nil)) (run-hooks 'elpaca-post-queue-hook) @@ -1614,14 +1614,14 @@ When quit with \\[keyboard-quit], running sub-processes are not stopped." (when (> (elpaca-q<-processed q) 0) (cl-decf (elpaca-q<-processed q))) (setf (elpaca-q<-status q) 'incomplete))) -(defun elpaca--expand-declaration (order body) - "Expand ORDER declaration, deferring BODY." +(defun elpaca--expand-declaration (order callback) + "Expand ORDER declaration, deferring CALLBACK." (unless order (signal 'wrong-type-argument '((or symbolp consp) nil))) (when (memq (car-safe order) '(quote \`)) (setq order (eval order t))) (let* ((id (elpaca--first order)) (q (or (and after-init-time (elpaca--q (elpaca-get id))) (car elpaca--queues))) (e (elpaca--queue order q))) - (when body (setf (alist-get id (elpaca-q<-forms q)) body)) + (when callback (setf (alist-get id (elpaca-q<-forms q)) callback)) (when after-init-time (elpaca--maybe-log) (unless (eq (elpaca--status e) 'failed) @@ -1639,7 +1639,8 @@ When quit with \\[keyboard-quit], running sub-processes are not stopped." Evaluate BODY forms synchronously once ORDER's queue is processed. See Info node `(elpaca) Basic Concepts'." (declare (indent 1) (debug form)) - `(elpaca--expand-declaration ',order ',body)) + (when body (setq body `(lambda () ,@body))) + `(elpaca--expand-declaration ',order ,body)) (defvar elpaca--try-package-history nil "History for `elpaca-try'.") ;;;###autoload