💥 revise advice naming convention (1/2)

This is first of three big naming convention updates that have been a
long time coming. With 2.1 on the horizon, all the breaking updates will
batched together in preparation for the long haul.

In this commit, we do away with the asterix to communicate that a
function is an advice function, and we replace it with the '-a' suffix.
e.g.

  doom*shut-up -> doom-shut-up-a
  doom*recenter -> doom-recenter-a
  +evil*static-reindent -> +evil--static-reindent-a

The rationale behind this change is:

1. Elisp's own formatting/indenting tools would occasionally struggle
   with | and * (particularly pp and cl-prettyprint). They have no
   problem with / and :, fortunately.
2. External syntax highlighters (like pygmentize, discord markdown or
   github markdown) struggle with it, sometimes refusing to highlight
   code beyond these symbols.
3. * and | are less expressive than - and -- in communicating the
   intended visibility, versatility and stability of a function.
4. It complicated the regexps we must use to search for them.
5. They were arbitrary and over-complicated to begin with, decided
   on haphazardly way back when Doom was simply "my private config".

Anyhow, like how predicate functions have the -p suffix, we'll adopt the
-a suffix for advice functions, -h for hook functions and -fn for
variable functions.

Other noteable changes:
- Replaces advice-{add,remove}! macro with new def-advice!
  macro. The old pair weren't as useful. The new def-advice! saves on a
  lot of space.
- Removed "stage" assertions to make sure you were using the right
  macros in the right place. Turned out to not be necessary, we'll
  employ better checks later.
This commit is contained in:
Henrik Lissner 2019-07-18 15:42:52 +02:00
parent e3a102d05a
commit 51d3b1b424
No known key found for this signature in database
GPG key ID: 5F6C0EA160557395
44 changed files with 398 additions and 484 deletions

View file

