;;; filenotify.el --- watch files for changes on disk
-;; Copyright (C) 2013 Free Software Foundation, Inc.
+;; Copyright (C) 2013-2014 Free Software Foundation, Inc.
;; Author: Michael Albinus <michael.albinus@gmx.de>
(pending-event (assoc desc file-notify--pending-events))
(actions (nth 1 event))
(file (file-notify--event-file-name event))
- file1 cookie callback)
+ file1 callback)
;; Make actions a list.
(unless (consp actions) (setq actions (cons actions nil)))
(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
permissions or modification time
If FILE is a directory, 'change' watches for file creation or
-deletion in that directory.
+deletion in that directory. This does not work recursively.
When any event happens, Emacs will call the CALLBACK function passing
it a single argument EVENT, which is of the form
(let* ((handler (find-file-name-handler file 'file-notify-add-watch))
(dir (directory-file-name
- (if (or (and (not handler) (eq file-notify--library 'w32notify))
- (file-directory-p file))
+ (if (file-directory-p file)
file
(file-name-directory file))))
desc func l-flags)
'("No file notification package available")))
;; Determine low-level function to be called.
- (setq func (cond
- ((eq file-notify--library 'gfilenotify) 'gfile-add-watch)
- ((eq file-notify--library 'inotify) 'inotify-add-watch)
- ((eq file-notify--library 'w32notify) 'w32notify-add-watch)))
+ (setq func
+ (cond
+ ((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--library 'gfilenotify)