Function: auto-revert-notify-add-watch
auto-revert-notify-add-watch is a byte-compiled function defined in
autorevert.el.gz.
Signature
(auto-revert-notify-add-watch)
Documentation
Enable file notification for current buffer's associated file.
Source Code
;; Defined in /usr/src/emacs/lisp/autorevert.el.gz
(defun auto-revert-notify-add-watch ()
"Enable file notification for current buffer's associated file."
;; We can assume that `auto-revert-notify-watch-descriptor' is nil.
(unless (or auto-revert-notify-watch-descriptor
(string-match auto-revert-notify-exclude-dir-regexp
(expand-file-name default-directory))
(file-symlink-p (or buffer-file-name default-directory)))
(let ((file (if buffer-file-name
(expand-file-name buffer-file-name default-directory)
(expand-file-name default-directory))))
(setq auto-revert-notify-watch-descriptor
(ignore-errors
(file-notify-add-watch
file
(if buffer-file-name '(change attribute-change) '(change))
'auto-revert-notify-handler))))
(if (null auto-revert-notify-watch-descriptor)
(setq-local auto-revert-use-notify nil)
(setq auto-revert-notify-modified-p t
auto-revert--buffer-by-watch-descriptor
(cons (cons auto-revert-notify-watch-descriptor (current-buffer))
auto-revert--buffer-by-watch-descriptor))
(add-hook 'kill-buffer-hook #'auto-revert-notify-rm-watch nil t))))