branch: elpa/magit
commit 43ea8570ffdf0911d776660f16ba48f79cc825ae
Author: Jonas Bernoulli <[email protected]>
Commit: Jonas Bernoulli <[email protected]>
magit--blob-normal-mode: Spin out new function
---
lisp/magit-files.el | 14 +++++++++-----
1 file changed, 9 insertions(+), 5 deletions(-)
diff --git a/lisp/magit-files.el b/lisp/magit-files.el
index 787fdb0ad93..3900441b9d1 100644
--- a/lisp/magit-files.el
+++ b/lisp/magit-files.el
@@ -156,19 +156,23 @@ REV is a revision or one of \"{worktree}\" or
\"{index}\"."
(save-excursion
(magit--insert-blob-contents magit-buffer-revision
(magit-file-relative-name))))
+ (magit--blob-normal-mode))
+
+(defun magit--blob-normal-mode ()
(let ((buffer-file-name magit-buffer-file-name)
(after-change-major-mode-hook
+ ;; Inhibit diff-hl and eglot; see bb8a65269d and 234a787b8c.
(seq-difference after-change-major-mode-hook
'(global-diff-hl-mode-enable-in-buffer ; Emacs >= 30
global-diff-hl-mode-enable-in-buffers ; Emacs < 30
eglot--maybe-activate-editing-mode)
#'eq)))
;; We want `normal-mode' to respect nil `enable-local-variables'.
- ;; The FIND-FILE argument wasn't designed for our use case, so we
- ;; have to use this strange invocation to achieve that.
- (normal-mode (not enable-local-variables)))
- (setq buffer-read-only t)
- (set-buffer-modified-p nil))
+ ;; The FIND-FILE argument wasn't designed for our use case,
+ ;; so we have to use this strange invocation to achieve that.
+ (normal-mode (not enable-local-variables))
+ (setq buffer-read-only t)
+ (set-buffer-modified-p nil)))
(define-advice lsp (:around (fn &rest args) magit-find-file)
"Do nothing when visiting blob using `magit-find-file' and similar.