diff options
| author | Michael Albinus | 2015-09-13 21:16:40 +0200 |
|---|---|---|
| committer | Michael Albinus | 2015-09-13 21:16:40 +0200 |
| commit | f6f92e87692c22840deee068408a418d6e04b7e3 (patch) | |
| tree | 7b0cf2b60232df1e72af3b153587cba340584c2e | |
| parent | a85472bbdcd16b0a695cd75f98b68ee39b86ae2f (diff) | |
| download | emacs-f6f92e87692c22840deee068408a418d6e04b7e3.tar.gz emacs-f6f92e87692c22840deee068408a418d6e04b7e3.zip | |
Introduce `file-notify-valid-p'
* lisp/filenotify.el (file-notify-valid-p): New defun.
(gfile-valid-p, w32notify-valid-p): Make them an alias to `identity'.
* lisp/net/tramp-adb.el (tramp-adb-file-name-handler-alist)
* lisp/net/tramp-gvfs.el (tramp-gvfs-file-name-handler-alist)
* lisp/net/tramp-sh.el (tramp-sh-file-name-handler-alist)
* lisp/net/tramp-smb.el (tramp-smb-file-name-handler-alist)
<file-notify-valid-p>: Add handler.
* lisp/net/tramp.el (tramp-file-name-for-operation):
Add `file-notify-valid-p'.
(tramp-handle-file-notify-valid-p): New defun.
* src/inotify.c (Finotify_valid_p): New defun.
(syms_of_inotify): Declare Sinotify_valid_p.
| -rw-r--r-- | lisp/filenotify.el | 32 | ||||
| -rw-r--r-- | lisp/net/tramp-adb.el | 1 | ||||
| -rw-r--r-- | lisp/net/tramp-gvfs.el | 1 | ||||
| -rw-r--r-- | lisp/net/tramp-sh.el | 1 | ||||
| -rw-r--r-- | lisp/net/tramp-smb.el | 1 | ||||
| -rw-r--r-- | lisp/net/tramp.el | 8 | ||||
| -rw-r--r-- | src/inotify.c | 11 |
7 files changed, 53 insertions, 2 deletions
diff --git a/lisp/filenotify.el b/lisp/filenotify.el index 89fc3733eba..9a48c5ee979 100644 --- a/lisp/filenotify.el +++ b/lisp/filenotify.el | |||
| @@ -357,6 +357,38 @@ DESCRIPTOR should be an object returned by `file-notify-add-watch'." | |||
| 357 | ((eq file-notify--library 'w32notify) 'w32notify-rm-watch)) | 357 | ((eq file-notify--library 'w32notify) 'w32notify-rm-watch)) |
| 358 | desc)))))) | 358 | desc)))))) |
| 359 | 359 | ||
| 360 | ;; Temporary declarations. | ||
| 361 | (defalias 'gfile-valid-p 'identity) | ||
| 362 | (defalias 'w32notify-valid-p 'identity) | ||
| 363 | |||
| 364 | (defun file-notify-valid-p (descriptor) | ||
| 365 | "Check a watch specified by its DESCRIPTOR. | ||
| 366 | DESCRIPTOR should be an object returned by `file-notify-add-watch'." | ||
| 367 | (let* ((desc (if (consp descriptor) (car descriptor) descriptor)) | ||
| 368 | (file (if (consp descriptor) (cdr descriptor))) | ||
| 369 | (registered (gethash desc file-notify-descriptors)) | ||
| 370 | (dir (car registered)) | ||
| 371 | handler) | ||
| 372 | |||
| 373 | (when (stringp dir) | ||
| 374 | (setq handler (find-file-name-handler dir 'file-notify-valid-p)) | ||
| 375 | |||
| 376 | (and (or ;; It is a directory. | ||
| 377 | (not file) | ||
| 378 | ;; The file is registered. | ||
| 379 | (assoc file (cdr registered))) | ||
| 380 | (if handler | ||
| 381 | ;; A file name handler could exist even if there is no | ||
| 382 | ;; local file notification support. | ||
| 383 | (funcall handler 'file-notify-valid-p descriptor) | ||
| 384 | (funcall | ||
| 385 | (cond | ||
| 386 | ((eq file-notify--library 'gfilenotify) 'gfile-valid-p) | ||
| 387 | ((eq file-notify--library 'inotify) 'inotify-valid-p) | ||
| 388 | ((eq file-notify--library 'w32notify) 'w32notify-valid-p)) | ||
| 389 | desc)) | ||
| 390 | t)))) | ||
| 391 | |||
| 360 | ;; The end: | 392 | ;; The end: |
| 361 | (provide 'filenotify) | 393 | (provide 'filenotify) |
| 362 | 394 | ||
diff --git a/lisp/net/tramp-adb.el b/lisp/net/tramp-adb.el index f818fcd61d6..2a7f1a52f13 100644 --- a/lisp/net/tramp-adb.el +++ b/lisp/net/tramp-adb.el | |||
| @@ -132,6 +132,7 @@ It is used for TCP/IP devices." | |||
| 132 | (file-newer-than-file-p . tramp-handle-file-newer-than-file-p) | 132 | (file-newer-than-file-p . tramp-handle-file-newer-than-file-p) |
| 133 | (file-notify-add-watch . tramp-handle-file-notify-add-watch) | 133 | (file-notify-add-watch . tramp-handle-file-notify-add-watch) |
| 134 | (file-notify-rm-watch . tramp-handle-file-notify-rm-watch) | 134 | (file-notify-rm-watch . tramp-handle-file-notify-rm-watch) |
| 135 | (file-notify-valid-p . tramp-handle-file-notify-valid-p) | ||
| 135 | (file-ownership-preserved-p . ignore) | 136 | (file-ownership-preserved-p . ignore) |
| 136 | (file-readable-p . tramp-handle-file-exists-p) | 137 | (file-readable-p . tramp-handle-file-exists-p) |
| 137 | (file-regular-p . tramp-handle-file-regular-p) | 138 | (file-regular-p . tramp-handle-file-regular-p) |
diff --git a/lisp/net/tramp-gvfs.el b/lisp/net/tramp-gvfs.el index 4dfdcd76e66..cf42b5951f7 100644 --- a/lisp/net/tramp-gvfs.el +++ b/lisp/net/tramp-gvfs.el | |||
| @@ -443,6 +443,7 @@ Every entry is a list (NAME ADDRESS).") | |||
| 443 | (file-newer-than-file-p . tramp-handle-file-newer-than-file-p) | 443 | (file-newer-than-file-p . tramp-handle-file-newer-than-file-p) |
| 444 | (file-notify-add-watch . tramp-gvfs-handle-file-notify-add-watch) | 444 | (file-notify-add-watch . tramp-gvfs-handle-file-notify-add-watch) |
| 445 | (file-notify-rm-watch . tramp-handle-file-notify-rm-watch) | 445 | (file-notify-rm-watch . tramp-handle-file-notify-rm-watch) |
| 446 | (file-notify-valid-p . tramp-handle-file-notify-valid-p) | ||
| 446 | (file-ownership-preserved-p . ignore) | 447 | (file-ownership-preserved-p . ignore) |
| 447 | (file-readable-p . tramp-gvfs-handle-file-readable-p) | 448 | (file-readable-p . tramp-gvfs-handle-file-readable-p) |
| 448 | (file-regular-p . tramp-handle-file-regular-p) | 449 | (file-regular-p . tramp-handle-file-regular-p) |
diff --git a/lisp/net/tramp-sh.el b/lisp/net/tramp-sh.el index d9490a0c04b..8598f0e758a 100644 --- a/lisp/net/tramp-sh.el +++ b/lisp/net/tramp-sh.el | |||
| @@ -1008,6 +1008,7 @@ of command line.") | |||
| 1008 | (file-newer-than-file-p . tramp-sh-handle-file-newer-than-file-p) | 1008 | (file-newer-than-file-p . tramp-sh-handle-file-newer-than-file-p) |
| 1009 | (file-notify-add-watch . tramp-sh-handle-file-notify-add-watch) | 1009 | (file-notify-add-watch . tramp-sh-handle-file-notify-add-watch) |
| 1010 | (file-notify-rm-watch . tramp-handle-file-notify-rm-watch) | 1010 | (file-notify-rm-watch . tramp-handle-file-notify-rm-watch) |
| 1011 | (file-notify-valid-p . tramp-handle-file-notify-valid-p) | ||
| 1011 | (file-ownership-preserved-p . tramp-sh-handle-file-ownership-preserved-p) | 1012 | (file-ownership-preserved-p . tramp-sh-handle-file-ownership-preserved-p) |
| 1012 | (file-readable-p . tramp-sh-handle-file-readable-p) | 1013 | (file-readable-p . tramp-sh-handle-file-readable-p) |
| 1013 | (file-regular-p . tramp-handle-file-regular-p) | 1014 | (file-regular-p . tramp-handle-file-regular-p) |
diff --git a/lisp/net/tramp-smb.el b/lisp/net/tramp-smb.el index c4f0f1f500a..5910d1fd3a4 100644 --- a/lisp/net/tramp-smb.el +++ b/lisp/net/tramp-smb.el | |||
| @@ -247,6 +247,7 @@ See `tramp-actions-before-shell' for more info.") | |||
| 247 | (file-newer-than-file-p . tramp-handle-file-newer-than-file-p) | 247 | (file-newer-than-file-p . tramp-handle-file-newer-than-file-p) |
| 248 | (file-notify-add-watch . tramp-handle-file-notify-add-watch) | 248 | (file-notify-add-watch . tramp-handle-file-notify-add-watch) |
| 249 | (file-notify-rm-watch . tramp-handle-file-notify-rm-watch) | 249 | (file-notify-rm-watch . tramp-handle-file-notify-rm-watch) |
| 250 | (file-notify-valid-p . tramp-handle-file-notify-valid-p) | ||
| 250 | (file-ownership-preserved-p . ignore) | 251 | (file-ownership-preserved-p . ignore) |
| 251 | (file-readable-p . tramp-handle-file-exists-p) | 252 | (file-readable-p . tramp-handle-file-exists-p) |
| 252 | (file-regular-p . tramp-handle-file-regular-p) | 253 | (file-regular-p . tramp-handle-file-regular-p) |
diff --git a/lisp/net/tramp.el b/lisp/net/tramp.el index 0969048c433..8b6ad7f1dc3 100644 --- a/lisp/net/tramp.el +++ b/lisp/net/tramp.el | |||
| @@ -2070,7 +2070,7 @@ ARGS are the arguments OPERATION has been called with." | |||
| 2070 | 'dired-print-file 'dired-shell-call-process)) | 2070 | 'dired-print-file 'dired-shell-call-process)) |
| 2071 | default-directory) | 2071 | default-directory) |
| 2072 | ;; PROC. | 2072 | ;; PROC. |
| 2073 | ((eq operation 'file-notify-rm-watch) | 2073 | ((member operation (list 'file-notify-rm-watch 'file-notify-valid-p)) |
| 2074 | (when (processp (nth 0 args)) | 2074 | (when (processp (nth 0 args)) |
| 2075 | (with-current-buffer (process-buffer (nth 0 args)) | 2075 | (with-current-buffer (process-buffer (nth 0 args)) |
| 2076 | default-directory))) | 2076 | default-directory))) |
| @@ -3421,6 +3421,10 @@ of." | |||
| 3421 | (tramp-message proc 6 "Kill %S" proc) | 3421 | (tramp-message proc 6 "Kill %S" proc) |
| 3422 | (kill-process proc)) | 3422 | (kill-process proc)) |
| 3423 | 3423 | ||
| 3424 | (defun tramp-handle-file-notify-valid-p (proc) | ||
| 3425 | "Like `file-notify-valid-p' for Tramp files." | ||
| 3426 | (and proc (processp proc) (memq (process-status proc) '(run open)))) | ||
| 3427 | |||
| 3424 | ;;; Functions for establishing connection: | 3428 | ;;; Functions for establishing connection: |
| 3425 | 3429 | ||
| 3426 | ;; The following functions are actions to be taken when seeing certain | 3430 | ;; The following functions are actions to be taken when seeing certain |
| @@ -3615,7 +3619,7 @@ This is needed in order to hide `last-coding-system-used', which is set | |||
| 3615 | for process communication also." | 3619 | for process communication also." |
| 3616 | (with-current-buffer (process-buffer proc) | 3620 | (with-current-buffer (process-buffer proc) |
| 3617 | ;; FIXME: If there is a gateway process, we need communication | 3621 | ;; FIXME: If there is a gateway process, we need communication |
| 3618 | ;; between several processes. Too complicated to implement, so we | 3622 | ;; between several processes. Too complicate to implement, so we |
| 3619 | ;; read output from all processes. | 3623 | ;; read output from all processes. |
| 3620 | (let ((p (if (tramp-get-connection-property proc "gateway" nil) nil proc)) | 3624 | (let ((p (if (tramp-get-connection-property proc "gateway" nil) nil proc)) |
| 3621 | buffer-read-only last-coding-system-used) | 3625 | buffer-read-only last-coding-system-used) |
diff --git a/src/inotify.c b/src/inotify.c index eddad73e8f7..b73e8733829 100644 --- a/src/inotify.c +++ b/src/inotify.c | |||
| @@ -367,6 +367,16 @@ See inotify_rm_watch(2) for more information. | |||
| 367 | return Qt; | 367 | return Qt; |
| 368 | } | 368 | } |
| 369 | 369 | ||
| 370 | DEFUN ("inotify-valid-p", Finotify_valid_p, Sinotify_valid_p, 1, 1, 0, | ||
| 371 | doc: /* "Check a watch specified by its WATCH-DESCRIPTOR. | ||
| 372 | |||
| 373 | WATCH-DESCRIPTOR should be an object returned by `inotify-add-watch'. */) | ||
| 374 | (Lisp_Object watch_descriptor) | ||
| 375 | { | ||
| 376 | Lisp_Object watch_object = Fassoc (watch_descriptor, watch_list); | ||
| 377 | return NILP (watch_object) ? Qnil : Qt; | ||
| 378 | } | ||
| 379 | |||
| 370 | void | 380 | void |
| 371 | syms_of_inotify (void) | 381 | syms_of_inotify (void) |
| 372 | { | 382 | { |
| @@ -401,6 +411,7 @@ syms_of_inotify (void) | |||
| 401 | 411 | ||
| 402 | defsubr (&Sinotify_add_watch); | 412 | defsubr (&Sinotify_add_watch); |
| 403 | defsubr (&Sinotify_rm_watch); | 413 | defsubr (&Sinotify_rm_watch); |
| 414 | defsubr (&Sinotify_valid_p); | ||
| 404 | 415 | ||
| 405 | staticpro (&watch_list); | 416 | staticpro (&watch_list); |
| 406 | 417 | ||