diff options
| author | John Wiegley | 2017-12-07 13:14:32 -0800 |
|---|---|---|
| committer | John Wiegley | 2017-12-07 13:14:32 -0800 |
| commit | 8fefa49d39dde99dfd13ff9551723ec387a3bfba (patch) | |
| tree | dbe4b1a57074f732c64c316652d9505c01612be8 /test/lisp | |
| parent | 80e8a599b4392bbb45a6263c8e750db267b8e4e9 (diff) | |
| download | emacs-8fefa49d39dde99dfd13ff9551723ec387a3bfba.tar.gz emacs-8fefa49d39dde99dfd13ff9551723ec387a3bfba.zip | |
Changes to the way auto-deferral is indicated
This change adds a new extension hook `use-package-autoloads/<KEYWORD>` for
specifying exactly which autoloads a keyword should imply. This is the proper
way to indicate autoloads, rather than adding to the `:commands` entry as was
done before.
Further, autoloading now must occur in order to cause implied deferred
loading; if :bind is used with only lambda forms, for example, this will not
cause deferred loading without `:defer t`.
Diffstat (limited to 'test/lisp')
| -rw-r--r-- | test/lisp/use-package/use-package-tests.el | 79 |
1 files changed, 55 insertions, 24 deletions
diff --git a/test/lisp/use-package/use-package-tests.el b/test/lisp/use-package/use-package-tests.el index ffff7ced326..08ac5293a99 100644 --- a/test/lisp/use-package/use-package-tests.el +++ b/test/lisp/use-package/use-package-tests.el | |||
| @@ -1001,30 +1001,30 @@ | |||
| 1001 | 1001 | ||
| 1002 | (ert-deftest use-package-test/:hook-1 () | 1002 | (ert-deftest use-package-test/:hook-1 () |
| 1003 | (let ((byte-compile-current-file t)) | 1003 | (let ((byte-compile-current-file t)) |
| 1004 | (should | 1004 | (match-expansion |
| 1005 | (equal | 1005 | (use-package foo |
| 1006 | (expand-minimally | 1006 | :bind (("C-a" . key)) |
| 1007 | (use-package foo | 1007 | :hook (hook . fun)) |
| 1008 | :bind (("C-a" . key)) | 1008 | `(progn |
| 1009 | :hook (hook . fun))) | 1009 | (eval-and-compile |
| 1010 | '(progn | 1010 | (eval-when-compile |
| 1011 | (eval-and-compile | 1011 | (with-demoted-errors |
| 1012 | (eval-when-compile | 1012 | "Cannot load foo: %S" nil |
| 1013 | (with-demoted-errors | 1013 | (load "foo" nil t)))) |
| 1014 | "Cannot load foo: %S" nil | 1014 | (unless |
| 1015 | (load "foo" nil t)))) | 1015 | (fboundp 'key) |
| 1016 | (unless (fboundp 'fun) | 1016 | (autoload #'key "foo" nil t)) |
| 1017 | (autoload #'fun "foo" nil t)) | 1017 | (eval-when-compile |
| 1018 | (eval-when-compile | 1018 | (declare-function key "foo")) |
| 1019 | (declare-function fun "foo")) | 1019 | (unless |
| 1020 | (unless (fboundp 'key) | 1020 | (fboundp 'fun) |
| 1021 | (autoload #'key "foo" nil t)) | 1021 | (autoload #'fun "foo" nil t)) |
| 1022 | (eval-when-compile | 1022 | (eval-when-compile |
| 1023 | (declare-function key "foo")) | 1023 | (declare-function fun "foo")) |
| 1024 | (ignore | 1024 | (ignore |
| 1025 | (add-hook 'hook-hook #'fun)) | 1025 | (add-hook 'hook-hook #'fun)) |
| 1026 | (ignore | 1026 | (ignore |
| 1027 | (bind-keys :package foo ("C-a" . key)))))))) | 1027 | (bind-keys :package foo ("C-a" . key))))))) |
| 1028 | 1028 | ||
| 1029 | (ert-deftest use-package-test/:hook-2 () | 1029 | (ert-deftest use-package-test/:hook-2 () |
| 1030 | (match-expansion | 1030 | (match-expansion |
| @@ -1079,6 +1079,37 @@ | |||
| 1079 | #'(lambda nil | 1079 | #'(lambda nil |
| 1080 | (bind-key "" erefactor-map emacs-lisp-mode-map))))))))) | 1080 | (bind-key "" erefactor-map emacs-lisp-mode-map))))))))) |
| 1081 | 1081 | ||
| 1082 | (ert-deftest use-package-test/:hook-6 () | ||
| 1083 | (match-expansion | ||
| 1084 | (use-package erefactor | ||
| 1085 | :load-path "foo" | ||
| 1086 | :after elisp-mode | ||
| 1087 | :hook (emacs-lisp-mode . function)) | ||
| 1088 | `(progn | ||
| 1089 | (eval-and-compile | ||
| 1090 | (add-to-list 'load-path "/Users/johnw/.emacs.d/foo")) | ||
| 1091 | (eval-after-load 'elisp-mode | ||
| 1092 | '(progn | ||
| 1093 | (unless (fboundp 'function) | ||
| 1094 | (autoload #'function "erefactor" nil t)) | ||
| 1095 | (ignore | ||
| 1096 | (add-hook 'emacs-lisp-mode-hook #'function))))))) | ||
| 1097 | |||
| 1098 | (ert-deftest use-package-test/:hook-7 () | ||
| 1099 | (match-expansion | ||
| 1100 | (use-package erefactor | ||
| 1101 | :load-path "foo" | ||
| 1102 | :after elisp-mode | ||
| 1103 | :hook (emacs-lisp-mode . (lambda () (function)))) | ||
| 1104 | `(progn | ||
| 1105 | (eval-and-compile | ||
| 1106 | (add-to-list 'load-path "/Users/johnw/.emacs.d/foo")) | ||
| 1107 | (eval-after-load 'elisp-mode | ||
| 1108 | '(progn | ||
| 1109 | (require 'erefactor nil nil) | ||
| 1110 | (ignore | ||
| 1111 | (add-hook 'emacs-lisp-mode-hook #'(lambda nil (function))))))))) | ||
| 1112 | |||
| 1082 | (ert-deftest use-package-test-normalize/:custom () | 1113 | (ert-deftest use-package-test-normalize/:custom () |
| 1083 | (flet ((norm (&rest args) | 1114 | (flet ((norm (&rest args) |
| 1084 | (apply #'use-package-normalize/:custom | 1115 | (apply #'use-package-normalize/:custom |