Fix use-package :vc keyword when byte-compiled

* lisp/use-package/use-package-core.el (use-package-handler/:vc):
Return the new 'body'. Otherwise, the entire package declaration gets
dropped when byte-compiling.
* test/lisp/use-package/use-package-tests.el
(use-package-test-handler/:vc-6): test it.
This commit is contained in:
Steven Allen 2023-05-16 16:07:36 -07:00 committed by Eli Zaretskii
parent f947a0219b
commit 8d6dd1682e
2 changed files with 13 additions and 1 deletions

View file

@ -1619,7 +1619,8 @@ Also see the Info node `(use-package) Creating an extension'."
;; See `use-package-handler/:ensure' for an explanation.
(if (bound-and-true-p byte-compile-current-file)
(funcall #'use-package-vc-install arg local-path) ; compile time
(push `(use-package-vc-install ',arg ,local-path) body)))) ; runtime
(push `(use-package-vc-install ',arg ,local-path) body)) ; runtime
body))
(defun use-package-normalize--vc-arg (arg)
"Normalize possible arguments to the `:vc' keyword.

View file

@ -1991,6 +1991,17 @@
(use-package-vc-install '(other-name) ,load-path?)
(require 'foo nil nil)))))
(ert-deftest use-package-test-handler/:vc-6 ()
(let ((byte-compile-current-file "use-package-core.el")
tried-to-install)
(cl-letf (((symbol-function #'use-package-vc-install)
(lambda (arg &optional local-path)
(setq tried-to-install arg))))
(should (equal
(use-package-handler/:vc 'foo nil 'some-pkg '(:init (foo)) nil)
'(foo)))
(should (eq tried-to-install 'some-pkg)))))
(ert-deftest use-package-test-normalize/:vc ()
(should (equal '(foo "version-string")
(use-package-normalize/:vc 'foo :vc '("version-string"))))