]> git.eshelyaron.com Git - emacs.git/commitdiff
Always wrap the expanded body from use-package in (progn)
authorJohn Wiegley <johnw@newartisans.com>
Fri, 1 Dec 2017 18:23:06 +0000 (10:23 -0800)
committerJohn Wiegley <johnw@newartisans.com>
Fri, 1 Dec 2017 18:23:21 +0000 (10:23 -0800)
lisp/use-package/use-package.el
test/lisp/use-package/use-package-tests.el

index 878fa673409eba2797f25539bdb127733e75d2fa..fe2233057704a8f67dcc666a355658994cfd4f6e 100644 (file)
@@ -1760,25 +1760,25 @@ this file.  Usage:
                                      (symbol-name name)) nil t)))))))))
 
       (let ((body
-             (macroexp-progn
-              (use-package-process-keywords name
-                (let ((args*
-                       (use-package-sort-keywords
-                        (if (and use-package-always-demand
-                                 (not (memq :defer args)))
-                            (plist-put args :demand t)
-                          args))))
-                  (when (and use-package-always-ensure
-                             (plist-member args* :load-path)
-                             (not (plist-member orig-args :ensure)))
-                    (plist-put args* :ensure nil))
-                  (unless (plist-member args* :init)
-                    (plist-put args* :init nil))
-                  (unless (plist-member args* :config)
-                    (plist-put args* :config '(t)))
-                  args*)
-                (and use-package-always-defer
-                     (list :deferred t))))))
+             `(progn
+                ,@(use-package-process-keywords name
+                    (let ((args*
+                           (use-package-sort-keywords
+                            (if (and use-package-always-demand
+                                     (not (memq :defer args)))
+                                (plist-put args :demand t)
+                              args))))
+                      (when (and use-package-always-ensure
+                                 (plist-member args* :load-path)
+                                 (not (plist-member orig-args :ensure)))
+                        (plist-put args* :ensure nil))
+                      (unless (plist-member args* :init)
+                        (plist-put args* :init nil))
+                      (unless (plist-member args* :config)
+                        (plist-put args* :config '(t)))
+                      args*)
+                    (and use-package-always-defer
+                         (list :deferred t))))))
         (when use-package-debug
           (display-buffer
            (save-current-buffer
@@ -1787,6 +1787,7 @@ this file.  Usage:
                (emacs-lisp-mode)
                (insert (pp-to-string body))
                (current-buffer)))))
+        (message "body = %s" body)
         body))))
 
 
index 6710d48faa8250d9d4699e5624c298021bddcd74..66a4af30b526c53856461edf7e2c455a769ece68 100644 (file)
 (ert-deftest use-package-test/:if ()
   (match-expansion
    (use-package foo :if t)
-   `(if (symbol-value 't)
-        (progn
-          (require 'foo nil 'nil))))
+   `(progn
+      (when (symbol-value 't)
+        (require 'foo nil 'nil))))
 
   (match-expansion
    (use-package foo :if (and t t))
-   `(if (and t t)
-        (progn
-          (require 'foo nil 'nil))))
+   `(progn
+      (when (and t t)
+        (require 'foo nil 'nil))))
 
   (match-expansion
    (use-package foo :if nil)
-   `(if nil
-        (progn
-          (require 'foo nil 'nil)))))
+   `(progn
+      (when nil
+        (require 'foo nil 'nil)))))
 
 (ert-deftest use-package-test/:when ()
   (match-expansion
    (use-package foo :when t)
-   `(if (symbol-value 't)
-        (progn
-          (require 'foo nil 'nil))))
+   `(progn
+      (when (symbol-value 't)
+        (require 'foo nil 'nil))))
 
   (match-expansion
    (use-package foo :when (and t t))
-   `(if (and t t)
-        (progn
-          (require 'foo nil 'nil))))
+   `(progn
+      (when (and t t)
+        (require 'foo nil 'nil))))
 
   (match-expansion
    (use-package foo :when nil)
-   `(if nil
-        (progn
-          (require 'foo nil 'nil)))))
+   `(progn
+      (when nil
+        (require 'foo nil 'nil)))))
 
-(ert-deftest use-package-test/:when ()
+(ert-deftest use-package-test/:unless ()
   (match-expansion
    (use-package foo :unless t)
-   `(if (symbol-value 't)
-        nil
-      (require 'foo nil 'nil)))
+   `(progn
+      (unless (symbol-value 't)
+        (require 'foo nil 'nil))))
 
   (match-expansion
    (use-package foo :unless (and t t))
-   `(if (and t t)
-        nil
-      (require 'foo nil 'nil)))
+   `(progn
+      (unless (and t t)
+        (require 'foo nil 'nil))))
 
   (match-expansion
    (use-package foo :unless nil)
-   `(if nil
-        nil
-      (require 'foo nil 'nil))))
+   `(progn
+      (unless nil
+        (require 'foo nil 'nil)))))
 
 ;; (ert-deftest use-package-test/:requires ()
 ;;   (should (equal (macroexpand (use-package))
 (ert-deftest use-package-test/:defines ()
   (match-expansion
    (use-package foo :defines bar)
-   `(require 'foo nil 'nil))
+   `(progn
+      (require 'foo nil 'nil)))
 
   (let ((byte-compile-current-file t))
     (match-expansion
 (ert-deftest use-package-test/:functions ()
   (match-expansion
    (use-package foo :functions bar)
-   `(require 'foo nil 'nil))
+   `(progn
+      (require 'foo nil 'nil)))
 
   (let ((byte-compile-current-file t))
     (match-expansion
 
   (match-expansion
    (use-package foo :defer t :functions bar)
-   `nil)
+   `(progn))
 
-  ;; jww (2017-12-01): This exposes a bug.
-  ;; (let ((byte-compile-current-file t))
-  ;;   (match-expansion
-  ;;    (use-package foo :defer t :functions bar)
-  ;;    `'nil))
+  (let ((byte-compile-current-file t))
+    (match-expansion
+     (use-package foo :defer t :functions bar)
+     `(progn
+        (eval-and-compile
+          (declare-function bar "foo")
+          (eval-when-compile
+            (with-demoted-errors "Cannot load foo: %S" nil
+                                 (load "foo" nil t)))))))
 
   (let ((byte-compile-current-file t))
     (match-expansion
 (ert-deftest use-package-test/:after ()
   (match-expansion
    (use-package foo :after bar)
-   `(eval-after-load 'bar
-      '(require 'foo nil t))))
+   `(progn
+      (eval-after-load 'bar
+        '(require 'foo nil t)))))
 
 ;; (ert-deftest use-package-test/:demand ()
 ;;   (should (equal (macroexpand (use-package))