branch: elpa/magit
commit fc29202838c0e4087b2798b18875aea85d0fb301
Author: Jonas Bernoulli <[email protected]>
Commit: Jonas Bernoulli <[email protected]>

    magit-find-blob-hook: New hook
    
    Replaces `magit-find-file-hook' and `magit-find-index-hook', which
    are now obsolete aliases.  If a hook function really only is suitable
    in when visiting a blob from the index or a blob from a commit, then
    one can check whether `magit-buffer-revision' is "{index}" or not.
---
 lisp/magit-files.el | 17 +++++++++--------
 1 file changed, 9 insertions(+), 8 deletions(-)

diff --git a/lisp/magit-files.el b/lisp/magit-files.el
index b5653eb2737..fd705cf2ba9 100644
--- a/lisp/magit-files.el
+++ b/lisp/magit-files.el
@@ -33,8 +33,14 @@
 
 ;;; Find Blob
 
-(defvar magit-find-file-hook nil)
-(add-hook 'magit-find-file-hook #'magit-blob-mode)
+(define-obsolete-variable-alias 'magit-find-file-hook
+  'magit-find-blob-hook "Magit 4.6.0")
+
+(define-obsolete-variable-alias 'magit-find-index-hook
+  'magit-find-blob-hook "Magit 4.6.0")
+
+(defvar magit-find-blob-hook nil)
+(add-hook 'magit-find-blob-hook #'magit-blob-mode)
 
 ;;;###autoload
 (defun magit-find-file (rev file)
@@ -136,9 +142,7 @@ A non-nil value for REVERT is ignored if REV is 
\"{worktree}\"."
          (setq default-directory (if (file-exists-p defdir) defdir topdir))
          (setq-local revert-buffer-function #'magit-revert-rev-file-buffer)
          (revert-buffer t t)
-         (run-hooks (if (equal rev "{index}")
-                        'magit-find-index-hook
-                      'magit-find-file-hook)))
+         (run-hooks 'magit-find-blob-hook))
        (current-buffer)))
     ((error "%s isn't inside a Git repository" file))))
 
@@ -193,9 +197,6 @@ See also https://github.com/doomemacs/doomemacs/pull/6309.";
 
 ;;; Find Index
 
-(defvar magit-find-index-hook nil)
-(add-hook 'magit-find-index-hook #'magit-blob-mode)
-
 (defun magit-find-file-index-noselect (file &optional revert)
   "Read FILE from the index into a buffer and return the buffer.
 FILE must to be relative to the top directory of the repository."

Reply via email to