From 07d3f8a3ee5205b188c80c22c5e2b86a013b9267 Mon Sep 17 00:00:00 2001 From: Case Duckworth Date: Thu, 29 Apr 2021 19:47:54 -0500 Subject: Change some `defun'+`advice-add' to `define-advice' --- init.el | 29 ++++++++++++----------------- 1 file changed, 12 insertions(+), 17 deletions(-) diff --git a/init.el b/init.el index eb7964e..8b9a086 100644 --- a/init.el +++ b/init.el @@ -237,11 +237,9 @@ (:hook-into emacs-lisp-mode)) ;; Add advice to pulse evaluated regions - (defun acdw/elisp-eval-region-advice (fn start end &rest args) + (define-advice eval-region (:around (fn start end &rest args) pulse-region) (pulse-momentary-highlight-region start end) - (apply fn start end args)) - - (advice-add 'eval-region :around #'acdw/elisp-eval-region-advice)) + (apply fn start end args))) (setup encoding (:option locale-coding-system 'utf-8-unix @@ -380,12 +378,11 @@ ;; `acdw/kill-line-and-join-advice' cribs from `crux-kill-and-join-forward'. ;; I can't simply advise `kill-line' with an override from crux because crux ;; itself calls `kill-line', leading to a infinite nesting situation. - (advice-add 'kill-line :around - (defun acdw/kill-line-and-join-advice (orig &rest args) - "If at end of line, join with following; otherwise kill line." - (if (and (eolp) (not (bolp))) - (delete-indentation 1) - (apply orig args))))) + (define-advice kill-line (:around (fn &rest args) join-killed-line) + (if (and (eolp) + (not (bolp))) + (delete-indentation 1) + (apply fn args)))) (setup minibuffer (:option minibuffer-prompt-properties @@ -742,13 +739,11 @@ if ripgrep is installed, otherwise `consult-grep'." (autoload 'elpher-go "elpher" nil t) ;; Make `eww' gemini/gopher aware. From Emacswiki. - (advice-add 'eww-browse-url :around - (defun elpher:eww-browse-url (original url &optional new-window) - "Handle gemini and gopher links." - (cond ((string-match-p "\\`\\(gemini\\|gopher\\)://" url) - (require 'elpher) - (elpher-go url)) - (t (funcall original url new-window))))) + (define-advice eww-browse-url (:around (fn url &rest args) gemini-elpher) + (cond ((string-match-p "\\`\\(gemini\\|gopher\\)://" url) + (require 'elpher) + (elpher-go url)) + (t (apply fn url args)))) (:when-loaded (setup (:straight (gemini-write -- cgit 1.4.1-21-gabe81