Skip to content

Commit 9407f5f

Browse files
authored
Merge pull request jwiegley#743 from CeleritasCelery/master
2 parents 4db51ba + be3c570 commit 9407f5f

File tree

3 files changed

+27
-22
lines changed

3 files changed

+27
-22
lines changed

README.md

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

389389
``` elisp
390-
(use-package ace-jump-mode
390+
(use-package company
391391
:hook prog-mode)
392392
393-
(use-package ace-jump-mode
394-
:hook (prog-mode . ace-jump-mode))
393+
(use-package company
394+
:hook (prog-mode . company-mode))
395395
396-
(use-package ace-jump-mode
397-
:commands ace-jump-mode
396+
(use-package company
397+
:commands company-mode
398398
:init
399-
(add-hook 'prog-mode-hook #'ace-jump-mode))
399+
(add-hook 'prog-mode-hook #'company-mode))
400400
```
401401

402402
And likewise, when multiple hooks should be applied, the following are also
403403
equivalent:
404404

405405
``` elisp
406-
(use-package ace-jump-mode
406+
(use-package company
407407
:hook (prog-mode text-mode))
408408
409-
(use-package ace-jump-mode
410-
:hook ((prog-mode text-mode) . ace-jump-mode))
409+
(use-package company
410+
:hook ((prog-mode text-mode) . company-mode))
411411
412-
(use-package ace-jump-mode
413-
:hook ((prog-mode . ace-jump-mode)
414-
(text-mode . ace-jump-mode)))
412+
(use-package company
413+
:hook ((prog-mode . company-mode)
414+
(text-mode . company-mode)))
415415
416-
(use-package ace-jump-mode
417-
:commands ace-jump-mode
416+
(use-package company
417+
:commands company-mode
418418
:init
419-
(add-hook 'prog-mode-hook #'ace-jump-mode)
420-
(add-hook 'text-mode-hook #'ace-jump-mode))
419+
(add-hook 'prog-mode-hook #'company-mode)
420+
(add-hook 'text-mode-hook #'company-mode))
421421
```
422422

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

use-package-core.el

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1295,7 +1295,10 @@ meaning:
12951295
(setq every nil)))
12961296
every))))
12971297
#'use-package-recognize-function
1298-
name label arg))))
1298+
(if (string-suffix-p "-mode" (symbol-name name))
1299+
name
1300+
(intern (concat (symbol-name name) "-mode")))
1301+
label arg))))
12991302

13001303
(defalias 'use-package-autoloads/:hook 'use-package-autoloads-mode)
13011304

use-package-tests.el

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -984,15 +984,17 @@
984984
'foopkg :hook args)))
985985
(should-error (norm nil))
986986
(should (equal (norm '(bar))
987+
'((bar . foopkg-mode))))
988+
(should (equal (norm '((bar . foopkg)))
987989
'((bar . foopkg))))
988990
(should (equal (norm '((bar . baz)))
989991
'((bar . baz))))
990992
(should (equal (norm '(((bar baz) . quux)))
991993
'(((bar baz) . quux))))
992994
(should (equal (norm '(bar baz))
993-
'(((bar baz) . foopkg))))
995+
'(((bar baz) . foopkg-mode))))
994996
(should (equal (norm '((bar baz) (quux bow)))
995-
'(((bar baz) . foopkg) ((quux bow) . foopkg))))
997+
'(((bar baz) . foopkg-mode) ((quux bow) . foopkg-mode))))
996998
(should (equal (norm '((bar . baz) (quux . bow)))
997999
'((bar . baz) (quux . bow))))
9981000
(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)