(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
(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)