Merge from emacs-24; up to 2012-12-27T20:09:45Z!juri@jurta.org
[bpt/emacs.git] / lisp / autorevert.el
index fe6cf21..a2ce601 100644 (file)
@@ -367,8 +367,9 @@ without being changed in the part that is already in the buffer."
          (delq (current-buffer) auto-revert-buffer-list)))
   (auto-revert-set-timer)
   (when auto-revert-mode
-    (auto-revert-buffers)
-    (setq auto-revert-tail-mode nil)))
+    (let (auto-revert-use-notify)
+      (auto-revert-buffers)
+      (setq auto-revert-tail-mode nil))))
 
 
 ;;;###autoload
@@ -422,7 +423,8 @@ Use `auto-revert-mode' for changes other than appends!"
            (y-or-n-p "File changed on disk, content may be missing.  \
 Perform a full revert? ")
            ;; Use this (not just revert-buffer) for point-preservation.
-           (auto-revert-handler))
+          (let (auto-revert-use-notify)
+            (auto-revert-handler)))
       ;; else we might reappend our own end when we save
       (add-hook 'before-save-hook (lambda () (auto-revert-tail-mode 0)) nil t)
       (or (local-variable-p 'auto-revert-tail-pos) ; don't lose prior position
@@ -467,7 +469,8 @@ specifies in the mode line."
   :global t :group 'auto-revert :lighter global-auto-revert-mode-text
   (auto-revert-set-timer)
   (if global-auto-revert-mode
-      (auto-revert-buffers)
+      (let (auto-revert-use-notify)
+       (auto-revert-buffers))
     (dolist (buf (buffer-list))
       (with-current-buffer buf
        (when auto-revert-use-notify
@@ -518,13 +521,15 @@ will use an up-to-date value of `auto-revert-interval'"
             (not auto-revert-notify-watch-descriptor))
     (let ((func (if (fboundp 'inotify-add-watch)
                    'inotify-add-watch 'w32notify-add-watch))
+         ;; `attrib' is needed for file modification time.
          (aspect (if (fboundp 'inotify-add-watch)
-                     '(create modify moved-to) '(size last-write-time))))
+                     '(attrib create modify moved-to) '(size last-write-time)))
+         (file (if (fboundp 'inotify-add-watch)
+                   (directory-file-name (expand-file-name default-directory))
+                 (buffer-file-name))))
       (setq auto-revert-notify-watch-descriptor
            (ignore-errors
-             (funcall
-              func (directory-file-name (expand-file-name default-directory))
-              aspect 'auto-revert-notify-handler)))
+             (funcall func file aspect 'auto-revert-notify-handler)))
       (if auto-revert-notify-watch-descriptor
          (progn
            (puthash
@@ -572,7 +577,8 @@ will use an up-to-date value of `auto-revert-interval'"
        ;; TODO: Filter events which stop watching, like `move' or `removed'.
        (cl-assert descriptor)
        (when (featurep 'inotify)
-         (cl-assert (or (memq 'create action)
+         (cl-assert (or (memq 'attrib action)
+                        (memq 'create action)
                         (memq 'modify action)
                         (memq 'moved-to action))))
        (when (featurep 'w32notify) (cl-assert (eq 'modified action)))