diff options
| author | John Wiegley | 2019-07-16 11:29:12 -0700 |
|---|---|---|
| committer | GitHub | 2019-07-16 11:29:12 -0700 |
| commit | 165f2dd968b8de1e740710ce3e0a47376c8dbc5b (patch) | |
| tree | 6b4fe6e237ab91cf72fc67f27cd6c3c78a8fb0b6 | |
| parent | 97f0287e1968d3ccd802fe52a4dbca707babd7fa (diff) | |
| parent | 20415fb9be8c7f0940c78aa163450109836344ec (diff) | |
| download | emacs-165f2dd968b8de1e740710ce3e0a47376c8dbc5b.tar.gz emacs-165f2dd968b8de1e740710ce3e0a47376c8dbc5b.zip | |
Use `require', not `load', when byte-compiling ()
Use `require', not `load', when byte-compiling
GitHub-reference: https://github.com/jwiegley/use-package/issues/783
| -rw-r--r-- | lisp/use-package/use-package-core.el | 3 | ||||
| -rw-r--r-- | test/lisp/use-package/use-package-tests.el | 66 |
2 files changed, 46 insertions, 23 deletions
diff --git a/lisp/use-package/use-package-core.el b/lisp/use-package/use-package-core.el index 7b4d26ba2a3..db5e20f7ddf 100644 --- a/lisp/use-package/use-package-core.el +++ b/lisp/use-package/use-package-core.el | |||
| @@ -651,7 +651,8 @@ extending any keys already present." | |||
| 651 | ,(when (eq use-package-verbose 'debug) | 651 | ,(when (eq use-package-verbose 'debug) |
| 652 | `(message ,(format "Compiling package %s" name-string))) | 652 | `(message ,(format "Compiling package %s" name-string))) |
| 653 | ,(unless (plist-get args :no-require) | 653 | ,(unless (plist-get args :no-require) |
| 654 | `(load ,name-string nil t))))))))) | 654 | `(unless (featurep ',name-symbol) |
| 655 | (load ,name-string nil t)))))))))) | ||
| 655 | 656 | ||
| 656 | ;; Certain keywords imply :defer, if :demand was not specified. | 657 | ;; Certain keywords imply :defer, if :demand was not specified. |
| 657 | (when (and (not (plist-member args :demand)) | 658 | (when (and (not (plist-member args :demand)) |
diff --git a/test/lisp/use-package/use-package-tests.el b/test/lisp/use-package/use-package-tests.el index 3e3e5a72a13..04a653e30e8 100644 --- a/test/lisp/use-package/use-package-tests.el +++ b/test/lisp/use-package/use-package-tests.el | |||
| @@ -162,7 +162,8 @@ | |||
| 162 | (eval-when-compile | 162 | (eval-when-compile |
| 163 | (with-demoted-errors | 163 | (with-demoted-errors |
| 164 | "Cannot load foo: %S" nil | 164 | "Cannot load foo: %S" nil |
| 165 | (load "foo" nil t))) | 165 | (unless (featurep 'foo) |
| 166 | (load "foo" nil t)))) | ||
| 166 | (t)) | 167 | (t)) |
| 167 | (require 'foo nil nil))))) | 168 | (require 'foo nil nil))))) |
| 168 | 169 | ||
| @@ -182,7 +183,8 @@ | |||
| 182 | (eval-when-compile | 183 | (eval-when-compile |
| 183 | (with-demoted-errors | 184 | (with-demoted-errors |
| 184 | "Cannot load foo: %S" nil | 185 | "Cannot load foo: %S" nil |
| 185 | (load "foo" nil t))) | 186 | (unless (featurep 'foo) |
| 187 | (load "foo" nil t)))) | ||
| 186 | (preface)) | 188 | (preface)) |
| 187 | (init) | 189 | (init) |
| 188 | (require 'foo nil nil) | 190 | (require 'foo nil nil) |
| @@ -206,7 +208,8 @@ | |||
| 206 | (eval-when-compile | 208 | (eval-when-compile |
| 207 | (with-demoted-errors | 209 | (with-demoted-errors |
| 208 | "Cannot load foo: %S" nil | 210 | "Cannot load foo: %S" nil |
| 209 | (load "foo" nil t))) | 211 | (unless (featurep 'foo) |
| 212 | (load "foo" nil t)))) | ||
| 210 | (preface)) | 213 | (preface)) |
| 211 | (init) | 214 | (init) |
| 212 | (eval-after-load 'foo | 215 | (eval-after-load 'foo |
| @@ -453,7 +456,8 @@ | |||
| 453 | (eval-when-compile | 456 | (eval-when-compile |
| 454 | (with-demoted-errors | 457 | (with-demoted-errors |
| 455 | "Cannot load foo: %S" nil | 458 | "Cannot load foo: %S" nil |
| 456 | (load "foo" nil t)))) | 459 | (unless (featurep 'foo) |
| 460 | (load "foo" nil t))))) | ||
| 457 | (require 'foo nil nil))))) | 461 | (require 'foo nil nil))))) |
| 458 | 462 | ||
| 459 | (ert-deftest use-package-test/:requires-3 () | 463 | (ert-deftest use-package-test/:requires-3 () |
| @@ -470,7 +474,8 @@ | |||
| 470 | (eval-and-compile | 474 | (eval-and-compile |
| 471 | (eval-when-compile | 475 | (eval-when-compile |
| 472 | (with-demoted-errors "Cannot load foo: %S" nil | 476 | (with-demoted-errors "Cannot load foo: %S" nil |
| 473 | (load "foo" nil t)))) | 477 | (unless (featurep 'foo) |
| 478 | (load "foo" nil t))))) | ||
| 474 | (require 'foo nil nil))))) | 479 | (require 'foo nil nil))))) |
| 475 | 480 | ||
| 476 | (ert-deftest use-package-test/:load-path-1 () | 481 | (ert-deftest use-package-test/:load-path-1 () |
| @@ -499,7 +504,8 @@ | |||
| 499 | (eval-and-compile | 504 | (eval-and-compile |
| 500 | (eval-when-compile | 505 | (eval-when-compile |
| 501 | (with-demoted-errors "Cannot load foo: %S" nil | 506 | (with-demoted-errors "Cannot load foo: %S" nil |
| 502 | (load "foo" nil t)))) | 507 | (unless (featurep 'foo) |
| 508 | (load "foo" nil t))))) | ||
| 503 | (require 'foo nil nil))))) | 509 | (require 'foo nil nil))))) |
| 504 | 510 | ||
| 505 | (ert-deftest use-package-test/:load-path-3 () | 511 | (ert-deftest use-package-test/:load-path-3 () |
| @@ -816,7 +822,8 @@ | |||
| 816 | (eval-and-compile | 822 | (eval-and-compile |
| 817 | (eval-when-compile | 823 | (eval-when-compile |
| 818 | (with-demoted-errors "Cannot load foo: %S" nil | 824 | (with-demoted-errors "Cannot load foo: %S" nil |
| 819 | (load "foo" nil t)))) | 825 | (unless (featurep 'foo) |
| 826 | (load "foo" nil t))))) | ||
| 820 | (unless (fboundp 'bar) | 827 | (unless (fboundp 'bar) |
| 821 | (autoload #'bar "foo" nil t)) | 828 | (autoload #'bar "foo" nil t)) |
| 822 | (eval-when-compile | 829 | (eval-when-compile |
| @@ -871,7 +878,8 @@ | |||
| 871 | (eval-and-compile | 878 | (eval-and-compile |
| 872 | (eval-when-compile | 879 | (eval-when-compile |
| 873 | (with-demoted-errors "Cannot load gnus-harvest: %S" nil | 880 | (with-demoted-errors "Cannot load gnus-harvest: %S" nil |
| 874 | (load "gnus-harvest" nil t)))) | 881 | (unless (featurep 'gnus-harvest) |
| 882 | (load "gnus-harvest" nil t))))) | ||
| 875 | (eval-when-compile | 883 | (eval-when-compile |
| 876 | (declare-function gnus-harvest-install "gnus-harvest")) | 884 | (declare-function gnus-harvest-install "gnus-harvest")) |
| 877 | (require 'gnus-harvest nil nil) | 885 | (require 'gnus-harvest nil nil) |
| @@ -896,7 +904,8 @@ | |||
| 896 | (eval-when-compile | 904 | (eval-when-compile |
| 897 | (with-demoted-errors | 905 | (with-demoted-errors |
| 898 | "Cannot load foo: %S" nil | 906 | "Cannot load foo: %S" nil |
| 899 | (load "foo" nil t)))) | 907 | (unless (featurep 'foo) |
| 908 | (load "foo" nil t))))) | ||
| 900 | (require 'foo nil nil))))) | 909 | (require 'foo nil nil))))) |
| 901 | 910 | ||
| 902 | (ert-deftest use-package-test/:functions-1 () | 911 | (ert-deftest use-package-test/:functions-1 () |
| @@ -914,7 +923,8 @@ | |||
| 914 | (eval-when-compile | 923 | (eval-when-compile |
| 915 | (with-demoted-errors | 924 | (with-demoted-errors |
| 916 | "Cannot load foo: %S" nil | 925 | "Cannot load foo: %S" nil |
| 917 | (load "foo" nil t)))) | 926 | (unless (featurep 'foo) |
| 927 | (load "foo" nil t))))) | ||
| 918 | (require 'foo nil nil))))) | 928 | (require 'foo nil nil))))) |
| 919 | 929 | ||
| 920 | (ert-deftest use-package-test/:functions-3 () | 930 | (ert-deftest use-package-test/:functions-3 () |
| @@ -930,7 +940,8 @@ | |||
| 930 | (declare-function bar "foo") | 940 | (declare-function bar "foo") |
| 931 | (eval-when-compile | 941 | (eval-when-compile |
| 932 | (with-demoted-errors "Cannot load foo: %S" nil | 942 | (with-demoted-errors "Cannot load foo: %S" nil |
| 933 | (load "foo" nil t))))))) | 943 | (unless (featurep 'foo) |
| 944 | (load "foo" nil t)))))))) | ||
| 934 | 945 | ||
| 935 | (ert-deftest use-package-test/:functions-5 () | 946 | (ert-deftest use-package-test/:functions-5 () |
| 936 | (let ((byte-compile-current-file t)) | 947 | (let ((byte-compile-current-file t)) |
| @@ -942,7 +953,8 @@ | |||
| 942 | (eval-when-compile | 953 | (eval-when-compile |
| 943 | (with-demoted-errors | 954 | (with-demoted-errors |
| 944 | "Cannot load foo: %S" nil | 955 | "Cannot load foo: %S" nil |
| 945 | (load "foo" nil t)))) | 956 | (unless (featurep 'foo) |
| 957 | (load "foo" nil t))))) | ||
| 946 | (eval-after-load 'foo | 958 | (eval-after-load 'foo |
| 947 | '(progn | 959 | '(progn |
| 948 | (config) | 960 | (config) |
| @@ -961,7 +973,8 @@ | |||
| 961 | (eval-and-compile | 973 | (eval-and-compile |
| 962 | (eval-when-compile | 974 | (eval-when-compile |
| 963 | (with-demoted-errors "Cannot load foo: %S" nil | 975 | (with-demoted-errors "Cannot load foo: %S" nil |
| 964 | (load "foo" nil t)))) | 976 | (unless (featurep 'foo) |
| 977 | (load "foo" nil t))))) | ||
| 965 | (require 'foo nil nil))))) | 978 | (require 'foo nil nil))))) |
| 966 | 979 | ||
| 967 | (ert-deftest use-package-test/:defer-3 () | 980 | (ert-deftest use-package-test/:defer-3 () |
| @@ -976,7 +989,8 @@ | |||
| 976 | `(eval-and-compile | 989 | `(eval-and-compile |
| 977 | (eval-when-compile | 990 | (eval-when-compile |
| 978 | (with-demoted-errors "Cannot load foo: %S" nil | 991 | (with-demoted-errors "Cannot load foo: %S" nil |
| 979 | (load "foo" nil t))))))) | 992 | (unless (featurep 'foo) |
| 993 | (load "foo" nil t)))))))) | ||
| 980 | 994 | ||
| 981 | (ert-deftest use-package-test-normalize/:hook () | 995 | (ert-deftest use-package-test-normalize/:hook () |
| 982 | (flet ((norm (&rest args) | 996 | (flet ((norm (&rest args) |
| @@ -1009,7 +1023,8 @@ | |||
| 1009 | (eval-when-compile | 1023 | (eval-when-compile |
| 1010 | (with-demoted-errors | 1024 | (with-demoted-errors |
| 1011 | "Cannot load foo: %S" nil | 1025 | "Cannot load foo: %S" nil |
| 1012 | (load "foo" nil t)))) | 1026 | (unless (featurep 'foo) |
| 1027 | (load "foo" nil t))))) | ||
| 1013 | (unless | 1028 | (unless |
| 1014 | (fboundp 'key) | 1029 | (fboundp 'key) |
| 1015 | (autoload #'key "foo" nil t)) | 1030 | (autoload #'key "foo" nil t)) |
| @@ -1143,7 +1158,8 @@ | |||
| 1143 | (eval-and-compile | 1158 | (eval-and-compile |
| 1144 | (eval-when-compile | 1159 | (eval-when-compile |
| 1145 | (with-demoted-errors "Cannot load foo: %S" nil | 1160 | (with-demoted-errors "Cannot load foo: %S" nil |
| 1146 | (load "foo" nil t)))) | 1161 | (unless (featurep 'foo) |
| 1162 | (load "foo" nil t))))) | ||
| 1147 | (init) | 1163 | (init) |
| 1148 | (require 'foo nil nil))))) | 1164 | (require 'foo nil nil))))) |
| 1149 | 1165 | ||
| @@ -1190,7 +1206,8 @@ | |||
| 1190 | (eval-and-compile | 1206 | (eval-and-compile |
| 1191 | (eval-when-compile | 1207 | (eval-when-compile |
| 1192 | (with-demoted-errors "Cannot load foo: %S" nil | 1208 | (with-demoted-errors "Cannot load foo: %S" nil |
| 1193 | (load "foo" nil t)))) | 1209 | (unless (featurep 'foo) |
| 1210 | (load "foo" nil t))))) | ||
| 1194 | (eval-after-load 'bar | 1211 | (eval-after-load 'bar |
| 1195 | '(require 'foo nil nil)))))) | 1212 | '(require 'foo nil nil)))))) |
| 1196 | 1213 | ||
| @@ -1333,7 +1350,8 @@ | |||
| 1333 | (eval-and-compile | 1350 | (eval-and-compile |
| 1334 | (eval-when-compile | 1351 | (eval-when-compile |
| 1335 | (with-demoted-errors "Cannot load foo: %S" nil | 1352 | (with-demoted-errors "Cannot load foo: %S" nil |
| 1336 | (load "foo" nil t)))) | 1353 | (unless (featurep 'foo) |
| 1354 | (load "foo" nil t))))) | ||
| 1337 | (require 'foo nil nil))))) | 1355 | (require 'foo nil nil))))) |
| 1338 | 1356 | ||
| 1339 | (ert-deftest use-package-test/:demand-3 () | 1357 | (ert-deftest use-package-test/:demand-3 () |
| @@ -1352,7 +1370,8 @@ | |||
| 1352 | (eval-and-compile | 1370 | (eval-and-compile |
| 1353 | (eval-when-compile | 1371 | (eval-when-compile |
| 1354 | (with-demoted-errors "Cannot load foo: %S" nil | 1372 | (with-demoted-errors "Cannot load foo: %S" nil |
| 1355 | (load "foo" nil t)))) | 1373 | (unless (featurep 'foo) |
| 1374 | (load "foo" nil t))))) | ||
| 1356 | (require 'foo nil nil) | 1375 | (require 'foo nil nil) |
| 1357 | (config) | 1376 | (config) |
| 1358 | t)))) | 1377 | t)))) |
| @@ -1372,7 +1391,8 @@ | |||
| 1372 | (eval-and-compile | 1391 | (eval-and-compile |
| 1373 | (eval-when-compile | 1392 | (eval-when-compile |
| 1374 | (with-demoted-errors "Cannot load foo: %S" nil | 1393 | (with-demoted-errors "Cannot load foo: %S" nil |
| 1375 | (load "foo" nil t)))) | 1394 | (unless (featurep 'foo) |
| 1395 | (load "foo" nil t))))) | ||
| 1376 | (eval-after-load 'bar | 1396 | (eval-after-load 'bar |
| 1377 | '(require 'foo nil nil)))))) | 1397 | '(require 'foo nil nil)))))) |
| 1378 | 1398 | ||
| @@ -1425,7 +1445,8 @@ | |||
| 1425 | (eval-and-compile | 1445 | (eval-and-compile |
| 1426 | (eval-when-compile | 1446 | (eval-when-compile |
| 1427 | (with-demoted-errors "Cannot load foo: %S" nil | 1447 | (with-demoted-errors "Cannot load foo: %S" nil |
| 1428 | (load "foo" nil t)))) | 1448 | (unless (featurep 'foo) |
| 1449 | (load "foo" nil t))))) | ||
| 1429 | (require 'foo nil nil) | 1450 | (require 'foo nil nil) |
| 1430 | (config) | 1451 | (config) |
| 1431 | t)))) | 1452 | t)))) |
| @@ -1446,7 +1467,8 @@ | |||
| 1446 | (eval-and-compile | 1467 | (eval-and-compile |
| 1447 | (eval-when-compile | 1468 | (eval-when-compile |
| 1448 | (with-demoted-errors "Cannot load foo: %S" nil | 1469 | (with-demoted-errors "Cannot load foo: %S" nil |
| 1449 | (load "foo" nil t)))) | 1470 | (unless (featurep 'foo) |
| 1471 | (load "foo" nil t))))) | ||
| 1450 | (eval-after-load 'foo | 1472 | (eval-after-load 'foo |
| 1451 | '(progn | 1473 | '(progn |
| 1452 | (config) | 1474 | (config) |