From: Filipp Gunbin Date: Wed, 4 Mar 2015 16:35:42 +0000 (+0300) Subject: * autorevert.el (auto-revert-notify-add-watch): fix handler installation X-Git-Tag: emacs-25.0.90~2564^2~225 X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=5599661ead86228d7fea5e8dbf3d3a4e59f3d4fd;p=emacs.git * autorevert.el (auto-revert-notify-add-watch): fix handler installation Fixes: bug#20000 --- diff --git a/lisp/ChangeLog b/lisp/ChangeLog index 5c04663f9e8..08dcca2fbe8 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog @@ -1,3 +1,9 @@ +2015-03-04 Filipp Gunbin + + * autorevert.el (auto-revert-notify-add-watch): fix handler + installation + Fixes: bug#20000 + 2015-03-04 Rüdiger Sonderfeld * net/eww.el (eww-search-prefix, eww-open-file, eww-search-words) diff --git a/lisp/autorevert.el b/lisp/autorevert.el index 6489a3e04c2..357916c6b4d 100644 --- a/lisp/autorevert.el +++ b/lisp/autorevert.el @@ -503,36 +503,37 @@ will use an up-to-date value of `auto-revert-interval'" "Enable file notification for current buffer's associated file." ;; We can assume that `buffer-file-name' and ;; `auto-revert-use-notify' are non-nil. - (when (or (string-match auto-revert-notify-exclude-dir-regexp - (expand-file-name default-directory)) - (file-symlink-p (or buffer-file-name default-directory))) - ;; Fallback to file checks. - (set (make-local-variable 'auto-revert-use-notify) nil)) - - (when (not auto-revert-notify-watch-descriptor) - (setq auto-revert-notify-watch-descriptor - (ignore-errors - (if buffer-file-name - (file-notify-add-watch - (expand-file-name buffer-file-name default-directory) - '(change attribute-change) - 'auto-revert-notify-handler) - (file-notify-add-watch - (expand-file-name default-directory) - '(change) - 'auto-revert-notify-handler)))) - (if auto-revert-notify-watch-descriptor - (progn - (puthash - auto-revert-notify-watch-descriptor - (cons (current-buffer) - (gethash auto-revert-notify-watch-descriptor - auto-revert-notify-watch-descriptor-hash-list)) - auto-revert-notify-watch-descriptor-hash-list) - (add-hook (make-local-variable 'kill-buffer-hook) - 'auto-revert-notify-rm-watch)) + (if (or (string-match auto-revert-notify-exclude-dir-regexp + (expand-file-name default-directory)) + (file-symlink-p (or buffer-file-name default-directory))) + ;; Fallback to file checks. - (set (make-local-variable 'auto-revert-use-notify) nil)))) + (set (make-local-variable 'auto-revert-use-notify) nil) + + (when (not auto-revert-notify-watch-descriptor) + (setq auto-revert-notify-watch-descriptor + (ignore-errors + (if buffer-file-name + (file-notify-add-watch + (expand-file-name buffer-file-name default-directory) + '(change attribute-change) + 'auto-revert-notify-handler) + (file-notify-add-watch + (expand-file-name default-directory) + '(change) + 'auto-revert-notify-handler)))) + (if auto-revert-notify-watch-descriptor + (progn + (puthash + auto-revert-notify-watch-descriptor + (cons (current-buffer) + (gethash auto-revert-notify-watch-descriptor + auto-revert-notify-watch-descriptor-hash-list)) + auto-revert-notify-watch-descriptor-hash-list) + (add-hook (make-local-variable 'kill-buffer-hook) + 'auto-revert-notify-rm-watch)) + ;; Fallback to file checks. + (set (make-local-variable 'auto-revert-use-notify) nil))))) ;; If we have file notifications, we want to update the auto-revert buffers ;; immediately when a notification occurs. Since file updates can happen very