branch: elpa/git-commit
commit df58c94081370e2c1aa7ab9ba90462f6d690800d
Author: Jonas Bernoulli <[email protected]>
Commit: Jonas Bernoulli <[email protected]>
Use define-advice instead of advice-add
---
docs/Makefile | 3 +--
lisp/magit-autorevert.el | 5 +----
lisp/magit-base.el | 13 +++----------
lisp/magit-files.el | 4 +---
lisp/magit-process.el | 16 ++++++----------
lisp/magit-section.el | 16 ++++++----------
6 files changed, 18 insertions(+), 39 deletions(-)
diff --git a/docs/Makefile b/docs/Makefile
index 8bd3107cb3..b9c5b5daf3 100644
--- a/docs/Makefile
+++ b/docs/Makefile
@@ -166,8 +166,7 @@ stats-upload:
# When making changes here, then also adjust the copy in magit-base.el.
define ORG_MAN_EXPORT
-(advice-add 'org-man-export :around 'org-man-export--magit-gitman)
-(defun org-man-export--magit-gitman (fn link description format)
+(define-advice org-man-export (:around (fn link description format) gitman)
(if (and (eq format 'texinfo) ;'
(string-match-p "\\`git" link))
(replace-regexp-in-string "%s" link "
diff --git a/lisp/magit-autorevert.el b/lisp/magit-autorevert.el
index e6a98d457d..e50dbe6496 100644
--- a/lisp/magit-autorevert.el
+++ b/lisp/magit-autorevert.el
@@ -244,7 +244,7 @@ defaults to nil) for any BUFFER."
;; ^ `tramp-handle-file-in-directory-p' lacks this optimization.
(file-in-directory-p dir top))))))
-(defun auto-revert-buffers--buffer-list-filter (fn)
+(define-advice auto-revert-buffers (:around (fn) buffer-list-filter)
(cl-incf magit-auto-revert-counter)
(if (or global-auto-revert-mode
(not auto-revert-buffer-list)
@@ -257,9 +257,6 @@ defaults to nil) for any BUFFER."
(unless auto-revert-timer
(auto-revert-set-timer))))
-(advice-add 'auto-revert-buffers :around
- #'auto-revert-buffers--buffer-list-filter)
-
;;; _
(provide 'magit-autorevert)
;;; magit-autorevert.el ends here
diff --git a/lisp/magit-base.el b/lisp/magit-base.el
index 2d6f7a0107..b4e34b569a 100644
--- a/lisp/magit-base.el
+++ b/lisp/magit-base.el
@@ -1121,7 +1121,7 @@ the value in the symbol's `saved-value' property if any,
or
;;; Kludges for Info Manuals
;;;###autoload
-(defun Info-follow-nearest-node--magit-gitman (fn &optional fork)
+(define-advice Info-follow-nearest-node (:around (fn &optional fork) gitman)
(let ((node (Info-get-token
(point) "\\*note[ \n\t]+"
"\\*note[ \n\t]+\\([^:]*\\):\\(:\\|[ \n\t]*(\\)?")))
@@ -1132,19 +1132,12 @@ the value in the symbol's `saved-value' property if
any, or
(man (match-string 1 node)))
('woman (require 'woman)
(woman (match-string 1 node)))
- (_
- (user-error "Invalid value for `magit-view-git-manual-method'")))
+ (_ (user-error "Invalid value for `magit-view-git-manual-method'")))
(funcall fn fork))))
-;;;###autoload
-(advice-add 'Info-follow-nearest-node :around
- #'Info-follow-nearest-node--magit-gitman)
-
;; When making changes here, then also adjust the copy in docs/Makefile.
;;;###autoload
-(advice-add 'org-man-export :around #'org-man-export--magit-gitman)
-;;;###autoload
-(defun org-man-export--magit-gitman (fn link description format)
+(define-advice org-man-export (:around (fn link description format) gitman)
(if (and (eq format 'texinfo)
(string-prefix-p "git" link))
(string-replace "%s" link "
diff --git a/lisp/magit-files.el b/lisp/magit-files.el
index e13491a259..f38be1d046 100644
--- a/lisp/magit-files.el
+++ b/lisp/magit-files.el
@@ -184,14 +184,12 @@ then only after asking. A non-nil value for REVERT is
ignored if REV is
(set-buffer-modified-p nil)
(goto-char (point-min))))
-(defun magit--lsp--disable-when-visiting-blob (fn &rest args)
+(define-advice lsp (:around (fn &rest args) magit-find-file)
"Do nothing when visiting blob using `magit-find-file' and similar.
See also https://github.com/doomemacs/doomemacs/pull/6309."
(unless magit-buffer-revision
(apply fn args)))
-(advice-add 'lsp :around #'magit--lsp--disable-when-visiting-blob)
-
;;; Find Index
(defvar magit-find-index-hook nil)
diff --git a/lisp/magit-process.el b/lisp/magit-process.el
index 9f74469d7e..3f3a394b15 100644
--- a/lisp/magit-process.el
+++ b/lisp/magit-process.el
@@ -1015,8 +1015,9 @@ as argument."
(add-hook 'magit-credential-hook #'magit-maybe-start-credential-cache-daemon)
-(defun tramp-sh-handle-start-file-process--magit-tramp-process-environment
- (fn name buffer program &rest args)
+(define-advice tramp-sh-handle-start-file-process
+ (:around (fn name buffer program &rest args)
+ magit-tramp-process-environment)
(if magit-tramp-process-environment
(apply fn name buffer
(car magit-tramp-process-environment)
@@ -1024,20 +1025,15 @@ as argument."
(cons program args)))
(apply fn name buffer program args)))
-(advice-add 'tramp-sh-handle-start-file-process :around
-
#'tramp-sh-handle-start-file-process--magit-tramp-process-environment)
-
-(defun tramp-sh-handle-process-file--magit-tramp-process-environment
- (fn program &optional infile destination display &rest args)
+(define-advice tramp-sh-handle-process-file
+ (:around (fn program &optional infile destination display &rest args)
+ magit-tramp-process-environment)
(if magit-tramp-process-environment
(apply fn "env" infile destination display
(append magit-tramp-process-environment
(cons program args)))
(apply fn program infile destination display args)))
-(advice-add 'tramp-sh-handle-process-file :around
- #'tramp-sh-handle-process-file--magit-tramp-process-environment)
-
(defvar-keymap magit-mode-line-process-map
:doc "Keymap for `mode-line-process'."
"<mode-line> <mouse-1>" ''magit-process-buffer)
diff --git a/lisp/magit-section.el b/lisp/magit-section.el
index 5e020c70a1..25e71c1b4a 100644
--- a/lisp/magit-section.el
+++ b/lisp/magit-section.el
@@ -774,12 +774,11 @@ Slight trimmed down."
(magit--menu-bar-keymap keymap))))
menu)
-(advice-add 'context-menu-region :around
- (lambda (fn menu click)
- "Disable in `magit-section-mode' buffers."
- (if (derived-mode-p 'magit-section-mode)
- menu
- (funcall fn menu click))))
+(define-advice context-menu-region (:around (fn menu click) magit-section-mode)
+ "Disable in `magit-section-mode' buffers."
+ (if (derived-mode-p 'magit-section-mode)
+ menu
+ (funcall fn menu click)))
;;; Commands
;;;; Movement
@@ -1981,7 +1980,7 @@ When `magit-section-preserve-visibility' is nil, do
nothing."
(or (eq search-invisible t)
(not (isearch-range-invisible beg end))))
-(defun isearch-clean-overlays@magit-mode (fn)
+(define-advice isearch-clean-overlays (:around (fn) magit-mode)
(if (derived-mode-p 'magit-mode)
(let ((pos (point)))
(dolist (section magit-section--opened-sections)
@@ -1990,9 +1989,6 @@ When `magit-section-preserve-visibility' is nil, do
nothing."
(setq magit-section--opened-sections nil))
(funcall fn)))
-(advice-add 'isearch-clean-overlays :around
- #'isearch-clean-overlays@magit-mode)
-
;;; Utilities
(cl-defun magit-section-selected-p (section &optional (selection nil
sselection))