From 8d6dd1682e2d42a813f9649e70da7aa7d6a95021 Mon Sep 17 00:00:00 2001 From: Steven Allen Date: Tue, 16 May 2023 16:07:36 -0700 Subject: [PATCH] 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. --- lisp/use-package/use-package-core.el | 3 ++- test/lisp/use-package/use-package-tests.el | 11 +++++++++++ 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/lisp/use-package/use-package-core.el b/lisp/use-package/use-package-core.el index 0d99e270a3f..e0e16134ed3 100644 --- a/lisp/use-package/use-package-core.el +++ b/lisp/use-package/use-package-core.el @@ -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. diff --git a/test/lisp/use-package/use-package-tests.el b/test/lisp/use-package/use-package-tests.el index c8c20fc51cb..9181a8171a7 100644 --- a/test/lisp/use-package/use-package-tests.el +++ b/test/lisp/use-package/use-package-tests.el @@ -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")))) -- 2.39.2