(defun use-package-memoize (f arg)
"Ensure the macro-expansion of F applied to ARG evaluates ARG
no more than once."
- (let ((loaded (cl-gensym "use-package--loaded"))
- (result (cl-gensym "use-package--result"))
- (next (cl-gensym "use-package--next")))
- `((lexical-let (,loaded ,result)
- ,@(funcall f `((if ,loaded
- ,result
- (setq ,loaded t)
- (setq ,result ,arg))))))))
+ (let ((loaded (cl-gentemp "use-package--loaded"))
+ (result (cl-gentemp "use-package--result"))
+ (next (cl-gentemp "use-package--next")))
+ `((defvar ,loaded nil)
+ (defvar ,result nil)
+ (defvar ,next #'(lambda () (if ,loaded ,result
+ (setq ,loaded t ,result ,arg))))
+ ,@(funcall f `((funcall ,next))))))
(defsubst use-package-normalize-value (label arg)
"Normalize the Lisp value given by ARG.
(ert-deftest use-package-test/:after-5 ()
(match-expansion
(use-package foo :after (:any bar quux))
- `(lexical-let (,_ ,_)
+ `(progn
+ (defvar ,_ nil)
+ (defvar ,_ nil)
+ (defvar ,_
+ #'(lambda nil
+ (if ,_ ,_
+ (setq ,_ t ,_
+ (require 'foo nil nil)))))
(eval-after-load 'bar
- '(if ,_ ,_
- (setq ,_ t)
- (setq ,_ (require 'foo nil nil))))
+ '(funcall ,_))
(eval-after-load 'quux
- '(if ,_ ,_
- (setq ,_ t)
- (setq ,_ (require 'foo nil nil)))))))
+ '(funcall ,_)))))
(ert-deftest use-package-test/:after-6 ()
(match-expansion
(use-package foo :after (:all (:any bar quux) bow))
- `(lexical-let (,_ ,_)
+ `(progn
+ (defvar ,_ nil)
+ (defvar ,_ nil)
+ (defvar ,_
+ #'(lambda nil
+ (if ,_ ,_
+ (setq ,_ t ,_
+ (require 'foo nil nil)))))
(eval-after-load 'bow
'(progn
(eval-after-load 'bar
- '(if ,_ ,_
- (setq ,_ t)
- (setq ,_ (require 'foo nil nil))))
+ '(funcall ,_))
(eval-after-load 'quux
- '(if ,_ ,_
- (setq ,_ t)
- (setq ,_ (require 'foo nil nil)))))))
- ))
+ '(funcall ,_)))))))
(ert-deftest use-package-test/:after-7 ()
(match-expansion
(use-package foo :after (:any (:all bar quux) bow))
- `(lexical-let (,_ ,_)
+ `(progn
+ (defvar ,_ nil)
+ (defvar ,_ nil)
+ (defvar ,_
+ #'(lambda nil
+ (if ,_ ,_
+ (setq ,_ t ,_
+ (require 'foo nil nil)))))
(eval-after-load 'quux
'(eval-after-load 'bar
- '(if ,_ ,_
- (setq ,_ t)
- (setq ,_ (require 'foo nil nil)))))
+ '(funcall ,_)))
(eval-after-load 'bow
- '(if ,_ ,_
- (setq ,_ t)
- (setq ,_ (require 'foo nil nil)))))
- ))
+ '(funcall ,_)))))
(ert-deftest use-package-test/:after-8 ()
(match-expansion
(use-package foo :after (:all (:any bar quux) (:any bow baz)))
- `(lexical-let (,_ ,_)
+ `(progn
+ (defvar ,_ nil)
+ (defvar ,_ nil)
+ (defvar ,_
+ #'(lambda nil
+ (if ,_ ,_
+ (setq ,_ t ,_
+ (require 'foo nil nil)))))
(eval-after-load 'bow
'(progn
(eval-after-load 'bar
- '(if ,_ ,_
- (setq ,_ t)
- (setq ,_ (require 'foo nil nil))))
+ '(funcall ,_))
(eval-after-load 'quux
- '(if ,_ ,_
- (setq ,_ t)
- (setq ,_ (require 'foo nil nil))))))
+ '(funcall ,_))))
(eval-after-load 'baz
'(progn
(eval-after-load 'bar
- '(if ,_ ,_
- (setq ,_ t)
- (setq ,_ (require 'foo nil nil))))
+ '(funcall ,_))
(eval-after-load 'quux
- '(if ,_ ,_
- (setq ,_ t)
- (setq ,_ (require 'foo nil nil)))))))
- ))
+ '(funcall ,_)))))))
(ert-deftest use-package-test/:after-9 ()
(match-expansion
(use-package foo :after (:any (:all bar quux) (:all bow baz)))
- `(lexical-let (,_ ,_)
+ `(progn
+ (defvar ,_ nil)
+ (defvar ,_ nil)
+ (defvar ,_
+ #'(lambda nil
+ (if ,_ ,_
+ (setq ,_ t ,_
+ (require 'foo nil nil)))))
(eval-after-load 'quux
'(eval-after-load 'bar
- '(if ,_ ,_
- (setq ,_ t)
- (setq ,_ (require 'foo nil nil)))))
+ '(funcall ,_)))
(eval-after-load 'baz
'(eval-after-load 'bow
- '(if ,_ ,_
- (setq ,_ t)
- (setq ,_ (require 'foo nil nil))))))
- ))
+ '(funcall ,_))))))
(ert-deftest use-package-test/:after-10 ()
(match-expansion
(use-package foo :after (:any (:all bar quux) (:any bow baz)))
- `(lexical-let (,_ ,_)
+ `(progn
+ (defvar ,_ nil)
+ (defvar ,_ nil)
+ (defvar ,_
+ #'(lambda nil
+ (if ,_ ,_
+ (setq ,_ t ,_
+ (require 'foo nil nil)))))
(eval-after-load 'quux
'(eval-after-load 'bar
- '(if ,_ ,_
- (setq ,_ t)
- (setq ,_ (require 'foo nil nil)))))
+ '(funcall ,_)))
(eval-after-load 'bow
- '(if ,_ ,_
- (setq ,_ t)
- (setq ,_ (require 'foo nil nil))))
+ '(funcall ,_))
(eval-after-load 'baz
- '(if ,_ ,_
- (setq ,_ t)
- (setq ,_ (require 'foo nil nil)))))
- ))
+ '(funcall ,_)))))
(ert-deftest use-package-test/:demand-1 ()
(match-expansion