Skip to content

Commit a5f66d7

Browse files
Activate magithub-minor-mode more conservatively
Replace "magithub-try-enabling-minor-mode-everywhere" with "magithub-try-enabling-minor-mode-for-repo", which only tries to enable magithub-minor-mode for buffers corresponding to files in the current repo. This solves the issue with magithub hanging indefinitely when you have a remote file open on a currently-inaccessible server. In such cases, magithub would try to enable its minro mode in the remote file's buffer, which would cause TRAMP to try to reconnect to the server, which would hang because the server was inaccessible.
1 parent e9826d2 commit a5f66d7

File tree

1 file changed

+13
-5
lines changed

1 file changed

+13
-5
lines changed

magithub.el

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1130,10 +1130,18 @@ See `magithub-try-enabling-minor-mode'."
11301130
(when (and magithub-minor-mode (buffer-live-p magithub-status-buffer))
11311131
(magithub-minor-mode -1)))
11321132

1133-
(defun magithub-try-enabling-minor-mode-everywhere ()
1134-
"Run `magithub-try-enabling-minor-mode' on all buffers."
1135-
(dolist (buf (buffer-list))
1136-
(with-current-buffer buf (magithub-try-enabling-minor-mode))))
1133+
(defun magithub-try-enabling-minor-mode-for-repo ()
1134+
"Run `magithub-try-enabling-minor-mode' on all buffers in the current repo."
1135+
(let* ((repo-directory (magit-get-top-dir default-directory))
1136+
(regexp (concat "^" (regexp-quote repo-directory))))
1137+
(message "Working in %s" repo-directory)
1138+
(message "Searching with %s" regexp)
1139+
(when repo-directory
1140+
(dolist (buf (buffer-list))
1141+
(with-current-buffer buf
1142+
(when (and (buffer-file-name)
1143+
(string-match-p regexp default-directory))
1144+
(magithub-try-enabling-minor-mode)))))))
11371145

11381146
(defun magithub-try-disabling-minor-mode-everywhere ()
11391147
"Run `magithub-try-disabling-minor-mode' on all buffers."
@@ -1155,7 +1163,7 @@ See `magithub-try-enabling-minor-mode'."
11551163
If the new `magit-mode' buffer is a status buffer, try enabling
11561164
`magithub-minor-mode' in all buffers."
11571165
(when (derived-mode-p 'magit-status-mode)
1158-
(magithub-try-enabling-minor-mode-everywhere)))
1166+
(magithub-try-enabling-minor-mode-for-repo)))
11591167
(add-hook 'magit-mode-hook 'magithub-magit-mode-hook)
11601168

11611169
(defun magithub-kill-buffer-hook ()

0 commit comments

Comments
 (0)