💥 revise hook/var fns naming convention (2/2)

This is second of three big naming convention changes. In this commit,
we change the naming conventions for hook functions and variable
functions:

1. Replace the bar | to indicate a hook function with a -h suffix, e.g.

     doom|init-ui -> doom-init-ui-h
     doom|run-local-var-hooks -> doom-run-local-var-hooks-h

2. And add a -fn suffix for functions meant to be set on variables,
   e.g.

     (setq magit-display-buffer-function #'+magit-display-buffer-fn)

See ccf327f8 for the reasoning behind these changes.
This commit is contained in:
Henrik Lissner 2019-07-18 15:27:20 +02:00
parent 51d3b1b424
commit 149b2617b0
No known key found for this signature in database
GPG key ID: 5F6C0EA160557395
58 changed files with 521 additions and 517 deletions

View file

@ -192,7 +192,7 @@ more information on modifiers."
(funcall orig-fn char)))
;;;###autoload
(defun +evil*fix-dabbrev-in-minibuffer ()
(defun +evil--fix-dabbrev-in-minibuffer-h ()
"Make `try-expand-dabbrev' from `hippie-expand' work in minibuffer. See
`he-dabbrev-beg', so we need to redefine syntax for '/'."
(set-syntax-table (let* ((table (make-syntax-table)))

View file

@ -36,9 +36,9 @@ directives. By default, this only recognizes C directives.")
;; more vim-like behavior
evil-symbol-word-search t
;; cursor appearance
evil-default-cursor '+evil-default-cursor
evil-default-cursor '+evil-default-cursor-fn
evil-normal-state-cursor 'box
evil-emacs-state-cursor '(box +evil-emacs-cursor)
evil-emacs-state-cursor '(box +evil-emacs-cursor-fn)
evil-insert-state-cursor 'bar
evil-visual-state-cursor 'hollow
;; must be set before evil/evil-collection is loaded
@ -53,11 +53,11 @@ directives. By default, this only recognizes C directives.")
(advice-add #'help-with-tutorial :after (lambda (&rest _) (evil-emacs-state +1)))
;; Done in a hook to ensure the popup rules load as late as possible
(defun +evil|init-popup-rules ()
(set-popup-rules!
'(("^\\*evil-registers" :size 0.3)
("^\\*Command Line" :size 8))))
(add-hook 'doom-init-modules-hook #'+evil|init-popup-rules)
(add-hook 'doom-init-modules-hook
(defun +evil--init-popup-rules-h ()
(set-popup-rules!
'(("^\\*evil-registers" :size 0.3)
("^\\*Command Line" :size 8)))))
;; Change the cursor color in emacs state. We do it this roundabout way
;; instead of changing `evil-default-cursor' (or `evil-emacs-state-cursor') so
@ -65,19 +65,17 @@ directives. By default, this only recognizes C directives.")
(defvar +evil--default-cursor-color "#ffffff")
(defvar +evil--emacs-cursor-color "#ff9999")
(defun +evil|update-cursor-color ()
(setq +evil--default-cursor-color (face-background 'cursor)
+evil--emacs-cursor-color (face-foreground 'warning)))
(add-hook 'doom-load-theme-hook #'+evil|update-cursor-color)
(add-hook 'doom-load-theme-hook
(defun +evil-update-cursor-color-h ()
(setq +evil--default-cursor-color (face-background 'cursor)
+evil--emacs-cursor-color (face-foreground 'warning))))
(defun +evil-default-cursor ()
(defun +evil-default-cursor-fn ()
(evil-set-cursor-color +evil--default-cursor-color))
(defun +evil-emacs-cursor ()
(defun +evil-emacs-cursor-fn ()
(evil-set-cursor-color +evil--emacs-cursor-color))
(defun +evil|update-shift-width ()
(setq evil-shift-width tab-width))
(add-hook 'after-change-major-mode-hook #'+evil|update-shift-width)
(setq-hook! 'after-change-major-mode-hook evil-shift-width tab-width)
;; --- keybind fixes ----------------------
@ -86,26 +84,26 @@ directives. By default, this only recognizes C directives.")
;; `evil-delete' in wgrep buffers.
(define-key wgrep-mode-map [remap evil-delete] #'+evil-delete))
(defun +evil|disable-highlights ()
"Disable ex search buffer highlights."
(when (evil-ex-hl-active-p 'evil-ex-search)
(evil-ex-nohighlight)
t))
(add-hook 'doom-escape-hook #'+evil|disable-highlights)
(add-hook 'doom-escape-hook
(defun +evil-disable-ex-highlights-h ()
"Disable ex search buffer highlights."
(when (evil-ex-hl-active-p 'evil-ex-search)
(evil-ex-nohighlight)
t)))
;; --- evil hacks -------------------------
(defun +evil|display-vimlike-save-message ()
"Shorter, vim-esque save messages."
(message "\"%s\" %dL, %dC written"
(if buffer-file-name
(file-relative-name (file-truename buffer-file-name) (doom-project-root))
(buffer-name))
(count-lines (point-min) (point-max))
(buffer-size)))
(unless noninteractive
(setq save-silently t)
(add-hook 'after-save-hook #'+evil|display-vimlike-save-message))
(add-hook 'after-save-hook
(defun +evil-display-vimlike-save-message-h ()
"Shorter, vim-esque save messages."
(message "\"%s\" %dL, %dC written"
(if buffer-file-name
(file-relative-name (file-truename buffer-file-name) (doom-project-root))
(buffer-name))
(count-lines (point-min) (point-max))
(buffer-size)))))
;; Make ESC (from normal mode) the universal escaper. See `doom-escape-hook'.
(advice-add #'evil-force-normal-state :after #'+evil-escape-a)
;; Don't move cursor when indenting
@ -116,7 +114,7 @@ directives. By default, this only recognizes C directives.")
(advice-add #'evil-ex-replace-special-filenames :override #'+evil-resolve-vim-path-a)
;; make `try-expand-dabbrev' (from `hippie-expand') work in minibuffer
(add-hook 'minibuffer-inactive-mode-hook #'+evil--fix-dabbrev-in-minibuffer-a)
(add-hook 'minibuffer-inactive-mode-hook #'+evil--fix-dabbrev-in-minibuffer-h)
;; Focus and recenter new splits
(advice-add #'evil-window-split :override #'+evil-window-split-a)
@ -201,20 +199,20 @@ directives. By default, this only recognizes C directives.")
:hook ((ruby-mode enh-ruby-mode) . embrace-ruby-mode-hook)
:hook (emacs-lisp-mode . embrace-emacs-lisp-mode-hook)
:hook ((lisp-mode emacs-lisp-mode clojure-mode racket-mode)
. +evil|embrace-lisp-mode-hook)
:hook ((org-mode LaTeX-mode) . +evil|embrace-latex-mode-hook)
. +evil-embrace-lisp-mode-hook-h)
:hook ((org-mode LaTeX-mode) . +evil-embrace-latex-mode-hook-h)
:hook ((c++-mode rust-mode rustic-mode csharp-mode java-mode swift-mode typescript-mode)
. +evil|embrace-angle-bracket-modes-hook)
. +evil-embrace-angle-bracket-modes-hook-h)
:init
(after! evil-surround
(evil-embrace-enable-evil-surround-integration))
:config
(setq evil-embrace-show-help-p nil)
(defun +evil|embrace-latex-mode-hook ()
(defun +evil-embrace-latex-mode-hook-h ()
(embrace-add-pair-regexp ?l "\\[a-z]+{" "}" #'+evil--embrace-latex))
(defun +evil|embrace-lisp-mode-hook ()
(defun +evil-embrace-lisp-mode-hook-h ()
(push (cons ?f (make-embrace-pair-struct
:key ?f
:read-function #'+evil--embrace-elisp-fn
@ -222,7 +220,7 @@ directives. By default, this only recognizes C directives.")
:right-regexp ")"))
embrace--pairs-list))
(defun +evil|embrace-angle-bracket-modes-hook ()
(defun +evil-embrace-angle-bracket-modes-hook-h ()
(set (make-local-variable 'evil-embrace-evil-surround-keys)
(delq ?< evil-embrace-evil-surround-keys))
(push (cons ?< (make-embrace-pair-struct
@ -260,11 +258,11 @@ directives. By default, this only recognizes C directives.")
(def-package! evil-exchange
:commands evil-exchange
:config
(defun +evil|escape-exchange ()
(when evil-exchange--overlays
(evil-exchange-cancel)
t))
(add-hook 'doom-escape-hook #'+evil|escape-exchange))
(add-hook 'doom-escape-hook
(defun +evil--escape-exchange-h ()
(when evil-exchange--overlays
(evil-exchange-cancel)
t))))
(def-package! evil-snipe

View file

@ -39,13 +39,13 @@
;; disable evil-escape in evil-mc; causes unwanted text on invocation
(add-to-list 'evil-mc-incompatible-minor-modes 'evil-escape-mode nil #'eq)
(defun +multiple-cursors|escape-multiple-cursors ()
"Clear evil-mc cursors and restore state."
(when (evil-mc-has-cursors-p)
(evil-mc-undo-all-cursors)
(evil-mc-resume-cursors)
t))
(add-hook 'doom-escape-hook #'+multiple-cursors|escape-multiple-cursors)
(add-hook 'doom-escape-hook
(defun +multiple-cursors-escape-multiple-cursors-h ()
"Clear evil-mc cursors and restore state."
(when (evil-mc-has-cursors-p)
(evil-mc-undo-all-cursors)
(evil-mc-resume-cursors)
t)))
;; Forward declare these so that ex completion and evil-mc support is
;; recognized before the autoloaded functions are loaded.
@ -71,30 +71,30 @@
(defvar +mc--compat-evil-prev-state nil)
(defvar +mc--compat-mark-was-active nil)
(defun +multiple-cursors|compat-switch-to-emacs-state ()
(when (and (bound-and-true-p evil-mode)
(not (memq evil-state '(insert emacs))))
(setq +mc--compat-evil-prev-state evil-state)
(when (region-active-p)
(setq +mc--compat-mark-was-active t))
(let ((mark-before (mark))
(point-before (point)))
(evil-emacs-state 1)
(when (or +mc--compat-mark-was-active (region-active-p))
(goto-char point-before)
(set-mark mark-before)))))
(add-hook 'multiple-cursors-mode-enabled-hook #'+multiple-cursors|compat-switch-to-emacs-state)
(add-hook 'multiple-cursors-mode-enabled-hook
(defun +multiple-cursors-compat-switch-to-emacs-state-h ()
(when (and (bound-and-true-p evil-mode)
(not (memq evil-state '(insert emacs))))
(setq +mc--compat-evil-prev-state evil-state)
(when (region-active-p)
(setq +mc--compat-mark-was-active t))
(let ((mark-before (mark))
(point-before (point)))
(evil-emacs-state 1)
(when (or +mc--compat-mark-was-active (region-active-p))
(goto-char point-before)
(set-mark mark-before))))))
(defun +multiple-cursors|compat-back-to-previous-state ()
(when +mc--compat-evil-prev-state
(unwind-protect
(case +mc--compat-evil-prev-state
((normal visual) (evil-force-normal-state))
(t (message "Don't know how to handle previous state: %S"
+mc--compat-evil-prev-state)))
(setq +mc--compat-evil-prev-state nil)
(setq +mc--compat-mark-was-active nil))))
(add-hook 'multiple-cursors-mode-disabled-hook #'+multiple-cursors|compat-back-to-previous-state)
(add-hook 'multiple-cursors-mode-disabled-hook
(defun +multiple-cursors-compat-back-to-previous-state-h ()
(when +mc--compat-evil-prev-state
(unwind-protect
(case +mc--compat-evil-prev-state
((normal visual) (evil-force-normal-state))
(t (message "Don't know how to handle previous state: %S"
+mc--compat-evil-prev-state)))
(setq +mc--compat-evil-prev-state nil)
(setq +mc--compat-mark-was-active nil)))))
;; When running edit-lines, point will return (position + 1) as a result of
;; how evil deals with regions
@ -106,10 +106,10 @@
(goto-char (1- (point)))
(push-mark (1- (mark))))))
(defun +multiple-cursors|evil-compat-rect-switch-state ()
(if rectangular-region-mode
(+multiple-cursors|compat-switch-to-emacs-state)
(setq +mc--compat-evil-prev-state nil)))
(add-hook 'rectangular-region-mode-hook '+multiple-cursors|evil-compat-rect-switch-state)
(add-hook 'rectangular-region-mode-hook
(defun +multiple-cursors-evil-compat-rect-switch-state-h ()
(if rectangular-region-mode
(+multiple-cursors-compat-switch-to-emacs-state-h)
(setq +mc--compat-evil-prev-state nil))))
(defvar mc--default-cmds-to-run-once nil)))