aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--lisp/emacs-lisp/thunk.el19
1 files changed, 9 insertions, 10 deletions
diff --git a/lisp/emacs-lisp/thunk.el b/lisp/emacs-lisp/thunk.el
index e1370c45911..8d28570dc2a 100644
--- a/lisp/emacs-lisp/thunk.el
+++ b/lisp/emacs-lisp/thunk.el
@@ -54,16 +54,15 @@
54 "Delay the evaluation of BODY." 54 "Delay the evaluation of BODY."
55 (declare (debug t)) 55 (declare (debug t))
56 (cl-assert lexical-binding) 56 (cl-assert lexical-binding)
57 (let ((forced (make-symbol "forced")) 57 `(let (forced
58 (val (make-symbol "val"))) 58 (val (lambda () ,@body)))
59 `(let (,forced ,val) 59 (lambda (&optional check)
60 (lambda (&optional check) 60 (if check
61 (if check 61 forced
62 ,forced 62 (unless forced
63 (unless ,forced 63 (setf val (funcall val))
64 (setf ,val (progn ,@body)) 64 (setf forced t))
65 (setf ,forced t)) 65 val))))
66 ,val)))))
67 66
68(defun thunk-force (delayed) 67(defun thunk-force (delayed)
69 "Force the evaluation of DELAYED. 68 "Force the evaluation of DELAYED.