refactor: rename orig-fn arg in advice to fn

A minor tweak to our naming conventions for the first argument of an
:around advice.
This commit is contained in:
Henrik Lissner 2021-08-04 01:18:06 -04:00
parent 12732be155
commit 06392a723f
51 changed files with 223 additions and 229 deletions

View file

@ -58,12 +58,12 @@
" of these options.\n")
(princ (buffer-string))))
(defun *org-babel-tangle (orig-fn &rest args)
(defun *org-babel-tangle (fn &rest args)
"Don't write tangled blocks to files, print them to stdout."
(cl-letf (((symbol-function 'write-region)
(lambda (start end filename &optional append visit lockname mustbenew)
(princ (buffer-string)))))
(apply orig-fn args)))
(apply fn args)))
(defun *org-babel-tangle-collect-blocks (&optional language tangle-file)
"Like `org-babel-tangle-collect-blocks', but will ignore blocks that are in

View file

@ -64,9 +64,9 @@
doom-emacs-dir ,doom-emacs-dir
doom-cache-dir ,(expand-file-name "cache/" doom-sandbox-dir)
doom-etc-dir ,(expand-file-name "etc/" doom-sandbox-dir))
(defun doom--write-to-etc-dir-a (orig-fn &rest args)
(defun doom--write-to-etc-dir-a (fn &rest args)
(let ((user-emacs-directory doom-etc-dir))
(apply orig-fn args)))
(apply fn args)))
(advice-add #'locate-user-emacs-file :around #'doom--write-to-etc-dir-a)
;; emacs essential variables
(setq before-init-time (current-time)

View file

@ -32,24 +32,24 @@ are open."
(recenter))
;;;###autoload
(defun doom-preserve-window-position-a (orig-fn &rest args)
(defun doom-preserve-window-position-a (fn &rest args)
"Generic advice for preserving cursor position on screen after scrolling."
(let ((row (cdr (posn-col-row (posn-at-point)))))
(prog1 (apply orig-fn args)
(prog1 (apply fn args)
(save-excursion
(let ((target-row (- (line-number-at-pos) row)))
(unless (< target-row 0)
(evil-scroll-line-to-top target-row)))))))
;;;###autoload
(defun doom-shut-up-a (orig-fn &rest args)
(defun doom-shut-up-a (fn &rest args)
"Generic advisor for silencing noisy functions.
In interactive Emacs, this just inhibits messages from appearing in the
minibuffer. They are still logged to *Messages*.
In tty Emacs, messages are suppressed completely."
(quiet! (apply orig-fn args)))
(quiet! (apply fn args)))
;;

View file

@ -36,11 +36,11 @@ original state.")
;; HACK Replace GUI popup prompts (which hang indefinitely in tty Emacs) with
;; simple prompts.
(defadvice! doom--straight-fallback-to-y-or-n-prompt-a (orig-fn &optional prompt)
(defadvice! doom--straight-fallback-to-y-or-n-prompt-a (fn &optional prompt)
:around #'straight-are-you-sure
(or doom-auto-accept
(if doom-interactive-p
(funcall orig-fn prompt)
(funcall fn prompt)
(y-or-n-p (format! "%s" (or prompt ""))))))
(defun doom--straight-recommended-option-p (prompt option)
@ -48,11 +48,11 @@ original state.")
if (string-match-p prompt-re prompt)
return (string-match-p opt-re option)))
(defadvice! doom--straight-fallback-to-tty-prompt-a (orig-fn prompt actions)
(defadvice! doom--straight-fallback-to-tty-prompt-a (fn prompt actions)
"Modifies straight to prompt on the terminal when in noninteractive sessions."
:around #'straight--popup-raw
(if doom-interactive-p
(funcall orig-fn prompt actions)
(funcall fn prompt actions)
(let ((doom--straight-auto-options doom--straight-auto-options))
;; We can't intercept C-g, so no point displaying any options for this key
;; when C-c is the proper way to abort batch Emacs.

View file

@ -142,7 +142,7 @@ tell you about it. Very annoying. This prevents that."
;; filesystem will murder your family. To appease it, I compress
;; `buffer-file-name' to a stable 40 characters.
;; TODO PR this upstream; should be a universal issue!
(defadvice! doom-make-hashed-auto-save-file-name-a (orig-fn)
(defadvice! doom-make-hashed-auto-save-file-name-a (fn)
"Compress the auto-save file name so paths don't get too long."
:around #'make-auto-save-file-name
(let ((buffer-file-name
@ -157,11 +157,11 @@ tell you about it. Very annoying. This prevents that."
'make-auto-save-file-name))
buffer-file-name
(sha1 buffer-file-name))))
(funcall orig-fn)))
(funcall fn)))
;; HACK Does the same for Emacs backup files, but also packages that use
;; `make-backup-file-name-1' directly (like undo-tree).
(defadvice! doom-make-hashed-backup-file-name-a (orig-fn file)
(defadvice! doom-make-hashed-backup-file-name-a (fn file)
"A few places use the backup file name so paths don't get too long."
:around #'make-backup-file-name-1
(let ((alist backup-directory-alist)
@ -171,7 +171,7 @@ tell you about it. Very annoying. This prevents that."
(if (string-match (car elt) file)
(setq backup-directory (cdr elt)
alist nil))))
(let ((file (funcall orig-fn file)))
(let ((file (funcall fn file)))
(if (or (null backup-directory)
(not (file-name-absolute-p backup-directory)))
file
@ -385,17 +385,17 @@ the unwritable tidbits."
:after-while #'save-place-find-file-hook
(if buffer-file-name (ignore-errors (recenter))))
(defadvice! doom--inhibit-saveplace-in-long-files-a (orig-fn &rest args)
(defadvice! doom--inhibit-saveplace-in-long-files-a (fn &rest args)
:around #'save-place-to-alist
(unless doom-large-file-p
(apply orig-fn args)))
(apply fn args)))
(defadvice! doom--dont-prettify-saveplace-cache-a (orig-fn)
(defadvice! doom--dont-prettify-saveplace-cache-a (fn)
"`save-place-alist-to-file' uses `pp' to prettify the contents of its cache.
`pp' can be expensive for longer lists, and there's no reason to prettify cache
files, so this replace calls to `pp' with the much faster `prin1'."
:around #'save-place-alist-to-file
(letf! ((#'pp #'prin1)) (funcall orig-fn))))
(letf! ((#'pp #'prin1)) (funcall fn))))
(use-package! server
@ -426,20 +426,20 @@ files, so this replace calls to `pp' with the much faster `prin1'."
(global-set-key [remap evil-jump-backward] #'better-jumper-jump-backward)
(global-set-key [remap xref-pop-marker-stack] #'better-jumper-jump-backward)
:config
(defun doom-set-jump-a (orig-fn &rest args)
"Set a jump point and ensure ORIG-FN doesn't set any new jump points."
(defun doom-set-jump-a (fn &rest args)
"Set a jump point and ensure 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)))
(apply fn args)))
(defun doom-set-jump-maybe-a (orig-fn &rest args)
"Set a jump point if ORIG-FN returns non-nil."
(defun doom-set-jump-maybe-a (fn &rest args)
"Set a jump point if fn returns non-nil."
(let ((origin (point-marker))
(result
(let* ((evil--jumps-jumping t)
(better-jumper--jumping t))
(apply orig-fn args))))
(apply fn args))))
(unless result
(with-current-buffer (marker-buffer origin)
(better-jumper-set-jump
@ -489,7 +489,7 @@ files, so this replace calls to `pp' with the much faster `prin1'."
(push '(t tab-width) dtrt-indent-hook-generic-mapping-list)
(defvar dtrt-indent-run-after-smie)
(defadvice! doom--fix-broken-smie-modes-a (orig-fn arg)
(defadvice! doom--fix-broken-smie-modes-a (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
@ -502,7 +502,7 @@ files, so this replace calls to `pp' with the much faster `prin1'."
(message "[WARNING] Indent detection: %s"
(error-message-string e))
(message ""))))) ; warn silently
(funcall orig-fn arg)))))
(funcall fn arg)))))
(use-package! helpful
;; a better *help* buffer
@ -517,11 +517,11 @@ files, so this replace calls to `pp' with the much faster `prin1'."
(global-set-key [remap describe-key] #'helpful-key)
(global-set-key [remap describe-symbol] #'helpful-symbol)
(defun doom-use-helpful-a (orig-fn &rest args)
"Force ORIG-FN to use helpful instead of the old describe-* commands."
(defun doom-use-helpful-a (fn &rest args)
"Force FN to use helpful instead of the old describe-* commands."
(letf! ((#'describe-function #'helpful-function)
(#'describe-variable #'helpful-variable))
(apply orig-fn args)))
(apply fn args)))
(after! apropos
;; patch apropos buttons to call helpful instead of help

View file

@ -367,13 +367,13 @@ This value is cached. If REFRESH-P, then don't use the cached value."
;; HACK Fix `:load-path' so it resolves relative paths to the containing file,
;; rather than `user-emacs-directory'. This is a done as a convenience
;; for users, wanting to specify a local directory.
(defadvice! doom--resolve-load-path-from-containg-file-a (orig-fn label arg &optional recursed)
(defadvice! doom--resolve-load-path-from-containg-file-a (fn label arg &optional recursed)
"Resolve :load-path from the current directory."
:around #'use-package-normalize-paths
;; `use-package-normalize-paths' resolves paths relative to
;; `user-emacs-directory', so we change that.
(let ((user-emacs-directory (if (stringp arg) (dir!))))
(funcall orig-fn label arg recursed)))
(funcall fn label arg recursed)))
;; Adds two keywords to `use-package' to expand its lazy-loading capabilities:
;;

View file

@ -102,10 +102,10 @@ uses a straight or package.el command directly).")
;; `let-alist' is built into Emacs 26 and onwards
(add-to-list 'straight-built-in-pseudo-packages 'let-alist))
(defadvice! doom--read-pinned-packages-a (orig-fn &rest args)
(defadvice! doom--read-pinned-packages-a (fn &rest args)
"Read `:pin's in `doom-packages' on top of straight's lockfiles."
:around #'straight--lockfile-read-all
(append (apply orig-fn args) ; lockfiles still take priority
(append (apply fn args) ; lockfiles still take priority
(doom-package-pinned-list)))

View file

@ -181,7 +181,7 @@ And if it's a function, evaluate it."
(if IS-WINDOWS " --path-separator=/")))
("find . -type f -print0"))))
(defadvice! doom--projectile-default-generic-command-a (orig-fn &rest args)
(defadvice! doom--projectile-default-generic-command-a (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
@ -190,7 +190,7 @@ when using many of projectile's command, e.g. `projectile-compile-command',
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))))
(ignore-errors (apply fn args))))
;;

View file

@ -103,30 +103,30 @@ font to that size. It's rarely a good idea to do so!")
(run-hooks 'doom-switch-frame-hook)
(setq doom--last-frame (selected-frame)))))
(defun doom-run-switch-buffer-hooks-a (orig-fn buffer-or-name &rest args)
(defun doom-run-switch-buffer-hooks-a (fn buffer-or-name &rest args)
(if (or doom-inhibit-switch-buffer-hooks
(and buffer-or-name
(eq (current-buffer)
(get-buffer buffer-or-name)))
(and (eq orig-fn #'switch-to-buffer) (car args)))
(apply orig-fn buffer-or-name args)
(and (eq fn #'switch-to-buffer) (car args)))
(apply fn buffer-or-name args)
(let ((gc-cons-threshold most-positive-fixnum)
(doom-inhibit-switch-buffer-hooks t)
(inhibit-redisplay t))
(when-let (buffer (apply orig-fn buffer-or-name args))
(when-let (buffer (apply fn buffer-or-name args))
(with-current-buffer (if (windowp buffer)
(window-buffer buffer)
buffer)
(run-hooks 'doom-switch-buffer-hook))
buffer))))
(defun doom-run-switch-to-next-prev-buffer-hooks-a (orig-fn &rest args)
(defun doom-run-switch-to-next-prev-buffer-hooks-a (fn &rest args)
(if doom-inhibit-switch-buffer-hooks
(apply orig-fn args)
(apply fn args)
(let ((gc-cons-threshold most-positive-fixnum)
(doom-inhibit-switch-buffer-hooks t)
(inhibit-redisplay t))
(when-let (buffer (apply orig-fn args))
(when-let (buffer (apply fn args))
(with-current-buffer buffer
(run-hooks 'doom-switch-buffer-hook))
buffer))))
@ -499,13 +499,13 @@ windows, switch to `doom-fallback-buffer'. Otherwise, delegate to original
(set-fontset-font t 'unicode font nil 'append)))))
:config
(cond ((daemonp)
(defadvice! doom--disable-all-the-icons-in-tty-a (orig-fn &rest args)
(defadvice! doom--disable-all-the-icons-in-tty-a (fn &rest args)
"Return a blank string in tty Emacs, which doesn't support multiple fonts."
: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 (or (not after-init-time) (display-multi-font-p))
(apply orig-fn args)
(apply fn args)
"")))
((not (display-graphic-p))
(defadvice! doom--disable-all-the-icons-in-tty-a (&rest _)
@ -617,7 +617,7 @@ windows, switch to `doom-fallback-buffer'. Otherwise, delegate to original
(with-selected-frame (or frame (selected-frame))
(load-theme doom-theme t))))
(defadvice! doom--load-theme-a (orig-fn theme &optional no-confirm no-enable)
(defadvice! doom--load-theme-a (fn theme &optional no-confirm no-enable)
"Record `doom-theme', disable old themes, and trigger `doom-load-theme-hook'."
:around #'load-theme
;; Run `load-theme' from an estranged buffer, where we can ensure that
@ -628,7 +628,7 @@ windows, switch to `doom-fallback-buffer'. Otherwise, delegate to original
;; Disable previous themes so there are no conflicts. If you truly want
;; multiple themes enabled, then use `enable-theme' instead.
(mapc #'disable-theme custom-enabled-themes)
(prog1 (funcall orig-fn theme no-confirm no-enable)
(prog1 (funcall fn theme no-confirm no-enable)
(when (and (not no-enable) (custom-theme-enabled-p theme))
(setq doom-theme theme)
(put 'doom-theme 'previous-themes (or last-themes 'none))

View file

@ -243,20 +243,15 @@ users).")
request-storage-directory (concat doom-cache-dir "request")
shared-game-score-directory (concat doom-etc-dir "shared-game-score/"))
(defadvice! doom--write-to-etc-dir-a (orig-fn &rest args)
"Resolve Emacs storage directory to `doom-etc-dir', to keep local files from
polluting `doom-emacs-dir'."
:around #'locate-user-emacs-file
(let ((user-emacs-directory doom-etc-dir))
(apply orig-fn args)))
(defadvice! doom--write-enabled-commands-to-doomdir-a (orig-fn &rest args)
(defadvice! doom--write-to-sane-paths-a (fn &rest args)
"When enabling a disabled command, the `put' call is written to
~/.emacs.d/init.el, which causes issues for Doom, so write it to the user's
config.el instead."
:around #'en/disable-command
(let ((user-init-file custom-file))
(apply orig-fn args)))
:around #'locate-user-emacs-file
(let ((user-emacs-directory doom-etc-dir)
(user-init-file custom-file))
(apply fn args)))
;;

View file

@ -139,7 +139,7 @@
#'+spell/correct))
;; TODO PR this fix upstream!
(defadvice! +spell--fix-face-detection-a (orig-fn &rest args)
(defadvice! +spell--fix-face-detection-a (fn &rest args)
"`spell-fu--faces-at-point' uses face detection that won't penetrary
overlays (like `hl-line'). This makes `spell-fu-faces-exclude' demonstrably less
useful when it'll still spellcheck excluded faces on any line that `hl-line' is
@ -148,7 +148,7 @@ displayed on, even momentarily."
(letf! (defun get-char-property (pos prop &optional obj)
(or (plist-get (text-properties-at pos) prop)
(funcall get-char-property pos prop obj)))
(apply orig-fn args)))
(apply fn args)))
(defadvice! +spell--create-word-dict-a (_word words-file _action)
"Prevent `spell-fu--word-add-or-remove' from throwing non-existant

View file

@ -211,10 +211,10 @@ results buffer.")
;; HACK Fix an issue where `counsel-projectile-find-file-action' would try to
;; open a candidate in an occur buffer relative to the wrong buffer,
;; causing it to fail to find the file we want.
(defadvice! +ivy--run-from-ivy-directory-a (orig-fn &rest args)
(defadvice! +ivy--run-from-ivy-directory-a (fn &rest args)
:around #'counsel-projectile-find-file-action
(let ((default-directory (ivy-state-directory ivy-last)))
(apply orig-fn args)))
(apply fn args)))
;; Don't use ^ as initial input. Set this here because `counsel' defines more
;; of its own, on top of the defaults.

View file

@ -118,26 +118,26 @@ more information on modifiers."
(back-to-indentation)))))))
;;;###autoload
(defun +evil--insert-newline-below-and-respect-comments-a (orig-fn count)
(defun +evil--insert-newline-below-and-respect-comments-a (fn count)
(if (or (not +evil-want-o/O-to-continue-comments)
(not (eq this-command 'evil-open-below))
(evil-insert-state-p)
(evil-emacs-state-p))
(funcall orig-fn count)
(funcall fn count)
(letf! (defun evil-insert-newline-below () (+evil--insert-newline))
(let ((evil-auto-indent evil-auto-indent))
(funcall orig-fn count)))))
(funcall fn count)))))
;;;###autoload
(defun +evil--insert-newline-above-and-respect-comments-a (orig-fn count)
(defun +evil--insert-newline-above-and-respect-comments-a (fn count)
(if (or (not +evil-want-o/O-to-continue-comments)
(not (eq this-command 'evil-open-above))
(evil-insert-state-p)
(evil-emacs-state-p))
(funcall orig-fn count)
(funcall fn count)
(letf! (defun evil-insert-newline-above () (+evil--insert-newline 'above))
(let ((evil-auto-indent evil-auto-indent))
(funcall orig-fn count)))))
(funcall fn count)))))
;;;###autoload (autoload '+evil-window-split-a "editor/evil/autoload/advice" nil t)
(evil-define-command +evil-window-split-a (&optional count file)
@ -179,7 +179,7 @@ more information on modifiers."
(if file (evil-edit file)))
;;;###autoload (autoload '+evil-join-a "editor/evil/autoload/advice" nil nil)
(defun +evil-join-a (orig-fn beg end)
(defun +evil-join-a (fn beg end)
"Join the selected lines.
This advice improves on `evil-join' by removing comment delimiters when joining
@ -189,7 +189,7 @@ From https://github.com/emacs-evil/evil/issues/606"
;; But revert to the default we're not in a comment, where
;; `fill-region-as-paragraph' is too greedy.
(if (not (doom-point-in-comment-p (min (max beg (1+ (point))) end)))
(funcall orig-fn beg end)
(funcall fn beg end)
(let* ((count (count-lines beg end))
(count (if (> count 1) (1- count) count))
(fixup-mark (make-marker)))

View file

@ -134,9 +134,9 @@ directives. By default, this only recognizes C directives.")
;; HACK '=' moves the cursor to the beginning of selection. Disable this,
;; since it's more disruptive than helpful.
(defadvice! +evil--dont-move-cursor-a (orig-fn &rest args)
(defadvice! +evil--dont-move-cursor-a (fn &rest args)
:around #'evil-indent
(save-excursion (apply orig-fn args)))
(save-excursion (apply fn args)))
;; REVIEW In evil, registers 2-9 are buffer-local. In vim, they're global,
;; so... Perhaps this should be PRed upstream?
@ -166,11 +166,11 @@ directives. By default, this only recognizes C directives.")
;; Prevent gw (`evil-fill') and gq (`evil-fill-and-move') from squeezing
;; spaces. It doesn't in vim, so it shouldn't in evil.
(defadvice! +evil--no-squeeze-on-fill-a (orig-fn &rest args)
(defadvice! +evil--no-squeeze-on-fill-a (fn &rest args)
:around '(evil-fill evil-fill-and-move)
(letf! (defun fill-region (from to &optional justify nosqueeze to-eop)
(funcall fill-region from to justify t to-eop))
(apply orig-fn args)))
(apply fn args)))
;; Make ESC (from normal mode) the universal escaper. See `doom-escape-hook'.
(advice-add #'evil-force-normal-state :after #'+evil-escape-a)

View file

@ -251,10 +251,10 @@ and complains if a module is loaded too early (during startup)."
(with-demoted-errors "evil-collection error: %s"
(evil-collection-init (list module)))))
(defadvice! +evil-collection-disable-blacklist-a (orig-fn)
(defadvice! +evil-collection-disable-blacklist-a (fn)
:around #'evil-collection-vterm-toggle-send-escape ; allow binding to ESC
(let (evil-collection-key-blacklist)
(funcall-interactively orig-fn)))
(funcall-interactively fn)))
;; These modes belong to packages that Emacs always loads at startup, causing
;; evil-collection and it's co-packages to all load immediately. We avoid this

View file

@ -146,10 +146,10 @@ must be non-read-only, empty, and there must be a rule in
(when-let (rule (cl-find-if #'+file-template-p +file-templates-alist))
(apply #'+file-templates--expand rule))))
(defadvice! +file-templates-inhibit-in-org-capture-a (orig-fn &rest args)
(defadvice! +file-templates-inhibit-in-org-capture-a (fn &rest args)
:around #'org-capture
(let ((+file-templates-inhibit t))
(apply orig-fn args)))
(apply fn args)))
;;

View file

@ -99,7 +99,7 @@ Stolen shamelessly from go-mode"
(if fmt (intern fmt))))
;;;###autoload
(defun +format-probe-a (orig-fn)
(defun +format-probe-a (fn)
"Use `+format-with' instead, if it is set.
Prompts for a formatter if universal arg is set."
(cond ((or buffer-read-only (eq +format-with :none))
@ -118,7 +118,7 @@ Prompts for a formatter if universal arg is set."
(bound-and-true-p eglot--managed-mode)
(eglot--server-capable :documentFormattingProvider))
(list 'eglot nil))
((funcall orig-fn))))
((funcall fn))))
;;;###autoload
(defun +format-buffer-a (formatter mode-result)

View file

@ -71,7 +71,7 @@ This is controlled by `+format-on-save-enabled-modes'."
;; Don't pop up imposing warnings about missing formatters, but still log it in
;; to *Messages*.
(defadvice! +format--all-buffer-from-hook-a (orig-fn &rest args)
(defadvice! +format--all-buffer-from-hook-a (fn &rest args)
:around #'format-all-buffer--from-hook
(letf! (defun format-all-buffer--with (formatter mode-result)
(when (or (eq formatter 'lsp)
@ -83,4 +83,4 @@ This is controlled by `+format-on-save-enabled-modes'."
(gethash formatter format-all--executable-table))
nil)))
(funcall format-all-buffer--with formatter mode-result)))
(apply orig-fn args)))
(apply fn args)))

View file

@ -92,7 +92,7 @@
;; HACK Allow these commands to be repeated by prefixing them with a numerical
;; argument. See gabesoft/evil-mc#110
(defadvice! +multiple-cursors--make-repeatable-a (orig-fn)
(defadvice! +multiple-cursors--make-repeatable-a (fn)
:around '(evil-mc-make-and-goto-first-cursor
evil-mc-make-and-goto-last-cursor
evil-mc-make-and-goto-prev-cursor
@ -104,7 +104,7 @@
evil-mc-skip-and-goto-prev-match
evil-mc-skip-and-goto-next-match)
(dotimes (i (if (integerp current-prefix-arg) current-prefix-arg 1))
(funcall orig-fn)))
(funcall fn)))
;; If we're entering insert mode, it's a good bet that we want to start using
;; our multiple cursors

View file

@ -297,15 +297,14 @@ shadow the default snippet)."
;;; Advice
;;;###autoload
(defun +snippets-expand-on-region-a (orig-fn &optional no-condition)
(defun +snippets-expand-on-region-a (fn &optional no-condition)
"Fix off-by-one when expanding snippets on an evil visual region.
Also strips whitespace out of selection. Also switches to insert mode. If
`evil-local-mode' isn't enabled, or we're not in visual mode, run ORIG-FN as
is."
`evil-local-mode' isn't enabled, or we're not in visual mode, run FN as is."
(if (not (and (bound-and-true-p evil-local-mode)
(evil-visual-state-p)))
(funcall orig-fn no-condition)
(funcall fn no-condition)
;; Trim whitespace in selected region, so as not to introduce extra
;; whitespace into `yas-selected-text'.
(evil-visual-select (save-excursion
@ -319,7 +318,7 @@ is."
'inclusive)
(letf! ((defun region-beginning () evil-visual-beginning)
(defun region-end () evil-visual-end))
(funcall orig-fn no-condition)))
(funcall fn no-condition)))
(when (and (bound-and-true-p evil-local-mode)
(not (or (evil-emacs-state-p)
(evil-insert-state-p)))

View file

@ -124,11 +124,11 @@
:defer t
:config
(setq aya-persist-snippets-dir +snippets-dir)
(defadvice! +snippets--inhibit-yas-global-mode-a (orig-fn &rest args)
(defadvice! +snippets--inhibit-yas-global-mode-a (fn &rest args)
"auto-yasnippet enables `yas-global-mode'. This is obnoxious for folks like
us who use yas-minor-mode and enable yasnippet more selectively. This advice
swaps `yas-global-mode' with `yas-minor-mode'."
:around '(aya-expand aya-open-line)
(letf! ((#'yas-global-mode #'yas-minor-mode)
(yas-global-mode yas-minor-mode))
(apply orig-fn args))))
(apply fn args))))

View file

@ -7,10 +7,10 @@
(defvar +word-wrap--major-mode-indent-var nil)
(defvar adaptive-wrap-extra-indent)
(defun +word-wrap--adjust-extra-indent-a (orig-fn beg end)
(defun +word-wrap--adjust-extra-indent-a (fn beg end)
"Contextually adjust extra word-wrap indentation."
(let ((adaptive-wrap-extra-indent (+word-wrap--calc-extra-indent beg)))
(funcall orig-fn beg end)))
(funcall fn beg end)))
(defun +word-wrap--calc-extra-indent (p)
"Calculate extra word-wrap indentation at point."

View file

@ -49,7 +49,7 @@
(setq git-timemachine-show-minibuffer-details t)
;; TODO PR this to `git-timemachine'
(defadvice! +vc-support-git-timemachine-a (orig-fn)
(defadvice! +vc-support-git-timemachine-a (fn)
"Allow `browse-at-remote' commands in git-timemachine buffers to open that
file in your browser at the visited revision."
:around #'browse-at-remote-get-url
@ -71,7 +71,7 @@ file in your browser at the visited revision."
(funcall url-formatter repo-url ref relname
(if start-line start-line)
(if (and end-line (not (equal start-line end-line))) end-line)))
(funcall orig-fn)))
(funcall fn)))
(defadvice! +vc-update-header-line-a (revision)
"Show revision details in the header-line, instead of the minibuffer.

View file

@ -273,20 +273,20 @@ Usefull for affecting HTML export config.")
(setq +mu4e-compose-org-msg-toggle-next
(not +mu4e-compose-org-msg-toggle-next))))
(defadvice! +mu4e-maybe-toggle-org-msg-a (orig-fn &optional toggle-p)
(defadvice! +mu4e-maybe-toggle-org-msg-a (fn &optional toggle-p)
:around #'mu4e-compose-new
:around #'mu4e-compose-reply
:around #'mu4e-compose-forward
:around #'mu4e-compose-resend
(interactive "p")
(+mu4e-compose-org-msg-handle-toggle (/= 1 (or toggle-p 0)))
(funcall orig-fn))
(funcall fn))
(defadvice! +mu4e-draft-open-signature-a (orig-fn &rest args)
(defadvice! +mu4e-draft-open-signature-a (fn &rest args)
"Prevent `mu4e-compose-signature' from being used with `org-msg-mode'."
:around #'mu4e-draft-open
(let ((mu4e-compose-signature (unless org-msg-mode mu4e-compose-signature)))
(apply orig-fn args)))
(apply fn args)))
(map! :map org-msg-edit-mode-map
"TAB" #'org-msg-tab) ; only <tab> bound by default

View file

@ -155,7 +155,7 @@
;; Advice
;;;###autoload
(defun +notmuch-dont-confirm-on-kill-process-a (orig-fn &rest args)
(defun +notmuch-dont-confirm-on-kill-process-a (fn &rest args)
"Don't prompt for confirmation when killing notmuch sentinel."
(let (confirm-kill-processes)
(apply orig-fn args)))
(apply fn args)))

