💥 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

@ -121,10 +121,9 @@
:defer t
:config
(setq company-dict-dir (expand-file-name "dicts" doom-private-dir))
(defun +company|enable-project-dicts (mode &rest _)
"Enable per-project dictionaries."
(if (symbol-value mode)
(add-to-list 'company-dict-minor-mode-list mode nil #'eq)
(setq company-dict-minor-mode-list (delq mode company-dict-minor-mode-list))))
(add-hook 'doom-project-hook #'+company|enable-project-dicts))
(add-hook 'doom-project-hook
(defun +company--enable-project-dicts-h (mode &rest _)
"Enable per-project dictionaries."
(if (symbol-value mode)
(add-to-list 'company-dict-minor-mode-list mode nil #'eq)
(setq company-dict-minor-mode-list (delq mode company-dict-minor-mode-list))))))

View file

@ -1,9 +1,7 @@
;;; completion/helm/autoload/posframe.el -*- lexical-binding: t; -*-
(add-hook 'helm-cleanup-hook #'+helm|posframe-cleanup)
;;;###autoload
(defun +helm-poshandler-frame-center-near-bottom (info)
(defun +helm-poshandler-frame-center-near-bottom-fn (info)
"Display the child frame in the center of the frame, slightly closer to the
bottom, which is easier on the eyes on big displays."
(let ((parent-frame (plist-get info :parent-frame))
@ -14,7 +12,7 @@ bottom, which is easier on the eyes on big displays."
(defvar +helm--posframe-buffer nil)
;;;###autoload
(defun +helm-posframe-display (buffer &optional _resume)
(defun +helm-posframe-display-fn (buffer &optional _resume)
"TODO"
(setq helm--buffer-in-new-frame-p t)
(let ((solaire-p (bound-and-true-p solaire-mode))
@ -52,7 +50,7 @@ bottom, which is easier on the eyes on big displays."
(text-scale-set +helm-posframe-text-scale)))))
;;;###autoload
(defun +helm|posframe-cleanup ()
(defun +helm-posframe-cleanup-h ()
"TODO"
;; Ensure focus is properly returned to the underlying window, by forcing a
;; chance in buffer/window focus. This gives the modeline a chance to refresh.
@ -60,3 +58,4 @@ bottom, which is easier on the eyes on big displays."
;;
(posframe-delete +helm--posframe-buffer))
(add-hook 'helm-cleanup-hook #'+helm-posframe-cleanup-h)

View file

@ -11,8 +11,7 @@ silently ignored.
This falls back to git-grep (then grep) if none of these available.")
;; Posframe (requires +childframe)
(defvar +helm-posframe-handler
#'+helm-poshandler-frame-center-near-bottom
(defvar +helm-posframe-handler #'+helm-poshandler-frame-center-near-bottom-fn
"The function that determines the location of the childframe. It should return
a cons cell representing the X and Y coordinates. See
`posframe-poshandler-frame-center' as a reference.")
@ -113,12 +112,12 @@ be negative.")
(set-popup-rule! "^\\*helm" :vslot -100 :size 0.22 :ttl nil)
;; Hide the modeline
(defun +helm|hide-mode-line (&rest _)
(defun +helm--hide-mode-line (&rest _)
(with-current-buffer (helm-buffer-get)
(unless helm-mode-line-string
(hide-mode-line-mode +1))))
(add-hook 'helm-after-initialize-hook #'+helm|hide-mode-line)
(advice-add #'helm-display-mode-line :override #'+helm|hide-mode-line)
(add-hook 'helm-after-initialize-hook #'+helm--hide-mode-line)
(advice-add #'helm-display-mode-line :override #'+helm--hide-mode-line)
(advice-add #'helm-ag-show-status-default-mode-line :override #'ignore)
;; Use helpful instead of describe-* to display documentation

View file

@ -1,6 +1,6 @@
;;; completion/ido/config.el -*- lexical-binding: t; -*-
(defun +ido|init ()
(defun +ido-init-h ()
(setq ido-ignore-buffers
'("\\` " "^\\*ESS\\*" "^\\*Messages\\*" "^\\*Help\\*" "^\\*Buffer"
"^\\*.*Completions\\*$" "^\\*Ediff" "^\\*tramp" "^\\*cvs-"
@ -52,7 +52,7 @@
(crm-custom-mode +1)
;;
(remove-hook 'ido-setup-hook #'+ido|init))
(remove-hook 'ido-setup-hook #'+ido-init-h))
;;
(add-hook 'ido-setup-hook #'+ido|init)
(add-hook 'ido-setup-hook #'+ido-init-h)

View file

@ -2,12 +2,12 @@
;;;###if (featurep! +childframe)
;;;###autoload
(defun +ivy-display-at-frame-center-near-bottom (str)
(defun +ivy-display-at-frame-center-near-bottom-fn (str)
"TODO"
(ivy-posframe--display str #'+ivy-poshandler-frame-center-near-bottom))
(ivy-posframe--display str #'+ivy-poshandler-frame-center-near-bottom-fn))
;;;###autoload
(defun +ivy-poshandler-frame-center-near-bottom (info)
(defun +ivy-poshandler-frame-center-near-bottom-fn (info)
"TODO"
(let ((parent-frame (plist-get info :parent-frame))
(pos (posframe-poshandler-frame-center info)))

View file

@ -77,19 +77,18 @@ immediately runs it on the current candidate (ending the ivy session)."
;; Ensure a jump point is registered before jumping to new locations with ivy
(defvar +ivy--origin nil)
(defun +ivy|record-position-maybe ()
(defun +ivy--record-position-maybe-fn ()
(with-ivy-window
(setq +ivy--origin (point-marker))))
(setq ivy-hooks-alist '((t . +ivy|record-position-maybe)))
(setq ivy-hooks-alist '((t . +ivy--record-position-maybe-fn)))
(defun +ivy|set-jump-point-maybe ()
(when (and (markerp +ivy--origin)
(not (equal (with-ivy-window (point-marker)) +ivy--origin)))
(with-current-buffer (marker-buffer +ivy--origin)
(better-jumper-set-jump +ivy--origin)))
(setq +ivy--origin nil))
(add-hook 'minibuffer-exit-hook #'+ivy|set-jump-point-maybe)
(add-hook 'minibuffer-exit-hook
(defun +ivy--set-jump-point-maybe-h ()
(when (and (markerp +ivy--origin)
(not (equal (with-ivy-window (point-marker)) +ivy--origin)))
(with-current-buffer (marker-buffer +ivy--origin)
(better-jumper-set-jump +ivy--origin)))
(setq +ivy--origin nil)))
(after! yasnippet
(add-to-list 'yas-prompt-functions #'+ivy-yas-prompt nil #'eq))
@ -277,11 +276,13 @@ evil-ex-specific constructs, so we disable it solely in evil-ex."
(min-height . ,ivy-height)))
;; default to posframe display function
(setf (alist-get t ivy-posframe-display-functions-alist) #'+ivy-display-at-frame-center-near-bottom)
(setf (alist-get t ivy-posframe-display-functions-alist)
#'+ivy-display-at-frame-center-near-bottom-fn)
;; posframe doesn't work well with async sources
(dolist (fn '(swiper counsel-ag counsel-grep counsel-git-grep))
(setf (alist-get fn ivy-posframe-display-functions-alist) #'ivy-display-function-fallback)))
(setf (alist-get fn ivy-posframe-display-functions-alist)
#'ivy-display-function-fallback)))
(def-package! flx