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") " of these options.\n")
(princ (buffer-string)))) (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." "Don't write tangled blocks to files, print them to stdout."
(cl-letf (((symbol-function 'write-region) (cl-letf (((symbol-function 'write-region)
(lambda (start end filename &optional append visit lockname mustbenew) (lambda (start end filename &optional append visit lockname mustbenew)
(princ (buffer-string))))) (princ (buffer-string)))))
(apply orig-fn args))) (apply fn args)))
(defun *org-babel-tangle-collect-blocks (&optional language tangle-file) (defun *org-babel-tangle-collect-blocks (&optional language tangle-file)
"Like `org-babel-tangle-collect-blocks', but will ignore blocks that are in "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-emacs-dir ,doom-emacs-dir
doom-cache-dir ,(expand-file-name "cache/" doom-sandbox-dir) doom-cache-dir ,(expand-file-name "cache/" doom-sandbox-dir)
doom-etc-dir ,(expand-file-name "etc/" 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)) (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) (advice-add #'locate-user-emacs-file :around #'doom--write-to-etc-dir-a)
;; emacs essential variables ;; emacs essential variables
(setq before-init-time (current-time) (setq before-init-time (current-time)

View file

@ -32,24 +32,24 @@ are open."
(recenter)) (recenter))
;;;###autoload ;;;###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." "Generic advice for preserving cursor position on screen after scrolling."
(let ((row (cdr (posn-col-row (posn-at-point))))) (let ((row (cdr (posn-col-row (posn-at-point)))))
(prog1 (apply orig-fn args) (prog1 (apply fn args)
(save-excursion (save-excursion
(let ((target-row (- (line-number-at-pos) row))) (let ((target-row (- (line-number-at-pos) row)))
(unless (< target-row 0) (unless (< target-row 0)
(evil-scroll-line-to-top target-row))))))) (evil-scroll-line-to-top target-row)))))))
;;;###autoload ;;;###autoload
(defun doom-shut-up-a (orig-fn &rest args) (defun doom-shut-up-a (fn &rest args)
"Generic advisor for silencing noisy functions. "Generic advisor for silencing noisy functions.
In interactive Emacs, this just inhibits messages from appearing in the In interactive Emacs, this just inhibits messages from appearing in the
minibuffer. They are still logged to *Messages*. minibuffer. They are still logged to *Messages*.
In tty Emacs, messages are suppressed completely." 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 ;; HACK Replace GUI popup prompts (which hang indefinitely in tty Emacs) with
;; simple prompts. ;; 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 :around #'straight-are-you-sure
(or doom-auto-accept (or doom-auto-accept
(if doom-interactive-p (if doom-interactive-p
(funcall orig-fn prompt) (funcall fn prompt)
(y-or-n-p (format! "%s" (or prompt "")))))) (y-or-n-p (format! "%s" (or prompt ""))))))
(defun doom--straight-recommended-option-p (prompt option) (defun doom--straight-recommended-option-p (prompt option)
@ -48,11 +48,11 @@ original state.")
if (string-match-p prompt-re prompt) if (string-match-p prompt-re prompt)
return (string-match-p opt-re option))) 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." "Modifies straight to prompt on the terminal when in noninteractive sessions."
:around #'straight--popup-raw :around #'straight--popup-raw
(if doom-interactive-p (if doom-interactive-p
(funcall orig-fn prompt actions) (funcall fn prompt actions)
(let ((doom--straight-auto-options doom--straight-auto-options)) (let ((doom--straight-auto-options doom--straight-auto-options))
;; We can't intercept C-g, so no point displaying any options for this key ;; 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. ;; 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 ;; filesystem will murder your family. To appease it, I compress
;; `buffer-file-name' to a stable 40 characters. ;; `buffer-file-name' to a stable 40 characters.
;; TODO PR this upstream; should be a universal issue! ;; 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." "Compress the auto-save file name so paths don't get too long."
:around #'make-auto-save-file-name :around #'make-auto-save-file-name
(let ((buffer-file-name (let ((buffer-file-name
@ -157,11 +157,11 @@ tell you about it. Very annoying. This prevents that."
'make-auto-save-file-name)) 'make-auto-save-file-name))
buffer-file-name buffer-file-name
(sha1 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 ;; HACK Does the same for Emacs backup files, but also packages that use
;; `make-backup-file-name-1' directly (like undo-tree). ;; `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." "A few places use the backup file name so paths don't get too long."
:around #'make-backup-file-name-1 :around #'make-backup-file-name-1
(let ((alist backup-directory-alist) (let ((alist backup-directory-alist)
@ -171,7 +171,7 @@ tell you about it. Very annoying. This prevents that."
(if (string-match (car elt) file) (if (string-match (car elt) file)
(setq backup-directory (cdr elt) (setq backup-directory (cdr elt)
alist nil)))) alist nil))))
(let ((file (funcall orig-fn file))) (let ((file (funcall fn file)))
(if (or (null backup-directory) (if (or (null backup-directory)
(not (file-name-absolute-p backup-directory))) (not (file-name-absolute-p backup-directory)))
file file
@ -385,17 +385,17 @@ the unwritable tidbits."
:after-while #'save-place-find-file-hook :after-while #'save-place-find-file-hook
(if buffer-file-name (ignore-errors (recenter)))) (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 :around #'save-place-to-alist
(unless doom-large-file-p (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. "`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 `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'." files, so this replace calls to `pp' with the much faster `prin1'."
:around #'save-place-alist-to-file :around #'save-place-alist-to-file
(letf! ((#'pp #'prin1)) (funcall orig-fn)))) (letf! ((#'pp #'prin1)) (funcall fn))))
(use-package! server (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 evil-jump-backward] #'better-jumper-jump-backward)
(global-set-key [remap xref-pop-marker-stack] #'better-jumper-jump-backward) (global-set-key [remap xref-pop-marker-stack] #'better-jumper-jump-backward)
:config :config
(defun doom-set-jump-a (orig-fn &rest args) (defun doom-set-jump-a (fn &rest args)
"Set a jump point and ensure ORIG-FN doesn't set any new jump points." "Set a jump point and ensure fn doesn't set any new jump points."
(better-jumper-set-jump (if (markerp (car args)) (car args))) (better-jumper-set-jump (if (markerp (car args)) (car args)))
(let ((evil--jumps-jumping t) (let ((evil--jumps-jumping t)
(better-jumper--jumping t)) (better-jumper--jumping t))
(apply orig-fn args))) (apply fn args)))
(defun doom-set-jump-maybe-a (orig-fn &rest args) (defun doom-set-jump-maybe-a (fn &rest args)
"Set a jump point if ORIG-FN returns non-nil." "Set a jump point if fn returns non-nil."
(let ((origin (point-marker)) (let ((origin (point-marker))
(result (result
(let* ((evil--jumps-jumping t) (let* ((evil--jumps-jumping t)
(better-jumper--jumping t)) (better-jumper--jumping t))
(apply orig-fn args)))) (apply fn args))))
(unless result (unless result
(with-current-buffer (marker-buffer origin) (with-current-buffer (marker-buffer origin)
(better-jumper-set-jump (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) (push '(t tab-width) dtrt-indent-hook-generic-mapping-list)
(defvar dtrt-indent-run-after-smie) (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 "Some smie modes throw errors when trying to guess their indentation, like
`nim-mode'. This prevents them from leaving Emacs in a broken state." `nim-mode'. This prevents them from leaving Emacs in a broken state."
:around #'dtrt-indent-mode :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" (message "[WARNING] Indent detection: %s"
(error-message-string e)) (error-message-string e))
(message ""))))) ; warn silently (message ""))))) ; warn silently
(funcall orig-fn arg))))) (funcall fn arg)))))
(use-package! helpful (use-package! helpful
;; a better *help* buffer ;; 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-key] #'helpful-key)
(global-set-key [remap describe-symbol] #'helpful-symbol) (global-set-key [remap describe-symbol] #'helpful-symbol)
(defun doom-use-helpful-a (orig-fn &rest args) (defun doom-use-helpful-a (fn &rest args)
"Force ORIG-FN to use helpful instead of the old describe-* commands." "Force FN to use helpful instead of the old describe-* commands."
(letf! ((#'describe-function #'helpful-function) (letf! ((#'describe-function #'helpful-function)
(#'describe-variable #'helpful-variable)) (#'describe-variable #'helpful-variable))
(apply orig-fn args))) (apply fn args)))
(after! apropos (after! apropos
;; patch apropos buttons to call helpful instead of help ;; 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, ;; 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 ;; rather than `user-emacs-directory'. This is a done as a convenience
;; for users, wanting to specify a local directory. ;; 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." "Resolve :load-path from the current directory."
:around #'use-package-normalize-paths :around #'use-package-normalize-paths
;; `use-package-normalize-paths' resolves paths relative to ;; `use-package-normalize-paths' resolves paths relative to
;; `user-emacs-directory', so we change that. ;; `user-emacs-directory', so we change that.
(let ((user-emacs-directory (if (stringp arg) (dir!)))) (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: ;; 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 ;; `let-alist' is built into Emacs 26 and onwards
(add-to-list 'straight-built-in-pseudo-packages 'let-alist)) (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." "Read `:pin's in `doom-packages' on top of straight's lockfiles."
:around #'straight--lockfile-read-all :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))) (doom-package-pinned-list)))

View file

@ -181,7 +181,7 @@ And if it's a function, evaluate it."
(if IS-WINDOWS " --path-separator=/"))) (if IS-WINDOWS " --path-separator=/")))
("find . -type f -print0")))) ("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 "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', when using many of projectile's command, e.g. `projectile-compile-command',
`projectile-run-project', `projectile-test-project', and `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 This suppresses the error so these commands will still run, but prompt you for
the command instead." the command instead."
:around #'projectile-default-generic-command :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) (run-hooks 'doom-switch-frame-hook)
(setq doom--last-frame (selected-frame))))) (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 (if (or doom-inhibit-switch-buffer-hooks
(and buffer-or-name (and buffer-or-name
(eq (current-buffer) (eq (current-buffer)
(get-buffer buffer-or-name))) (get-buffer buffer-or-name)))
(and (eq orig-fn #'switch-to-buffer) (car args))) (and (eq fn #'switch-to-buffer) (car args)))
(apply orig-fn buffer-or-name args) (apply fn buffer-or-name args)
(let ((gc-cons-threshold most-positive-fixnum) (let ((gc-cons-threshold most-positive-fixnum)
(doom-inhibit-switch-buffer-hooks t) (doom-inhibit-switch-buffer-hooks t)
(inhibit-redisplay 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) (with-current-buffer (if (windowp buffer)
(window-buffer buffer) (window-buffer buffer)
buffer) buffer)
(run-hooks 'doom-switch-buffer-hook)) (run-hooks 'doom-switch-buffer-hook))
buffer)))) 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 (if doom-inhibit-switch-buffer-hooks
(apply orig-fn args) (apply fn args)
(let ((gc-cons-threshold most-positive-fixnum) (let ((gc-cons-threshold most-positive-fixnum)
(doom-inhibit-switch-buffer-hooks t) (doom-inhibit-switch-buffer-hooks t)
(inhibit-redisplay t)) (inhibit-redisplay t))
(when-let (buffer (apply orig-fn args)) (when-let (buffer (apply fn args))
(with-current-buffer buffer (with-current-buffer buffer
(run-hooks 'doom-switch-buffer-hook)) (run-hooks 'doom-switch-buffer-hook))
buffer)))) buffer))))
@ -499,13 +499,13 @@ windows, switch to `doom-fallback-buffer'. Otherwise, delegate to original
(set-fontset-font t 'unicode font nil 'append))))) (set-fontset-font t 'unicode font nil 'append)))))
:config :config
(cond ((daemonp) (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." "Return a blank string in tty Emacs, which doesn't support multiple fonts."
:around '(all-the-icons-octicon all-the-icons-material :around '(all-the-icons-octicon all-the-icons-material
all-the-icons-faicon all-the-icons-fileicon all-the-icons-faicon all-the-icons-fileicon
all-the-icons-wicon all-the-icons-alltheicon) all-the-icons-wicon all-the-icons-alltheicon)
(if (or (not after-init-time) (display-multi-font-p)) (if (or (not after-init-time) (display-multi-font-p))
(apply orig-fn args) (apply fn args)
""))) "")))
((not (display-graphic-p)) ((not (display-graphic-p))
(defadvice! doom--disable-all-the-icons-in-tty-a (&rest _) (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)) (with-selected-frame (or frame (selected-frame))
(load-theme doom-theme t)))) (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'." "Record `doom-theme', disable old themes, and trigger `doom-load-theme-hook'."
:around #'load-theme :around #'load-theme
;; Run `load-theme' from an estranged buffer, where we can ensure that ;; 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 ;; Disable previous themes so there are no conflicts. If you truly want
;; multiple themes enabled, then use `enable-theme' instead. ;; multiple themes enabled, then use `enable-theme' instead.
(mapc #'disable-theme custom-enabled-themes) (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)) (when (and (not no-enable) (custom-theme-enabled-p theme))
(setq doom-theme theme) (setq doom-theme theme)
(put 'doom-theme 'previous-themes (or last-themes 'none)) (put 'doom-theme 'previous-themes (or last-themes 'none))

View file

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

View file

@ -139,7 +139,7 @@
#'+spell/correct)) #'+spell/correct))
;; TODO PR this fix upstream! ;; 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 "`spell-fu--faces-at-point' uses face detection that won't penetrary
overlays (like `hl-line'). This makes `spell-fu-faces-exclude' demonstrably less 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 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) (letf! (defun get-char-property (pos prop &optional obj)
(or (plist-get (text-properties-at pos) prop) (or (plist-get (text-properties-at pos) prop)
(funcall get-char-property pos prop obj))) (funcall get-char-property pos prop obj)))
(apply orig-fn args))) (apply fn args)))
(defadvice! +spell--create-word-dict-a (_word words-file _action) (defadvice! +spell--create-word-dict-a (_word words-file _action)
"Prevent `spell-fu--word-add-or-remove' from throwing non-existant "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 ;; 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, ;; open a candidate in an occur buffer relative to the wrong buffer,
;; causing it to fail to find the file we want. ;; 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 :around #'counsel-projectile-find-file-action
(let ((default-directory (ivy-state-directory ivy-last))) (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 ;; Don't use ^ as initial input. Set this here because `counsel' defines more
;; of its own, on top of the defaults. ;; of its own, on top of the defaults.

View file

@ -118,26 +118,26 @@ more information on modifiers."
(back-to-indentation))))))) (back-to-indentation)))))))
;;;###autoload ;;;###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) (if (or (not +evil-want-o/O-to-continue-comments)
(not (eq this-command 'evil-open-below)) (not (eq this-command 'evil-open-below))
(evil-insert-state-p) (evil-insert-state-p)
(evil-emacs-state-p)) (evil-emacs-state-p))
(funcall orig-fn count) (funcall fn count)
(letf! (defun evil-insert-newline-below () (+evil--insert-newline)) (letf! (defun evil-insert-newline-below () (+evil--insert-newline))
(let ((evil-auto-indent evil-auto-indent)) (let ((evil-auto-indent evil-auto-indent))
(funcall orig-fn count))))) (funcall fn count)))))
;;;###autoload ;;;###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) (if (or (not +evil-want-o/O-to-continue-comments)
(not (eq this-command 'evil-open-above)) (not (eq this-command 'evil-open-above))
(evil-insert-state-p) (evil-insert-state-p)
(evil-emacs-state-p)) (evil-emacs-state-p))
(funcall orig-fn count) (funcall fn count)
(letf! (defun evil-insert-newline-above () (+evil--insert-newline 'above)) (letf! (defun evil-insert-newline-above () (+evil--insert-newline 'above))
(let ((evil-auto-indent evil-auto-indent)) (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) ;;;###autoload (autoload '+evil-window-split-a "editor/evil/autoload/advice" nil t)
(evil-define-command +evil-window-split-a (&optional count file) (evil-define-command +evil-window-split-a (&optional count file)
@ -179,7 +179,7 @@ more information on modifiers."
(if file (evil-edit file))) (if file (evil-edit file)))
;;;###autoload (autoload '+evil-join-a "editor/evil/autoload/advice" nil nil) ;;;###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. "Join the selected lines.
This advice improves on `evil-join' by removing comment delimiters when joining 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 ;; But revert to the default we're not in a comment, where
;; `fill-region-as-paragraph' is too greedy. ;; `fill-region-as-paragraph' is too greedy.
(if (not (doom-point-in-comment-p (min (max beg (1+ (point))) end))) (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)) (let* ((count (count-lines beg end))
(count (if (> count 1) (1- count) count)) (count (if (> count 1) (1- count) count))
(fixup-mark (make-marker))) (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, ;; HACK '=' moves the cursor to the beginning of selection. Disable this,
;; since it's more disruptive than helpful. ;; 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 :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, ;; REVIEW In evil, registers 2-9 are buffer-local. In vim, they're global,
;; so... Perhaps this should be PRed upstream? ;; 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 ;; Prevent gw (`evil-fill') and gq (`evil-fill-and-move') from squeezing
;; spaces. It doesn't in vim, so it shouldn't in evil. ;; 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) :around '(evil-fill evil-fill-and-move)
(letf! (defun fill-region (from to &optional justify nosqueeze to-eop) (letf! (defun fill-region (from to &optional justify nosqueeze to-eop)
(funcall fill-region from to justify t 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'. ;; Make ESC (from normal mode) the universal escaper. See `doom-escape-hook'.
(advice-add #'evil-force-normal-state :after #'+evil-escape-a) (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" (with-demoted-errors "evil-collection error: %s"
(evil-collection-init (list module))))) (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 :around #'evil-collection-vterm-toggle-send-escape ; allow binding to ESC
(let (evil-collection-key-blacklist) (let (evil-collection-key-blacklist)
(funcall-interactively orig-fn))) (funcall-interactively fn)))
;; These modes belong to packages that Emacs always loads at startup, causing ;; 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 ;; 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)) (when-let (rule (cl-find-if #'+file-template-p +file-templates-alist))
(apply #'+file-templates--expand rule)))) (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 :around #'org-capture
(let ((+file-templates-inhibit t)) (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)))) (if fmt (intern fmt))))
;;;###autoload ;;;###autoload
(defun +format-probe-a (orig-fn) (defun +format-probe-a (fn)
"Use `+format-with' instead, if it is set. "Use `+format-with' instead, if it is set.
Prompts for a formatter if universal arg is set." Prompts for a formatter if universal arg is set."
(cond ((or buffer-read-only (eq +format-with :none)) (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) (bound-and-true-p eglot--managed-mode)
(eglot--server-capable :documentFormattingProvider)) (eglot--server-capable :documentFormattingProvider))
(list 'eglot nil)) (list 'eglot nil))
((funcall orig-fn)))) ((funcall fn))))
;;;###autoload ;;;###autoload
(defun +format-buffer-a (formatter mode-result) (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 ;; Don't pop up imposing warnings about missing formatters, but still log it in
;; to *Messages*. ;; 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 :around #'format-all-buffer--from-hook
(letf! (defun format-all-buffer--with (formatter mode-result) (letf! (defun format-all-buffer--with (formatter mode-result)
(when (or (eq formatter 'lsp) (when (or (eq formatter 'lsp)
@ -83,4 +83,4 @@ This is controlled by `+format-on-save-enabled-modes'."
(gethash formatter format-all--executable-table)) (gethash formatter format-all--executable-table))
nil))) nil)))
(funcall format-all-buffer--with formatter mode-result))) (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 ;; HACK Allow these commands to be repeated by prefixing them with a numerical
;; argument. See gabesoft/evil-mc#110 ;; 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 :around '(evil-mc-make-and-goto-first-cursor
evil-mc-make-and-goto-last-cursor evil-mc-make-and-goto-last-cursor
evil-mc-make-and-goto-prev-cursor evil-mc-make-and-goto-prev-cursor
@ -104,7 +104,7 @@
evil-mc-skip-and-goto-prev-match evil-mc-skip-and-goto-prev-match
evil-mc-skip-and-goto-next-match) evil-mc-skip-and-goto-next-match)
(dotimes (i (if (integerp current-prefix-arg) current-prefix-arg 1)) (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 ;; If we're entering insert mode, it's a good bet that we want to start using
;; our multiple cursors ;; our multiple cursors

View file

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

View file

@ -124,11 +124,11 @@
:defer t :defer t
:config :config
(setq aya-persist-snippets-dir +snippets-dir) (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 "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 us who use yas-minor-mode and enable yasnippet more selectively. This advice
swaps `yas-global-mode' with `yas-minor-mode'." swaps `yas-global-mode' with `yas-minor-mode'."
:around '(aya-expand aya-open-line) :around '(aya-expand aya-open-line)
(letf! ((#'yas-global-mode #'yas-minor-mode) (letf! ((#'yas-global-mode #'yas-minor-mode)
(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 +word-wrap--major-mode-indent-var nil)
(defvar adaptive-wrap-extra-indent) (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." "Contextually adjust extra word-wrap indentation."
(let ((adaptive-wrap-extra-indent (+word-wrap--calc-extra-indent beg))) (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) (defun +word-wrap--calc-extra-indent (p)
"Calculate extra word-wrap indentation at point." "Calculate extra word-wrap indentation at point."

View file

@ -49,7 +49,7 @@
(setq git-timemachine-show-minibuffer-details t) (setq git-timemachine-show-minibuffer-details t)
;; TODO PR this to `git-timemachine' ;; 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 "Allow `browse-at-remote' commands in git-timemachine buffers to open that
file in your browser at the visited revision." file in your browser at the visited revision."
:around #'browse-at-remote-get-url :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 (funcall url-formatter repo-url ref relname
(if start-line start-line) (if start-line start-line)
(if (and end-line (not (equal start-line end-line))) end-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) (defadvice! +vc-update-header-line-a (revision)
"Show revision details in the header-line, instead of the minibuffer. "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 (setq +mu4e-compose-org-msg-toggle-next
(not +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-new
:around #'mu4e-compose-reply :around #'mu4e-compose-reply
:around #'mu4e-compose-forward :around #'mu4e-compose-forward
:around #'mu4e-compose-resend :around #'mu4e-compose-resend
(interactive "p") (interactive "p")
(+mu4e-compose-org-msg-handle-toggle (/= 1 (or toggle-p 0))) (+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'." "Prevent `mu4e-compose-signature' from being used with `org-msg-mode'."
:around #'mu4e-draft-open :around #'mu4e-draft-open
(let ((mu4e-compose-signature (unless org-msg-mode mu4e-compose-signature))) (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 (map! :map org-msg-edit-mode-map
"TAB" #'org-msg-tab) ; only <tab> bound by default "TAB" #'org-msg-tab) ; only <tab> bound by default

View file

@ -155,7 +155,7 @@
;; Advice ;; Advice
;;;###autoload ;;;###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." "Don't prompt for confirmation when killing notmuch sentinel."
(let (confirm-kill-processes) (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 ;; 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 ;; performed at once in a `c++-mode' buffer, e.g. with `iedit' or
;; multiple cursors. ;; 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 :around #'c-after-change-mark-abnormal-strings
(ignore-errors (apply orig-fn args))) (ignore-errors (apply fn args)))
;; Custom style, based off of linux ;; Custom style, based off of linux
(setq c-basic-offset tab-width (setq c-basic-offset tab-width

View file

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

View file

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

View file

@ -19,7 +19,7 @@
(set-company-backend! 'dante-mode #'dante-company) (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. "Marks the buffer as falsely modified.
Dante quietly saves the current buffer (without triggering save hooks) before Dante quietly saves the current buffer (without triggering save hooks) before
invoking flycheck, unexpectedly leaving the buffer in an unmodified state. This 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)." reformatting)."
:around #'dante-async-load-current-buffer :around #'dante-async-load-current-buffer
(let ((modified-p (buffer-modified-p))) (let ((modified-p (buffer-modified-p)))
(apply orig-fn args) (apply fn args)
(if modified-p (set-buffer-modified-p t)))) (if modified-p (set-buffer-modified-p t))))
(when (featurep 'evil) (when (featurep 'evil)

View file

@ -15,11 +15,11 @@
:definition #'meghanada-jump-declaration :definition #'meghanada-jump-declaration
:references #'meghanada-reference) :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." "Toggle `meghanada-mode'. Fail gracefully if java is unavailable."
:around #'meghanada-mode :around #'meghanada-mode
(if (executable-find meghanada-java-path) (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'." (message "Can't find %S binary. Is java installed? Aborting `meghanada-mode'."
meghanada-java-path))) meghanada-java-path)))

View file

@ -51,7 +51,7 @@
(setq latex-preview-pane-multifile-mode 'auctex) (setq latex-preview-pane-multifile-mode 'auctex)
;; TODO PR this to maintained fork. Original project appears abandoned ;; 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." "Once the preview pane has been closed it should not be reopened."
:around #'latex-preview-pane-update :around #'latex-preview-pane-update
(letf! (defun init-latex-preview-pane (&rest _) (letf! (defun init-latex-preview-pane (&rest _)
@ -59,7 +59,7 @@
;; window, but it's already gone, so it ends up deleting the ;; window, but it's already gone, so it ends up deleting the
;; wrong window. ;; wrong window.
(setq-local latex-preview-pane-mode nil)) (setq-local latex-preview-pane-mode nil))
(apply orig-fn args))) (apply fn args)))
(define-key! doc-view-mode-map (define-key! doc-view-mode-map
"ESC" #'delete-window "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))) (add-to-list 'LaTeX-indent-environment-list `(,env +latex-indent-item-fn)))
;; Fix #1849: allow fill-paragraph in itemize/enumerate ;; 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 :around #'LaTeX-fill-region-as-para-do
(let ((LaTeX-indent-environment-list (let ((LaTeX-indent-environment-list
(append LaTeX-indent-environment-list (append LaTeX-indent-environment-list
'(("itemize" +latex-indent-item-fn) '(("itemize" +latex-indent-item-fn)
("enumerate" +latex-indent-item-fn))))) ("enumerate" +latex-indent-item-fn)))))
(apply orig-fn args))) (apply fn args)))
(defadvice! +latex--dont-indent-itemize-and-enumerate-a (orig-fn &rest args) (defadvice! +latex--dont-indent-itemize-and-enumerate-a (fn &rest args)
:around #'LaTeX-fill-region-as-paragraph :around #'LaTeX-fill-region-as-paragraph
(let ((LaTeX-indent-environment-list LaTeX-indent-environment-list)) (let ((LaTeX-indent-environment-list LaTeX-indent-environment-list))
(delq! "itemize" LaTeX-indent-environment-list 'assoc) (delq! "itemize" LaTeX-indent-environment-list 'assoc)
(delq! "enumerate" LaTeX-indent-environment-list 'assoc) (delq! "enumerate" LaTeX-indent-environment-list 'assoc)
(apply orig-fn args)))) (apply fn args))))
(use-package! preview (use-package! preview

View file

@ -13,11 +13,11 @@
'(("^\\*Ledger Report" :size 0.5 :quit 'other :ttl 0) '(("^\\*Ledger Report" :size 0.5 :quit 'other :ttl 0)
("^\\*Ledger Error" :quit t :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." "Fail gracefully if ledger binary isn't available."
:around #'ledger-check-version :around #'ledger-check-version
(if (executable-find ledger-binary-path) (if (executable-find ledger-binary-path)
(funcall orig-fn) (funcall fn)
(message "Couldn't find '%s' executable" ledger-binary-path))) (message "Couldn't find '%s' executable" ledger-binary-path)))
;; `ledger-mode' lacks imenu support out of the box, so we gie it some. At ;; `ledger-mode' lacks imenu support out of the box, so we gie it some. At
@ -74,10 +74,10 @@
"s" #'ledger-display-ledger-stats "s" #'ledger-display-ledger-stats
"b" #'ledger-display-balance-at-point))) "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." "Fix inaccurate keybind message."
:around #'ledger-report :around #'ledger-report
(quiet! (apply orig-fn args)) (quiet! (apply fn args))
(with-current-buffer (get-buffer ledger-report-buffer-name) (with-current-buffer (get-buffer ledger-report-buffer-name)
(setq header-line-format (setq header-line-format
(substitute-command-keys (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 (after! ob
(add-to-list 'org-babel-default-lob-header-args '(:sync))) (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. "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 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'." Also adds support for a `:sync' parameter to override `:async'."
:around #'ob-async-org-babel-execute-src-block :around #'ob-async-org-babel-execute-src-block
(if (null fn) (if (null orig-fn)
(funcall orig-fn fn arg info params) (funcall fn orig-fn arg info params)
(let* ((info (or info (org-babel-get-src-block-info))) (let* ((info (or info (org-babel-get-src-block-info)))
(params (org-babel-merge-params (nth 2 info) params))) (params (org-babel-merge-params (nth 2 info) params)))
(if (or (assq :sync params) (if (or (assq :sync params)
@ -271,8 +271,8 @@ Also adds support for a `:sync' parameter to override `:async'."
(car info)) (car info))
(sleep-for 0.2)) (sleep-for 0.2))
t)) t))
(funcall fn arg info params) (funcall orig-fn arg info params)
(funcall orig-fn 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) (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." "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 (org-babel-do-in-edit-buffer
(call-interactively #'indent-for-tab-command)))) (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." "Prevent potentially expensive mode hooks in `org-babel-do-in-edit-buffer' ops."
:around #'org-src--edit-element :around #'org-src--edit-element
(apply orig-fn datum name (apply fn datum name
(if (and (eq org-src-window-setup 'switch-invisibly) (if (and (eq org-src-window-setup 'switch-invisibly)
(functionp initialize)) (functionp initialize))
;; org-babel-do-in-edit-buffer is used to execute quick, one-off ;; 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 ;; HACK Doom doesn't support `customize'. Best not to advertise it as an
;; option in `org-capture's menu. ;; 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 :around #'org-mks
(funcall orig-fn table title prompt (funcall fn table title prompt
(remove '("C" "Customize org-capture-templates") (remove '("C" "Customize org-capture-templates")
specials))) specials)))
@ -572,14 +572,14 @@ relative to `org-directory', unless it is an absolute path."
(mathjax . t) (mathjax . t)
(variable . "revealjs-url=https://revealjs.com")))) (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 "Exporting and tangling trigger save hooks; inadvertantly triggering
mutating hooks on exported output, like formatters." mutating hooks on exported output, like formatters."
:around '(org-export-to-file org-babel-tangle) :around '(org-export-to-file org-babel-tangle)
(let (before-save-hook after-save-hook) (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) :around '(org-export-to-file org-export-as)
(let ((old-async-init-file org-export-async-init-file) (let ((old-async-init-file org-export-async-init-file)
(org-export-async-init-file (make-temp-file "doom-org-async-export"))) (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) nil t)
(delete-file load-file-name))) (delete-file load-file-name)))
(current-buffer))) (current-buffer)))
(apply orig-fn args)))) (apply fn args))))
(defun +org-init-habit-h () (defun +org-init-habit-h ()
@ -662,14 +662,14 @@ With numerical argument N, show content up to level N."
(when (get-buffer-window) (when (get-buffer-window)
(recenter))) (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." "Fix variable height faces in eldoc breadcrumbs."
:around #'org-format-outline-path :around #'org-format-outline-path
(let ((org-level-faces (let ((org-level-faces
(cl-loop for face in org-level-faces (cl-loop for face in org-level-faces
collect `(:foreground ,(face-foreground face nil t) collect `(:foreground ,(face-foreground face nil t)
:weight bold)))) :weight bold))))
(apply orig-fn args))) (apply fn args)))
(after! org-eldoc (after! org-eldoc
;; HACK Fix #2972: infinite recursion when eldoc kicks in in 'org' or ;; 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))))) nil 'local)))))
(defvar recentf-exclude) (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." "Prevent temporarily opened agenda buffers from polluting recentf."
:around #'org-get-agenda-file-buffer :around #'org-get-agenda-file-buffer
(let ((recentf-exclude (list (lambda (_file) t))) (let ((recentf-exclude (list (lambda (_file) t)))
@ -720,18 +720,18 @@ can grow up to be fully-fledged org-mode buffers."
vc-handled-backends vc-handled-backends
org-mode-hook org-mode-hook
find-file-hook) find-file-hook)
(funcall orig-fn file))) (funcall fn file)))
;; HACK With https://code.orgmode.org/bzg/org-mode/commit/48da60f4, inline ;; HACK With https://code.orgmode.org/bzg/org-mode/commit/48da60f4, inline
;; image previews broke for users with imagemagick support built in. This ;; image previews broke for users with imagemagick support built in. This
;; reverses the problem, but should be removed once it is addressed ;; reverses the problem, but should be removed once it is addressed
;; upstream (if ever). ;; 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 :around #'org-display-inline-images
(letf! (defun create-image (file-or-data &optional type data-p &rest props) (letf! (defun create-image (file-or-data &optional type data-p &rest props)
(let ((type (if (plist-get props :width) type))) (let ((type (if (plist-get props :width) type)))
(apply create-image file-or-data type data-p props))) (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) (defadvice! +org--fix-inconsistent-uuidgen-case-a (uuid)
"Ensure uuidgen always produces lowercase output regardless of system." "Ensure uuidgen always produces lowercase output regardless of system."
@ -1023,12 +1023,12 @@ compelling reason, so..."
:config :config
(setq toc-org-hrefify-default "gh") (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." "Prevent the jarring scrolling that occurs when the-ToC is regenerated."
:around #'toc-org-insert-toc :around #'toc-org-insert-toc
(let ((p (set-marker (make-marker) (point))) (let ((p (set-marker (make-marker) (point)))
(s (window-start))) (s (window-start)))
(prog1 (apply orig-fn args) (prog1 (apply fn args)
(goto-char p) (goto-char p)
(set-window-start nil s t) (set-window-start nil s t)
(set-marker p nil))))) (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) :n [C-left] #'org-tree-slide-move-previous-tree)
(add-hook 'org-tree-slide-mode-hook #'evil-normalize-keymaps)) (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." "Omit the first heading if `+org-present-hide-first-heading' is non-nil."
:around #'org-tree-slide--display-tree-with-narrow :around #'org-tree-slide--display-tree-with-narrow
(letf! (defun org-narrow-to-subtree () (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))) (when (and (org-at-heading-p) (not (eobp)))
(backward-char 1)) (backward-char 1))
(point))))))) (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. ;; Don't display warning message dedicated for v1 users. Need to be set early.
(setq org-roam-v2-ack t) (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'. "Suppress automatic building of sqlite3 binary when loading `org-roam'.
This is a blocking operation that can take a while to complete This is a blocking operation that can take a while to complete
and better be deferred when there will be an actual demand for and better be deferred when there will be an actual demand for
the database. See `+org-init-roam-h' for the launch process." the database. See `+org-init-roam-h' for the launch process."
:around #'emacsql-sqlite-ensure-binary :around #'emacsql-sqlite-ensure-binary
(if (not (boundp 'org-roam-db-version)) (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) (advice-remove #'emacsql-sqlite-ensure-binary #'+org-roam-suppress-sqlite-build-a)
nil)) nil))

View file

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

View file

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

View file

@ -9,9 +9,9 @@
(set-popup-rule! "^\\*gist-" :ignore t) (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 :around #'gist-list-render
(funcall orig-fn (car args) t) (funcall fn (car args) t)
(unless (cadr args) (unless (cadr args)
(pop-to-buffer (current-buffer)))) (pop-to-buffer (current-buffer))))

View file

@ -151,10 +151,10 @@ Dictionary.app behind the scenes to get definitions.")
;; xref to be one too. ;; xref to be one too.
(remove-hook 'xref-backend-functions #'etags--xref-backend) (remove-hook 'xref-backend-functions #'etags--xref-backend)
;; ...however, it breaks `projectile-find-tag', unless we put it back. ;; ...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 :around #'projectile-find-tag
(let ((xref-backend-functions '(etags--xref-backend t))) (let ((xref-backend-functions '(etags--xref-backend t)))
(funcall orig-fn))) (funcall fn)))
;; This integration is already built into evil ;; This integration is already built into evil
(unless (featurep! :editor 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 ;; 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'). ;; 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 :around #'ivy-xref-show-xrefs
(when (functionp fetcher) (when (functionp fetcher)
(setf (alist-get 'fetched-xrefs alist) (setf (alist-get 'fetched-xrefs alist)
(funcall fetcher))) (funcall fetcher)))
(funcall orig-fn fetcher alist))) (funcall fn fetcher alist)))
(use-package! helm-xref (use-package! helm-xref
:when (featurep! :completion helm)) :when (featurep! :completion helm))

View file

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

View file

@ -18,11 +18,11 @@
(add-hook 'kill-buffer-hook #'+pdf-cleanup-windows-h nil t))) (add-hook 'kill-buffer-hook #'+pdf-cleanup-windows-h nil t)))
:config :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." "Install epdfinfo after the first PDF file, if needed."
:around #'pdf-view-mode :around #'pdf-view-mode
(if (file-executable-p pdf-info-epdfinfo-program) (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 ;; If we remain in pdf-view-mode, it'll spit out cryptic errors. This
;; graceful failure is better UX. ;; graceful failure is better UX.
(fundamental-mode) (fundamental-mode)
@ -74,10 +74,10 @@
nil 'local)))))) nil 'local))))))
;; Silence "File *.pdf is large (X MiB), really open?" prompts for pdfs ;; 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 :around #'abort-if-file-too-large
(unless (string-match-p "\\.pdf\\'" filename) (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 (use-package! saveplace-pdf-view

View file

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

View file

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

View file

@ -9,7 +9,7 @@
;;;###package hydra ;;;###package hydra
(setq lv-use-separator t) (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 :around #'lv-window
(let ((doom-inhibit-switch-window-hooks t)) (let ((doom-inhibit-switch-window-hooks t))
(funcall orig-fn))) (funcall fn)))

View file

@ -41,10 +41,10 @@
:config :config
;; HACK Fix #4102 due to empty all-the-icons return value (caused by ;; 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. ;; `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 :around #'doom-modeline-propertize-icon
(when (display-graphic-p) (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 ;; Fix an issue where these two variables aren't defined in TTY Emacs on MacOS
(defvar mouse-wheel-down-event nil) (defvar mouse-wheel-down-event nil)
@ -64,9 +64,9 @@
;; Some functions modify the buffer, causing the modeline to show a false ;; Some functions modify the buffer, causing the modeline to show a false
;; modified state, so force them to behave. ;; 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 :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 ;;; 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. "Make regexps in `display-buffer-alist' case-sensitive.
To reduce fewer edge cases and improve performance when `display-buffer-alist' To reduce fewer edge cases and improve performance when `display-buffer-alist'
grows larger." grows larger."
:around #'display-buffer-assq-regexp :around #'display-buffer-assq-regexp
(let (case-fold-search) (let (case-fold-search)
(apply orig-fn args))) (apply fn args)))
;; Don't try to resize popup windows ;; Don't try to resize popup windows
(advice-add #'balance-windows :around #'+popup-save-a) (advice-add #'balance-windows :around #'+popup-save-a)
@ -50,14 +50,14 @@ to this commmand."
(+popup/close nil 'force)))) (+popup/close nil 'force))))
(global-set-key [remap quit-window] #'+popup/quit-window) (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 "When `pop-to-buffer' is called with non-nil ACTION, that ACTION should
override `display-buffer-alist'." override `display-buffer-alist'."
:around #'switch-to-buffer-other-tab :around #'switch-to-buffer-other-tab
:around #'switch-to-buffer-other-window :around #'switch-to-buffer-other-window
:around #'switch-to-buffer-other-frame :around #'switch-to-buffer-other-frame
(let ((display-buffer-alist nil)) (let ((display-buffer-alist nil))
(apply orig-fn args))) (apply fn args)))
;; ;;
@ -68,21 +68,21 @@ override `display-buffer-alist'."
;;;###package company ;;;###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 :around #'company-show-doc-buffer
(let ((+popup--inhibit-select t)) (let ((+popup--inhibit-select t))
(apply orig-fn args))) (apply fn args)))
;;;###package compile ;;;###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 "Fix links in popup compilation buffers creating a new window each time they
were followed." were followed."
:around #'compilation-goto-locus :around #'compilation-goto-locus
(letf! (defun pop-to-buffer (buffer &optional action norecord) (letf! (defun pop-to-buffer (buffer &optional action norecord)
(let ((pop-up-windows (not (+popup-buffer-p (current-buffer))))) (let ((pop-up-windows (not (+popup-buffer-p (current-buffer)))))
(funcall pop-to-buffer buffer action norecord))) (funcall pop-to-buffer buffer action norecord)))
(apply orig-fn args))) (apply fn args)))
;;;###package eshell ;;;###package eshell
@ -213,7 +213,7 @@ the command buffer."
(setq helm-default-display-buffer-functions '(+popup-display-buffer-stacked-side-window-fn)) (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 ;; 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 :around #'org-insert-link
(letf! ((defun org-completing-read (&rest args) (letf! ((defun org-completing-read (&rest args)
(when-let (win (get-buffer-window "*Org Links*")) (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. ;; ...but it must exist for org to clean up later.
(get-buffer-create "*Org Links*")) (get-buffer-create "*Org Links*"))
(apply org-completing-read args))) (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' ;; Fix left-over popup window when closing persistent help for `helm-M-x'
(defadvice! +popup--helm-elisp--persistent-help-a (candidate _fun &optional _name) (defadvice! +popup--helm-elisp--persistent-help-a (candidate _fun &optional _name)
@ -248,24 +248,24 @@ the command buffer."
;;;###package org ;;;###package org
(after! org (after! org
;; Org has a scorched-earth window management policy I'm not fond of. i.e. it (defadvice! +popup--suppress-delete-other-windows-a (fn &rest args)
;; kills all other windows just so it can monopolize the frame. No thanks. We "Org has a scorched-earth window management policy I'm not fond of. i.e. it
;; can do better. kills all other windows just so it can monopolize the frame. No thanks. We can
(defadvice! +popup--suppress-delete-other-windows-a (orig-fn &rest args) do better."
:around '(org-add-log-note :around #'org-add-log-note
org-capture-place-template :around #'org-capture-place-template
org-export--dispatch-ui :around #'org-export--dispatch-ui
org-agenda-get-restriction-and-command :around #'org-agenda-get-restriction-and-command
org-goto-location :around #'org-goto-location
org-fast-tag-selection :around #'org-fast-tag-selection
org-fast-todo-selection) :around #'org-fast-todo-selection
(if +popup-mode (if +popup-mode
(letf! ((#'delete-other-windows #'ignore) (letf! ((#'delete-other-windows #'ignore)
(#'delete-window #'ignore)) (#'delete-window #'ignore))
(apply orig-fn args)) (apply fn args))
(apply orig-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, "`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 for some reason, which is very unconventional, and so requires these gymnastics
to tame (i.e. to get the popup manager to handle it)." 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 (with-current-buffer buffer
(+popup-buffer-mode +1)) (+popup-buffer-mode +1))
(funcall internal-temp-output-buffer-show buffer))) (funcall internal-temp-output-buffer-show buffer)))
(apply orig-fn args)) (apply fn args))
(apply orig-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 "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. content and displays it in a side window without deleting all other windows.
Ugh, such an ugly hack." Ugh, such an ugly hack."
@ -299,32 +299,32 @@ Ugh, such an ugly hack."
(when (> (window-buffer-height window) (when (> (window-buffer-height window)
(window-height window)) (window-height window))
(fit-window-to-buffer window (window-buffer-height window))))) (fit-window-to-buffer window (window-buffer-height window)))))
(apply orig-fn args)) (apply fn args))
(apply orig-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..." "If you switch workspaces or the src window is recreated..."
:around #'org-edit-src-exit :around #'org-edit-src-exit
(let* ((window (selected-window)) (let* ((window (selected-window))
(popup-p (+popup-window-p window))) (popup-p (+popup-window-p window)))
(prog1 (apply orig-fn args) (prog1 (apply fn args)
(when (and popup-p (window-live-p window)) (when (and popup-p (window-live-p window))
(delete-window window))))) (delete-window window)))))
;; Ensure todo, agenda, and other minor popups are delegated to the popup system. ;; 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.'" "Use `pop-to-buffer' instead of `switch-to-buffer' to open buffer.'"
:around #'org-switch-to-buffer-other-window :around #'org-switch-to-buffer-other-window
(if +popup-mode (if +popup-mode
(pop-to-buffer buf nil norecord) (pop-to-buffer buf nil norecord)
(funcall orig-fn buf norecord)))) (funcall fn buf norecord))))
;;;###package org-journal ;;;###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 :around #'org-journal-search-by-string
(letf! ((#'switch-to-buffer #'pop-to-buffer)) (letf! ((#'switch-to-buffer #'pop-to-buffer))
(apply orig-fn args))) (apply fn args)))
;;;###package persp-mode ;;;###package persp-mode
@ -352,10 +352,10 @@ Ugh, such an ugly hack."
;;;###package profiler ;;;###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 :around #'profiler-report-find-entry
(letf! ((#'find-function #'find-function-other-window)) (letf! ((#'find-function #'find-function-other-window))
(funcall orig-fn function))) (funcall fn function)))
;;;###package wgrep ;;;###package wgrep
@ -384,11 +384,11 @@ Ugh, such an ugly hack."
;;;###package windmove ;;;###package windmove
;; Users should be able to hop into popups easily, but Elisp shouldn't. ;; 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." "Allow *interactive* window moving commands to traverse popups."
:around '(windmove-up windmove-down windmove-left windmove-right) :around '(windmove-up windmove-down windmove-left windmove-right)
(letf! (defun windmove-find-other-window (dir &optional arg window) (letf! (defun windmove-find-other-window (dir &optional arg window)
(window-in-direction (window-in-direction
(pcase dir (`up 'above) (`down 'below) (_ dir)) (pcase dir (`up 'above) (`down 'below) (_ dir))
window (bound-and-true-p +popup-mode) arg windmove-wrap-around t)) 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)) (+popup/close nil t))
;;;###autoload ;;;###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 "Sets aside all popups before executing the original function, usually to
prevent the popup(s) from messing up the UI (or vice versa)." prevent the popup(s) from messing up the UI (or vice versa)."
(save-popups! (apply orig-fn args))) (save-popups! (apply fn args)))
;;;###autoload ;;;###autoload
(defun +popup-display-buffer-fullframe-fn (buffer alist) (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")) treemacs-last-error-persist-file (concat doom-cache-dir "treemacs-last-error-persist"))
:config :config
;; ...but not from treemacs-visit-node-ace-* commands. ;; ...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 :around '(treemacs-visit-node-ace
treemacs-visit-node-ace-horizontal-split treemacs-visit-node-ace-horizontal-split
treemacs-visit-node-ace-vertical-split) treemacs-visit-node-ace-vertical-split)
(let ((aw-ignored-buffers (cons 'treemacs-mode aw-ignored-buffers))) (let ((aw-ignored-buffers (cons 'treemacs-mode aw-ignored-buffers)))
(apply orig-fn args))) (apply fn args)))
;; Don't follow the cursor ;; Don't follow the cursor
(treemacs-follow-mode -1) (treemacs-follow-mode -1)

View file

@ -577,8 +577,8 @@ This be hooked to `projectile-after-switch-project-hook'."
;;; Advice ;;; Advice
;;;###autoload ;;;###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." "Don't autosave if no real buffers are open."
(when (doom-real-buffer-list) (when (doom-real-buffer-list)
(apply orig-fn args)) (apply fn args))
t) t)