messages while reverting, even when @code{auto-revert-verbose} is
non-@code{nil}.
+@vindex buffer-auto-revert-by-notification
+Some non-file buffers can be updated reliably by file notification on
+their default directory; Dired buffers is an example. The major mode
+can indicate this by setting @code{buffer-auto-revert-by-notification}
+to a non-@code{nil} value in that buffer, allowing Auto Revert to
+avoid periodic polling. Such notification does not include changes to
+files in that directory, only to the directory itself.
+
The details depend on the particular types of buffers and are
explained in the corresponding sections.
notification is not supported. The new variable currently has no
effect in 'global-auto-revert-mode'. The default value is nil.
+*** New variable 'buffer-auto-revert-by-notification'
+A major mode can declare that notification on the buffer's default
+directory is sufficient to know when updates are required, by setting
+the new variable 'buffer-auto-revert-by-notification' to a non-nil
+value. Auto Revert mode can use this information to avoid polling the
+buffer periodically when 'auto-revert-avoid-polling' is non-nil.
+
\f
* New Modes and Packages in Emacs 27.1
(auto-revert-remove-current-buffer))
(when (auto-revert-active-p)
;; Enable file notification.
+ ;; Don't bother creating a notifier for non-file buffers
+ ;; unless it explicitly indicates that this works.
(when (and auto-revert-use-notify
- (not auto-revert-notify-watch-descriptor))
+ (not auto-revert-notify-watch-descriptor)
+ (or buffer-file-name
+ buffer-auto-revert-by-notification))
(auto-revert-notify-add-watch))
(auto-revert-handler)))))
(setq bufs (cdr bufs)))
(setq buffer-invisibility-spec (list t)))
(setq-local revert-buffer-function #'dired-revert)
(setq-local buffer-stale-function #'dired-buffer-stale-p)
+ (setq-local buffer-auto-revert-by-notification t)
(setq-local page-delimiter "\n\n")
(setq-local dired-directory (or dirname default-directory))
;; list-buffers uses this to display the dir being edited in this buffer.
For more information on how this variable is used by Auto Revert mode,
see Info node `(emacs)Supporting additional buffers'.")
+(defvar-local buffer-auto-revert-by-notification nil
+ "Whether a buffer can rely on notification in Auto-Revert mode.
+If non-nil, monitoring changes to the directory of the current
+buffer is sufficient for knowing when that buffer needs to be
+updated in Auto Revert Mode. Such notification does not include
+changes to files in that directory, only to the directory itself.
+
+This variable only applies to buffers where `buffer-file-name' is
+nil; other buffers are tracked by their files.")
+
(defvar before-revert-hook nil
"Normal hook for `revert-buffer' to run before reverting.
The function `revert-buffer--default' runs this.