Skip to content

Commit be3c570

Browse files
Fix tests and documentation for hook
1 parent 8bad61f commit be3c570

File tree

2 files changed

+23
-21
lines changed

2 files changed

+23
-21
lines changed

README.md

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -306,37 +306,37 @@ The `:hook` keyword allows adding functions onto package hooks. Thus,
306306
all of the following are equivalent:
307307

308308
``` elisp
309-
(use-package ace-jump-mode
309+
(use-package company
310310
:hook prog-mode)
311311
312-
(use-package ace-jump-mode
313-
:hook (prog-mode . ace-jump-mode))
312+
(use-package company
313+
:hook (prog-mode . company-mode))
314314
315-
(use-package ace-jump-mode
316-
:commands ace-jump-mode
315+
(use-package company
316+
:commands company-mode
317317
:init
318-
(add-hook 'prog-mode-hook #'ace-jump-mode))
318+
(add-hook 'prog-mode-hook #'company-mode))
319319
```
320320

321321
And likewise, when multiple hooks should be applied, the following are also
322322
equivalent:
323323

324324
``` elisp
325-
(use-package ace-jump-mode
325+
(use-package company
326326
:hook (prog-mode text-mode))
327327
328-
(use-package ace-jump-mode
329-
:hook ((prog-mode text-mode) . ace-jump-mode))
328+
(use-package company
329+
:hook ((prog-mode text-mode) . company-mode))
330330
331-
(use-package ace-jump-mode
332-
:hook ((prog-mode . ace-jump-mode)
333-
(text-mode . ace-jump-mode)))
331+
(use-package company
332+
:hook ((prog-mode . company-mode)
333+
(text-mode . company-mode)))
334334
335-
(use-package ace-jump-mode
336-
:commands ace-jump-mode
335+
(use-package company
336+
:commands company-mode
337337
:init
338-
(add-hook 'prog-mode-hook #'ace-jump-mode)
339-
(add-hook 'text-mode-hook #'ace-jump-mode))
338+
(add-hook 'prog-mode-hook #'company-mode)
339+
(add-hook 'text-mode-hook #'company-mode))
340340
```
341341

342342
When using `:hook` omit the "-hook" suffix if you specify the hook

use-package-tests.el

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -998,15 +998,17 @@
998998
'foopkg :hook args)))
999999
(should-error (norm nil))
10001000
(should (equal (norm '(bar))
1001+
'((bar . foopkg-mode))))
1002+
(should (equal (norm '((bar . foopkg)))
10011003
'((bar . foopkg))))
10021004
(should (equal (norm '((bar . baz)))
10031005
'((bar . baz))))
10041006
(should (equal (norm '(((bar baz) . quux)))
10051007
'(((bar baz) . quux))))
10061008
(should (equal (norm '(bar baz))
1007-
'(((bar baz) . foopkg))))
1009+
'(((bar baz) . foopkg-mode))))
10081010
(should (equal (norm '((bar baz) (quux bow)))
1009-
'(((bar baz) . foopkg) ((quux bow) . foopkg))))
1011+
'(((bar baz) . foopkg-mode) ((quux bow) . foopkg-mode))))
10101012
(should (equal (norm '((bar . baz) (quux . bow)))
10111013
'((bar . baz) (quux . bow))))
10121014
(should (equal (norm '(((bar1 bar2) . baz) ((quux1 quux2) . bow)))
@@ -1945,9 +1947,9 @@
19451947
(use-package nonexistent
19461948
:hook lisp-mode)
19471949
`(when (locate-library nonexistent)
1948-
(unless (fboundp 'nonexistent)
1949-
(autoload #'nonexistent "nonexistent" nil t))
1950-
(add-hook 'lisp-mode-hook #'nonexistent)))))
1950+
(unless (fboundp 'nonexistent-mode)
1951+
(autoload #'nonexistent-mode "nonexistent" nil t))
1952+
(add-hook 'lisp-mode-hook #'nonexistent-mode)))))
19511953

19521954
(ert-deftest bind-key/:prefix-map ()
19531955
(match-expansion

0 commit comments

Comments
 (0)