@ -255,41 +255,6 @@ regex PATTERN. Returns the number of killed buffers."
(doom-set-buffer-real (current-buffer) t))
;;
;; Advice
;;;###autoload
(defun doom*switch-to-fallback-buffer-maybe (orig-fn)
"Advice for `kill-current-buffer'. If in a dedicated window, delete it. If there
are no real buffers left OR if all remaining buffers are visible in other
windows, switch to `doom-fallback-buffer'. Otherwise, delegate to original
`kill-current-buffer'."
(let ((buf (current-buffer)))
(cond ((window-dedicated-p)
(delete-window))
((eq buf (doom-fallback-buffer))
(message "Can't kill the fallback buffer."))
((doom-real-buffer-p buf)
(if (and buffer-file-name
(buffer-modified-p buf)
(not (y-or-n-p
(format "Buffer %s is modified; kill anyway?" buf))))
(message "Aborted")
(set-buffer-modified-p nil)
(let (buffer-list-update-hook)
(when (or ;; if there aren't more real buffers than visible buffers,
;; then there are no real, non-visible buffers left.
(not (cl-set-difference (doom-real-buffer-list)
(doom-visible-buffers)))
;; if we end up back where we start (or previous-buffer
;; returns nil), we have nowhere left to go
(memq (switch-to-prev-buffer nil t) (list buf 'nil)))
(switch-to-buffer (doom-fallback-buffer)))
(unless (delq (selected-window) (get-buffer-window-list buf nil t))
(kill-buffer buf)))))
((funcall orig-fn)))))
;;
;; Interactive commands

View file

@ -348,7 +348,6 @@ This excludes core packages listed in `doom-core-packages'.
If ALL-P, gather packages unconditionally across all modules, including disabled
ones."
(let ((noninteractive t)
(doom--stage 'packages)
(doom-modules (doom-modules))
doom-packages
doom-disabled-packages

View file

@ -27,12 +27,12 @@ are open."
;; Advice
;;;###autoload
(defun doom*recenter (&rest _)
(defun doom-recenter-a (&rest _)
"Generic advisor for recentering window (typically :after other functions)."
(recenter))
;;;###autoload
(defun doom*shut-up (orig-fn &rest args)
(defun doom-shut-up-a (orig-fn &rest args)
"Generic advisor for silencing noisy functions."
(quiet! (apply orig-fn args)))

View file

@ -54,13 +54,13 @@ detected.")
;; Remove hscroll-margin in shells, otherwise it causes jumpiness
(setq-hook! '(eshell-mode-hook term-mode-hook) hscroll-margin 0)
(defun doom*optimize-literal-mode-for-large-files (buffer)
(def-advice! doom--optimize-literal-mode-for-large-files-a (buffer)
:filter-return #'find-file-noselect-1
(with-current-buffer buffer
(when find-file-literally
(setq buffer-read-only t)
(buffer-disable-undo))
buffer))
(advice-add #'find-file-noselect-1 :filter-return #'doom*optimize-literal-mode-for-large-files)
;;
@ -171,11 +171,10 @@ savehist file."
(setq save-place-file (concat doom-cache-dir "saveplace")
save-place-forget-unreadable-files t
save-place-limit 200)
(defun doom*recenter-on-load-saveplace (&rest _)
(def-advice! doom--recenter-on-load-saveplace-a (&rest _)
"Recenter on cursor when loading a saved place."
:after-while #'save-place-find-file-hook
(if buffer-file-name (ignore-errors (recenter))))
(advice-add #'save-place-find-file-hook
:after-while #'doom*recenter-on-load-saveplace)
(save-place-mode +1))
(def-package! server
@ -202,14 +201,14 @@ savehist file."
(better-jumper-mode +1)
(add-hook 'better-jumper-post-jump-hook #'recenter)
(defun doom*set-jump (orig-fn &rest args)
(defun doom-set-jump-a (orig-fn &rest args)
"Set a jump point and ensure ORIG-FN doesn't set any new jump points."
(better-jumper-set-jump (if (markerp (car args)) (car args)))
(let ((evil--jumps-jumping t)
(better-jumper--jumping t))
(apply orig-fn args)))
(defun doom*set-jump-maybe (orig-fn &rest args)
(defun doom-set-jump-maybe-a (orig-fn &rest args)
"Set a jump point if ORIG-FN returns non-nil."
(let ((origin (point-marker))
(result
@ -261,9 +260,10 @@ savehist file."
(push '(t tab-width) dtrt-indent-hook-generic-mapping-list)
(defvar dtrt-indent-run-after-smie)
(defun doom*fix-broken-smie-modes (orig-fn arg)
(def-advice! doom--fix-broken-smie-modes-a (orig-fn arg)
"Some smie modes throw errors when trying to guess their indentation, like
`nim-mode'. This prevents them from leaving Emacs in a broken state."
:around #'dtrt-indent-mode
(let ((dtrt-indent-run-after-smie dtrt-indent-run-after-smie))
(cl-letf* ((old-smie-config-guess (symbol-function 'smie-config-guess))
((symbol-function 'smie-config-guess)
@ -273,8 +273,7 @@ savehist file."
(message "[WARNING] Indent detection: %s"
(error-message-string e))
(message "")))))) ; warn silently
(funcall orig-fn arg))))
(advice-add #'dtrt-indent-mode :around #'doom*fix-broken-smie-modes))
(funcall orig-fn arg)))))
(def-package! helpful
@ -354,17 +353,16 @@ savehist file."
`(("." . ,(concat doom-cache-dir "undo-tree-hist/"))))
(when (executable-find "zstd")
(defun doom*undo-tree-make-history-save-file-name (file)
(concat file ".zst"))
(advice-add #'undo-tree-make-history-save-file-name :filter-return
#'doom*undo-tree-make-history-save-file-name))
(def-advice! doom--undo-tree-make-history-save-file-name-a (file)
:filter-return #'undo-tree-make-history-save-file-name
(concat file ".zst")))
(defun doom*strip-text-properties-from-undo-history (&rest _)
(def-advice! doom--undo-tree-strip-text-properties-a (&rest _)
:before #'undo-list-transfer-to-tree
(dolist (item buffer-undo-list)
(and (consp item)
(stringp (car item))
(setcar item (substring-no-properties (car item))))))
(advice-add #'undo-list-transfer-to-tree :before #'doom*strip-text-properties-from-undo-history)
(global-undo-tree-mode +1))

View file

@ -76,21 +76,6 @@ list is returned as-is."
collect (cadr hook)
else collect (intern (format "%s-hook" (symbol-name hook)))))))
(defun doom--assert-stage-p (stage macro)
(unless (or (bound-and-true-p byte-compile-current-file)
;; Don't complain if we're being evaluated on-the-fly. Since forms
;; are often evaluated (by `eval-region') or expanded (by
;; macroexpand) in a temp buffer in `emacs-lisp-mode'...
(eq major-mode 'emacs-lisp-mode))
(cl-assert (eq stage doom--stage)
nil
"Found %s call in non-%s.el file (%s)"
macro (symbol-name stage)
(let ((path (FILE!)))
(if (file-in-directory-p path doom-emacs-dir)
(file-relative-name path doom-emacs-dir)
(abbreviate-file-name path))))))
;;
;;; Public library
@ -303,32 +288,26 @@ If N and M = 1, there's no benefit to using this macro over `remove-hook'.
(nreverse forms))))
collect `(add-hook ',hook #',fn 'append)))))
(defun advice-add! (symbols where functions)
"Variadic version of `advice-add'.
(defmacro def-advice! (symbol arglist docstring where places &rest body)
"Define an advice called NAME and add it to PLACES.
SYMBOLS and FUNCTIONS can be lists of functions."
(let ((functions (if (functionp functions)
(list functions)
functions)))
(dolist (s (doom-enlist symbols))
(dolist (f (doom-enlist functions))
(advice-add s where f)))))
(defun advice-remove! (symbols where-or-fns &optional functions)
"Variadic version of `advice-remove'.
WHERE-OR-FNS is ignored if FUNCTIONS is provided. This lets you substitute
advice-add with advice-remove and evaluate them without having to modify every
statement."
(unless functions
(setq functions where-or-fns
where-or-fns nil))
(let ((functions (if (functionp functions)
(list functions)
functions)))
(dolist (s (doom-enlist symbols))
(dolist (f (doom-enlist functions))
(advice-remove s f)))))
ARGLIST is as in `defun'. WHERE is a keyword as passed to `advice-add', and
PLACE is the function to which to add the advice, like in `advice-add'.
DOCSTRING and BODY are as in `defun'."
(declare (doc-string 3) (indent defun))
(unless (stringp docstring)
(push places body)
(setq places where
where docstring
docstring (format "%s advice for %s." where places)))
`(progn
(defun ,symbol ,arglist
,docstring
,@body)
(dolist (target (doom-enlist ,places))
(if (eq ,where :remove)
(advice-remove target #',symbol)
(advice-add target ,where #',symbol)))))
(cl-defmacro associate! (mode &key modes match files when)
"Enables a minor mode if certain conditions are met.

View file

@ -435,7 +435,6 @@ WARNING: If :pre-init or :pre-config hooks return nil, the original
`def-package!''s :init/:config block (respectively) is overwritten, so remember
to have them return non-nil (or exploit that to overwrite Doom's config)."
(declare (indent defun))
(doom--assert-stage-p 'init #'package!)
(unless (memq when '(:pre-init :post-init :pre-config :post-config))
(error "'%s' isn't a valid hook for def-package-hook!" when))
`(progn
@ -470,8 +469,7 @@ module."
(let ((doom--current-module ',(cons category module))
(doom--current-flags ',flags))
(load! "init" module-path :noerror)
(let ((doom--stage 'config))
(load! "config" module-path :noerror)))
(load! "config" module-path :noerror))
('error
(lwarn 'doom-modules :error
"%s in '%s %s' -> %s"

View file

@ -179,7 +179,6 @@ Accepts the following properties:
Returns t if package is successfully registered, and nil if it was disabled
elsewhere."
(declare (indent defun))
(doom--assert-stage-p 'packages #'package!)
(let ((old-plist (cdr (assq name doom-packages))))
(when recipe
(when (cl-evenp (length recipe))
@ -218,21 +217,9 @@ elsewhere."
`((add-to-list 'doom-disabled-packages ',name nil 'eq)
nil))))))
(defmacro packages! (&rest packages)
"A convenience macro for `package!' for declaring multiple packages at once.
Only use this macro in a module's packages.el file."
(doom--assert-stage-p 'packages #'packages!)
(macroexp-progn
(cl-loop for desc in packages
collect (macroexpand `(package! ,@(doom-enlist desc))))))
(defmacro disable-packages! (&rest packages)
"A convenience macro like `package!', but allows you to disable multiple
packages at once.
Only use this macro in a module's packages.el file."
(doom--assert-stage-p 'packages #'disable-packages!)
"A convenience macro for disabling packages in bulk.
Only use this macro in a module's (or your private) packages.el file."
(macroexp-progn
(cl-loop for pkg in packages
collect (macroexpand `(package! ,pkg :disable t)))))

View file

@ -44,31 +44,14 @@ Emacs.")
(global-set-key [remap find-tag] #'projectile-find-tag)
:config
(defun doom*projectile-cache-timers ()
"Persist `projectile-projects-cache-time' across sessions, so that
`projectile-files-cache-expire' checks won't reset when restarting Emacs."
(projectile-serialize projectile-projects-cache-time doom-projectile-cache-timer-file))
(advice-add #'projectile-serialize-cache :before #'doom*projectile-cache-timers)
;; Restore it
(setq projectile-projects-cache-time (projectile-unserialize doom-projectile-cache-timer-file))
(add-hook 'dired-before-readin-hook #'projectile-track-known-projects-find-file-hook)
(projectile-mode +1)
;; a more generic project root file
(push ".project" projectile-project-root-files-bottom-up)
(push (abbreviate-file-name doom-local-dir) projectile-globally-ignored-directories)
(defun doom*projectile-default-generic-command (orig-fn &rest args)
"If projectile can't tell what kind of project you're in, it issues an error
when using many of projectile's command, e.g. `projectile-compile-command',
`projectile-run-project', `projectile-test-project', and
`projectile-configure-project', for instance.
This suppresses the error so these commands will still run, but prompt you for
the command instead."
(ignore-errors (apply orig-fn args)))
(advice-add #'projectile-default-generic-command :around #'doom*projectile-default-generic-command)
;; Treat current directory in dired as a "file in a project" and track it
(add-hook 'dired-before-readin-hook #'projectile-track-known-projects-find-file-hook)
;; Accidentally indexing big directories like $HOME or / will massively bloat
;; projectile's cache (into the hundreds of MBs). This purges those entries
@ -111,16 +94,6 @@ c) are not valid projectile projects."
projectile-project-root-files)
projectile-project-root-files-bottom-up nil)))
;; Projectile root-searching functions can cause an infinite loop on TRAMP
;; connections, so disable them.
;; TODO Is this still necessary?
(defun doom*projectile-locate-dominating-file (orig-fn file name)
"Don't traverse the file system if on a remote connection."
(when (and (stringp file)
(not (file-remote-p file nil t)))
(funcall orig-fn file name)))
(advice-add #'projectile-locate-dominating-file :around #'doom*projectile-locate-dominating-file)
(cond
;; If fd exists, use it for git and generic projects. fd is a rust program
;; that is significantly faster than git ls-files or find, and it respects
@ -143,7 +116,37 @@ c) are not valid projectile projects."
projectile-indexing-method 'alien)
;; fix breakage on windows in git projects
(unless (executable-find "tr")
(setq projectile-git-submodule-command nil)))))
(setq projectile-git-submodule-command nil))))
(def-advice! doom--projectile-cache-timers-a ()
"Persist `projectile-projects-cache-time' across sessions, so that
`projectile-files-cache-expire' checks won't reset when restarting Emacs."
:before #'projectile-serialize-cache
(projectile-serialize projectile-projects-cache-time doom-projectile-cache-timer-file))
;; Restore it
(setq projectile-projects-cache-time (projectile-unserialize doom-projectile-cache-timer-file))
(def-advice! doom--projectile-default-generic-command-a (orig-fn &rest args)
"If projectile can't tell what kind of project you're in, it issues an error
when using many of projectile's command, e.g. `projectile-compile-command',
`projectile-run-project', `projectile-test-project', and
`projectile-configure-project', for instance.
This suppresses the error so these commands will still run, but prompt you for
the command instead."
:around #'projectile-default-generic-command
(ignore-errors (apply orig-fn args)))
;; Projectile root-searching functions can cause an infinite loop on TRAMP
;; connections, so disable them.
;; TODO Is this still necessary?
(def-advice! doom--projectile-locate-dominating-file-a (orig-fn file name)
"Don't traverse the file system if on a remote connection."
:around #'projectile-locate-dominating-file
(when (and (stringp file)
(not (file-remote-p file nil t)))
(funcall orig-fn file name))))
;;
;; Project-based minor modes

View file

@ -102,8 +102,8 @@ behavior). Do not set this directly, this is let-bound in `doom|init-theme'.")
(run-hooks 'doom-switch-frame-hook)
(setq doom--last-frame (selected-frame)))))
(defun doom*run-switch-buffer-hooks (orig-fn buffer-or-name &rest args)
(let ((gc-cons-threshold doom-gc-cons-upper-limit))
(defun doom-run-switch-buffer-hooks-a (orig-fn buffer-or-name &rest args)
(let ((gc-cons-threshold most-positive-fixnum))
(if (or doom-inhibit-switch-buffer-hooks
(eq (current-buffer) (get-buffer buffer-or-name))
(and (eq orig-fn #'switch-to-buffer) (car args)))
@ -116,8 +116,8 @@ behavior). Do not set this directly, this is let-bound in `doom|init-theme'.")
(run-hooks 'doom-switch-buffer-hook))
buffer)))))
(defun doom*run-switch-to-next-prev-buffer-hooks (orig-fn &rest args)
(let ((gc-cons-threshold doom-gc-cons-upper-limit))
(defun doom-run-switch-to-next-prev-buffer-hooks-a (orig-fn &rest args)
(let ((gc-cons-threshold most-positive-fixnum))
(if doom-inhibit-switch-buffer-hooks
(apply orig-fn args)
(let ((doom-inhibit-switch-buffer-hooks t))
@ -126,13 +126,7 @@ behavior). Do not set this directly, this is let-bound in `doom|init-theme'.")
(run-hooks 'doom-switch-buffer-hook))
buffer)))))
(defun doom*run-load-theme-hooks (theme &optional _no-confirm no-enable)
"Set up `doom-load-theme-hook' to run after `load-theme' is called."
(unless no-enable
(setq doom-theme theme)
(run-hooks 'doom-load-theme-hook)))
(defun doom|protect-fallback-buffer ()
(defun doom-protect-fallback-buffer-h ()
"Don't kill the scratch buffer. Meant for `kill-buffer-query-functions'."
(not (eq (current-buffer) (doom-fallback-buffer))))
@ -239,6 +233,39 @@ read-only or not file-visiting."
window-divider-default-right-width 1)
(add-hook 'doom-init-ui-hook #'window-divider-mode)
(def-advice! doom-switch-to-fallback-buffer-maybe-a (orig-fn)
"Switch to `doom-fallback-buffer' if on last real buffer.
Advice for `kill-current-buffer'. If in a dedicated window, delete it. If there
are no real buffers left OR if all remaining buffers are visible in other
windows, switch to `doom-fallback-buffer'. Otherwise, delegate to original
`kill-current-buffer'."
:around #'kill-current-buffer
(let ((buf (current-buffer)))
(cond ((window-dedicated-p)
(delete-window))
((eq buf (doom-fallback-buffer))
(message "Can't kill the fallback buffer."))
((doom-real-buffer-p buf)
(if (and buffer-file-name
(buffer-modified-p buf)
(not (y-or-n-p
(format "Buffer %s is modified; kill anyway?" buf))))
(message "Aborted")
(set-buffer-modified-p nil)
(let (buffer-list-update-hook)
(when (or ;; if there aren't more real buffers than visible buffers,
;; then there are no real, non-visible buffers left.
(not (cl-set-difference (doom-real-buffer-list)
(doom-visible-buffers)))
;; if we end up back where we start (or previous-buffer
;; returns nil), we have nowhere left to go
(memq (switch-to-prev-buffer nil t) (list buf 'nil)))
(switch-to-buffer (doom-fallback-buffer)))
(unless (delq (selected-window) (get-buffer-window-list buf nil t))
(kill-buffer buf)))))
((funcall orig-fn)))))
;;
;;; Built-in packages
@ -329,16 +356,14 @@ read-only or not file-visiting."
:commands (all-the-icons-octicon all-the-icons-faicon all-the-icons-fileicon
all-the-icons-wicon all-the-icons-material all-the-icons-alltheicon)
:init
(defun doom*disable-all-the-icons-in-tty (orig-fn &rest args)
(def-advice! doom--disable-all-the-icons-in-tty-a (orig-fn &rest args)
"all-the-icons doesn't work in the terminal, so we \"disable\" them."
:around '(all-the-icons-octicon all-the-icons-material
all-the-icons-faicon all-the-icons-fileicon
all-the-icons-wicon all-the-icons-alltheicon)
(if (display-graphic-p)
(apply orig-fn args)
""))
:config
;; all-the-icons doesn't work in the terminal, so we "disable" it.
(dolist (fn '(all-the-icons-octicon all-the-icons-material
all-the-icons-faicon all-the-icons-fileicon
all-the-icons-wicon all-the-icons-alltheicon))
(advice-add fn :around #'doom*disable-all-the-icons-in-tty)))
"")))
;;;###package hide-mode-line-mode
(add-hook 'completion-list-mode-hook #'hide-mode-line-mode)
@ -482,6 +507,26 @@ By default, this uses Apple Color Emoji on MacOS and Symbola on Linux."
(let ((doom--prefer-theme-elc t))
(load-theme doom-theme t)))))
(def-advice! doom--run-load-theme-hooks-a (theme &optional _no-confirm no-enable)
"Set up `doom-load-theme-hook' to run after `load-theme' is called."
:after #'load-theme
(unless no-enable
(setq doom-theme theme)
(run-hooks 'doom-load-theme-hook)))
(def-advice! doom--prefer-compiled-theme-a (orig-fn &rest args)
"Make `load-theme' prioritize the byte-compiled theme for a moderate boost in
startup (or theme switch) time, so long as `doom--prefer-theme-elc' is non-nil."
:around #'load-theme
(if (or (null after-init-time)
doom--prefer-theme-elc)
(cl-letf* ((old-locate-file (symbol-function 'locate-file))
((symbol-function 'locate-file)
(lambda (filename path &optional _suffixes predicate)
(funcall old-locate-file filename path '("c" "") predicate))))
(apply orig-fn args))
(apply orig-fn args)))
;;
;;; Bootstrap
@ -499,10 +544,10 @@ By default, this uses Apple Color Emoji on MacOS and Symbola on Linux."
;; + `doom-switch-frame-hook'
(add-hook 'buffer-list-update-hook #'doom|run-switch-window-hooks)
(add-hook 'focus-in-hook #'doom|run-switch-frame-hooks)
(advice-add! '(switch-to-next-buffer switch-to-prev-buffer)
:around #'doom*run-switch-to-next-prev-buffer-hooks)
(advice-add! '(switch-to-buffer display-buffer)
:around #'doom*run-switch-buffer-hooks))
(dolist (fn '(switch-to-next-buffer switch-to-prev-buffer))
(advice-add fn :around #'doom-run-switch-to-next-prev-buffer-hooks-a))
(dolist (fn '(switch-to-buffer display-buffer))
(advice-add fn :around #'doom-run-switch-buffer-hooks-a)))
;; Apply `doom-theme'
(add-hook (if (daemonp)
@ -513,9 +558,6 @@ By default, this uses Apple Color Emoji on MacOS and Symbola on Linux."
(add-hook 'doom-after-init-modules-hook #'doom|init-fonts)
;; Ensure unicode fonts are set on each frame
(add-hook 'after-make-frame-functions #'doom|init-emoji-fonts)
;; Setup `doom-load-theme-hook' and ensure `doom-theme' is always set to the
;; currently loaded theme
(advice-add #'load-theme :after #'doom*run-load-theme-hooks)
(add-hook 'window-setup-hook #'doom|init-ui)
@ -527,35 +569,13 @@ By default, this uses Apple Color Emoji on MacOS and Symbola on Linux."
(unless (fboundp 'define-fringe-bitmap)
(defun define-fringe-bitmap (&rest _)))
(defun doom*prefer-compiled-theme (orig-fn &rest args)
"Make `load-theme' prioritize the byte-compiled theme for a moderate boost in
startup (or theme switch) time, so long as `doom--prefer-theme-elc' is non-nil."
(if (or (null after-init-time)
doom--prefer-theme-elc)
(cl-letf* ((old-locate-file (symbol-function 'locate-file))
((symbol-function 'locate-file)
(lambda (filename path &optional _suffixes predicate)
(funcall old-locate-file filename path '("c" "") predicate))))
(apply orig-fn args))
(apply orig-fn args)))
(advice-add #'load-theme :around #'doom*prefer-compiled-theme)
(after! whitespace
(defun doom*disable-whitespace-mode-in-childframes (orig-fn)
(defun doom-disable-whitespace-mode-in-childframes-a (orig-fn)
"`whitespace-mode' inundates child frames with whitspace markers, so disable
it to fix all that visual noise."
(unless (frame-parameter nil 'parent-frame)
(funcall orig-fn)))
(add-function :around whitespace-enable-predicate #'doom*disable-whitespace-mode-in-childframes)
(defun doom|disable-whitespace-mode-in-childframes (frame)
"`whitespace-mode' inundates child frames with whitspace markers, so disable
it to fix all that visual noise."
(when (frame-parameter frame 'parent-frame)
(with-selected-frame frame
(setq-local whitespace-style nil)
frame)))
(add-hook 'after-make-frame-functions #'doom|disable-whitespace-mode-in-childframes))
(add-function :around whitespace-enable-predicate #'doom-disable-whitespace-mode-in-childframes-a))
;; Don't allow cursor to enter the prompt
(setq minibuffer-prompt-properties '(read-only t intangible t cursor-intangible t face minibuffer-prompt))
@ -572,8 +592,5 @@ it to fix all that visual noise."
(doom-silence-motion-key backward-delete-char "<backspace>")
(doom-silence-motion-key delete-char "<delete>")
;; Switch to `doom-fallback-buffer' if on last real buffer
(advice-add #'kill-current-buffer :around #'doom*switch-to-fallback-buffer-maybe)
(provide 'core-ui)
;;; core-ui.el ends here

View file

@ -130,7 +130,6 @@ Doom was setup, which may cause problems.")
(defvar doom--last-emacs-file (concat doom-local-dir "emacs-version.el"))
(defvar doom--last-emacs-version nil)
(defvar doom--refreshed-p nil)
(defvar doom--stage 'init)
;;

View file

@ -62,13 +62,15 @@
(setq a (switch-to-buffer (get-buffer-create "a"))
b (get-buffer-create "b"))
(spy-on 'hook)
(add-hook 'buffer-list-update-hook #'doom|run-switch-window-hooks)
(add-hook 'focus-in-hook #'doom|run-switch-frame-hooks)
(advice-add! '(switch-to-buffer display-buffer) :around #'doom*run-switch-buffer-hooks))
(add-hook 'buffer-list-update-hook #'doom-run-switch-window-hooks-h)
(add-hook 'focus-in-hook #'doom-run-switch-frame-hooks-h)
(dolist (fn '(switch-to-buffer display-buffer))
(advice-add fn :around #'doom-run-switch-buffer-hooks-a)))
(after-each
(remove-hook 'buffer-list-update-hook #'doom|run-switch-window-hooks)
(remove-hook 'focus-in-hook #'doom|run-switch-frame-hooks)
(advice-remove! '(switch-to-buffer display-buffer) #'doom*run-switch-buffer-hooks)
(remove-hook 'buffer-list-update-hook #'doom-run-switch-window-hooks-h)
(remove-hook 'focus-in-hook #'doom-run-switch-frame-hooks-h)
(dolist (fn '(switch-to-buffer display-buffer))
(advice-remove fn #'doom-run-switch-buffer-hooks-a))
(kill-buffer a)
(kill-buffer b))