- EVENT_INIT (event);
- event.kind = FILE_NOTIFY_EVENT;
- event.frame_or_window = Qnil;
- event.arg = list2 (Fcons (monitor_object,
- Fcons (symbol,
- Fcons (build_string (name),
- otail))),
- XCDR (watch_object));
-
- /* Store it into the input event queue. */
- kbd_buffer_store_event (&event);
+
+ /* Check, whether event_type is expected. */
+ flags = XCAR (XCDR (XCDR (watch_object)));
+ if ((!NILP (Fmember (Qchange, flags)) &&
+ !NILP (Fmember (symbol, list5 (Qchanged, Qchanges_done_hint,
+ Qdeleted, Qcreated, Qmoved)))) ||
+ (!NILP (Fmember (Qattribute_change, flags)) &&
+ ((EQ (symbol, Qattribute_changed)))))
+ {
+ /* Construct an event. */
+ EVENT_INIT (event);
+ event.kind = FILE_NOTIFY_EVENT;
+ event.frame_or_window = Qnil;
+ event.arg = list2 (Fcons (monitor_object,
+ Fcons (symbol,
+ Fcons (build_string (name),
+ otail))),
+ XCAR (XCDR (XCDR (XCDR (watch_object)))));
+
+ /* Store it into the input event queue. */
+ kbd_buffer_store_event (&event);
+ // XD_DEBUG_MESSAGE ("%s", XD_OBJECT_TO_STRING (event.arg));
+ }
+
+ /* Cancel monitor if file or directory is deleted. */
+ if (!NILP (Fmember (symbol, list2 (Qdeleted, Qmoved))) &&
+ !g_file_monitor_is_cancelled (monitor))
+ g_file_monitor_cancel (monitor);