View file

@ -70,9 +70,9 @@ This is ignored by ccls.")
;; HACK Suppress 'Args out of range' error in when multiple modifications are
;; performed at once in a `c++-mode' buffer, e.g. with `iedit' or
;; multiple cursors.
(undefadvice! +cc--suppress-silly-errors-a (orig-fn &rest args)
(undefadvice! +cc--suppress-silly-errors-a (fn &rest args)
:around #'c-after-change-mark-abnormal-strings
(ignore-errors (apply orig-fn args)))
(ignore-errors (apply fn args)))
;; Custom style, based off of linux
(setq c-basic-offset tab-width

View file

@ -35,13 +35,13 @@
(when (featurep! +lsp)
(add-hook 'csharp-mode-local-vars-hook #'lsp!))
(defadvice! +csharp-disable-clear-string-fences-a (orig-fn &rest args)
(defadvice! +csharp-disable-clear-string-fences-a (fn &rest args)
"This turns off `c-clear-string-fences' for `csharp-mode'. When
on for `csharp-mode' font lock breaks after an interpolated string
or terminating simple string."
:around #'csharp-disable-clear-string-fences
(unless (eq major-mode 'csharp-mode)
(apply orig-fn args))))
(apply fn args))))
(use-package! omnisharp
:unless (featurep! +lsp)

View file

@ -115,10 +115,10 @@ employed so that flycheck still does *some* helpful linting.")
;; Recenter window after following definition
(advice-add #'elisp-def :after #'doom-recenter-a)
(defadvice! +emacs-lisp-append-value-to-eldoc-a (orig-fn sym)
(defadvice! +emacs-lisp-append-value-to-eldoc-a (fn sym)
"Display variable value next to documentation in eldoc."
:around #'elisp-get-var-docstring
(when-let (ret (funcall orig-fn sym))
(when-let (ret (funcall fn sym))
(if (boundp sym)
(concat ret " "
(let* ((truncated " [...]")
@ -209,10 +209,10 @@ employed so that flycheck still does *some* helpful linting.")
(advice-add 'describe-function-1 :after #'elisp-demos-advice-describe-function-1)
(advice-add 'helpful-update :after #'elisp-demos-advice-helpful-update)
:config
(defadvice! +emacs-lisp--add-doom-elisp-demos-a (orig-fn symbol)
(defadvice! +emacs-lisp--add-doom-elisp-demos-a (fn symbol)
"Add Doom's own demos to help buffers."
:around #'elisp-demos--search
(or (funcall orig-fn symbol)
(or (funcall fn symbol)
(when-let (demos-file (doom-module-locate-path :lang 'emacs-lisp "demos.org"))
(with-temp-buffer
(insert-file-contents demos-file)

View file

@ -19,7 +19,7 @@
(set-company-backend! 'dante-mode #'dante-company)
(defadvice! +haskell--restore-modified-state-a (orig-fn &rest args)
(defadvice! +haskell--restore-modified-state-a (fn &rest args)
"Marks the buffer as falsely modified.
Dante quietly saves the current buffer (without triggering save hooks) before
invoking flycheck, unexpectedly leaving the buffer in an unmodified state. This
@ -27,7 +27,7 @@ is annoying if we depend on save hooks to do work on the buffer (like
reformatting)."
:around #'dante-async-load-current-buffer
(let ((modified-p (buffer-modified-p)))
(apply orig-fn args)
(apply fn args)
(if modified-p (set-buffer-modified-p t))))
(when (featurep 'evil)

View file

@ -15,11 +15,11 @@
:definition #'meghanada-jump-declaration
:references #'meghanada-reference)
(defadvice! +java-meghanada-fail-gracefully-a (orig-fn &rest args)
(defadvice! +java-meghanada-fail-gracefully-a (fn &rest args)
"Toggle `meghanada-mode'. Fail gracefully if java is unavailable."
:around #'meghanada-mode
(if (executable-find meghanada-java-path)
(apply orig-fn args)
(apply fn args)
(message "Can't find %S binary. Is java installed? Aborting `meghanada-mode'."
meghanada-java-path)))

View file

@ -51,7 +51,7 @@
(setq latex-preview-pane-multifile-mode 'auctex)
;; TODO PR this to maintained fork. Original project appears abandoned
(defadvice! +latex--dont-reopen-preview-pane-a (orig-fn &rest args)
(defadvice! +latex--dont-reopen-preview-pane-a (fn &rest args)
"Once the preview pane has been closed it should not be reopened."
:around #'latex-preview-pane-update
(letf! (defun init-latex-preview-pane (&rest _)
@ -59,7 +59,7 @@
;; window, but it's already gone, so it ends up deleting the
;; wrong window.
(setq-local latex-preview-pane-mode nil))
(apply orig-fn args)))
(apply fn args)))
(define-key! doc-view-mode-map
"ESC" #'delete-window

View file

@ -167,19 +167,19 @@ Math faces should stay fixed by the mixed-pitch blacklist, this is mostly for
(add-to-list 'LaTeX-indent-environment-list `(,env +latex-indent-item-fn)))
;; Fix #1849: allow fill-paragraph in itemize/enumerate
(defadvice! +latex--re-indent-itemize-and-enumerate-a (orig-fn &rest args)
(defadvice! +latex--re-indent-itemize-and-enumerate-a (fn &rest args)
:around #'LaTeX-fill-region-as-para-do
(let ((LaTeX-indent-environment-list
(append LaTeX-indent-environment-list
'(("itemize" +latex-indent-item-fn)
("enumerate" +latex-indent-item-fn)))))
(apply orig-fn args)))
(defadvice! +latex--dont-indent-itemize-and-enumerate-a (orig-fn &rest args)
(apply fn args)))
(defadvice! +latex--dont-indent-itemize-and-enumerate-a (fn &rest args)
:around #'LaTeX-fill-region-as-paragraph
(let ((LaTeX-indent-environment-list LaTeX-indent-environment-list))
(delq! "itemize" LaTeX-indent-environment-list 'assoc)
(delq! "enumerate" LaTeX-indent-environment-list 'assoc)
(apply orig-fn args))))
(apply fn args))))
(use-package! preview

View file

@ -13,11 +13,11 @@
'(("^\\*Ledger Report" :size 0.5 :quit 'other :ttl 0)
("^\\*Ledger Error" :quit t :ttl 0)))
(defadvice! +ledger--fail-gracefully-if-absent-a (orig-fn)
(defadvice! +ledger--fail-gracefully-if-absent-a (fn)
"Fail gracefully if ledger binary isn't available."
:around #'ledger-check-version
(if (executable-find ledger-binary-path)
(funcall orig-fn)
(funcall fn)
(message "Couldn't find '%s' executable" ledger-binary-path)))
;; `ledger-mode' lacks imenu support out of the box, so we gie it some. At
@ -74,10 +74,10 @@
"s" #'ledger-display-ledger-stats
"b" #'ledger-display-balance-at-point)))
(defadvice! +ledger--fix-key-help-a (orig-fn &rest args)
(defadvice! +ledger--fix-key-help-a (fn &rest args)
"Fix inaccurate keybind message."
:around #'ledger-report
(quiet! (apply orig-fn args))
(quiet! (apply fn args))
(with-current-buffer (get-buffer ledger-report-buffer-name)
(setq header-line-format
(substitute-command-keys

View file

@ -238,7 +238,7 @@ Is relative to `org-directory', unless it is absolute. Is used in Doom's default
(after! ob
(add-to-list 'org-babel-default-lob-header-args '(:sync)))
(defadvice! +org-babel-disable-async-maybe-a (orig-fn &optional fn arg info params)
(defadvice! +org-babel-disable-async-maybe-a (fn &optional orig-fn arg info params)
"Use ob-comint where supported, disable async altogether where it isn't.
We have access to two async backends: ob-comint or ob-async, which have
@ -251,8 +251,8 @@ Note: ob-comint support will only kick in for languages listed in
Also adds support for a `:sync' parameter to override `:async'."
:around #'ob-async-org-babel-execute-src-block
(if (null fn)
(funcall orig-fn fn arg info params)
(if (null orig-fn)
(funcall fn orig-fn arg info params)
(let* ((info (or info (org-babel-get-src-block-info)))
(params (org-babel-merge-params (nth 2 info) params)))
(if (or (assq :sync params)
@ -271,8 +271,8 @@ Also adds support for a `:sync' parameter to override `:async'."
(car info))
(sleep-for 0.2))
t))
(funcall fn arg info params)
(funcall orig-fn fn arg info params)))))
(funcall orig-fn arg info params)
(funcall fn orig-fn arg info params)))))
(defadvice! +org-fix-newline-and-indent-in-src-blocks-a (&optional indent _arg _interactive)
"Mimic `newline-and-indent' in src blocks w/ lang-appropriate indentation."
@ -283,10 +283,10 @@ Also adds support for a `:sync' parameter to override `:async'."
(org-babel-do-in-edit-buffer
(call-interactively #'indent-for-tab-command))))
(defadvice! +org-inhibit-mode-hooks-a (orig-fn datum name &optional initialize &rest args)
(defadvice! +org-inhibit-mode-hooks-a (fn datum name &optional initialize &rest args)
"Prevent potentially expensive mode hooks in `org-babel-do-in-edit-buffer' ops."
:around #'org-src--edit-element
(apply orig-fn datum name
(apply fn datum name
(if (and (eq org-src-window-setup 'switch-invisibly)
(functionp initialize))
;; org-babel-do-in-edit-buffer is used to execute quick, one-off
@ -426,9 +426,9 @@ I like:
;; HACK Doom doesn't support `customize'. Best not to advertise it as an
;; option in `org-capture's menu.
(defadvice! +org--remove-customize-option-a (orig-fn table title &optional prompt specials)
(defadvice! +org--remove-customize-option-a (fn table title &optional prompt specials)
:around #'org-mks
(funcall orig-fn table title prompt
(funcall fn table title prompt
(remove '("C" "Customize org-capture-templates")
specials)))
@ -572,14 +572,14 @@ relative to `org-directory', unless it is an absolute path."
(mathjax . t)
(variable . "revealjs-url=https://revealjs.com"))))
(defadvice! +org--dont-trigger-save-hooks-a (orig-fn &rest args)
(defadvice! +org--dont-trigger-save-hooks-a (fn &rest args)
"Exporting and tangling trigger save hooks; inadvertantly triggering
mutating hooks on exported output, like formatters."
:around '(org-export-to-file org-babel-tangle)
(let (before-save-hook after-save-hook)
(apply orig-fn args)))
(apply fn args)))
(defadvice! +org--fix-async-export-a (orig-fn &rest args)
(defadvice! +org--fix-async-export-a (fn &rest args)
:around '(org-export-to-file org-export-as)
(let ((old-async-init-file org-export-async-init-file)
(org-export-async-init-file (make-temp-file "doom-org-async-export")))
@ -593,7 +593,7 @@ mutating hooks on exported output, like formatters."
nil t)
(delete-file load-file-name)))
(current-buffer)))
(apply orig-fn args))))
(apply fn args))))
(defun +org-init-habit-h ()
@ -662,14 +662,14 @@ With numerical argument N, show content up to level N."
(when (get-buffer-window)
(recenter)))
(defadvice! +org--strip-properties-from-outline-a (orig-fn &rest args)
(defadvice! +org--strip-properties-from-outline-a (fn &rest args)
"Fix variable height faces in eldoc breadcrumbs."
:around #'org-format-outline-path
(let ((org-level-faces
(cl-loop for face in org-level-faces
collect `(:foreground ,(face-foreground face nil t)
:weight bold))))
(apply orig-fn args)))
(apply fn args)))
(after! org-eldoc
;; HACK Fix #2972: infinite recursion when eldoc kicks in in 'org' or
@ -710,7 +710,7 @@ can grow up to be fully-fledged org-mode buffers."
nil 'local)))))
(defvar recentf-exclude)
(defadvice! +org--optimize-backgrounded-agenda-buffers-a (orig-fn file)
(defadvice! +org--optimize-backgrounded-agenda-buffers-a (fn file)
"Prevent temporarily opened agenda buffers from polluting recentf."
:around #'org-get-agenda-file-buffer
(let ((recentf-exclude (list (lambda (_file) t)))
@ -720,18 +720,18 @@ can grow up to be fully-fledged org-mode buffers."
vc-handled-backends
org-mode-hook
find-file-hook)
(funcall orig-fn file)))
(funcall fn file)))
;; HACK With https://code.orgmode.org/bzg/org-mode/commit/48da60f4, inline
;; image previews broke for users with imagemagick support built in. This
;; reverses the problem, but should be removed once it is addressed
;; upstream (if ever).
(defadvice! +org--fix-inline-images-for-imagemagick-users-a (orig-fn &rest args)
(defadvice! +org--fix-inline-images-for-imagemagick-users-a (fn &rest args)
:around #'org-display-inline-images
(letf! (defun create-image (file-or-data &optional type data-p &rest props)
(let ((type (if (plist-get props :width) type)))
(apply create-image file-or-data type data-p props)))
(apply orig-fn args)))
(apply fn args)))
(defadvice! +org--fix-inconsistent-uuidgen-case-a (uuid)
"Ensure uuidgen always produces lowercase output regardless of system."
@ -1023,12 +1023,12 @@ compelling reason, so..."
:config
(setq toc-org-hrefify-default "gh")
(defadvice! +org-inhibit-scrolling-a (orig-fn &rest args)
(defadvice! +org-inhibit-scrolling-a (fn &rest args)
"Prevent the jarring scrolling that occurs when the-ToC is regenerated."
:around #'toc-org-insert-toc
(let ((p (set-marker (make-marker) (point)))
(s (window-start)))
(prog1 (apply orig-fn args)
(prog1 (apply fn args)
(goto-char p)
(set-window-start nil s t)
(set-marker p nil)))))

View file

@ -45,7 +45,7 @@ headings as titles, and you have more freedom to place them wherever you like.")
:n [C-left] #'org-tree-slide-move-previous-tree)
(add-hook 'org-tree-slide-mode-hook #'evil-normalize-keymaps))
(defadvice! +org-present--hide-first-heading-maybe-a (orig-fn &rest args)
(defadvice! +org-present--hide-first-heading-maybe-a (fn &rest args)
"Omit the first heading if `+org-present-hide-first-heading' is non-nil."
:around #'org-tree-slide--display-tree-with-narrow
(letf! (defun org-narrow-to-subtree ()
@ -64,4 +64,4 @@ headings as titles, and you have more freedom to place them wherever you like.")
(when (and (org-at-heading-p) (not (eobp)))
(backward-char 1))
(point)))))))
(apply orig-fn args))))
(apply fn args))))

