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

@ -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)