static DWORD filter_list_to_flags (Lisp_Object filter_list) { DWORD flags = 0; if (NILP (filter_list)) return flags; if (!NILP (Fmember (Qfile_name, filter_list))) flags |= FILE_NOTIFY_CHANGE_FILE_NAME; if (!NILP (Fmember (Qdirectory_name, filter_list))) flags |= FILE_NOTIFY_CHANGE_DIR_NAME; if (!NILP (Fmember (Qattributes, filter_list))) flags |= FILE_NOTIFY_CHANGE_ATTRIBUTES; if (!NILP (Fmember (Qsize, filter_list))) flags |= FILE_NOTIFY_CHANGE_SIZE; if (!NILP (Fmember (Qlast_write_time, filter_list))) flags |= FILE_NOTIFY_CHANGE_LAST_WRITE; if (!NILP (Fmember (Qlast_access_time, filter_list))) flags |= FILE_NOTIFY_CHANGE_LAST_ACCESS; if (!NILP (Fmember (Qcreation_time, filter_list))) flags |= FILE_NOTIFY_CHANGE_CREATION; if (!NILP (Fmember (Qsecurity_desc, filter_list))) flags |= FILE_NOTIFY_CHANGE_SECURITY; return flags; }
/* Generate a file notification event. */ static void kqueue_generate_event (Lisp_Object watch_object, Lisp_Object actions, Lisp_Object file, Lisp_Object file1) { Lisp_Object flags, action, entry; struct input_event event; /* Check, whether all actions shall be monitored. */ flags = Fnth (make_number (2), watch_object); action = actions; do { if (NILP (action)) break; entry = XCAR (action); if (NILP (Fmember (entry, flags))) { action = XCDR (action); actions = Fdelq (entry, actions); } else action = XCDR (action); } while (1); /* Store it into the input event queue. */ if (! NILP (actions)) { EVENT_INIT (event); event.kind = FILE_NOTIFY_EVENT; event.frame_or_window = Qnil; event.arg = list2 (Fcons (XCAR (watch_object), Fcons (actions, NILP (file1) ? Fcons (file, Qnil) : list2 (file, file1))), Fnth (make_number (3), watch_object)); kbd_buffer_store_event (&event); } }
/* This is the callback function for arriving signals from g_file_monitor. It shall create a Lisp event, and put it into Emacs input queue. */ static gboolean dir_monitor_callback (GFileMonitor *monitor, GFile *file, GFile *other_file, GFileMonitorEvent event_type, gpointer user_data) { Lisp_Object symbol, monitor_object, watch_object, flags; char *name = g_file_get_parse_name (file); char *oname = other_file ? g_file_get_parse_name (other_file) : NULL; /* Determine event symbol. */ switch (event_type) { case G_FILE_MONITOR_EVENT_CHANGED: symbol = Qchanged; break; case G_FILE_MONITOR_EVENT_CHANGES_DONE_HINT: symbol = Qchanges_done_hint; break; case G_FILE_MONITOR_EVENT_DELETED: symbol = Qdeleted; break; case G_FILE_MONITOR_EVENT_CREATED: symbol = Qcreated; break; case G_FILE_MONITOR_EVENT_ATTRIBUTE_CHANGED: symbol = Qattribute_changed; break; case G_FILE_MONITOR_EVENT_PRE_UNMOUNT: symbol = Qpre_unmount; break; case G_FILE_MONITOR_EVENT_UNMOUNTED: symbol = Qunmounted; break; case G_FILE_MONITOR_EVENT_MOVED: symbol = Qmoved; break; default: goto cleanup; } /* Determine callback function. */ monitor_object = make_pointer_integer (monitor); eassert (INTEGERP (monitor_object)); watch_object = assq_no_quit (monitor_object, watch_list); if (CONSP (watch_object)) { struct input_event event; Lisp_Object otail = oname ? list1 (build_string (oname)) : Qnil; /* 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); } /* Cleanup. */ cleanup: g_free (name); g_free (oname); return TRUE; }
repv gh_member(repv x, repv ls) { return Fmember (x, ls); }