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