Unify hook modifications

Now i use `add-hook` only if not within a `use-package` block; otherwise, i use `:hook`.
This commit is contained in:
Gergely Polonkai 2018-11-21 13:39:14 +01:00
parent 8b560b69f4
commit 3b968986b2

View File

@ -1307,15 +1307,19 @@ For in-Emacs browsing needs.
** Which function am I in?
#+BEGIN_SRC emacs-lisp
(defun gpolonkai/activate-which-func-mode ()
(if (fboundp 'which-function-mode)
(which-function-mode)
(which-func-mode)))
#+END_SRC
#+BEGIN_SRC emacs-lisp
(use-package which-func
:config
(add-hook 'prog-mode-hook
(lambda ()
(if (fboundp 'which-function-mode)
(which-function-mode)
(which-func-mode))))
(setq which-func-unknown "∅"))
(setq which-func-unknown "∅")
:hook
(prog-mode . gpolonkai/activate-which-func-mode))
#+END_SRC
** Fortune cookies
@ -1443,7 +1447,8 @@ I dont usually like to see them, but there are occasions when they can be use
auto-package-update-delete-old-versions t)
;; Lets do this in after-init-hook, as use-package invocations may modify
;; the list of installed packages
(add-hook 'after-init-hook 'auto-package-update-maybe))
:hook
(after-init . auto-package-update-maybe))
#+END_SRC
** Nyanyanyanyanya
@ -1533,8 +1538,8 @@ Highlight point. Sometimes its not easy to see.
#+BEGIN_SRC emacs-lisp
(when (display-graphic-p)
(use-package eshell-fringe-status
:config
(add-hook 'eshell-mode-hook 'eshell-fringe-status-mode)))
:hook
(eshell-mode . eshell-fringe-status-mode)))
#+END_SRC
*** Extras for the EShell prompt
@ -1554,8 +1559,8 @@ Highlight point. Sometimes its not easy to see.
#+BEGIN_SRC emacs-lisp
(use-package form-feed
:config
(add-hook 'emacs-lisp-mode-hook 'form-feed-mode))
:hook
(emacs-lisp-mode . form-feed-mode))
#+END_SRC
** Highlight the current line
@ -1570,15 +1575,13 @@ Highlight point. Sometimes its not easy to see.
** GNU Globals
#+BEGIN_SRC emacs-lisp
(defun gpolonkai/cond-enable-ggtags-mode ()
(when (derived-mode-p 'c-mode 'c++-mode 'java-mode)
(ggtags-mode t)))
(use-package ggtags
:config
(add-hook 'c-mode-hook
(lambda ()
(ggtags-mode t)))
(add-hook 'c-mode-common-hook
(lambda ()
(when (derived-mode-p 'c-mode 'c++-mode 'java-mode)
(ggtags-mode t)))))
:hook
(c-mode-common . gpolonkai/cond-enable-ggtags-mode))
#+END_SRC
** Multiple cursors
@ -1586,19 +1589,21 @@ Highlight point. Sometimes its not easy to see.
Because one is never enough.
#+BEGIN_SRC emacs-lisp
(defun gpolonkai/no-blink-matching-paren ()
(setq blink-matching-paren nil))
(defun gpolonkai/blink-matching-paren ()
(setq blink-matching-paren t))
(use-package multiple-cursors
:init
(defvar gpolonkai/mc-prefix-map (make-sparse-keymap)
"Prefix keymap for multiple-cursors")
(define-prefix-command 'gpolonkai/mc-prefix-map)
(define-key global-map (kbd "C-c m") 'gpolonkai/mc-prefix-map)
:config
(add-hook 'multiple-cursors-mode-enabled-hook
(lambda ()
(setq blink-matching-paren nil)))
(add-hook 'multiple-cursors-mode-disabled-hook
(lambda ()
(setq blink-matching-paren t)))
:hook
(multiple-cursors-mode-enabled . gpolonkai/no-blink-matching-paren)
(multiple-cursors-mode-disabled . gpolonkai/blink-matching-paren)
:bind (:map gpolonkai/mc-prefix-map
("t" . mc/mark-all-like-this)
("m" . mc/mark-all-like-this-dwim)
@ -1650,13 +1655,10 @@ Because one is never enough.
magit-push-always-verify nil)
:bind
(:map ctl-x-map
("g" . magit-status)))
#+END_SRC
("g" . magit-status))
:hook
(git-commit-mode . turn-on-flyspell))
I also want FlySpell to be enabled during Git commit message editing.
#+BEGIN_SRC emacs-lisp
(add-hook 'git-commit-mode-hook 'turn-on-flyspell)
#+END_SRC
** Zone
@ -1704,10 +1706,9 @@ I also want FlySpell to be enabled during Git commit message editing.
:demand
:config
(show-smartparens-global-mode t)
(add-hook 'prog-mode-hook
'turn-on-smartparens-strict-mode)
(add-hook 'markdown-mode-hook
'turn-on-smartparens-strict-mode)
:hook
(prog-mode . turn-on-smartparens-strict-mode)
(markdown-mode . turn-on-smartparens-strict-mode)
:bind
(([f9] . smartparens-strict-mode)
("C-c s u" . sp-unwrap-sexp)
@ -1845,10 +1846,10 @@ To highlight colours based on their name or hex code.
#+BEGIN_SRC emacs-lisp
(use-package rainbow-mode
:config
(add-hook 'css-mode-hook 'rainbow-mode)
(add-hook 'scss-mode-hook 'rainbow-mode)
(add-hook 'sass-mode 'rainbow-mode))
:hook
(css-mode . rainbow-mode)
(scss-mode . rainbow-mode)
(sass-mode . rainbow-mode))
#+END_SRC
** Zygospore
@ -1952,11 +1953,9 @@ For all your spell-checking needs.
#+BEGIN_SRC emacs-lisp
(use-package flyspell
:config
(add-hook 'prog-mode-hook
'flyspell-prog-mode)
(add-hook 'text-mode-hook
'flyspell-mode))
:hook
(prog-mode . flyspell-prog-mode)
(text-mode . flyspell-mode))
#+END_SRC
** Delete all the whitespace
@ -2036,10 +2035,10 @@ Because even secretaries need a secretary today.
(use-package secretaria
:after
alert
:config
:hook
;; use this for getting a reminder every 30 minutes of those tasks
;; scheduled for today and which have no time of day defined.
(add-hook 'after-init-hook #'secretaria-unknown-time-always-remind-me))
(after-init . secretaria-unknown-time-always-remind-me))
#+END_SRC
** The Silver Searcher
@ -2264,8 +2263,8 @@ mode.
#+BEGIN_SRC emacs-lisp
(use-package electric-case
:config
(add-hook 'c-mode-hook 'electric-case-c-init))
:hook
(c-mode . electric-case-c-init))
#+END_SRC
** Electric operator
@ -2275,10 +2274,11 @@ Automatically add spaces around operators.
#+BEGIN_SRC emacs-lisp
(use-package electric-operator
:config
(add-hook 'c-mode-common-hook 'electric-operator-mode)
;; Apply electric-operator-mode to vala-mode, too
(apply #'electric-operator-add-rules-for-mode 'vala-mode
(electric-operator-get-rules-for-mode 'prog-mode)))
(electric-operator-get-rules-for-mode 'prog-mode))
:hook
(c-mode-common . electric-operator-mode))
#+END_SRC
** Yasnippets
@ -2288,7 +2288,8 @@ Automatically add spaces around operators.
:demand
:config
(yas-global-mode 1)
(add-hook 'post-command-hook 'sachachua/change-cursor-color-when-can-expand))
:hook
(post-command . sachachua/change-cursor-color-when-can-expand))
#+END_SRC
*** Extra snippets for Vala
@ -2309,9 +2310,8 @@ Automatically add spaces around operators.
#+BEGIN_SRC emacs-lisp
(use-package rainbow-delimiters
:config
(add-hook 'prog-mode-hook
#'rainbow-delimiters-mode))
:hook
(prog-mode . rainbow-delimiters-mode))
#+END_SRC
** REST Client
@ -2335,8 +2335,8 @@ A big help during refactoring.
#+BEGIN_SRC emacs-lisp
(use-package glasses
:delight " 👓"
:config
(add-hook 'prog-mode-hook 'glasses-mode))
:hook
(prog-mode . glasses-mode))
#+END_SRC
** GObject boilerplate generator
@ -2389,19 +2389,18 @@ Maybe add ∉ for ~not in~ later, if possible.
#+BEGIN_SRC emacs-lisp
(use-package auto-virtualenv
:config
(add-hook 'python-mode-hook 'auto-virtualenv-set-virtualenv)
(add-hook 'projectile-after-switch-project-hook
'auto-virtualenv-set-virtualenv))
:hook
(python-mode . auto-virtualenv-set-virtualenv)
(projectile-after-switch-project . auto-virtualenv-set-virtualenv))
#+END_SRC
** Anaconda mode
#+BEGIN_SRC emacs-lisp
(use-package anaconda-mode
:config
(add-hook 'python-mode-hook 'anaconda-mode)
(add-hook 'python-mode-hook 'anaconda-eldoc-mode))
:hook
(python-mode . anaconda-mode)
(python-mode . anaconda-eldoc-mode))
#+END_SRC
** PipEnv
@ -2410,7 +2409,8 @@ Because its great.
#+BEGIN_SRC emacs-lisp
(use-package pipenv
:hook (python-mode . pipenv-mode)
:hook
(python-mode . pipenv-mode)
:init
(setq pipenv-projectile-after-switch-function #'pipenv-projectile-after-switch-extended))
#+END_SRC
@ -2496,8 +2496,9 @@ Because thats still my favourite language.
(use-package emmet-mode
:config
(setq emmet-self-closing-tag-style "")
(add-hook 'web-mode 'emmet-mode)
(add-hook 'css-mode 'emmet-mode))
:hook
(web-mode . emmet-mode)
(css-mode . emmet-mode))
#+END_SRC
** Query HTML tags by CSS selectors
@ -2619,8 +2620,9 @@ This is a big one; I use a lot of customisation here.
'("g" "GT2 note" entry
(file+headline (lambda () (concat org-directory "gt2-notes.org")) "Captures")
"** %^{Title}\n :PROPERTIES:\n :on: %T\n :END:\n %i%?"))
(add-hook 'ediff-select-hook 'f-ediff-org-unfold-tree-element)
(add-hook 'ediff-unselect-hook 'f-ediff-org-fold-tree)
:hook
(ediff-select . f-ediff-org-unfold-tree-element)
(ediff-unselect . f-ediff-org-fold-tree)
:bind
(:map gpolonkai/pers-map
("a" . gpolonkai/org-agenda-list)
@ -2790,8 +2792,7 @@ See previous versions of the current file.
(--set-emoji-font nil)
:config
(add-to-list 'company-backends 'company-emoji)
(add-hook 'after-make-frame-functions
'--set-emoji-font))
(add-hook 'after-make-frame-functions '--set-emoji-font))
#+END_SRC
** Anaconda backend for Company
@ -2845,15 +2846,16 @@ See previous versions of the current file.
** GNU Globals with Helm
#+BEGIN_SRC emacs-lisp
(defun gpolonkai/enable-helm-gtags-mode ()
(helm-gtags-mode t))
(use-package helm-gtags
:init
(setq-default helm-gtags-auto-update t
helm-gtags-ignore-case t
helm-gtags-path-style 'relative)
:config
(add-hook 'c-mode-hook
(lambda ()
(helm-gtags-mode t)))
:hook
(c-mode . gpolonkai/enable-helm-gtags-mode)
:bind
(:map helm-gtags-mode-map
("M-t" . helm-gtags-find-tag)