diff options
-rw-r--r-- | lisp/ChangeLog | 24 | ||||
-rw-r--r-- | lisp/autorevert.el | 22 | ||||
-rw-r--r-- | lisp/filenotify.el | 40 | ||||
-rw-r--r-- | lisp/net/tramp-adb.el | 3 | ||||
-rw-r--r-- | lisp/net/tramp-gvfs.el | 3 | ||||
-rw-r--r-- | lisp/net/tramp-sh.el | 10 | ||||
-rw-r--r-- | lisp/net/tramp-smb.el | 3 | ||||
-rw-r--r-- | lisp/net/tramp.el | 4 |
8 files changed, 80 insertions, 29 deletions
diff --git a/lisp/ChangeLog b/lisp/ChangeLog index 25fd3e6171e..fc38ef046a4 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog @@ -1,3 +1,27 @@ +2013-07-18 Michael Albinus <michael.albinus@gmx.de> + + * filenotify.el (file-notify--library): Renamed from + `file-notify-support'. Do not autoload. Adapt all uses. + (file-notify-supported-p): New defun. + + * autorevert.el (auto-revert-use-notify): Use + `file-notify-supported-p' instead of `file-notify-support'. Adapt + docstring. + (auto-revert-notify-add-watch): Use `file-notify-supported-p'. + + * net/tramp.el (tramp-file-name-for-operation): + Add `file-notify-supported-p'. + + * net/tramp-sh.el (tramp-sh-handle-file-notify-supported-p): + New defun. + (tramp-sh-file-name-handler-alist): Add it as handler for + `file-notify-supported-p '. + + * net/tramp-adb.el (tramp-adb-file-name-handler-alist): + * net/tramp-gvfs.el (tramp-gvfs-file-name-handler-alist): + * net/tramp-smb.el (tramp-smb-file-name-handler-alist): + Add `ignore' as handler for `file-notify-*' functions. + 2013-07-17 Eli Zaretskii <eliz@gnu.org> * simple.el (line-move-partial, line-move): Don't start vscroll or diff --git a/lisp/autorevert.el b/lisp/autorevert.el index 00e88fc4a3d..5c593e2ef71 100644 --- a/lisp/autorevert.el +++ b/lisp/autorevert.el @@ -271,21 +271,20 @@ This variable becomes buffer local when set in any fashion.") :type 'boolean :version "24.4") -(defcustom auto-revert-use-notify (and file-notify-support t) +(defcustom auto-revert-use-notify + ;; We use the support of the local filesystem as default. + (file-notify-supported-p temporary-file-directory) "If non-nil Auto Revert Mode uses file notification functions. -This requires Emacs being compiled with file notification -support (see `file-notify-support'). You should set this variable -through Custom." +You should set this variable through Custom." :group 'auto-revert :type 'boolean :set (lambda (variable value) - (set-default variable (and file-notify-support value)) + (set-default variable value) (unless (symbol-value variable) - (when file-notify-support - (dolist (buf (buffer-list)) - (with-current-buffer buf - (when (symbol-value 'auto-revert-notify-watch-descriptor) - (auto-revert-notify-rm-watch))))))) + (dolist (buf (buffer-list)) + (with-current-buffer buf + (when (symbol-value 'auto-revert-notify-watch-descriptor) + (auto-revert-notify-rm-watch)))))) :initialize 'custom-initialize-default :version "24.4") @@ -513,7 +512,8 @@ will use an up-to-date value of `auto-revert-interval'" (set (make-local-variable 'auto-revert-use-notify) nil)) (when (and buffer-file-name auto-revert-use-notify - (not auto-revert-notify-watch-descriptor)) + (not auto-revert-notify-watch-descriptor) + (file-notify-supported-p buffer-file-name)) (setq auto-revert-notify-watch-descriptor (ignore-errors (file-notify-add-watch diff --git a/lisp/filenotify.el b/lisp/filenotify.el index e170db2dd5f..c9a7e106faa 100644 --- a/lisp/filenotify.el +++ b/lisp/filenotify.el @@ -27,8 +27,7 @@ ;;; Code: -;;;###autoload -(defconst file-notify-support +(defconst file-notify--library (cond ((featurep 'gfilenotify) 'gfilenotify) ((featurep 'inotify) 'inotify) @@ -191,6 +190,17 @@ car of that event, which is the symbol `file-notify'." (funcall callback (list desc action file file1)) (funcall callback (list desc action file))))))) +(defun file-notify-supported-p (file) + "Returns non-nil if filesystem pertaining to FILE could be watched." + (unless (stringp file) + (signal 'wrong-type-argument (list file))) + (setq file (expand-file-name file)) + + (let ((handler (find-file-name-handler file 'file-notify-supported-p))) + (if handler + (funcall handler 'file-notify-supported-p file) + (and file-notify--library t)))) + (defun file-notify-add-watch (file flags callback) "Add a watch for filesystem events pertaining to FILE. This arranges for filesystem events pertaining to FILE to be reported @@ -238,7 +248,7 @@ FILE is the name of the file whose event is being reported." (let* ((handler (find-file-name-handler file 'file-notify-add-watch)) (dir (directory-file-name - (if (or (and (not handler) (eq file-notify-support 'w32notify)) + (if (or (and (not handler) (eq file-notify--library 'w32notify)) (file-directory-p file)) file (file-name-directory file)))) @@ -259,32 +269,32 @@ FILE is the name of the file whose event is being reported." ;; Check, whether Emacs has been compiled with file ;; notification support. - (unless file-notify-support + (unless file-notify--library (signal 'file-notify-error '("No file notification package available"))) ;; Determine low-level function to be called. (setq func (cond - ((eq file-notify-support 'gfilenotify) 'gfile-add-watch) - ((eq file-notify-support 'inotify) 'inotify-add-watch) - ((eq file-notify-support 'w32notify) 'w32notify-add-watch))) + ((eq file-notify--library 'gfilenotify) 'gfile-add-watch) + ((eq file-notify--library 'inotify) 'inotify-add-watch) + ((eq file-notify--library 'w32notify) 'w32notify-add-watch))) ;; Determine respective flags. - (if (eq file-notify-support 'gfilenotify) + (if (eq file-notify--library 'gfilenotify) (setq l-flags '(watch-mounts send-moved)) (when (memq 'change flags) (setq l-flags (cond - ((eq file-notify-support 'inotify) '(create modify move delete)) - ((eq file-notify-support 'w32notify) + ((eq file-notify--library 'inotify) '(create modify move delete)) + ((eq file-notify--library 'w32notify) '(file-name directory-name size last-write-time))))) (when (memq 'attribute-change flags) (add-to-list 'l-flags (cond - ((eq file-notify-support 'inotify) 'attrib) - ((eq file-notify-support 'w32notify) 'attributes))))) + ((eq file-notify--library 'inotify) 'attrib) + ((eq file-notify--library 'w32notify) 'attributes))))) ;; Call low-level function. (setq desc (funcall func dir l-flags 'file-notify-callback)))) @@ -311,9 +321,9 @@ DESCRIPTOR should be an object returned by `file-notify-add-watch'." (funcall handler 'file-notify-rm-watch descriptor) (funcall (cond - ((eq file-notify-support 'gfilenotify) 'gfile-rm-watch) - ((eq file-notify-support 'inotify) 'inotify-rm-watch) - ((eq file-notify-support 'w32notify) 'w32notify-rm-watch)) + ((eq file-notify--library 'gfilenotify) 'gfile-rm-watch) + ((eq file-notify--library 'inotify) 'inotify-rm-watch) + ((eq file-notify--library 'w32notify) 'w32notify-rm-watch)) descriptor))) (remhash descriptor file-notify-descriptors))) diff --git a/lisp/net/tramp-adb.el b/lisp/net/tramp-adb.el index 14fb8575fff..56c0ee2dc2d 100644 --- a/lisp/net/tramp-adb.el +++ b/lisp/net/tramp-adb.el @@ -108,6 +108,9 @@ (file-writable-p . tramp-adb-handle-file-writable-p) (file-local-copy . tramp-adb-handle-file-local-copy) (file-modes . tramp-handle-file-modes) + (file-notify-add-watch . ignore) + (file-notify-rm-watch . ignore) + (file-notify-supported-p . ignore) (expand-file-name . tramp-adb-handle-expand-file-name) (find-backup-file-name . tramp-handle-find-backup-file-name) (directory-files . tramp-handle-directory-files) diff --git a/lisp/net/tramp-gvfs.el b/lisp/net/tramp-gvfs.el index c2fdc0491b6..526408140c2 100644 --- a/lisp/net/tramp-gvfs.el +++ b/lisp/net/tramp-gvfs.el @@ -435,6 +435,9 @@ Every entry is a list (NAME ADDRESS).") (file-name-nondirectory . tramp-handle-file-name-nondirectory) ;; `file-name-sans-versions' performed by default handler. (file-newer-than-file-p . tramp-handle-file-newer-than-file-p) + (file-notify-add-watch . ignore) + (file-notify-rm-watch . ignore) + (file-notify-supported-p . ignore) (file-ownership-preserved-p . ignore) (file-readable-p . tramp-gvfs-handle-file-readable-p) (file-regular-p . tramp-handle-file-regular-p) diff --git a/lisp/net/tramp-sh.el b/lisp/net/tramp-sh.el index c92eacd4473..d2fc1b9979e 100644 --- a/lisp/net/tramp-sh.el +++ b/lisp/net/tramp-sh.el @@ -867,7 +867,8 @@ of command line.") (set-file-acl . tramp-sh-handle-set-file-acl) (vc-registered . tramp-sh-handle-vc-registered) (file-notify-add-watch . tramp-sh-handle-file-notify-add-watch) - (file-notify-rm-watch . tramp-sh-handle-file-notify-rm-watch)) + (file-notify-rm-watch . tramp-sh-handle-file-notify-rm-watch) + (file-notify-supported-p . tramp-sh-handle-file-notify-supported-p)) "Alist of handler functions. Operations not mentioned here will be handled by the normal Emacs functions.") @@ -3498,6 +3499,13 @@ Fall back to normal file name handler if no Tramp handler exists." (tramp-message proc 6 (format "Kill %S" proc)) (kill-process proc)) +(defun tramp-sh-handle-file-notify-supported-p (file-name) + "Like `file-notify-supported-p' for Tramp files." + (with-parsed-tramp-file-name (expand-file-name file-name) nil + (and (or (tramp-get-remote-gvfs-monitor-dir v) + (tramp-get-remote-inotifywait v)) + t))) + ;;; Internal Functions: (defun tramp-maybe-send-script (vec script name) diff --git a/lisp/net/tramp-smb.el b/lisp/net/tramp-smb.el index 65c52ae4f3c..d9bb5057e7a 100644 --- a/lisp/net/tramp-smb.el +++ b/lisp/net/tramp-smb.el @@ -209,6 +209,9 @@ See `tramp-actions-before-shell' for more info.") (file-name-nondirectory . tramp-handle-file-name-nondirectory) ;; `file-name-sans-versions' performed by default handler. (file-newer-than-file-p . tramp-handle-file-newer-than-file-p) + (file-notify-add-watch . ignore) + (file-notify-rm-watch . ignore) + (file-notify-supported-p . ignore) (file-ownership-preserved-p . ignore) (file-readable-p . tramp-handle-file-exists-p) (file-regular-p . tramp-handle-file-regular-p) diff --git a/lisp/net/tramp.el b/lisp/net/tramp.el index 3513701d20e..fd5435bd3d4 100644 --- a/lisp/net/tramp.el +++ b/lisp/net/tramp.el @@ -1980,8 +1980,8 @@ ARGS are the arguments OPERATION has been called with." ;; Emacs 22+ only. 'set-file-times ;; Emacs 24+ only. - 'file-acl 'file-notify-add-watch 'file-selinux-context - 'set-file-acl 'set-file-selinux-context + 'file-acl 'file-notify-add-watch 'file-notify-supported-p + 'file-selinux-context 'set-file-acl 'set-file-selinux-context ;; XEmacs only. 'abbreviate-file-name 'create-file-buffer 'dired-file-modtime 'dired-make-compressed-filename |