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

@ -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."