Implement lazy auto-revert
Instead of using auto-revert-mode or global-auto-revert-mode, we employ lazy auto reverting on focus-in-hook, doom-switch-buffer-hook and after-save-hook. We do this because autorevert abuses inotify handles, which can grind Emacs to a halt if you have hundreds of buffers open and something performs expensive mtime or attribute-altering IO on their files outside of Emacs. We only really need revert checks when we switch to or save a buffer, or when we focus the Emacs frame.
This commit is contained in:
parent
41de07177b
commit
d6aea001c5
1 changed files with 20 additions and 4 deletions
|
@ -73,11 +73,27 @@ detected.")
|
||||||
;;; Built-in plugins
|
;;; Built-in plugins
|
||||||
|
|
||||||
(def-package! autorevert
|
(def-package! autorevert
|
||||||
;; revert buffers for changed files
|
;; revert buffers when their files/state have changed
|
||||||
:after-call after-find-file
|
:hook (focus-in . doom|auto-revert-buffers)
|
||||||
|
:hook (doom-switch-buffer . auto-revert-handler)
|
||||||
|
:hook (after-save . doom|auto-revert-buffers)
|
||||||
:config
|
:config
|
||||||
(setq auto-revert-verbose nil)
|
(setq auto-revert-verbose t ; let us know when it happens
|
||||||
(global-auto-revert-mode +1))
|
auto-revert-use-notify nil
|
||||||
|
auto-revert-stop-on-user-input nil)
|
||||||
|
|
||||||
|
;; Instead of using `auto-revert-mode' or `global-auto-revert-mode', we employ
|
||||||
|
;; lazy auto reverting on `focus-in-hook' and `doom-switch-buffer-hook'.
|
||||||
|
;;
|
||||||
|
;; This is because autorevert abuses the heck out of inotify handles which can
|
||||||
|
;; grind Emacs to a halt if you do expensive IO (outside of Emacs) on the
|
||||||
|
;; files you have open (like compression). We only really need revert changes
|
||||||
|
;; when we switch to a buffer or when we focus the Emacs frame.
|
||||||
|
(defun doom|auto-revert-buffers ()
|
||||||
|
"Auto revert's stale buffers (that are visible)."
|
||||||
|
(dolist (buf (doom-visible-buffers))
|
||||||
|
(with-current-buffer buf
|
||||||
|
(auto-revert-handler)))))
|
||||||
|
|
||||||
(def-package! recentf
|
(def-package! recentf
|
||||||
;; Keep track of recently opened files
|
;; Keep track of recently opened files
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue