update packages
This commit is contained in:
@@ -104,6 +104,32 @@ seconds of user inactivity. That is not desirable."
|
||||
|
||||
;;; Mode
|
||||
|
||||
;;;###autoload
|
||||
(progn ; magit-custom-initialize-after-init
|
||||
(defun magit-custom-initialize-after-init (symbol value)
|
||||
;; Use `apply-partially' instead of the wonders of lexical bindings,
|
||||
;; because of bugs in the autoload handling of package managers, which
|
||||
;; cause these variables to be treated as dynamic. See #5476 and #5485.
|
||||
(internal--define-uninitialized-variable symbol)
|
||||
(cond ((not after-init-time)
|
||||
(letrec ((f (apply-partially
|
||||
(lambda (symbol value)
|
||||
(ignore-errors
|
||||
(remove-hook 'after-init-hook f))
|
||||
(custom-initialize-set symbol value))
|
||||
symbol value)))
|
||||
(add-hook 'after-init-hook f)))
|
||||
((not load-file-name)
|
||||
(custom-initialize-set symbol value))
|
||||
((letrec ((f (apply-partially
|
||||
(lambda (thisfile symbol value file)
|
||||
(when (equal file thisfile)
|
||||
(ignore-errors
|
||||
(remove-hook 'after-load-functions f))
|
||||
(custom-initialize-set symbol value)))
|
||||
load-file-name symbol value)))
|
||||
(add-hook 'after-load-functions f))))))
|
||||
|
||||
(defun magit-turn-on-auto-revert-mode-if-desired (&optional file)
|
||||
(cond (file
|
||||
(when-let ((buffer (find-buffer-visiting file)))
|
||||
@@ -128,54 +154,20 @@ seconds of user inactivity. That is not desirable."
|
||||
:link '(info-link "(magit)Automatic Reverting of File-Visiting Buffers")
|
||||
:group 'magit-auto-revert
|
||||
:group 'magit-essentials
|
||||
;; - When `global-auto-revert-mode' is enabled, then this mode is
|
||||
;; redundant.
|
||||
;; - In all other cases enable the mode because if buffers are not
|
||||
;; automatically reverted that would make many very common tasks
|
||||
;; much more cumbersome.
|
||||
:init-value (not (or global-auto-revert-mode
|
||||
noninteractive)))
|
||||
;; - Unfortunately `:init-value t' only sets the value of the mode
|
||||
;; variable but does not cause the mode function to be called.
|
||||
;; - I don't think it works like this on purpose, but since one usually
|
||||
;; should not enable global modes by default, it is understandable.
|
||||
;; - 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 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 (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-since 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.
|
||||
(magit-auto-revert-mode--init-kludge)
|
||||
;; By the time the init file has been fully loaded the
|
||||
;; values of the relevant variables might have changed.
|
||||
(add-hook 'after-init-hook #'magit-auto-revert-mode--init-kludge t))
|
||||
:init-value (not (or global-auto-revert-mode noninteractive))
|
||||
:initialize #'magit-custom-initialize-after-init)
|
||||
|
||||
(defun magit-auto-revert-mode--disable ()
|
||||
"When enabling `global-auto-revert-mode', disable `magit-auto-revert-mode'."
|
||||
(when (and global-auto-revert-mode
|
||||
(bound-and-true-p magit-auto-revert-mode))
|
||||
(magit-auto-revert-mode -1)))
|
||||
|
||||
(add-hook 'global-auto-revert-mode-hook #'magit-auto-revert-mode--disable)
|
||||
|
||||
(put 'magit-auto-revert-mode 'function-documentation
|
||||
"Toggle Magit Auto Revert mode.
|
||||
|
||||
If called interactively, enable Magit Auto Revert mode if ARG is
|
||||
positive, and disable it if ARG is zero or negative. If called
|
||||
from Lisp, also enable the mode if ARG is omitted or nil, and
|
||||
@@ -210,8 +202,11 @@ Like nearly every mode, this mode should be enabled or disabled
|
||||
by calling the respective mode function, the reason being that
|
||||
changing the state of a mode involves more than merely toggling
|
||||
a single switch, so setting the mode variable is not enough.
|
||||
Also, you should not use `after-init-hook' to disable this mode.")
|
||||
Also, you should not use `after-init-hook' to disable this mode.
|
||||
|
||||
\(fn &optional ARG)")
|
||||
|
||||
;;;###autoload
|
||||
(defun magit-auto-revert-buffers ()
|
||||
(when (and magit-auto-revert-immediately
|
||||
(or global-auto-revert-mode
|
||||
@@ -268,4 +263,15 @@ defaults to nil) for any BUFFER."
|
||||
|
||||
;;; _
|
||||
(provide 'magit-autorevert)
|
||||
;; Local Variables:
|
||||
;; read-symbol-shorthands: (
|
||||
;; ("and$" . "cond-let--and$")
|
||||
;; ("and>" . "cond-let--and>")
|
||||
;; ("and-let" . "cond-let--and-let")
|
||||
;; ("if-let" . "cond-let--if-let")
|
||||
;; ("when-let" . "cond-let--when-let")
|
||||
;; ("while-let" . "cond-let--while-let")
|
||||
;; ("match-string" . "match-string")
|
||||
;; ("match-str" . "match-string-no-properties"))
|
||||
;; End:
|
||||
;;; magit-autorevert.el ends here
|
||||
|
||||
Reference in New Issue
Block a user