* 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.
((eq file-notify--library 'w32notify) 'w32notify-rm-watch))
desc))))))
+;; Temporary declarations.
+(defalias 'gfile-valid-p 'identity)
+(defalias 'w32notify-valid-p 'identity)
+
+(defun file-notify-valid-p (descriptor)
+ "Check a watch specified by its DESCRIPTOR.
+DESCRIPTOR should be an object returned by `file-notify-add-watch'."
+ (let* ((desc (if (consp descriptor) (car descriptor) descriptor))
+ (file (if (consp descriptor) (cdr descriptor)))
+ (registered (gethash desc file-notify-descriptors))
+ (dir (car registered))
+ handler)
+
+ (when (stringp dir)
+ (setq handler (find-file-name-handler dir 'file-notify-valid-p))
+
+ (and (or ;; It is a directory.
+ (not file)
+ ;; The file is registered.
+ (assoc file (cdr registered)))
+ (if handler
+ ;; A file name handler could exist even if there is no
+ ;; local file notification support.
+ (funcall handler 'file-notify-valid-p descriptor)
+ (funcall
+ (cond
+ ((eq file-notify--library 'gfilenotify) 'gfile-valid-p)
+ ((eq file-notify--library 'inotify) 'inotify-valid-p)
+ ((eq file-notify--library 'w32notify) 'w32notify-valid-p))
+ desc))
+ t))))
+
;; The end:
(provide 'filenotify)
(file-newer-than-file-p . tramp-handle-file-newer-than-file-p)
(file-notify-add-watch . tramp-handle-file-notify-add-watch)
(file-notify-rm-watch . tramp-handle-file-notify-rm-watch)
+ (file-notify-valid-p . tramp-handle-file-notify-valid-p)
(file-ownership-preserved-p . ignore)
(file-readable-p . tramp-handle-file-exists-p)
(file-regular-p . tramp-handle-file-regular-p)
(file-newer-than-file-p . tramp-handle-file-newer-than-file-p)
(file-notify-add-watch . tramp-gvfs-handle-file-notify-add-watch)
(file-notify-rm-watch . tramp-handle-file-notify-rm-watch)
+ (file-notify-valid-p . tramp-handle-file-notify-valid-p)
(file-ownership-preserved-p . ignore)
(file-readable-p . tramp-gvfs-handle-file-readable-p)
(file-regular-p . tramp-handle-file-regular-p)
(file-newer-than-file-p . tramp-sh-handle-file-newer-than-file-p)
(file-notify-add-watch . tramp-sh-handle-file-notify-add-watch)
(file-notify-rm-watch . tramp-handle-file-notify-rm-watch)
+ (file-notify-valid-p . tramp-handle-file-notify-valid-p)
(file-ownership-preserved-p . tramp-sh-handle-file-ownership-preserved-p)
(file-readable-p . tramp-sh-handle-file-readable-p)
(file-regular-p . tramp-handle-file-regular-p)
(file-newer-than-file-p . tramp-handle-file-newer-than-file-p)
(file-notify-add-watch . tramp-handle-file-notify-add-watch)
(file-notify-rm-watch . tramp-handle-file-notify-rm-watch)
+ (file-notify-valid-p . tramp-handle-file-notify-valid-p)
(file-ownership-preserved-p . ignore)
(file-readable-p . tramp-handle-file-exists-p)
(file-regular-p . tramp-handle-file-regular-p)
'dired-print-file 'dired-shell-call-process))
default-directory)
;; PROC.
- ((eq operation 'file-notify-rm-watch)
+ ((member operation (list 'file-notify-rm-watch 'file-notify-valid-p))
(when (processp (nth 0 args))
(with-current-buffer (process-buffer (nth 0 args))
default-directory)))
(tramp-message proc 6 "Kill %S" proc)
(kill-process proc))
+(defun tramp-handle-file-notify-valid-p (proc)
+ "Like `file-notify-valid-p' for Tramp files."
+ (and proc (processp proc) (memq (process-status proc) '(run open))))
+
;;; Functions for establishing connection:
;; The following functions are actions to be taken when seeing certain
for process communication also."
(with-current-buffer (process-buffer proc)
;; FIXME: If there is a gateway process, we need communication
- ;; between several processes. Too complicated to implement, so we
+ ;; between several processes. Too complicate to implement, so we
;; read output from all processes.
(let ((p (if (tramp-get-connection-property proc "gateway" nil) nil proc))
buffer-read-only last-coding-system-used)
return Qt;
}
+DEFUN ("inotify-valid-p", Finotify_valid_p, Sinotify_valid_p, 1, 1, 0,
+ doc: /* "Check a watch specified by its WATCH-DESCRIPTOR.
+
+WATCH-DESCRIPTOR should be an object returned by `inotify-add-watch'. */)
+ (Lisp_Object watch_descriptor)
+{
+ Lisp_Object watch_object = Fassoc (watch_descriptor, watch_list);
+ return NILP (watch_object) ? Qnil : Qt;
+}
+
void
syms_of_inotify (void)
{
defsubr (&Sinotify_add_watch);
defsubr (&Sinotify_rm_watch);
+ defsubr (&Sinotify_valid_p);
staticpro (&watch_list);