emacs-elpa-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[nongnu] elpa/git-commit 8586e49d81: magit-auto-revert-mode: Leave disab


From: ELPA Syncer
Subject: [nongnu] elpa/git-commit 8586e49d81: magit-auto-revert-mode: Leave disabled in one more case
Date: Mon, 6 Mar 2023 09:59:56 -0500 (EST)

branch: elpa/git-commit
commit 8586e49d81d88dcd483aa534e95a8b2b5fe0f640
Author: Jonas Bernoulli <jonas@bernoul.li>
Commit: Jonas Bernoulli <jonas@bernoul.li>

    magit-auto-revert-mode: Leave disabled in one more case
    
    If, during initialization, `magit-autorevert' loaded without
    `global-auto-revert-mode' already being enabled, then the default
    value of `magit-auto-revert-mode' becomes t.  If later, but still
    during initialization, `global-auto-revert-mode' is enabled, then
    that default for `magit-auto-revert-mode' is not appropriate and
    we have to explicitly disable it.
    
    Usually it should not be necessary to loag Magit during initialization
    and `global-auto-revert-mode' is something one would expect to be
    enabled early on, if so desired; but still, this is something that
    can happen and we should try to handle it as users would expect.
    
    Note that we didn't already intend to do that before this commit.
    We however used to do something similar for the obsolete and since
    removed `magit-revert-buffers' variable.  In [1: 2253379bf7] we
    removed that variable.
    
    1: 2018-06-05 2253379bf72e97371774add0aae71cc4b57a69a1
       magit-revert-buffers: Remove deprecated variable
    
    Closes #4891.
---
 lisp/magit-autorevert.el | 34 +++++++++++++++++++---------------
 1 file changed, 19 insertions(+), 15 deletions(-)

diff --git a/lisp/magit-autorevert.el b/lisp/magit-autorevert.el
index 744bcd29d6..28f4573477 100644
--- a/lisp/magit-autorevert.el
+++ b/lisp/magit-autorevert.el
@@ -133,26 +133,30 @@ seconds of user inactivity.  That is not desirable."
 ;; - If the user has set the variable `magit-auto-revert-mode' to nil
 ;;   after loading magit (instead of doing so before loading magit or
 ;;   by using the function), then we should still respect that setting.
-;; - If the user sets one of these variables after loading magit and
-;;   after `after-init-hook' has run, then that won't have an effect
-;;   and there is nothing we can do about it.
+;; - If the user enables `global-auto-revert-mode' after loading magit
+;;   and after `after-init-hook' has run, then `magit-auto-revert-mode'
+;;   remains enabled; and there is nothing we can do about it.
+;; - However if the init file causes `magit-autorevert' to be loaded
+;;   and only later it enables `global-auto-revert-mode', then we can
+;;   and should leave `magit-auto-revert-mode' disabled.
 (defun magit-auto-revert-mode--init-kludge ()
   "This is an internal kludge to be used on `after-init-hook'.
 Do not use this function elsewhere, and don't remove it from
 the `after-init-hook'.  For more information see the comments
 and code surrounding the definition of this function."
-  (if magit-auto-revert-mode
-      (let ((start (current-time)))
-        (magit-message "Turning on magit-auto-revert-mode...")
-        (magit-auto-revert-mode 1)
-        (magit-message
-         "Turning on magit-auto-revert-mode...done%s"
-         (let ((elapsed (float-time (time-subtract nil start))))
-           (if (> elapsed 0.2)
-               (format " (%.3fs, %s buffers checked)" elapsed
-                       (length (buffer-list)))
-             ""))))
-    (magit-auto-revert-mode -1)))
+  (if (or (not magit-auto-revert-mode)
+          (and global-auto-revert-mode (not after-init-time)))
+      (magit-auto-revert-mode -1)
+    (let ((start (current-time)))
+      (magit-message "Turning on magit-auto-revert-mode...")
+      (magit-auto-revert-mode 1)
+      (magit-message
+       "Turning on magit-auto-revert-mode...done%s"
+       (let ((elapsed (float-time (time-subtract nil start))))
+         (if (> elapsed 0.2)
+             (format " (%.3fs, %s buffers checked)" elapsed
+                     (length (buffer-list)))
+           ""))))))
 (if after-init-time
     ;; Since `after-init-hook' has already been
     ;; run, turn the mode on or off right now.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]