Support w32 file notifications in batch mode.
src/w32proc.c (sys_select): Don't wait on interrupt_handle if it is
invalid (which happens in batch mode). If non-interactive, call
handle_file_notifications to store file notification events in the
input queue.
src/w32notify.c (send_notifications): Handle FRAME_INITIAL frames as
well.
src/w32inevt.c (handle_file_notifications): Now external, not
static.
src/w32term.h (handle_file_notifications): Provide prototype.
src/emacs.c (main) [HAVE_W32NOTIFY]: When non-interactive, call
init_crit, since init_display, which does that otherwise, is not
called.
+2013-11-28 Eli Zaretskii <eliz@gnu.org>
+
+ Support w32 file notifications in batch mode.
+ * w32proc.c (sys_select): Don't wait on interrupt_handle if it is
+ invalid (which happens in batch mode). If non-interactive, call
+ handle_file_notifications to store file notification events in the
+ input queue. (Bug#15933)
+
+ * w32notify.c (send_notifications): Handle FRAME_INITIAL frames as
+ well.
+
+ * w32inevt.c (handle_file_notifications): Now external, not
+ static.
+
+ * w32term.h (handle_file_notifications): Provide prototype.
+
+ * emacs.c (main) [HAVE_W32NOTIFY]: When non-interactive, call
+ init_crit, since init_display, which does that otherwise, is not
+ called.
+
2013-11-27 Glenn Morris <rgm@gnu.org>
* Makefile.in ($(lispsource)/international/charprop.el): New.
init_keyboard (); /* This too must precede init_sys_modes. */
if (!noninteractive)
init_display (); /* Determine terminal type. Calls init_sys_modes. */
+#if HAVE_W32NOTIFY
+ else
+ init_crit (); /* w32notify.c needs this in batch mode. */
+#endif /* HAVE_W32NOTIFY */
init_xdisp ();
#ifdef HAVE_WINDOW_SYSTEM
init_fringe ();
}
#if HAVE_W32NOTIFY
-static int
+int
handle_file_notifications (struct input_event *hold_quit)
{
BYTE *p = file_notifications;
return nevents;
}
#else /* !HAVE_W32NOTIFY */
-static int
+int
handle_file_notifications (struct input_event *hold_quit)
{
return 0;
&& PostThreadMessage (dwMainThreadId, WM_EMACS_FILENOTIFY, 0, 0))
|| (FRAME_W32_P (f)
&& PostMessage (FRAME_W32_WINDOW (f),
- WM_EMACS_FILENOTIFY, 0, 0)))
+ WM_EMACS_FILENOTIFY, 0, 0))
+ /* When we are running in batch mode, there's no one to
+ send a message, so we just signal the data is
+ available and hope sys_select will be called soon and
+ will read the data. */
+ || (FRAME_INITIAL_P (f) && noninteractive))
notification_buffer_in_use = 1;
done = 1;
}
FD_ZERO (rfds);
nr = 0;
- /* Always wait on interrupt_handle, to detect C-g (quit). */
- wait_hnd[0] = interrupt_handle;
- fdindex[0] = -1;
+ /* If interrupt_handle is available and valid, always wait on it, to
+ detect C-g (quit). */
+ nh = 0;
+ if (interrupt_handle && interrupt_handle != INVALID_HANDLE_VALUE)
+ {
+ wait_hnd[0] = interrupt_handle;
+ fdindex[0] = -1;
+ nh++;
+ }
/* Build a list of pipe handles to wait on. */
- nh = 1;
for (i = 0; i < nfds; i++)
if (FD_ISSET (i, &orfds))
{
FD_SET (i, rfds);
return 1;
}
+ else if (noninteractive)
+ {
+ if (handle_file_notifications (NULL))
+ return 1;
+ }
}
else
{
{
if (timeout)
Sleep (timeout_ms);
+ if (noninteractive)
+ {
+ if (handle_file_notifications (NULL))
+ return 1;
+ }
return 0;
}
}
else if (active == WAIT_TIMEOUT)
{
+ if (noninteractive)
+ {
+ if (handle_file_notifications (NULL))
+ return 1;
+ }
return 0;
}
else if (active >= WAIT_OBJECT_0
break;
} while (active < nh + nc);
+ if (noninteractive)
+ {
+ if (handle_file_notifications (NULL))
+ nr++;
+ }
+
/* If no input has arrived and timeout hasn't expired, wait again. */
if (nr == 0)
{
extern void *notifications_desc;
extern Lisp_Object w32_get_watch_object (void *);
extern Lisp_Object lispy_file_action (DWORD);
+extern int handle_file_notifications (struct input_event *);
extern void w32_initialize_display_info (Lisp_Object);
extern void initialize_w32_display (struct terminal *, int *, int *);