aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJohn Wiegley2017-12-01 10:23:06 -0800
committerJohn Wiegley2017-12-01 10:23:21 -0800
commitf5b034154f8fa2bab0375e34143de9d462ee1232 (patch)
treea4deafdeb6cb8db837651f16e91633f682eba2a0
parent21b9b6551dae815a5ccee491735d7b9a0d27d2ad (diff)
downloademacs-f5b034154f8fa2bab0375e34143de9d462ee1232.tar.gz
emacs-f5b034154f8fa2bab0375e34143de9d462ee1232.zip
Always wrap the expanded body from use-package in (progn)
-rw-r--r--lisp/use-package/use-package.el39
-rw-r--r--test/lisp/use-package/use-package-tests.el83
2 files changed, 65 insertions, 57 deletions
diff --git a/lisp/use-package/use-package.el b/lisp/use-package/use-package.el
index 878fa673409..fe223305770 100644
--- a/lisp/use-package/use-package.el
+++ b/lisp/use-package/use-package.el
@@ -1760,25 +1760,25 @@ this file. Usage:
1760 (symbol-name name)) nil t))))))))) 1760 (symbol-name name)) nil t)))))))))
1761 1761
1762 (let ((body 1762 (let ((body
1763 (macroexp-progn 1763 `(progn
1764 (use-package-process-keywords name 1764 ,@(use-package-process-keywords name
1765 (let ((args* 1765 (let ((args*
1766 (use-package-sort-keywords 1766 (use-package-sort-keywords
1767 (if (and use-package-always-demand 1767 (if (and use-package-always-demand
1768 (not (memq :defer args))) 1768 (not (memq :defer args)))
1769 (plist-put args :demand t) 1769 (plist-put args :demand t)
1770 args)))) 1770 args))))
1771 (when (and use-package-always-ensure 1771 (when (and use-package-always-ensure
1772 (plist-member args* :load-path) 1772 (plist-member args* :load-path)
1773 (not (plist-member orig-args :ensure))) 1773 (not (plist-member orig-args :ensure)))
1774 (plist-put args* :ensure nil)) 1774 (plist-put args* :ensure nil))
1775 (unless (plist-member args* :init) 1775 (unless (plist-member args* :init)
1776 (plist-put args* :init nil)) 1776 (plist-put args* :init nil))
1777 (unless (plist-member args* :config) 1777 (unless (plist-member args* :config)
1778 (plist-put args* :config '(t))) 1778 (plist-put args* :config '(t)))
1779 args*) 1779 args*)
1780 (and use-package-always-defer 1780 (and use-package-always-defer
1781 (list :deferred t)))))) 1781 (list :deferred t))))))
1782 (when use-package-debug 1782 (when use-package-debug
1783 (display-buffer 1783 (display-buffer
1784 (save-current-buffer 1784 (save-current-buffer
@@ -1787,6 +1787,7 @@ this file. Usage:
1787 (emacs-lisp-mode) 1787 (emacs-lisp-mode)
1788 (insert (pp-to-string body)) 1788 (insert (pp-to-string body))
1789 (current-buffer))))) 1789 (current-buffer)))))
1790 (message "body = %s" body)
1790 body)))) 1791 body))))
1791 1792
1792 1793
diff --git a/test/lisp/use-package/use-package-tests.el b/test/lisp/use-package/use-package-tests.el
index 6710d48faa8..66a4af30b52 100644
--- a/test/lisp/use-package/use-package-tests.el
+++ b/test/lisp/use-package/use-package-tests.el
@@ -267,59 +267,59 @@
267(ert-deftest use-package-test/:if () 267(ert-deftest use-package-test/:if ()
268 (match-expansion 268 (match-expansion
269 (use-package foo :if t) 269 (use-package foo :if t)
270 `(if (symbol-value 't) 270 `(progn
271 (progn 271 (when (symbol-value 't)
272 (require 'foo nil 'nil)))) 272 (require 'foo nil 'nil))))
273 273
274 (match-expansion 274 (match-expansion
275 (use-package foo :if (and t t)) 275 (use-package foo :if (and t t))
276 `(if (and t t) 276 `(progn
277 (progn 277 (when (and t t)
278 (require 'foo nil 'nil)))) 278 (require 'foo nil 'nil))))
279 279
280 (match-expansion 280 (match-expansion
281 (use-package foo :if nil) 281 (use-package foo :if nil)
282 `(if nil 282 `(progn
283 (progn 283 (when nil
284 (require 'foo nil 'nil))))) 284 (require 'foo nil 'nil)))))
285 285
286(ert-deftest use-package-test/:when () 286(ert-deftest use-package-test/:when ()
287 (match-expansion 287 (match-expansion
288 (use-package foo :when t) 288 (use-package foo :when t)
289 `(if (symbol-value 't) 289 `(progn
290 (progn 290 (when (symbol-value 't)
291 (require 'foo nil 'nil)))) 291 (require 'foo nil 'nil))))
292 292
293 (match-expansion 293 (match-expansion
294 (use-package foo :when (and t t)) 294 (use-package foo :when (and t t))
295 `(if (and t t) 295 `(progn
296 (progn 296 (when (and t t)
297 (require 'foo nil 'nil)))) 297 (require 'foo nil 'nil))))
298 298
299 (match-expansion 299 (match-expansion
300 (use-package foo :when nil) 300 (use-package foo :when nil)
301 `(if nil 301 `(progn
302 (progn 302 (when nil
303 (require 'foo nil 'nil))))) 303 (require 'foo nil 'nil)))))
304 304
305(ert-deftest use-package-test/:when () 305(ert-deftest use-package-test/:unless ()
306 (match-expansion 306 (match-expansion
307 (use-package foo :unless t) 307 (use-package foo :unless t)
308 `(if (symbol-value 't) 308 `(progn
309 nil 309 (unless (symbol-value 't)
310 (require 'foo nil 'nil))) 310 (require 'foo nil 'nil))))
311 311
312 (match-expansion 312 (match-expansion
313 (use-package foo :unless (and t t)) 313 (use-package foo :unless (and t t))
314 `(if (and t t) 314 `(progn
315 nil 315 (unless (and t t)
316 (require 'foo nil 'nil))) 316 (require 'foo nil 'nil))))
317 317
318 (match-expansion 318 (match-expansion
319 (use-package foo :unless nil) 319 (use-package foo :unless nil)
320 `(if nil 320 `(progn
321 nil 321 (unless nil
322 (require 'foo nil 'nil)))) 322 (require 'foo nil 'nil)))))
323 323
324;; (ert-deftest use-package-test/:requires () 324;; (ert-deftest use-package-test/:requires ()
325;; (should (equal (macroexpand (use-package)) 325;; (should (equal (macroexpand (use-package))
@@ -446,7 +446,8 @@
446(ert-deftest use-package-test/:defines () 446(ert-deftest use-package-test/:defines ()
447 (match-expansion 447 (match-expansion
448 (use-package foo :defines bar) 448 (use-package foo :defines bar)
449 `(require 'foo nil 'nil)) 449 `(progn
450 (require 'foo nil 'nil)))
450 451
451 (let ((byte-compile-current-file t)) 452 (let ((byte-compile-current-file t))
452 (match-expansion 453 (match-expansion
@@ -463,7 +464,8 @@
463(ert-deftest use-package-test/:functions () 464(ert-deftest use-package-test/:functions ()
464 (match-expansion 465 (match-expansion
465 (use-package foo :functions bar) 466 (use-package foo :functions bar)
466 `(require 'foo nil 'nil)) 467 `(progn
468 (require 'foo nil 'nil)))
467 469
468 (let ((byte-compile-current-file t)) 470 (let ((byte-compile-current-file t))
469 (match-expansion 471 (match-expansion
@@ -479,13 +481,17 @@
479 481
480 (match-expansion 482 (match-expansion
481 (use-package foo :defer t :functions bar) 483 (use-package foo :defer t :functions bar)
482 `nil) 484 `(progn))
483 485
484 ;; jww (2017-12-01): This exposes a bug. 486 (let ((byte-compile-current-file t))
485 ;; (let ((byte-compile-current-file t)) 487 (match-expansion
486 ;; (match-expansion 488 (use-package foo :defer t :functions bar)
487 ;; (use-package foo :defer t :functions bar) 489 `(progn
488 ;; `'nil)) 490 (eval-and-compile
491 (declare-function bar "foo")
492 (eval-when-compile
493 (with-demoted-errors "Cannot load foo: %S" nil
494 (load "foo" nil t)))))))
489 495
490 (let ((byte-compile-current-file t)) 496 (let ((byte-compile-current-file t))
491 (match-expansion 497 (match-expansion
@@ -576,8 +582,9 @@
576(ert-deftest use-package-test/:after () 582(ert-deftest use-package-test/:after ()
577 (match-expansion 583 (match-expansion
578 (use-package foo :after bar) 584 (use-package foo :after bar)
579 `(eval-after-load 'bar 585 `(progn
580 '(require 'foo nil t)))) 586 (eval-after-load 'bar
587 '(require 'foo nil t)))))
581 588
582;; (ert-deftest use-package-test/:demand () 589;; (ert-deftest use-package-test/:demand ()
583;; (should (equal (macroexpand (use-package)) 590;; (should (equal (macroexpand (use-package))