Function: auto-revert-buffer

auto-revert-buffer is a byte-compiled function defined in autorevert.el.gz.

Signature

(auto-revert-buffer BUF)

Documentation

Revert a single buffer BUF.

This is performed as specified by Auto-Revert and Global Auto-Revert Modes.

Probably introduced at or before Emacs version 31.1.

Source Code

;; Defined in /usr/src/emacs/lisp/autorevert.el.gz
(defun auto-revert-buffer (buf)
  "Revert a single buffer BUF.

This is performed as specified by Auto-Revert and Global
Auto-Revert Modes."
  (let ((auto-revert-buffer-in-progress t))
    (if (not (buffer-live-p buf))
        (auto-revert-remove-current-buffer buf)
      (with-current-buffer buf
        ;; Test if someone has turned off Auto-Revert Mode in a
        ;; non-standard way, for example by changing major mode.
        (when (and (not auto-revert-mode)
                   (not auto-revert-tail-mode))
          (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)
                     (or buffer-file-name
                         buffer-auto-revert-by-notification))
            (auto-revert-notify-add-watch))
          (auto-revert-handler))))))