(cl-defstruct (file-notify--watch
(:constructor nil)
- (:constructor file-notify--watch-make (directory filename callback)))
+ (:constructor
+ file-notify--watch-make (directory filename callback)))
;; Watched directory
directory
;; Watched relative filename, nil if watching the directory.
"Hash table for registered file notification descriptors.
A key in this hash table is the descriptor as returned from
`inotify', `kqueue', `gfilenotify', `w32notify' or a file name
-handler. The value in the hash table is file-notify--watch
+handler. The value in the hash table is `file-notify--watch'
struct.")
(defun file-notify--rm-descriptor (descriptor)
"Remove DESCRIPTOR from `file-notify-descriptors'.
-DESCRIPTOR should be an object returned by
-`file-notify-add-watch'. If it is registered in
-`file-notify-descriptors', a stopped event is sent."
+DESCRIPTOR should be an object returned by `file-notify-add-watch'.
+If it is registered in `file-notify-descriptors', a stopped event is sent."
(when-let (watch (gethash descriptor file-notify-descriptors))
;; Send `stopped' event.
(unwind-protect
(and (stringp (nth 3 event))
(directory-file-name
(expand-file-name
- (nth 3 event)
- (file-notify--watch-directory watch))))))
+ (nth 3 event) (file-notify--watch-directory watch))))))
;; Cookies are offered by `inotify' only.
(defun file-notify--event-cookie (event)
((memq action '(attrib link)) 'attribute-changed)
((memq action '(create added)) 'created)
((memq action '(modify modified write)) 'changed)
- ((memq action '(delete delete-self move-self removed)) 'deleted)
+ ((memq action
+ '(delete delete-self move-self removed)) 'deleted)
;; Make the event pending.
((memq action '(moved-from renamed-from))
(setq file-notify--pending-event
- `((,desc ,action ,file ,(file-notify--event-cookie event))
+ `((,desc ,action ,file
+ ,(file-notify--event-cookie event))
,(file-notify--watch-callback watch)))
nil)
;; Look for pending event.
;; Apply callback.
(when (and action
(or
- ;; If there is no relative file name for that watch,
- ;; we watch the whole directory.
+ ;; If there is no relative file name for that
+ ;; watch, we watch the whole directory.
(null (file-notify--watch-filename watch))
;; File matches.
(string-equal
(file-name-nondirectory file1)))))
;;(message
;;"file-notify-callback %S %S %S %S %S"
- ;;desc
- ;;action file file1 watch)
+ ;;desc action file file1 watch)
(if file1
(funcall (file-notify--watch-callback watch)
`(,desc ,action ,file ,file1))
'file-notify-rm-watch)))
(condition-case nil
(if handler
- ;; A file name handler could exist even if there is no local
- ;; file notification support.
+ ;; A file name handler could exist even if there is no
+ ;; local file notification support.
(funcall handler 'file-notify-rm-watch descriptor)
(funcall
IN_ONLYDIR
Format: (descriptor . ((id filename callback mask) ...))
- */
+*/
static Lisp_Object watch_list;
static Lisp_Object
/* Add a new watch to watch-descriptor WD watching FILENAME and using
CALLBACK. Returns a cons (DESCRIPTOR . ID) uniquely identifying the
- new watch. */
+ new watch. */
static Lisp_Object
-add_watch (int wd, Lisp_Object filename, Lisp_Object aspect, Lisp_Object callback)
+add_watch (int wd, Lisp_Object filename,
+ Lisp_Object aspect, Lisp_Object callback)
{
Lisp_Object descriptor = make_number (wd);
Lisp_Object elt = Fassoc (descriptor, watch_list);
}
}
-/* Remove watch associated with (descriptor, id). */
+/* Remove watch associated with (descriptor, id). */
static void
remove_watch (Lisp_Object descriptor, Lisp_Object id)
{
if (! NILP (watch))
XSETCDR (elt, Fdelete (watch, XCDR (elt)));
- /* Remove the descriptor if noone is watching it. */
+ /* Remove the descriptor if noone is watching it. */
if (NILP (XCDR (elt)))
remove_descriptor (descriptor, false);
}
If a directory is watched then NAME is the name of file that caused the event.
-COOKIE is an object that can be compared using `equal' to identify two matchingt
+COOKIE is an object that can be compared using `equal' to identify two matching
renames (moved-from and moved-to).
See inotify(7) and inotify_add_watch(2) for further information. The inotify fd
is managed internally and there is no corresponding inotify_init. Use
-`inotify-rm-watch' to remove a watch.
- */)
+`inotify-rm-watch' to remove a watch. */)
(Lisp_Object filename, Lisp_Object aspect, Lisp_Object callback)
{
Lisp_Object encoded_file_name;
WATCH-DESCRIPTOR should be an object returned by `inotify-add-watch'.
-See inotify_rm_watch(2) for more information.
- */)
+See inotify_rm_watch(2) for more information. */)
(Lisp_Object watch_descriptor)
{
#ifdef INOTIFY_DEBUG
DEFUN ("inotify-watch-list", Finotify_watch_list, Sinotify_watch_list, 0, 0, 0,
- doc: /* Return a copy of the internal watch_list. */)
+ doc: /* Return a copy of the internal watch_list. */)
{
return Fcopy_sequence (watch_list);
}
DEFUN ("inotify-allocated-p", Finotify_allocated_p, Sinotify_allocated_p, 0, 0, 0,
- doc: /* Return non-nil, if a inotify instance is allocated. */)
+ doc: /* Return non-nil, if a inotify instance is allocated. */)
{
return inotifyfd < 0 ? Qnil : Qt;
}