]> git.eshelyaron.com Git - emacs.git/commitdiff
Ensure that :commands always declare-function at compile time
authorJohn Wiegley <johnw@newartisans.com>
Mon, 4 Dec 2017 19:05:11 +0000 (11:05 -0800)
committerJohn Wiegley <johnw@newartisans.com>
Mon, 4 Dec 2017 19:05:11 +0000 (11:05 -0800)
up-core.el
up-tests.el

index deaead24e85c2425884335e93436f777de15aede..d1732c3b2a27aa3d803f14a4bbb34cde29a8c083 100644 (file)
@@ -1147,20 +1147,20 @@ deferred until the prefix key sequence is pressed."
 
 (defun use-package-handler/:commands (name keyword arg rest state)
   (use-package-concat
-   (unless (plist-get state :demand)
-     ;; Since we deferring load, establish any necessary autoloads, and also
-     ;; keep the byte-compiler happy.
-     (let ((name-string (use-package-as-string name)))
-       (cl-mapcan
-        #'(lambda (command)
-            (when (symbolp command)
-              (append
+   ;; Since we deferring load, establish any necessary autoloads, and also
+   ;; keep the byte-compiler happy.
+   (let ((name-string (use-package-as-string name)))
+     (cl-mapcan
+      #'(lambda (command)
+          (when (symbolp command)
+            (append
+             (unless (plist-get state :demand)
                `((unless (fboundp ',command)
-                   (autoload #',command ,name-string nil t)))
-               (when (bound-and-true-p byte-compile-current-file)
-                 `((eval-when-compile
-                     (declare-function ,command ,name-string)))))))
-        (delete-dups arg))))
+                   (autoload #',command ,name-string nil t))))
+             (when (bound-and-true-p byte-compile-current-file)
+               `((eval-when-compile
+                   (declare-function ,command ,name-string)))))))
+      (delete-dups arg)))
    (use-package-process-keywords name rest state)))
 
 ;;;; :defer
index c23d706c32c715929904fab5d3c5c101af331b09..3bcc340eaca06feaa52844a891b3755f53f3586b 100644 (file)
         (autoload #'bar "foo" nil t))
       (bar))))
 
+(ert-deftest use-package-test/:commands-5 ()
+  (match-expansion
+   (use-package gnus-harvest
+     :load-path "lisp/gnus-harvest"
+     :commands gnus-harvest-install
+     :demand t
+     :config
+     (if (featurep 'message-x)
+         (gnus-harvest-install 'message-x)
+       (gnus-harvest-install)))
+   `(progn
+      (eval-and-compile
+        (add-to-list 'load-path "/Users/johnw/.emacs.d/lisp/gnus-harvest"))
+      (require 'gnus-harvest nil nil)
+      (if (featurep 'message-x)
+          (gnus-harvest-install 'message-x)
+        (gnus-harvest-install))
+      t)))
+
+(ert-deftest use-package-test/:commands-6 ()
+  (let ((byte-compile-current-file t))
+    (match-expansion
+     (use-package gnus-harvest
+       :load-path "lisp/gnus-harvest"
+       :commands gnus-harvest-install
+       :demand t
+       :config
+       (if (featurep 'message-x)
+           (gnus-harvest-install 'message-x)
+         (gnus-harvest-install)))
+     `(progn
+        (eval-and-compile
+          (add-to-list 'load-path "/Users/johnw/.emacs.d/lisp/gnus-harvest"))
+        (eval-and-compile
+          (eval-when-compile
+            (with-demoted-errors "Cannot load gnus-harvest: %S" nil
+                                 (load "gnus-harvest" nil t))))
+        (eval-when-compile
+          (declare-function gnus-harvest-install "gnus-harvest"))
+        (require 'gnus-harvest nil nil)
+        (if
+            (featurep 'message-x)
+            (gnus-harvest-install 'message-x)
+          (gnus-harvest-install))
+        t))))
+
 (ert-deftest use-package-test/:defines-1 ()
   (match-expansion
    (use-package foo :defines bar)