]> git.eshelyaron.com Git - emacs.git/commitdiff
Fix use-package :vc keyword when byte-compiled
authorSteven Allen <steven@stebalien.com>
Tue, 16 May 2023 23:07:36 +0000 (16:07 -0700)
committerEli Zaretskii <eliz@gnu.org>
Sat, 3 Jun 2023 07:27:46 +0000 (10:27 +0300)
* 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
test/lisp/use-package/use-package-tests.el

index 0d99e270a3fbd9cd498e547c1503c6ef87447f2a..e0e16134ed3662b62cf921b764311a2a2a03714d 100644 (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.
index c8c20fc51cbf1d1f3fa85912df8cfe6d190a3f4e..9181a8171a72f10f999dd7c006ff1d558e303c51 100644 (file)
              (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"))))