]> git.eshelyaron.com Git - emacs.git/commitdiff
If use-package-verbose is t, show loading times when :after is used
authorJohn Wiegley <johnw@newartisans.com>
Fri, 1 Dec 2017 21:38:41 +0000 (13:38 -0800)
committerJohn Wiegley <johnw@newartisans.com>
Fri, 1 Dec 2017 21:39:05 +0000 (13:39 -0800)
lisp/use-package/use-package.el
test/lisp/use-package/use-package-tests.el

index ae361de6f6bf0d7667e0472df4187896bb528bdb..04a811f4d4cbab37274ae0a07cbe7f1bf1dd5d02 100644 (file)
@@ -305,8 +305,8 @@ appended."
   "Return a form which will load or require NAME depending on
 whether it's a string or symbol."
   (if (stringp name)
-      `(load ,name ',noerror)
-    `(require ',name nil ',noerror)))
+      `(load ,name ,noerror)
+    `(require ',name nil ,noerror)))
 
 (defun use-package-expand (name label form)
   "FORM is a list of forms, so `((foo))' if only `foo' is being called."
@@ -346,6 +346,20 @@ ARGS is a list of forms, so `((foo))' if only `foo' is being called."
                  ',(intern (concat "use-package--" name-string
                                    "--post-" keyword-name "-hook")))))))))))
 
