summaryrefslogtreecommitdiff
path: root/lisp/filenotify.el
diff options
context:
space:
mode:
authorMichael Albinus <michael.albinus@gmx.de>2013-07-18 12:03:49 +0200
committerMichael Albinus <michael.albinus@gmx.de>2013-07-18 12:03:49 +0200
commite06ec67f56e7cce9b956e2882950379e96514266 (patch)
tree988cdc15f463410f4da9ae664c929409145bf6bb /lisp/filenotify.el
parenta8cd4836451373f56b719cf3b80fb3344a3422db (diff)
downloademacs-e06ec67f56e7cce9b956e2882950379e96514266.tar.gz
* 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.
Diffstat (limited to 'lisp/filenotify.el')
-rw-r--r--lisp/filenotify.el40
1 files changed, 25 insertions, 15 deletions
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)))