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:
parent
12732be155
commit
06392a723f
51 changed files with 223 additions and 229 deletions
|
@ -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
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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)))
|
||||
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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)))))
|
||||
|
|
|
@ -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))))
|
||||
|
|
|
@ -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))
|
||||
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue