[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[nongnu] elpa/git-commit 85e169736e 05/13: magit-refresh: No longer hard
From: |
ELPA Syncer |
Subject: |
[nongnu] elpa/git-commit 85e169736e 05/13: magit-refresh: No longer hardcode dedicated post-command hooks |
Date: |
Fri, 6 May 2022 15:58:12 -0400 (EDT) |
branch: elpa/git-commit
commit 85e169736e03ebe52722d2c6a7e613f79b636f37
Author: Jonas Bernoulli <jonas@bernoul.li>
Commit: Jonas Bernoulli <jonas@bernoul.li>
magit-refresh: No longer hardcode dedicated post-command hooks
This helps avoiding circular dependencies.
---
lisp/magit-apply.el | 20 ++++++++++++++------
lisp/magit-commit.el | 19 ++++++++++++-------
lisp/magit-mode.el | 22 ++++++++--------------
3 files changed, 34 insertions(+), 27 deletions(-)
diff --git a/lisp/magit-apply.el b/lisp/magit-apply.el
index 7bc825ec13..0302f53046 100644
--- a/lisp/magit-apply.el
+++ b/lisp/magit-apply.el
@@ -106,9 +106,6 @@ is a member of `magit-post-stage-hook-commands'."
:group 'magit-commands
:type 'hook)
-(defvar magit-post-stage-hook-commands
- '(magit-stage magit-stage-file magit-stage-modified))
-
(defcustom magit-post-unstage-hook nil
"Hook run after unstaging changes.
This hook is run by `magit-refresh' if `this-command'
@@ -117,9 +114,6 @@ is a member of `magit-post-unstage-hook-commands'."
:group 'magit-commands
:type 'hook)
-(defvar magit-post-unstage-hook-commands
- '(magit-unstage magit-unstage-file magit-unstage-all))
-
;;; Commands
;;;; Apply
@@ -389,6 +383,13 @@ ignored) files."
(borg--maybe-absorb-gitdir package)))))))
(magit-wip-commit-after-apply files " after stage")))
+(defvar magit-post-stage-hook-commands
+ '(magit-stage magit-stage-file magit-stage-modified))
+
+(defun magit-run-post-stage-hook ()
+ (when (memq this-command magit-post-stage-hook-commands)
+ (magit-run-hook-with-benchmark 'magit-post-stage-hook)))
+
;;;; Unstage
(defun magit-unstage ()
@@ -460,6 +461,13 @@ without requiring confirmation."
(magit-run-git "reset" "HEAD" "--" magit-buffer-diff-files)
(magit-wip-commit-after-apply nil " after unstage"))
+(defvar magit-post-unstage-hook-commands
+ '(magit-unstage magit-unstage-file magit-unstage-all))
+
+(defun magit-run-post-unstage-hook-commands ()
+ (when (memq this-command magit-post-unstage-hook-commands)
+ (magit-run-hook-with-benchmark 'magit-post-unstage-hook)))
+
;;;; Discard
(defun magit-discard ()
diff --git a/lisp/magit-commit.el b/lisp/magit-commit.el
index f28766a88f..c56246a1f9 100644
--- a/lisp/magit-commit.el
+++ b/lisp/magit-commit.el
@@ -126,13 +126,6 @@ must then use a prefix argument."
:group 'magit-commands
:type 'string)
-(defvar magit-post-commit-hook-commands
- '(magit-commit-extend
- magit-commit-fixup
- magit-commit-augment
- magit-commit-instant-fixup
- magit-commit-instant-squash))
-
;;; Popup
;;;###autoload (autoload 'magit-commit "magit-commit" nil t)
@@ -600,6 +593,18 @@ See `magit-commit-absorb' for an alternative
implementation."
:argument "--strict="
:reader #'transient-read-number-N0)
+(defvar magit-post-commit-hook-commands
+ '(magit-commit-extend
+ magit-commit-fixup
+ magit-commit-augment
+ magit-commit-instant-fixup
+ magit-commit-instant-squash))
+
+(defun magit-run-post-commit-hook ()
+ (when (and (not this-command)
+ (memq last-command magit-post-commit-hook-commands))
+ (run-hooks 'magit-post-commit-hook)))
+
;;; Pending Diff
(defun magit-commit-diff ()
diff --git a/lisp/magit-mode.el b/lisp/magit-mode.el
index d47768f07d..e33d459832 100644
--- a/lisp/magit-mode.el
+++ b/lisp/magit-mode.el
@@ -37,10 +37,6 @@
;; For `magit-display-buffer-fullcolumn-most-v1' from `git-commit'
(defvar git-commit-mode)
-;; For `magit-refresh'
-(defvar magit-post-commit-hook-commands)
-(defvar magit-post-stage-hook-commands)
-(defvar magit-post-unstage-hook-commands)
;; For `magit-refresh' and `magit-refresh-all'
(declare-function magit-auto-revert-buffers "magit-autorevert" ())
;; For `magit-refresh-buffer'
@@ -94,7 +90,10 @@ inside your function."
:type 'hook
:options '(magit-maybe-save-repository-buffers))
-(defcustom magit-post-refresh-hook nil
+(defcustom magit-post-refresh-hook
+ '(magit-run-post-commit-hook
+ magit-run-post-stage-hook
+ magit-run-post-unstage-hook)
"Hook run after refreshing in `magit-refresh'.
This hook, or `magit-pre-refresh-hook', should be used
@@ -105,7 +104,10 @@ To run a function with a particular buffer current, use
inside your function."
:package-version '(magit . "2.4.0")
:group 'magit-refresh
- :type 'hook)
+ :type 'hook
+ :options '(magit-run-post-commit-hook
+ magit-run-post-stage-hook
+ magit-run-post-unstage-hook))
(defcustom magit-display-buffer-function #'magit-display-buffer-traditional
"The function used to display a Magit buffer.
@@ -1049,14 +1051,6 @@ Run hooks `magit-pre-refresh-hook' and
`magit-post-refresh-hook'."
(with-current-buffer it
(magit-refresh-buffer)))
(magit-auto-revert-buffers)
- (cond
- ((and (not this-command)
- (memq last-command magit-post-commit-hook-commands))
- (magit-run-hook-with-benchmark 'magit-post-commit-hook))
- ((memq this-command magit-post-stage-hook-commands)
- (magit-run-hook-with-benchmark 'magit-post-stage-hook))
- ((memq this-command magit-post-unstage-hook-commands)
- (magit-run-hook-with-benchmark 'magit-post-unstage-hook)))
(magit-run-hook-with-benchmark 'magit-post-refresh-hook)
(when magit-refresh-verbose
(let* ((c (caar magit--refresh-cache))
- [nongnu] elpa/git-commit d176c2a278 01/13: magit-custom-initialize-reset: Improve docstring, (continued)
- [nongnu] elpa/git-commit d176c2a278 01/13: magit-custom-initialize-reset: Improve docstring, ELPA Syncer, 2022/05/06
- [nongnu] elpa/git-commit ec64fa4d63 06/13: magit-refresh: No longer hardcode magit-auto-revert-buffers, ELPA Syncer, 2022/05/06
- [nongnu] elpa/git-commit 2d679dff02 10/13: Move definition of magit-tramp-process-environment, ELPA Syncer, 2022/05/06
- [nongnu] elpa/git-commit e35f2b9be7 09/13: magit-blame.el: Move internal variables to beginning of file, ELPA Syncer, 2022/05/06
- [nongnu] elpa/git-commit 42a954adb4 03/13: Remove unnecessary variable declaration, ELPA Syncer, 2022/05/06
- [nongnu] elpa/git-commit ce29c373b9 08/13: magit-section.el: Move internal variables to beginning of file, ELPA Syncer, 2022/05/06
- [nongnu] elpa/git-commit 632536ca9c 07/13: Add magit-status-goto-initial-section to magit-create-buffer-hook, ELPA Syncer, 2022/05/06
- [nongnu] elpa/git-commit cc07643bb1 12/13: Use fboundp instead of declare-function for magit-blame functions, ELPA Syncer, 2022/05/06
- [nongnu] elpa/git-commit 6c98ba3dac 13/13: Use fboundp instead of requiring magit-wip, ELPA Syncer, 2022/05/06
- [nongnu] elpa/git-commit 16aa4340c8 02/13: Add missing section headings, ELPA Syncer, 2022/05/06
- [nongnu] elpa/git-commit 85e169736e 05/13: magit-refresh: No longer hardcode dedicated post-command hooks,
ELPA Syncer <=
- [nongnu] elpa/git-commit c3268fc69d 04/13: git-commit.el: Rearrange dependencies, ELPA Syncer, 2022/05/06
- [nongnu] elpa/git-commit f365aa48c4 11/13: Move shared infix argument magit:--gpg-sign to magit.el, ELPA Syncer, 2022/05/06