diff options
| author | Michael Albinus | 2015-09-11 11:40:33 +0200 |
|---|---|---|
| committer | Michael Albinus | 2015-09-11 11:40:33 +0200 |
| commit | 58e79d70dd4b778bfda6bacfa66b54d0f32816c8 (patch) | |
| tree | 77101a3f0e08131e8def6cfd30b44680f5cf3aa3 | |
| parent | 8aa0386420f9d982b99568f27a5953dfc737640e (diff) | |
| download | emacs-58e79d70dd4b778bfda6bacfa66b54d0f32816c8.tar.gz emacs-58e79d70dd4b778bfda6bacfa66b54d0f32816c8.zip | |
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.el | 23 |
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." | |||
| 3727 | ;; gvfs-monitor-dir. | 3727 | ;; gvfs-monitor-dir. |
| 3728 | ((setq command (tramp-get-remote-gvfs-monitor-dir v)) | 3728 | ((setq command (tramp-get-remote-gvfs-monitor-dir v)) |
| 3729 | (setq filter 'tramp-sh-file-gvfs-monitor-dir-process-filter | 3729 | (setq filter 'tramp-sh-file-gvfs-monitor-dir-process-filter |
| 3730 | events | ||
| 3731 | (cond | ||
| 3732 | ((and (memq 'change flags) (memq 'attribute-change flags)) | ||
| 3733 | '(created changed changes-done-hint moved deleted | ||
| 3734 | attribute-changed)) | ||
| 3735 | ((memq 'change flags) | ||
| 3736 | '(created changed changes-done-hint moved deleted)) | ||
| 3737 | ((memq 'attribute-change flags) '(attribute-changed))) | ||
| 3730 | sequence `(,command ,localname))) | 3738 | sequence `(,command ,localname))) |
| 3731 | ;; inotifywait. | 3739 | ;; inotifywait. |
| 3732 | ((setq command (tramp-get-remote-inotifywait v)) | 3740 | ((setq command (tramp-get-remote-inotifywait v)) |
| @@ -3734,8 +3742,11 @@ Fall back to normal file name handler if no Tramp handler exists." | |||
| 3734 | events | 3742 | events |
| 3735 | (cond | 3743 | (cond |
| 3736 | ((and (memq 'change flags) (memq 'attribute-change flags)) | 3744 | ((and (memq 'change flags) (memq 'attribute-change flags)) |
| 3737 | "create,modify,move,delete,attrib") | 3745 | (concat "create,modify,move,moved_from,moved_to,move_self," |
| 3738 | ((memq 'change flags) "create,modify,move,delete") | 3746 | "delete,delete_self,attrib")) |
| 3747 | ((memq 'change flags) | ||
| 3748 | (concat "create,modify,move,moved_from,moved_to,move_self," | ||
| 3749 | "delete,delete_self")) | ||
| 3739 | ((memq 'attribute-change flags) "attrib")) | 3750 | ((memq 'attribute-change flags) "attrib")) |
| 3740 | sequence `(,command "-mq" "-e" ,events ,localname))) | 3751 | sequence `(,command "-mq" "-e" ,events ,localname))) |
| 3741 | ;; None. | 3752 | ;; None. |
| @@ -3758,12 +3769,15 @@ Fall back to normal file name handler if no Tramp handler exists." | |||
| 3758 | (mapconcat 'identity sequence " ")) | 3769 | (mapconcat 'identity sequence " ")) |
| 3759 | (tramp-message v 6 "Run `%s', %S" (mapconcat 'identity sequence " ") p) | 3770 | (tramp-message v 6 "Run `%s', %S" (mapconcat 'identity sequence " ") p) |
| 3760 | (tramp-set-connection-property p "vector" v) | 3771 | (tramp-set-connection-property p "vector" v) |
| 3772 | ;; Needed for `tramp-sh-file-gvfs-monitor-dir-process-filter'. | ||
| 3773 | (tramp-compat-process-put p 'events events) | ||
| 3761 | (tramp-compat-set-process-query-on-exit-flag p nil) | 3774 | (tramp-compat-set-process-query-on-exit-flag p nil) |
| 3762 | (set-process-filter p filter) | 3775 | (set-process-filter p filter) |
| 3763 | p)))) | 3776 | p)))) |
| 3764 | 3777 | ||
| 3765 | (defun tramp-sh-file-gvfs-monitor-dir-process-filter (proc string) | 3778 | (defun tramp-sh-file-gvfs-monitor-dir-process-filter (proc string) |
| 3766 | "Read output from \"gvfs-monitor-dir\" and add corresponding file-notify events." | 3779 | "Read output from \"gvfs-monitor-dir\" and add corresponding \ |
| 3780 | file-notify events." | ||
| 3767 | (let ((remote-prefix | 3781 | (let ((remote-prefix |
| 3768 | (with-current-buffer (process-buffer proc) | 3782 | (with-current-buffer (process-buffer proc) |
| 3769 | (file-remote-p default-directory))) | 3783 | (file-remote-p default-directory))) |
| @@ -3798,7 +3812,8 @@ Fall back to normal file name handler if no Tramp handler exists." | |||
| 3798 | ;; Usually, we would add an Emacs event now. Unfortunately, | 3812 | ;; Usually, we would add an Emacs event now. Unfortunately, |
| 3799 | ;; `unread-command-events' does not accept several events at | 3813 | ;; `unread-command-events' does not accept several events at |
| 3800 | ;; once. Therefore, we apply the callback directly. | 3814 | ;; once. Therefore, we apply the callback directly. |
| 3801 | (tramp-compat-funcall 'file-notify-callback object))) | 3815 | (when (member (cadr object) (tramp-compat-process-get proc 'events)) |
| 3816 | (tramp-compat-funcall 'file-notify-callback object)))) | ||
| 3802 | 3817 | ||
| 3803 | ;; Save rest of the string. | 3818 | ;; Save rest of the string. |
| 3804 | (when (zerop (length string)) (setq string nil)) | 3819 | (when (zerop (length string)) (setq string nil)) |