aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMichael Albinus2019-04-06 11:36:34 +0200
committerMichael Albinus2019-04-06 11:36:34 +0200
commitbcc6468b39916de6a3756c98e744ed5d0534eb40 (patch)
tree3c3de6e71ea5ba356bb49e64a09032b28760c7df
parent10cd65878c741d2a22a1f2c36c54fcad4e516f72 (diff)
downloademacs-bcc6468b39916de6a3756c98e744ed5d0534eb40.tar.gz
emacs-bcc6468b39916de6a3756c98e744ed5d0534eb40.zip
Fix Bug#34847
* lisp/autorevert.el (auto-revert-remove-current-buffer): Add optional argument BUFFER. (auto-revert-notify-rm-watch): Remove local hook. (auto-revert-buffers): Check `buffer-live-p' in time. (Bug#34847)
-rw-r--r--lisp/autorevert.el52
1 files changed, 27 insertions, 25 deletions
diff --git a/lisp/autorevert.el b/lisp/autorevert.el
index bc7c616ecb7..e6dfafca2a5 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
@@ -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.