1
0
mirror of https://git.savannah.gnu.org/git/emacs.git synced 2024-11-24 07:20:37 +00:00

Allow the expansion of :after (:or foo bar) to be byte-compiled

This commit is contained in:
John Wiegley 2017-12-06 06:01:49 +00:00
parent b2b91af2e5
commit 2cd3ebd5d5
2 changed files with 61 additions and 76 deletions

View File

@ -643,14 +643,11 @@ no more than once."
(let ((loaded (cl-gensym "use-package--loaded"))
(result (cl-gensym "use-package--result"))
(next (cl-gensym "use-package--next")))
`((defconst ,loaded nil)
(defconst ,result nil)
(defconst ,next #'(lambda ()
(if ,loaded
,result
(setq ,loaded t)
(setq ,result ,arg))))
,@(funcall f `((funcall ,next))))))
`((lexical-let (,loaded ,result)
,@(funcall f `((if ,loaded
,result
(setq ,loaded t)
(setq ,result ,arg))))))))
(defsubst use-package-normalize-value (label arg)
"Normalize the Lisp value given by ARG.

View File

@ -1176,119 +1176,107 @@
(ert-deftest use-package-test/:after-5 ()
(match-expansion
(use-package foo :after (:any bar quux))
`(progn
(defconst ,_ nil)
(defconst ,_ nil)
(defconst ,_
#'(lambda nil
(if ,_ ,_
(setq ,_ t)
(setq ,_
(require 'foo nil nil)))))
`(lexical-let (,_ ,_)
(eval-after-load 'bar
'(funcall ,_))
'(if ,_ ,_
(setq ,_ t)
(setq ,_ (require 'foo nil nil))))
(eval-after-load 'quux
'(funcall ,_)))))
'(if ,_ ,_
(setq ,_ t)
(setq ,_ (require 'foo nil nil)))))))
(ert-deftest use-package-test/:after-6 ()
(match-expansion
(use-package foo :after (:all (:any bar quux) bow))
`(progn
(defconst ,_ nil)
(defconst ,_ nil)
(defconst ,_
#'(lambda nil
(if ,_ ,_
(setq ,_ t)
(setq ,_
(require 'foo nil nil)))))
`(lexical-let (,_ ,_)
(eval-after-load 'bow
'(progn
(eval-after-load 'bar
'(funcall ,_))
'(if ,_ ,_
(setq ,_ t)
(setq ,_ (require 'foo nil nil))))
(eval-after-load 'quux
'(funcall ,_)))))))
'(if ,_ ,_
(setq ,_ t)
(setq ,_ (require 'foo nil nil)))))))
))
(ert-deftest use-package-test/:after-7 ()
(match-expansion
(use-package foo :after (:any (:all bar quux) bow))
`(progn
(defconst ,_ nil)
(defconst ,_ nil)
(defconst ,_
#'(lambda nil
(if ,_ ,_
(setq ,_ t)
(setq ,_
(require 'foo nil nil)))))
`(lexical-let (,_ ,_)
(eval-after-load 'quux
'(eval-after-load 'bar
'(funcall ,_)))
'(if ,_ ,_
(setq ,_ t)
(setq ,_ (require 'foo nil nil)))))
(eval-after-load 'bow
'(funcall ,_)))))
'(if ,_ ,_
(setq ,_ t)
(setq ,_ (require 'foo nil nil)))))
))
(ert-deftest use-package-test/:after-8 ()
(match-expansion
(use-package foo :after (:all (:any bar quux) (:any bow baz)))
`(progn
(defconst ,_ nil)
(defconst ,_ nil)
(defconst ,_
#'(lambda nil
(if ,_ ,_
(setq ,_ t)
(setq ,_
(require 'foo nil nil)))))
`(lexical-let (,_ ,_)
(eval-after-load 'bow
'(progn
(eval-after-load 'bar
'(funcall ,_))
'(if ,_ ,_
(setq ,_ t)
(setq ,_ (require 'foo nil nil))))
(eval-after-load 'quux
'(funcall ,_))))
'(if ,_ ,_
(setq ,_ t)
(setq ,_ (require 'foo nil nil))))))
(eval-after-load 'baz
'(progn
(eval-after-load 'bar
'(funcall ,_))
'(if ,_ ,_
(setq ,_ t)
(setq ,_ (require 'foo nil nil))))
(eval-after-load 'quux
'(funcall ,_)))))))
'(if ,_ ,_
(setq ,_ t)
(setq ,_ (require 'foo nil nil)))))))
))
(ert-deftest use-package-test/:after-9 ()
(match-expansion
(use-package foo :after (:any (:all bar quux) (:all bow baz)))
`(progn
(defconst ,_ nil)
(defconst ,_ nil)
(defconst ,_
#'(lambda nil
(if ,_ ,_
(setq ,_ t)
(setq ,_
(require 'foo nil nil)))))
`(lexical-let (,_ ,_)
(eval-after-load 'quux
'(eval-after-load 'bar
'(funcall ,_)))
'(if ,_ ,_
(setq ,_ t)
(setq ,_ (require 'foo nil nil)))))
(eval-after-load 'baz
'(eval-after-load 'bow
'(funcall ,_))))))
'(if ,_ ,_
(setq ,_ t)
(setq ,_ (require 'foo nil nil))))))
))
(ert-deftest use-package-test/:after-10 ()
(match-expansion
(use-package foo :after (:any (:all bar quux) (:any bow baz)))
`(progn
(defconst ,_ nil)
(defconst ,_ nil)
(defconst ,_
#'(lambda nil (if ,_ ,_
(setq ,_ t)
(setq ,_
(require 'foo nil nil)))))
`(lexical-let (,_ ,_)
(eval-after-load 'quux
'(eval-after-load 'bar
'(funcall ,_)))
'(if ,_ ,_
(setq ,_ t)
(setq ,_ (require 'foo nil nil)))))
(eval-after-load 'bow
'(funcall ,_))
'(if ,_ ,_
(setq ,_ t)
(setq ,_ (require 'foo nil nil))))
(eval-after-load 'baz
'(funcall ,_)))))
'(if ,_ ,_
(setq ,_ t)
(setq ,_ (require 'foo nil nil)))))
))
(ert-deftest use-package-test/:demand-1 ()
(match-expansion