+(defun use-package--require (name &optional no-require body)
+  (use-package--with-elapsed-timer
+      (format "Loading package %s" name)
+    (if use-package-expand-minimally
+        (use-package-concat
+         (unless no-require
+           (list (use-package-load-name name)))
+         body)
+      (if no-require
+          body
+        `((if (not ,(use-package-load-name name t))
+              (ignore (message (format "Cannot load %s" ',name)))
+            ,@body))))))
+
 (defun use-package--with-elapsed-timer (text body)
   "BODY is a list of forms, so `((foo))' if only `foo' is being called."
   (declare (indent 1))
@@ -1204,7 +1218,7 @@ representing symbols (that may need to be autloaded)."
        (list (funcall
               (use-package-require-after-load arg)
               (macroexp-progn
-               `((require (quote ,name) nil t))))))
+               (use-package--require name)))))
      body)))
 
 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
@@ -1262,20 +1276,8 @@ representing symbols (that may need to be autloaded)."
         (unless (or (null config-body) (equal config-body '(t)))
           `((eval-after-load ,(if (symbolp name) `',name name)
               ',(macroexp-progn config-body))))
-
-      (use-package--with-elapsed-timer
-          (format "Loading package %s" name)
-        (if use-package-expand-minimally
-            (use-package-concat
-             (unless (plist-get state ':no-require)
-               (list (use-package-load-name name)))
-             config-body)
-          (if (plist-get state ':no-require)
-              config-body
-            `((if (not ,(use-package-load-name name t))
-                  (ignore
-                   (message (format "Cannot load %s" ',name)))
-                ,@config-body))))))))
+      (use-package--require name (plist-get state ':no-require)
+                            config-body))))
 
 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
 ;;
index 60cf2ff7b15578c8545a894e8312bb5a4b021542..7bc2a486b79d0167e5039b176d6308ae1ca2a734 100644 (file)
    `(progn
       (eval-and-compile
         (t))
-      (require 'foo nil 'nil)))
+      (require 'foo nil nil)))
 
   (let ((byte-compile-current-file t))
     (match-expansion
                 "Cannot load foo: %S" nil
                 (load "foo" nil t)))
           (t))
-        (require 'foo nil 'nil))))
+        (require 'foo nil nil))))
 
   (let ((byte-compile-current-file t))
     (match-expansion
                 (load "foo" nil t)))
           (preface))
         (init)
-        (require 'foo nil 'nil)
+        (require 'foo nil nil)
         (config)
         t)))
 
    (use-package foo :pin foo)
    `(progn
       (use-package-pin-package 'foo "foo")
-      (require 'foo nil 'nil)))
+      (require 'foo nil nil)))
 
   (match-expansion
    (use-package foo :pin "foo")
    `(progn
       (use-package-pin-package 'foo "foo")
-      (require 'foo nil 'nil))))
+      (require 'foo nil nil))))
 
 (ert-deftest use-package-test/:defer-install ()
   (match-expansion
    (use-package foo :defer-install t)
    `(progn
-      (require 'foo nil 'nil))))
+      (require 'foo nil nil))))
 
 (ert-deftest use-package-test-normalize/:ensure ()
   (flet ((norm (&rest args)
      (use-package foo :ensure t)
      `(progn
         (use-package-ensure-elpa 'foo 't 'nil)
-        (require 'foo nil 'nil))))
+        (require 'foo nil nil))))
 
   (let ((use-package-always-ensure t))
     (match-expansion
      (use-package foo :ensure t)
      `(progn
         (use-package-ensure-elpa 'foo 't 'nil)
-        (require 'foo nil 'nil))))
+        (require 'foo nil nil))))
 
   (let ((use-package-always-ensure nil))
     (match-expansion
      (use-package foo :ensure nil)
      `(progn
         (use-package-ensure-elpa 'foo 'nil 'nil)
-        (require 'foo nil 'nil))))
+        (require 'foo nil nil))))
 
   (let ((use-package-always-ensure t))
     (match-expansion
      (use-package foo :ensure nil)
      `(progn
         (use-package-ensure-elpa 'foo 'nil 'nil)
-        (require 'foo nil 'nil))))
+        (require 'foo nil nil))))
 
   (let ((use-package-always-ensure nil))
     (match-expansion
      `(progn
         (eval-and-compile
           (add-to-list 'load-path ,(pred stringp)))
-        (require 'foo nil 'nil))))
+        (require 'foo nil nil))))
 
   (let ((use-package-always-ensure t))
     (match-expansion
         (use-package-ensure-elpa 'foo 'nil 'nil)
         (eval-and-compile
           (add-to-list 'load-path ,(pred stringp)))
-        (require 'foo nil 'nil))))
+        (require 'foo nil nil))))
 
   (let ((use-package-always-ensure nil))
     (match-expansion
         (use-package-ensure-elpa 'foo 'nil 'nil)
         (eval-and-compile
           (add-to-list 'load-path ,(pred stringp)))
-        (require 'foo nil 'nil))))
+        (require 'foo nil nil))))
 
   (let ((use-package-always-ensure t))
     (match-expansion
         (use-package-ensure-elpa 'foo 'nil 'nil)
         (eval-and-compile
           (add-to-list 'load-path ,(pred stringp)))
-        (require 'foo nil 'nil))))
+        (require 'foo nil nil))))
 
   (let ((use-package-always-ensure nil))
     (match-expansion
         (use-package-ensure-elpa 'foo 't 'nil)
         (eval-and-compile
           (add-to-list 'load-path ,(pred stringp)))
-        (require 'foo nil 'nil))))
+        (require 'foo nil nil))))
 
   (let ((use-package-always-ensure t))
     (match-expansion
         (use-package-ensure-elpa 'foo 't 'nil)
         (eval-and-compile
           (add-to-list 'load-path ,(pred stringp)))
-        (require 'foo nil 'nil))))
+        (require 'foo nil nil))))
 
   (let (tried-to-install)
     (flet ((use-package-ensure-elpa
    (use-package foo :if t)
    `(progn
       (when (symbol-value 't)
-        (require 'foo nil 'nil))))
+        (require 'foo nil nil))))
 
   (match-expansion
    (use-package foo :if (and t t))
    `(progn
       (when (and t t)
-        (require 'foo nil 'nil))))
+        (require 'foo nil nil))))
 
   (match-expansion
    (use-package foo :if nil)
    `(progn
       (when nil
-        (require 'foo nil 'nil)))))
+        (require 'foo nil nil)))))
 
 (ert-deftest use-package-test/:when ()
   (match-expansion
    (use-package foo :when t)
    `(progn
       (when (symbol-value 't)
-        (require 'foo nil 'nil))))
+        (require 'foo nil nil))))
 
   (match-expansion
    (use-package foo :when (and t t))
    `(progn
       (when (and t t)
-        (require 'foo nil 'nil))))
+        (require 'foo nil nil))))
 
   (match-expansion
    (use-package foo :when nil)
    `(progn
       (when nil
-        (require 'foo nil 'nil)))))
+        (require 'foo nil nil)))))
 
 (ert-deftest use-package-test/:unless ()
   (match-expansion
    (use-package foo :unless t)
    `(progn
       (unless (symbol-value 't)
-        (require 'foo nil 'nil))))
+        (require 'foo nil nil))))
 
   (match-expansion
    (use-package foo :unless (and t t))
    `(progn
       (unless (and t t)
-        (require 'foo nil 'nil))))
+        (require 'foo nil nil))))
 
   (match-expansion
    (use-package foo :unless nil)
    `(progn
       (unless nil
-        (require 'foo nil 'nil)))))
+        (require 'foo nil nil)))))
 
 (ert-deftest use-package-test/:requires ()
   (match-expansion
    (use-package foo :requires bar)
    `(progn
       (when (not (member nil (mapcar #'featurep '(bar))))
-        (require 'foo nil 'nil))))
+        (require 'foo nil nil))))
 
   (let ((byte-compile-current-file t))
     (match-expansion
             (eval-when-compile
               (with-demoted-errors "Cannot load foo: %S" nil
                                    (load "foo" nil t))))
-          (require 'foo nil 'nil))))))
+          (require 'foo nil nil))))))
 
 (ert-deftest use-package-test/:load-path ()
   (match-expansion
                              #'string=
                              (expand-file-name
                               "bar" user-emacs-directory)))))
-      (require 'foo nil 'nil)))
+      (require 'foo nil nil)))
 
   (let ((byte-compile-current-file t))
     (match-expansion
           (eval-when-compile
             (with-demoted-errors "Cannot load foo: %S" nil
                                  (load "foo" nil t))))
-        (require 'foo nil 'nil))))
+        (require 'foo nil nil))))
 
   (match-expansion
    (use-package foo :load-path ("bar" "quux"))
                              #'string=
                              (expand-file-name
                               "quux" user-emacs-directory)))))
-      (require 'foo nil 'nil)))
+      (require 'foo nil nil)))
 
   (match-expansion
    (use-package foo :load-path (lambda () (list "bar" "quux")))
                              #'string=
                              (expand-file-name
                               "quux" user-emacs-directory)))))
-      (require 'foo nil 'nil))))
+      (require 'foo nil nil))))
 
 (ert-deftest use-package-test/:no-require ()
   (match-expansion
   (match-expansion
    (use-package foo :defines bar)
    `(progn
-      (require 'foo nil 'nil)))
+      (require 'foo nil nil)))
 
   (let ((byte-compile-current-file t))
     (match-expansion
             (with-demoted-errors
                 "Cannot load foo: %S" nil
                 (load "foo" nil t))))
-        (require 'foo nil 'nil)))))
+        (require 'foo nil nil)))))
 
 (ert-deftest use-package-test/:functions ()
   (match-expansion
    (use-package foo :functions bar)
    `(progn
-      (require 'foo nil 'nil)))
+      (require 'foo nil nil)))
 
   (let ((byte-compile-current-file t))
     (match-expansion
             (with-demoted-errors
                 "Cannot load foo: %S" nil
                 (load "foo" nil t))))
-        (require 'foo nil 'nil))))
+        (require 'foo nil nil))))
 
   (match-expansion
    (use-package foo :defer t :functions bar)
   (match-expansion
    (use-package foo)
    `(progn
-      (require 'foo nil 'nil)))
+      (require 'foo nil nil)))
 
   (let ((byte-compile-current-file t))
     (match-expansion
           (eval-when-compile
             (with-demoted-errors "Cannot load foo: %S" nil
                                  (load "foo" nil t))))
-        (require 'foo nil 'nil))))
+        (require 'foo nil nil))))
 
   (match-expansion
    (use-package foo :defer t)
    (use-package foo :custom (foo bar))
    `(progn
       (customize-set-variable 'foo bar "Customized with use-package foo")
-      (require 'foo nil 'nil))))
+      (require 'foo nil nil))))
 
 (ert-deftest use-package-test/:custom-face ()
   (match-expansion
    (use-package foo :custom-face (foo ((t (:background "#e4edfc")))))
    `(progn
       (custom-set-faces '(foo ((t (:background "#e4edfc")))))
-      (require 'foo nil 'nil))))
+      (require 'foo nil nil))))
 
 (ert-deftest use-package-test/:init ()
   (match-expansion
    (use-package foo :init (init))
    `(progn
       (init)
-      (require 'foo nil 'nil)))
+      (require 'foo nil nil)))
 
   (let ((byte-compile-current-file t))
     (match-expansion
             (with-demoted-errors "Cannot load foo: %S" nil
                                  (load "foo" nil t))))
         (init)
-        (require 'foo nil 'nil)))))
+        (require 'foo nil nil)))))
 
 (ert-deftest use-package-test/:after ()
   (match-expansion
    (use-package foo :after bar)
    `(progn
       (eval-after-load 'bar
-        '(require 'foo nil t))))
+        '(require 'foo nil nil))))
 
   (let ((byte-compile-current-file t))
     (match-expansion
             (with-demoted-errors "Cannot load foo: %S" nil
                                  (load "foo" nil t))))
         (eval-after-load 'bar
-          '(require 'foo nil t)))))
+          '(require 'foo nil nil)))))
 
   (match-expansion
    (use-package foo :after (bar quux))
    `(progn
       (eval-after-load 'quux
         '(eval-after-load 'bar
-           '(require 'foo nil t)))))
+           '(require 'foo nil nil)))))
 
   (match-expansion
    (use-package foo :after (:all bar quux))
    `(progn
       (eval-after-load 'quux
         '(eval-after-load 'bar
-           '(require 'foo nil t)))))
+           '(require 'foo nil nil)))))
 
   (match-expansion
    (use-package foo :after (:any bar quux))
    `(progn
       (progn
         (eval-after-load 'bar
-          '(require 'foo nil t))
+          '(require 'foo nil nil))
         (eval-after-load 'quux
-          '(require 'foo nil t)))))
+          '(require 'foo nil nil)))))
 
   (match-expansion
    (use-package foo :after (:all (:any bar quux) bow))
       (eval-after-load 'bow
         '(progn
            (eval-after-load 'bar
-             '(require 'foo nil t))
+             '(require 'foo nil nil))
            (eval-after-load 'quux
-             '(require 'foo nil t))))))
+             '(require 'foo nil nil))))))
 
   (match-expansion
    (use-package foo :after (:any (:all bar quux) bow))
       (progn
         (eval-after-load 'quux
           '(eval-after-load 'bar
-             '(require 'foo nil t)))
+             '(require 'foo nil nil)))
         (eval-after-load 'bow
-          '(require 'foo nil t)))))
+          '(require 'foo nil nil)))))
 
   (match-expansion
    (use-package foo :after (:all (:any bar quux) (:any bow baz)))
         (eval-after-load 'bow
           '(progn
              (eval-after-load 'bar
-               '(require 'foo nil t))
+               '(require 'foo nil nil))
              (eval-after-load 'quux
-               '(require 'foo nil t))))
+               '(require 'foo nil nil))))
         (eval-after-load 'baz
           '(progn
              (eval-after-load 'bar
-               '(require 'foo nil t))
+               '(require 'foo nil nil))
              (eval-after-load 'quux
-               '(require 'foo nil t)))))))
+               '(require 'foo nil nil)))))))
 
   (match-expansion
    (use-package foo :after (:any (:all bar quux) (:all bow baz)))
       (progn
         (eval-after-load 'quux
           '(eval-after-load 'bar
-             '(require 'foo nil t)))
+             '(require 'foo nil nil)))
         (eval-after-load 'baz
           '(eval-after-load 'bow
-             '(require 'foo nil t))))))
+             '(require 'foo nil nil))))))
 
   (match-expansion
    (use-package foo :after (:any (:all bar quux) (:any bow baz)))
       (progn
         (eval-after-load 'quux
           '(eval-after-load 'bar
-             '(require 'foo nil t)))
+             '(require 'foo nil nil)))
         (progn
           (eval-after-load 'bow
-            '(require 'foo nil t))
+            '(require 'foo nil nil))
           (eval-after-load 'baz
-            '(require 'foo nil t)))))))
+            '(require 'foo nil nil)))))))
 
 (ert-deftest use-package-test/:demand ()
   (match-expansion
    (use-package foo :demand t)
    `(progn
-      (require 'foo nil 'nil)))
+      (require 'foo nil nil)))
 
   (let ((byte-compile-current-file t))
     (match-expansion
           (eval-when-compile
             (with-demoted-errors "Cannot load foo: %S" nil
                                  (load "foo" nil t))))
-        (require 'foo nil 'nil))))
+        (require 'foo nil nil))))
 
   (match-expansion
    (use-package foo :demand t :config (config))
    `(progn
-      (require 'foo nil 'nil)
+      (require 'foo nil nil)
       (config)
       t))
 
           (eval-when-compile
             (with-demoted-errors "Cannot load foo: %S" nil
                                  (load "foo" nil t))))
-        (require 'foo nil 'nil)
+        (require 'foo nil nil)
         (config)
         t)))
 
    (use-package foo :demand t :after bar)
    `(progn
       (eval-after-load 'bar
-        '(require 'foo nil t))))
+        '(require 'foo nil nil))))
 
   (let ((byte-compile-current-file t))
     (match-expansion
             (with-demoted-errors "Cannot load foo: %S" nil
                                  (load "foo" nil t))))
         (eval-after-load 'bar
-          '(require 'foo nil t))))))
+          '(require 'foo nil nil))))))
 
 (ert-deftest use-package-test/:config ()
   (match-expansion
    (use-package foo :config (config))
    `(progn
-      (require 'foo nil 'nil)
+      (require 'foo nil nil)
       (config)
       t))
 
           (eval-when-compile
             (with-demoted-errors "Cannot load foo: %S" nil
                                  (load "foo" nil t))))
-        (require 'foo nil 'nil)
+        (require 'foo nil nil)
         (config)
         t)))
 
   (match-expansion
    (use-package foo :diminish nil)
    `(progn
-      (require 'foo nil 'nil)
+      (require 'foo nil nil)
       (if (fboundp 'diminish)
           (diminish 'foo-mode))))
 
   (match-expansion
    (use-package foo :diminish bar)
    `(progn
-      (require 'foo nil 'nil)
+      (require 'foo nil nil)
       (if (fboundp 'diminish)
           (diminish 'bar))))
 
   (match-expansion
    (use-package foo :diminish "bar")
    `(progn
-      (require 'foo nil 'nil)
+      (require 'foo nil nil)
       (if (fboundp 'diminish)
           (diminish 'foo-mode "bar"))))
 
   (match-expansion
    (use-package foo :diminish (foo . "bar"))
    `(progn
-      (require 'foo nil 'nil)
+      (require 'foo nil nil)
       (if (fboundp 'diminish)
           (diminish 'foo "bar")))))
 
   (match-expansion
    (use-package foo :delight)
    `(progn
-      (require 'foo nil 'nil)
+      (require 'foo nil nil)
       (if (fboundp 'delight)
           (delight '((foo-mode nil foo))))))
 
    (match-expansion
     (use-package foo :delight nil)
     `(progn
-       (require 'foo nil 'nil)
+       (require 'foo nil nil)
        (if (fboundp 'diminish)
            (diminish 'foo-mode)))))
 
   (match-expansion
    (use-package foo :delight bar)
    `(progn
-      (require 'foo nil 'nil)
+      (require 'foo nil nil)
       (if (fboundp 'delight)
           (delight '((bar nil foo))))))
 
   (match-expansion
    (use-package foo :delight "bar")
    `(progn
-      (require 'foo nil 'nil)
+      (require 'foo nil nil)
       (if (fboundp 'delight)
           (delight '((foo-mode "bar" foo))))))
 
    (match-expansion
     (use-package foo :delight (foo . "bar"))
     `(progn
-       (require 'foo nil 'nil)
+       (require 'foo nil nil)
        (if (fboundp 'diminish)
            (diminish 'foo "bar")))))
 
   (match-expansion
    (use-package foo :delight (foo "bar"))
    `(progn
-      (require 'foo nil 'nil)
+      (require 'foo nil nil)
       (if (fboundp 'delight)
           (delight '((foo "bar" foo)))))))