summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael Albinus <michael.albinus@gmx.de>2015-09-11 11:40:33 +0200
committerMichael Albinus <michael.albinus@gmx.de>2015-09-11 11:40:33 +0200
commit58e79d70dd4b778bfda6bacfa66b54d0f32816c8 (patch)
tree77101a3f0e08131e8def6cfd30b44680f5cf3aa3
parent8aa0386420f9d982b99568f27a5953dfc737640e (diff)
downloademacs-58e79d70dd4b778bfda6bacfa66b54d0f32816c8.tar.gz
Improve file notifications in Tramp
* lisp/net/tramp-sh.el (tramp-sh-handle-file-notify-add-watch): Set proper events to watch for. (tramp-sh-file-gvfs-monitor-dir-process-filter): Report only watched events.
-rw-r--r--lisp/net/tramp-sh.el23
1 files changed, 19 insertions, 4 deletions
diff --git a/lisp/net/tramp-sh.el b/lisp/net/tramp-sh.el
index 79b024e8310..d9490a0c04b 100644
--- a/lisp/net/tramp-sh.el
+++ b/lisp/net/tramp-sh.el
@@ -3727,6 +3727,14 @@ Fall back to normal file name handler if no Tramp handler exists."
;; gvfs-monitor-dir.
((setq command (tramp-get-remote-gvfs-monitor-dir v))
(setq filter 'tramp-sh-file-gvfs-monitor-dir-process-filter
+ events
+ (cond
+ ((and (memq 'change flags) (memq 'attribute-change flags))
+ '(created changed changes-done-hint moved deleted
+ attribute-changed))
+ ((memq 'change flags)
+ '(created changed changes-done-hint moved deleted))
+ ((memq 'attribute-change flags) '(attribute-changed)))
sequence `(,command ,localname)))
;; inotifywait.
((setq command (tramp-get-remote-inotifywait v))
@@ -3734,8 +3742,11 @@ Fall back to normal file name handler if no Tramp handler exists."
events
(cond
((and (memq 'change flags) (memq 'attribute-change flags))
- "create,modify,move,delete,attrib")
- ((memq 'change flags) "create,modify,move,delete")
+ (concat "create,modify,move,moved_from,moved_to,move_self,"
+ "delete,delete_self,attrib"))
+ ((memq 'change flags)
+ (concat "create,modify,move,moved_from,moved_to,move_self,"
+ "delete,delete_self"))
((memq 'attribute-change flags) "attrib"))
sequence `(,command "-mq" "-e" ,events ,localname)))
;; None.
@@ -3758,12 +3769,15 @@ Fall back to normal file name handler if no Tramp handler exists."
(mapconcat 'identity sequence " "))
(tramp-message v 6 "Run `%s', %S" (mapconcat 'identity sequence " ") p)
(tramp-set-connection-property p "vector" v)
+ ;; Needed for `tramp-sh-file-gvfs-monitor-dir-process-filter'.
+ (tramp-compat-process-put p 'events events)
(tramp-compat-set-process-query-on-exit-flag p nil)
(set-process-filter p filter)
p))))
(defun tramp-sh-file-gvfs-monitor-dir-process-filter (proc string)
- "Read output from \"gvfs-monitor-dir\" and add corresponding file-notify events."
+ "Read output from \"gvfs-monitor-dir\" and add corresponding \
+file-notify events."
(let ((remote-prefix
(with-current-buffer (process-buffer proc)
(file-remote-p default-directory)))
@@ -3798,7 +3812,8 @@ Fall back to normal file name handler if no Tramp handler exists."
;; Usually, we would add an Emacs event now. Unfortunately,
;; `unread-command-events' does not accept several events at
;; once. Therefore, we apply the callback directly.
- (tramp-compat-funcall 'file-notify-callback object)))
+ (when (member (cadr object) (tramp-compat-process-get proc 'events))
+ (tramp-compat-funcall 'file-notify-callback object))))
;; Save rest of the string.
(when (zerop (length string)) (setq string nil))