[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Emacs-diffs] master d10036d: Fix Bug#33194
From: |
Michael Albinus |
Subject: |
[Emacs-diffs] master d10036d: Fix Bug#33194 |
Date: |
Sun, 4 Nov 2018 06:51:46 -0500 (EST) |
branch: master
commit d10036d73759234d67cb587e1876fbfbf7483e83
Author: Michael Albinus <address@hidden>
Commit: Michael Albinus <address@hidden>
Fix Bug#33194
* lisp/autorevert.el (auto-revert-notify-add-watch):
Handle buffers with same descriptor properly.
(auto-revert-notify-handler): Handle all buffers with same
descriptor. (Bug#33194)
* lisp/filenotify.el (file-notify-callback): Simplify.
---
lisp/autorevert.el | 58 +++++++++++++++++++++++++++++++-----------------------
lisp/filenotify.el | 13 ++++++------
2 files changed, 39 insertions(+), 32 deletions(-)
diff --git a/lisp/autorevert.el b/lisp/autorevert.el
index fc3469e..2cf5b42 100644
--- a/lisp/autorevert.el
+++ b/lisp/autorevert.el
@@ -515,32 +515,43 @@ will use an up-to-date value of `auto-revert-interval'"
(defun auto-revert-notify-add-watch ()
"Enable file notification for current buffer's associated file."
- ;; We can assume that `buffer-file-name' and
- ;; `auto-revert-notify-watch-descriptor' are non-nil.
+ ;; 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)))
- (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))))
- (when auto-revert-notify-watch-descriptor
- (setq auto-revert-notify-modified-p t)
- (puthash
- auto-revert-notify-watch-descriptor
- (cons (current-buffer)
- (gethash auto-revert-notify-watch-descriptor
- auto-revert-notify-watch-descriptor-hash-list))
+ ;; Check, whether this has been activated already.
+ (let ((file (if buffer-file-name
+ (expand-file-name buffer-file-name default-directory)
+ (expand-file-name default-directory))))
+ (maphash
+ (lambda (key _value)
+ (when (and
+ (equal (file-notify--watch-absolute-filename
+ (gethash key file-notify-descriptors))
+ (directory-file-name file))
+ (equal (file-notify--watch-callback
+ (gethash key file-notify-descriptors))
+ 'auto-revert-notify-handler))
+ (setq auto-revert-notify-watch-descriptor key)))
auto-revert-notify-watch-descriptor-hash-list)
- (add-hook 'kill-buffer-hook #'auto-revert-notify-rm-watch nil t))))
+ ;; Create a new watch if needed.
+ (unless auto-revert-notify-watch-descriptor
+ (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))))
+ (when auto-revert-notify-watch-descriptor
+ (setq auto-revert-notify-modified-p t)
+ (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 'kill-buffer-hook #'auto-revert-notify-rm-watch nil t)))))
;; If we have file notifications, we want to update the auto-revert buffers
;; immediately when a notification occurs. Since file updates can happen very
@@ -626,10 +637,7 @@ no more reverts are possible until the next call of
auto-revert-buffers-counter)
(auto-revert-handler)
(setq auto-revert-buffers-counter-lockedout
- auto-revert-buffers-counter))
-
- ;; No need to check other buffers.
- (cl-return)))))))))
+ auto-revert-buffers-counter))))))))))
(defun auto-revert-active-p ()
"Check if auto-revert is active (in current buffer or globally)."
diff --git a/lisp/filenotify.el b/lisp/filenotify.el
index 59a8c0e..a133f9e 100644
--- a/lisp/filenotify.el
+++ b/lisp/filenotify.el
@@ -45,11 +45,11 @@ could use another implementation.")
(:constructor nil)
(:constructor
file-notify--watch-make (directory filename callback)))
- ;; Watched directory
+ ;; Watched directory.
directory
;; Watched relative filename, nil if watching the directory.
filename
- ;; Function to propagate events to
+ ;; Function to propagate events to.
callback)
(defun file-notify--watch-absolute-filename (watch)
@@ -242,11 +242,10 @@ EVENT is the cadr of the event in
`file-notify-handle-event'
;;(message
;;"file-notify-callback %S %S %S %S %S"
;;desc action file file1 watch)
- (if file1
- (funcall (file-notify--watch-callback watch)
- `(,desc ,action ,file ,file1))
- (funcall (file-notify--watch-callback watch)
- `(,desc ,action ,file))))
+ (funcall (file-notify--watch-callback watch)
+ (if file1
+ `(,desc ,action ,file ,file1)
+ `(,desc ,action ,file))))
;; Send `stopped' event.
(when (or stopped
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Emacs-diffs] master d10036d: Fix Bug#33194,
Michael Albinus <=