💥 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

@ -250,7 +250,7 @@ regex PATTERN. Returns the number of killed buffers."
;; Hooks
;;;###autoload
(defun doom|mark-buffer-as-real ()
(defun doom-mark-buffer-as-real-h ()
"Hook function that marks the current buffer as real."
(doom-set-buffer-real (current-buffer) t))

View file

@ -21,7 +21,7 @@ to persist across Emacs sessions.")
name under `pcache-directory' (by default a subdirectory under
`doom-cache-dir'). One file may contain multiple cache entries.")
(defun doom|save-persistent-cache ()
(defun doom-save-persistent-cache-h ()
"Hook to run when an Emacs session is killed. Saves all persisted variables
listed in `doom-cache-alists' to files."
(dolist (alist (butlast doom-cache-alists 1))
@ -29,7 +29,7 @@ listed in `doom-cache-alists' to files."
for var in (cdr alist)
if (symbol-value var)
do (doom-cache-set var it nil key))))
(add-hook 'kill-emacs-hook #'doom|save-persistent-cache)
(add-hook 'kill-emacs-hook #'doom-save-persistent-cache-h)
;;

View file

@ -1,5 +1,9 @@
;;; core/autoload/config.el -*- lexical-binding: t; -*-
;;;###autoload
(defvar doom-reload-hook nil
"A list of hooks to run when `doom/reload' is called.")
;;;###autoload
(defvar doom-reloading-p nil
"TODO")
@ -72,16 +76,6 @@ Uses the same mechanism as 'bin/doom env reload'."
(error "Failed to generate env file"))
(doom-load-env-vars doom-env-file))
;;;###autoload
(defun doom/reload-font ()
"Reload your fonts, if they're set.
See `doom|init-fonts'."
(interactive)
(when doom-font
(set-frame-font doom-font t))
(doom|init-fonts)
(mapc #'doom|init-emoji-fonts (frame-list)))
;;;###autoload
(defun doom/reload-theme ()
"Reload the current color theme."
@ -92,4 +86,4 @@ See `doom|init-fonts'."
(when (and doom-theme (not (memq doom-theme custom-enabled-themes)))
(let (doom--prefer-theme-elc)
(load-theme doom-theme t)))
(doom|init-fonts)))
(doom-init-fonts-h)))

View file

@ -169,12 +169,12 @@ markdown and copies it to your clipboard, ready to be pasted into bug reports!"
(load! "config" (plist-get plist :path) t)))
doom-modules)
(run-hook-wrapped 'doom-init-modules-hook #'doom-try-run-hook)
(doom|run-all-startup-hooks)))
(doom-run-all-startup-hooks-h)))
(`vanilla-doom ; only Doom core
`((setq doom-private-dir "/tmp/does/not/exist"
doom-init-modules-p t)
(load-file ,user-init-file)
(doom|run-all-startup-hooks)))
(doom-run-all-startup-hooks-h)))
(`vanilla ; nothing loaded
`((package-initialize)))))))
"\n(unwind-protect (progn\n" contents "\n)\n"
@ -357,7 +357,7 @@ If INIT-FILE is non-nil, profile that instead of USER-INIT-FILE."
init-file
esup-server-port
esup-depth)
"--eval=(doom|run-all-startup-hooks)"))))
"--eval=(doom-run-all-startup-hooks-h)"))))
(when esup-run-as-batch-p
(setq process-args (append process-args '("--batch"))))
(setq esup-child-process (apply #'start-process process-args)))

View file

@ -65,6 +65,15 @@ FRAME parameter defaults to current frame."
;;
;;; Commands
;;;###autoload
(defun doom/reload-font ()
"Reload your fonts, if they're set.
See `doom-init-fonts-h'."
(interactive)
(when doom-font
(set-frame-font doom-font t))
(mapc #'doom-init-emoji-fonts-h (frame-list)))
;;;###autoload
(defun doom/increase-font-size (count)
"Enlargens the font size across the current frame."

View file

@ -54,7 +54,7 @@ following:
(when (and (eq major-mode 'fundamental-mode)
(functionp mode))
(funcall mode))
(add-hook 'kill-buffer-hook #'doom|persist-scratch-buffer nil 'local)
(add-hook 'kill-buffer-hook #'doom-persist-scratch-buffer-h nil 'local)
(run-hooks 'doom-scratch-buffer-created-hook))
buffer)))
@ -63,7 +63,7 @@ following:
;;; Persistent scratch buffer
;;;###autoload
(defun doom|persist-scratch-buffer ()
(defun doom-persist-scratch-buffer-h ()
"Save the current buffer to `doom-scratch-dir'."
(write-region
(point-min) (point-max)
@ -71,16 +71,16 @@ following:
doom-scratch-dir)))
;;;###autoload
(defun doom|persist-scratch-buffers ()
(defun doom-persist-scratch-buffers-h ()
"Save all scratch buffers to `doom-scratch-dir'."
(setq doom-scratch-buffers (cl-delete-if-not #'buffer-live-p doom-scratch-buffers))
(dolist (buffer doom-scratch-buffers)
(with-current-buffer buffer
(doom|persist-scratch-buffer))))
(doom-persist-scratch-buffer-h))))
;;;###autoload
(unless noninteractive
(add-hook 'kill-emacs-hook #'doom|persist-scratch-buffers))
(add-hook 'kill-emacs-hook #'doom-persist-scratch-buffers-h))
;;

View file

@ -211,25 +211,25 @@ Respects `require-final-newline'."
;; Hooks
;;;###autoload
(defun doom|enable-delete-trailing-whitespace ()
(defun doom-enable-delete-trailing-whitespace-h ()
"Enables the automatic deletion of trailing whitespaces upon file save.
i.e. enables `ws-butler-mode' in the current buffer."
(ws-butler-mode +1))
;;;###autoload
(defun doom|disable-delete-trailing-whitespace ()
(defun doom-disable-delete-trailing-whitespace-h ()
"Disables the automatic deletion of trailing whitespaces upon file save.
i.e. disables `ws-butler-mode' in the current buffer."
(ws-butler-mode -1))
;;;###autoload
(defun doom|enable-show-trailing-whitespace ()
(defun doom-enable-show-trailing-whitespace-h ()
"Enable `show-trailing-whitespace' in the current buffer."
(setq-local show-trailing-whitespace t))
;;;###autoload
(defun doom|disable-show-trailing-whitespace ()
(defun doom-disable-show-trailing-whitespace-h ()
"Disable `show-trailing-whitespace' in the current buffer."
(setq-local show-trailing-whitespace nil))

View file

@ -41,14 +41,14 @@ are open."
;; Hooks
;;;###autoload
(defun doom|apply-ansi-color-to-compilation-buffer ()
(defun doom-apply-ansi-color-to-compilation-buffer-h ()
"Applies ansi codes to the compilation buffers. Meant for
`compilation-filter-hook'."
(with-silent-modifications
(ansi-color-apply-on-region compilation-filter-start (point))))
;;;###autoload
(defun doom|disable-show-paren-mode ()
(defun doom-disable-show-paren-mode-h ()
"Turn off `show-paren-mode' buffer-locally."
(setq-local show-paren-mode nil))