aboutsummaryrefslogtreecommitdiffstats
path: root/lisp/autorevert.el
diff options
context:
space:
mode:
Diffstat (limited to 'lisp/autorevert.el')
-rw-r--r--lisp/autorevert.el54
1 files changed, 28 insertions, 26 deletions
diff --git a/lisp/autorevert.el b/lisp/autorevert.el
index bc7c616ecb7..4fb865e8adb 100644
--- a/lisp/autorevert.el
+++ b/lisp/autorevert.el
@@ -343,10 +343,11 @@ This has been reported by a file notification event.")
343 343
344;; Functions: 344;; Functions:
345 345
346(defun auto-revert-remove-current-buffer () 346(defun auto-revert-remove-current-buffer (&optional buffer)
347 "Remove dead buffer from `auto-revert-buffer-list'." 347 "Remove BUFFER from `auto-revert-buffer-list'.
348BUFFER defaults to `current-buffer'."
348 (setq auto-revert-buffer-list 349 (setq auto-revert-buffer-list
349 (delq (current-buffer) auto-revert-buffer-list))) 350 (delq (or buffer (current-buffer)) auto-revert-buffer-list)))
350 351
351;;;###autoload 352;;;###autoload
352(define-minor-mode auto-revert-mode 353(define-minor-mode auto-revert-mode
@@ -464,7 +465,7 @@ If `global-auto-revert-non-file-buffers' is non-nil, this mode
464may also revert some non-file buffers, as described in the 465may also revert some non-file buffers, as described in the
465documentation of that variable. It ignores buffers with modes 466documentation of that variable. It ignores buffers with modes
466matching `global-auto-revert-ignore-modes', and buffers with a 467matching `global-auto-revert-ignore-modes', and buffers with a
467non-nil vale of `global-auto-revert-ignore-buffer'. 468non-nil value of `global-auto-revert-ignore-buffer'.
468 469
469When a buffer is reverted, a message is generated. This can be 470When a buffer is reverted, a message is generated. This can be
470suppressed by setting `auto-revert-verbose' to nil. 471suppressed by setting `auto-revert-verbose' to nil.
@@ -509,7 +510,7 @@ will use an up-to-date value of `auto-revert-interval'"
509 (ignore-errors 510 (ignore-errors
510 (file-notify-rm-watch auto-revert-notify-watch-descriptor))))) 511 (file-notify-rm-watch auto-revert-notify-watch-descriptor)))))
511 auto-revert-notify-watch-descriptor-hash-list) 512 auto-revert-notify-watch-descriptor-hash-list)
512 (remove-hook 'kill-buffer-hook #'auto-revert-notify-rm-watch)) 513 (remove-hook 'kill-buffer-hook #'auto-revert-notify-rm-watch t))
513 (setq auto-revert-notify-watch-descriptor nil 514 (setq auto-revert-notify-watch-descriptor nil
514 auto-revert-notify-modified-p nil)) 515 auto-revert-notify-modified-p nil))
515 516
@@ -772,10 +773,12 @@ the timer when no buffers need to be checked."
772 (setq bufs (delq nil 773 (setq bufs (delq nil
773 (mapcar 774 (mapcar
774 (lambda (buf) 775 (lambda (buf)
775 (with-current-buffer buf 776 (and (buffer-live-p buf)
776 (and (or (not (file-remote-p default-directory)) 777 (with-current-buffer buf
777 (file-remote-p default-directory nil t)) 778 (and
778 buf))) 779 (or (not (file-remote-p default-directory))
780 (file-remote-p default-directory nil t))
781 buf))))
779 bufs))) 782 bufs)))
780 ;; Partition `bufs' into two halves depending on whether or not 783 ;; Partition `bufs' into two halves depending on whether or not
781 ;; the buffers are in `auto-revert-remaining-buffers'. The two 784 ;; the buffers are in `auto-revert-remaining-buffers'. The two
@@ -792,24 +795,23 @@ the timer when no buffers need to be checked."
792 (not (and auto-revert-stop-on-user-input 795 (not (and auto-revert-stop-on-user-input
793 (input-pending-p)))) 796 (input-pending-p))))
794 (let ((buf (car bufs))) 797 (let ((buf (car bufs)))
795 (with-current-buffer buf 798 (if (not (buffer-live-p buf))
796 (if (buffer-live-p buf)
797 (progn
798 ;; Test if someone has turned off Auto-Revert Mode
799 ;; in a non-standard way, for example by changing
800 ;; major mode.
801 (if (and (not auto-revert-mode)
802 (not auto-revert-tail-mode)
803 (memq buf auto-revert-buffer-list))
804 (auto-revert-remove-current-buffer))
805 (when (auto-revert-active-p)
806 ;; Enable file notification.
807 (when (and auto-revert-use-notify
808 (not auto-revert-notify-watch-descriptor))
809 (auto-revert-notify-add-watch))
810 (auto-revert-handler)))
811 ;; Remove dead buffer from `auto-revert-buffer-list'. 799 ;; Remove dead buffer from `auto-revert-buffer-list'.
812 (auto-revert-remove-current-buffer)))) 800 (auto-revert-remove-current-buffer buf)
801 (with-current-buffer buf
802 ;; Test if someone has turned off Auto-Revert Mode
803 ;; in a non-standard way, for example by changing
804 ;; major mode.
805 (if (and (not auto-revert-mode)
806 (not auto-revert-tail-mode)
807 (memq buf auto-revert-buffer-list))
808 (auto-revert-remove-current-buffer))
809 (when (auto-revert-active-p)
810 ;; Enable file notification.
811 (when (and auto-revert-use-notify
812 (not auto-revert-notify-watch-descriptor))
813 (auto-revert-notify-add-watch))
814 (auto-revert-handler)))))
813 (setq bufs (cdr bufs))) 815 (setq bufs (cdr bufs)))
814 (setq auto-revert-remaining-buffers bufs) 816 (setq auto-revert-remaining-buffers bufs)
815 ;; Check if we should cancel the timer. 817 ;; Check if we should cancel the timer.