View file

@ -29,14 +29,14 @@ of org-mode to properly utilize ID links.")
;; Don't display warning message dedicated for v1 users. Need to be set early.
(setq org-roam-v2-ack t)
(defadvice! +org-roam-suppress-sqlite-build-a (orig-fn &rest args)
(defadvice! +org-roam-suppress-sqlite-build-a (fn &rest args)
"Suppress automatic building of sqlite3 binary when loading `org-roam'.
This is a blocking operation that can take a while to complete
and better be deferred when there will be an actual demand for
the database. See `+org-init-roam-h' for the launch process."
:around #'emacsql-sqlite-ensure-binary
(if (not (boundp 'org-roam-db-version))
(apply orig-fn args)
(apply fn args)
(advice-remove #'emacsql-sqlite-ensure-binary #'+org-roam-suppress-sqlite-build-a)
nil))

View file

@ -10,12 +10,12 @@
(setq-hook! 'restclient-mode-hook
imenu-generic-expression '((nil "^[A-Z]+\s+.+" 0)))
(defadvice! +rest--permit-self-signed-ssl-a (orig-fn &rest args)
(defadvice! +rest--permit-self-signed-ssl-a (fn &rest args)
"Forces underlying SSL verification to prompt for self-signed or invalid
certs, rather than reject them silently."
:around #'restclient-http-do
(let (gnutls-verify-error tls-checktrust)
(apply orig-fn args)))
(apply fn args)))
(map! :map restclient-mode-map
:n [return] #'+rest/dwim-at-point

View file

@ -30,7 +30,7 @@
(add-to-list 'editorconfig-exclude-regexps
"\\.\\(zip\\|\\(doc\\|xls\\|ppt\\)x\\)\\'")
(defadvice! +editorconfig--smart-detection-a (orig-fn)
(defadvice! +editorconfig--smart-detection-a (fn)
"Retrieve the properties for the current file. If it doesn't have an
extension, try to guess one."
:around #'editorconfig-call-editorconfig-exec
@ -42,7 +42,7 @@ extension, try to guess one."
(if-let (ext (alist-get major-mode +editorconfig-mode-alist))
(concat "." ext)
"")))))
(funcall orig-fn)))
(funcall fn)))
(add-hook! 'editorconfig-after-apply-functions
(defun +editorconfig-disable-indent-detection-h (props)

View file

@ -9,9 +9,9 @@
(set-popup-rule! "^\\*gist-" :ignore t)
(defadvice! +gist--open-in-popup-a (orig-fn &rest args)
(defadvice! +gist--open-in-popup-a (fn &rest args)
:around #'gist-list-render
(funcall orig-fn (car args) t)
(funcall fn (car args) t)
(unless (cadr args)
(pop-to-buffer (current-buffer))))

View file

@ -151,10 +151,10 @@ Dictionary.app behind the scenes to get definitions.")
;; xref to be one too.
(remove-hook 'xref-backend-functions #'etags--xref-backend)
;; ...however, it breaks `projectile-find-tag', unless we put it back.
(defadvice! +lookup--projectile-find-tag-a (orig-fn)
(defadvice! +lookup--projectile-find-tag-a (fn)
:around #'projectile-find-tag
(let ((xref-backend-functions '(etags--xref-backend t)))
(funcall orig-fn)))
(funcall fn)))
;; This integration is already built into evil
(unless (featurep! :editor evil)
@ -170,12 +170,12 @@ Dictionary.app behind the scenes to get definitions.")
;; HACK Fix #4386: `ivy-xref-show-xrefs' calls `fetcher' twice, which has
;; side effects that breaks in some cases (i.e. on `dired-do-find-regexp').
(defadvice! +lookup--fix-ivy-xrefs (orig-fn fetcher alist)
(defadvice! +lookup--fix-ivy-xrefs (fn fetcher alist)
:around #'ivy-xref-show-xrefs
(when (functionp fetcher)
(setf (alist-get 'fetched-xrefs alist)
(funcall fetcher)))
(funcall orig-fn fetcher alist)))
(funcall fn fetcher alist)))
(use-package! helm-xref
:when (featurep! :completion helm))

View file

@ -27,7 +27,7 @@
(after! flycheck
(load! "autoload/flycheck-eglot")))
(defadvice! +lsp--defer-server-shutdown-a (orig-fn &optional server)
(defadvice! +lsp--defer-server-shutdown-a (fn &optional server)
"Defer server shutdown for a few seconds.
This gives the user a chance to open other project files before the server is
auto-killed (which is a potentially expensive process). It also prevents the
@ -45,4 +45,4 @@ server getting expensively restarted when reverting buffers."
(prog1 (funcall eglot-shutdown server)
(+lsp-optimization-mode -1))))
server)))
(funcall orig-fn server))))
(funcall fn server))))

View file

@ -73,14 +73,14 @@ about it (it will be logged to *Messages* however).")
:implementations '(lsp-find-implementation :async t)
:type-definition #'lsp-find-type-definition)
(defadvice! +lsp--respect-user-defined-checkers-a (orig-fn &rest args)
(defadvice! +lsp--respect-user-defined-checkers-a (fn &rest args)
"Ensure user-defined `flycheck-checker' isn't overwritten by `lsp'."
:around #'lsp-diagnostics-flycheck-enable
(if flycheck-checker
(let ((old-checker flycheck-checker))
(apply orig-fn args)
(apply fn args)
(setq-local flycheck-checker old-checker))
(apply orig-fn args)))
(apply fn args)))
(add-hook! 'lsp-mode-hook
(defun +lsp-display-guessed-project-root-h ()
@ -102,7 +102,7 @@ about it (it will be logged to *Messages* however).")
(remq 'company-capf company-backends))))))))
(defvar +lsp--deferred-shutdown-timer nil)
(defadvice! +lsp-defer-server-shutdown-a (orig-fn &optional restart)
(defadvice! +lsp-defer-server-shutdown-a (fn &optional restart)
"Defer server shutdown for a few seconds.
This gives the user a chance to open other project files before the server is
auto-killed (which is a potentially expensive process). It also prevents the
@ -112,7 +112,7 @@ server getting expensively restarted when reverting buffers."
restart
(null +lsp-defer-shutdown)
(= +lsp-defer-shutdown 0))
(prog1 (funcall orig-fn restart)
(prog1 (funcall fn restart)
(+lsp-optimization-mode -1))
(when (timerp +lsp--deferred-shutdown-timer)
(cancel-timer +lsp--deferred-shutdown-timer))
@ -123,11 +123,11 @@ server getting expensively restarted when reverting buffers."
(with-lsp-workspace workspace
(unless (lsp--workspace-buffers workspace)
(let ((lsp-restart 'ignore))
(funcall orig-fn))
(funcall fn))
(+lsp-optimization-mode -1))))
lsp--cur-workspace))))
(defadvice! +lsp-dont-prompt-to-install-servers-maybe-a (orig-fn &rest args)
(defadvice! +lsp-dont-prompt-to-install-servers-maybe-a (fn &rest args)
:around #'lsp
(when (buffer-file-name)
(require 'lsp-mode)
@ -136,7 +136,7 @@ server getting expensively restarted when reverting buffers."
(-andfn #'lsp--matching-clients?
#'lsp--server-binary-present?))
(not (memq +lsp-prompt-to-install-server '(nil quiet))))
(apply orig-fn args)
(apply fn args)
;; HACK `lsp--message' overrides `inhibit-message', so use `quiet!'
(let ((doom-debug-p
(or doom-debug-p
@ -169,12 +169,12 @@ server getting expensively restarted when reverting buffers."
(use-package! lsp-ui
:hook (lsp-mode . lsp-ui-mode)
:init
(defadvice! +lsp--use-hook-instead-a (orig-fn &rest args)
(defadvice! +lsp--use-hook-instead-a (fn &rest args)
"Change `lsp--auto-configure' to not force `lsp-ui-mode' on us. Using a hook
instead is more sensible."
:around #'lsp--auto-configure
(letf! ((#'lsp-ui-mode #'ignore))
(apply orig-fn args)))
(apply fn args)))
:config
(when (featurep! +peek)

View file

@ -18,11 +18,11 @@
(add-hook 'kill-buffer-hook #'+pdf-cleanup-windows-h nil t)))
:config
(defadvice! +pdf--install-epdfinfo-a (orig-fn &rest args)
(defadvice! +pdf--install-epdfinfo-a (fn &rest args)
"Install epdfinfo after the first PDF file, if needed."
:around #'pdf-view-mode
(if (file-executable-p pdf-info-epdfinfo-program)
(apply orig-fn args)
(apply fn args)
;; If we remain in pdf-view-mode, it'll spit out cryptic errors. This
;; graceful failure is better UX.
(fundamental-mode)
@ -74,10 +74,10 @@
nil 'local))))))
;; Silence "File *.pdf is large (X MiB), really open?" prompts for pdfs
(defadvice! +pdf-suppress-large-file-prompts-a (orig-fn size op-type filename &optional offer-raw)
(defadvice! +pdf-suppress-large-file-prompts-a (fn size op-type filename &optional offer-raw)
:around #'abort-if-file-too-large
(unless (string-match-p "\\.pdf\\'" filename)
(funcall orig-fn size op-type filename offer-raw))))
(funcall fn size op-type filename offer-raw))))
(use-package! saveplace-pdf-view

View file

@ -1,12 +1,12 @@
;;; tools/prodigy/config.el -*- lexical-binding: t; -*-
(after! prodigy
(defadvice! +prodigy--add-project-property-a (orig-fn &rest args)
(defadvice! +prodigy--add-project-property-a (fn &rest args)
"Adds a new :project property to prodigy services, which hides the service
unless invoked from the relevant project."
:around #'prodigy-services
(let ((project-root (downcase (or (doom-project-root) default-directory)))
(services (apply orig-fn args)))
(services (apply fn args)))
(if current-prefix-arg
services
(cl-remove-if-not (lambda (service)

View file

@ -28,12 +28,12 @@
("XXX" font-lock-constant-face bold)))
(defadvice! +hl-todo-clamp-font-lock-fontify-region-a (orig-fn &rest args)
(defadvice! +hl-todo-clamp-font-lock-fontify-region-a (fn &rest args)
"Fix an `args-out-of-range' error in some modes."
:around #'hl-todo-mode
(letf! (defun font-lock-fontify-region (beg end &optional loudly)
(funcall font-lock-fontify-region (max beg 1) end loudly))
(apply orig-fn args)))
(apply fn args)))
;; Use a more primitive todo-keyword detection method in major modes that
;; don't use/have a valid syntax table entry for comments.

View file

@ -9,7 +9,7 @@
;;;###package hydra
(setq lv-use-separator t)
(defadvice! +hydra--inhibit-window-switch-hooks-a (orig-fn)
(defadvice! +hydra--inhibit-window-switch-hooks-a (fn)
:around #'lv-window
(let ((doom-inhibit-switch-window-hooks t))
(funcall orig-fn)))
(funcall fn)))

View file

@ -41,10 +41,10 @@
:config
;; HACK Fix #4102 due to empty all-the-icons return value (caused by
;; `doom--disable-all-the-icons-in-tty-a' advice) in tty daemon frames.
(defadvice! +modeline-disable-icon-in-daemon-a (orig-fn &rest args)
(defadvice! +modeline-disable-icon-in-daemon-a (fn &rest args)
:around #'doom-modeline-propertize-icon
(when (display-graphic-p)
(apply orig-fn args)))
(apply fn args)))
;; Fix an issue where these two variables aren't defined in TTY Emacs on MacOS
(defvar mouse-wheel-down-event nil)
@ -64,9 +64,9 @@
;; Some functions modify the buffer, causing the modeline to show a false
;; modified state, so force them to behave.
(defadvice! +modeline--inhibit-modification-hooks-a (orig-fn &rest args)
(defadvice! +modeline--inhibit-modification-hooks-a (fn &rest args)
:around #'ws-butler-after-save
(with-silent-modifications (apply orig-fn args)))
(with-silent-modifications (apply fn args)))
;;

View file

@ -26,14 +26,14 @@
;;
;;; Core functions
(defadvice! +popup--make-case-sensitive-a (orig-fn &rest args)
(defadvice! +popup--make-case-sensitive-a (fn &rest args)
"Make regexps in `display-buffer-alist' case-sensitive.
To reduce fewer edge cases and improve performance when `display-buffer-alist'
grows larger."
:around #'display-buffer-assq-regexp
(let (case-fold-search)
(apply orig-fn args)))
(apply fn args)))
;; Don't try to resize popup windows
(advice-add #'balance-windows :around #'+popup-save-a)
@ -50,14 +50,14 @@ to this commmand."
(+popup/close nil 'force))))
(global-set-key [remap quit-window] #'+popup/quit-window)
(defadvice! +popup-override-display-buffer-alist-a (orig-fn &rest args)
(defadvice! +popup-override-display-buffer-alist-a (fn &rest args)
"When `pop-to-buffer' is called with non-nil ACTION, that ACTION should
override `display-buffer-alist'."
:around #'switch-to-buffer-other-tab
:around #'switch-to-buffer-other-window
:around #'switch-to-buffer-other-frame
(let ((display-buffer-alist nil))
(apply orig-fn args)))
(apply fn args)))
;;
@ -68,21 +68,21 @@ override `display-buffer-alist'."
;;;###package company
(defadvice! +popup--dont-select-me-a (orig-fn &rest args)
(defadvice! +popup--dont-select-me-a (fn &rest args)
:around #'company-show-doc-buffer
(let ((+popup--inhibit-select t))
(apply orig-fn args)))
(apply fn args)))
;;;###package compile
(defadvice! +popup--compilation-goto-locus-a (orig-fn &rest args)
(defadvice! +popup--compilation-goto-locus-a (fn &rest args)
"Fix links in popup compilation buffers creating a new window each time they
were followed."
:around #'compilation-goto-locus
(letf! (defun pop-to-buffer (buffer &optional action norecord)
(let ((pop-up-windows (not (+popup-buffer-p (current-buffer)))))
(funcall pop-to-buffer buffer action norecord)))
(apply orig-fn args)))
(apply fn args)))
;;;###package eshell
@ -213,7 +213,7 @@ the command buffer."
(setq helm-default-display-buffer-functions '(+popup-display-buffer-stacked-side-window-fn))
;; Fix #897: "cannot open side window" error when TAB-completing file links
(defadvice! +popup--helm-hide-org-links-popup-a (orig-fn &rest args)
(defadvice! +popup--helm-hide-org-links-popup-a (fn &rest args)
:around #'org-insert-link
(letf! ((defun org-completing-read (&rest args)
(when-let (win (get-buffer-window "*Org Links*"))
@ -227,7 +227,7 @@ the command buffer."
;; ...but it must exist for org to clean up later.
(get-buffer-create "*Org Links*"))
(apply org-completing-read args)))
(apply #'funcall-interactively orig-fn args)))
(apply #'funcall-interactively fn args)))
;; Fix left-over popup window when closing persistent help for `helm-M-x'
(defadvice! +popup--helm-elisp--persistent-help-a (candidate _fun &optional _name)
@ -248,24 +248,24 @@ the command buffer."
;;;###package org
(after! org
;; Org has a scorched-earth window management policy I'm not fond of. i.e. it
;; kills all other windows just so it can monopolize the frame. No thanks. We
;; can do better.
(defadvice! +popup--suppress-delete-other-windows-a (orig-fn &rest args)
:around '(org-add-log-note
org-capture-place-template
org-export--dispatch-ui
org-agenda-get-restriction-and-command
org-goto-location
org-fast-tag-selection
org-fast-todo-selection)
(defadvice! +popup--suppress-delete-other-windows-a (fn &rest args)
"Org has a scorched-earth window management policy I'm not fond of. i.e. it
kills all other windows just so it can monopolize the frame. No thanks. We can
do better."
:around #'org-add-log-note
:around #'org-capture-place-template
:around #'org-export--dispatch-ui
:around #'org-agenda-get-restriction-and-command
:around #'org-goto-location
:around #'org-fast-tag-selection
:around #'org-fast-todo-selection
(if +popup-mode
(letf! ((#'delete-other-windows #'ignore)
(#'delete-window #'ignore))
(apply orig-fn args))
(apply orig-fn args)))
(apply fn args))
(apply fn args)))
(defadvice! +popup--org-fix-goto-a (orig-fn &rest args)
(defadvice! +popup--org-fix-goto-a (fn &rest args)
"`org-goto' uses `with-output-to-temp-buffer' to display its help buffer,
for some reason, which is very unconventional, and so requires these gymnastics
to tame (i.e. to get the popup manager to handle it)."
@ -277,10 +277,10 @@ to tame (i.e. to get the popup manager to handle it)."
(with-current-buffer buffer
(+popup-buffer-mode +1))
(funcall internal-temp-output-buffer-show buffer)))
(apply orig-fn args))
(apply orig-fn args)))
(apply fn args))
(apply fn args)))
(defadvice! +popup--org-fix-popup-window-shrinking-a (orig-fn &rest args)
(defadvice! +popup--org-fix-popup-window-shrinking-a (fn &rest args)
"Hides the mode-line in *Org tags* buffer so you can actually see its
content and displays it in a side window without deleting all other windows.
Ugh, such an ugly hack."
@ -299,32 +299,32 @@ Ugh, such an ugly hack."
(when (> (window-buffer-height window)
(window-height window))
(fit-window-to-buffer window (window-buffer-height window)))))
(apply orig-fn args))
(apply orig-fn args)))
(apply fn args))
(apply fn args)))
(defadvice! +popup--org-edit-src-exit-a (orig-fn &rest args)
(defadvice! +popup--org-edit-src-exit-a (fn &rest args)
"If you switch workspaces or the src window is recreated..."
:around #'org-edit-src-exit
(let* ((window (selected-window))
(popup-p (+popup-window-p window)))
(prog1 (apply orig-fn args)
(prog1 (apply fn args)
(when (and popup-p (window-live-p window))
(delete-window window)))))
;; Ensure todo, agenda, and other minor popups are delegated to the popup system.
(defadvice! +popup--org-pop-to-buffer-a (orig-fn buf &optional norecord)
(defadvice! +popup--org-pop-to-buffer-a (fn buf &optional norecord)
"Use `pop-to-buffer' instead of `switch-to-buffer' to open buffer.'"
:around #'org-switch-to-buffer-other-window
(if +popup-mode
(pop-to-buffer buf nil norecord)
(funcall orig-fn buf norecord))))
(funcall fn buf norecord))))
;;;###package org-journal
(defadvice! +popup--use-popup-window-a (orig-fn &rest args)
(defadvice! +popup--use-popup-window-a (fn &rest args)
:around #'org-journal-search-by-string
(letf! ((#'switch-to-buffer #'pop-to-buffer))
(apply orig-fn args)))
(apply fn args)))
;;;###package persp-mode
@ -352,10 +352,10 @@ Ugh, such an ugly hack."
;;;###package profiler
(defadvice! +popup--profiler-report-find-entry-in-other-window-a (orig-fn function)
(defadvice! +popup--profiler-report-find-entry-in-other-window-a (fn function)
:around #'profiler-report-find-entry
(letf! ((#'find-function #'find-function-other-window))
(funcall orig-fn function)))
(funcall fn function)))
;;;###package wgrep
@ -384,11 +384,11 @@ Ugh, such an ugly hack."
;;;###package windmove
;; Users should be able to hop into popups easily, but Elisp shouldn't.
(defadvice! +popup--ignore-window-parameters-a (orig-fn &rest args)
(defadvice! +popup--ignore-window-parameters-a (fn &rest args)
"Allow *interactive* window moving commands to traverse popups."
:around '(windmove-up windmove-down windmove-left windmove-right)
(letf! (defun windmove-find-other-window (dir &optional arg window)
(window-in-direction
(pcase dir (`up 'above) (`down 'below) (_ dir))
window (bound-and-true-p +popup-mode) arg windmove-wrap-around t))
(apply orig-fn args)))
(apply fn args)))

View file

@ -464,10 +464,10 @@ window and return that window."
(+popup/close nil t))
;;;###autoload
(defun +popup-save-a (orig-fn &rest args)
(defun +popup-save-a (fn &rest args)
"Sets aside all popups before executing the original function, usually to
prevent the popup(s) from messing up the UI (or vice versa)."
(save-popups! (apply orig-fn args)))
(save-popups! (apply fn args)))
;;;###autoload
(defun +popup-display-buffer-fullframe-fn (buffer alist)

View file

@ -27,12 +27,12 @@ This must be set before `treemacs' has loaded.")
treemacs-last-error-persist-file (concat doom-cache-dir "treemacs-last-error-persist"))
:config
;; ...but not from treemacs-visit-node-ace-* commands.
(defadvice! +treemacs--ace-window-ignore-treemacs-buffer-a (orig-fn &rest args)
(defadvice! +treemacs--ace-window-ignore-treemacs-buffer-a (fn &rest args)
:around '(treemacs-visit-node-ace
treemacs-visit-node-ace-horizontal-split
treemacs-visit-node-ace-vertical-split)
(let ((aw-ignored-buffers (cons 'treemacs-mode aw-ignored-buffers)))
(apply orig-fn args)))
(apply fn args)))
;; Don't follow the cursor
(treemacs-follow-mode -1)

View file

@ -577,8 +577,8 @@ This be hooked to `projectile-after-switch-project-hook'."
;;; Advice
;;;###autoload
(defun +workspaces-autosave-real-buffers-a (orig-fn &rest args)
(defun +workspaces-autosave-real-buffers-a (fn &rest args)
"Don't autosave if no real buffers are open."
(when (doom-real-buffer-list)
(apply orig-fn args))
(apply fn args))
t)