+2013-08-15 Dmitry Antipov <dmantipov@yandex.ru>
+
+ * lisp.h (FOR_EACH_ALIST_VALUE): New macro
+ to do `for' loops over alist values.
+ * buffer.h (FOR_EACH_BUFFER):
+ * process.c (FOR_EACH_PROCESS): Use it.
+ (handle_child_signal, status_notify, Fget_buffer_process)
+ (kill_buffer_processes): Use FOR_EACH_PROCESS.
+
2013-08-15 Dmitry Antipov <dmantipov@yandex.ru>
* term.c (get_named_tty, create_tty_output, tty_free_frame_resources)
/* FOR_EACH_LIVE_BUFFER (LIST_VAR, BUF_VAR) followed by a statement is
a `for' loop which iterates over the buffers from Vbuffer_alist. */
-#define FOR_EACH_LIVE_BUFFER(list_var, buf_var) \
- for (list_var = Vbuffer_alist; \
- (CONSP (list_var) && (buf_var = XCDR (XCAR (list_var)), 1)); \
- list_var = XCDR (list_var))
+#define FOR_EACH_LIVE_BUFFER(list_var, buf_var) \
+ FOR_EACH_ALIST_VALUE (Vbuffer_alist, list_var, buf_var)
/* Get text properties of B. */
#define DATAGRAM_CONN_P(proc) (0)
#endif
+/* FOR_EACH_PROCESS (LIST_VAR, PROC_VAR) followed by a statement is
+ a `for' loop which iterates over processes from Vprocess_alist. */
+
+#define FOR_EACH_PROCESS(list_var, proc_var) \
+ FOR_EACH_ALIST_VALUE (Vprocess_alist, list_var, proc_var)
+
/* These setters are used only in this file, so they can be private. */
static void
pset_buffer (struct Lisp_Process *p, Lisp_Object val)
static void
handle_child_signal (int sig)
{
- Lisp_Object tail;
+ Lisp_Object tail, proc;
/* Find the process that signaled us, and record its status. */
}
/* Otherwise, if it is asynchronous, it is in Vprocess_alist. */
- for (tail = Vprocess_alist; CONSP (tail); tail = XCDR (tail))
+ FOR_EACH_PROCESS (tail, proc)
{
- Lisp_Object proc = XCDR (XCAR (tail));
struct Lisp_Process *p = XPROCESS (proc);
int status;
that we run, we get called again to handle their status changes. */
update_tick = process_tick;
- for (tail = Vprocess_alist; CONSP (tail); tail = XCDR (tail))
+ FOR_EACH_PROCESS (tail, proc)
{
Lisp_Object symbol;
- register struct Lisp_Process *p;
-
- proc = Fcdr (XCAR (tail));
- p = XPROCESS (proc);
+ register struct Lisp_Process *p = XPROCESS (proc);
if (p->tick != p->update_tick)
{
buf = Fget_buffer (buffer);
if (NILP (buf)) return Qnil;
- for (tail = Vprocess_alist; CONSP (tail); tail = XCDR (tail))
- {
- proc = Fcdr (XCAR (tail));
- if (PROCESSP (proc) && EQ (XPROCESS (proc)->buffer, buf))
- return proc;
- }
+ FOR_EACH_PROCESS (tail, proc)
+ if (EQ (XPROCESS (proc)->buffer, buf))
+ return proc;
#endif /* subprocesses */
return Qnil;
}
#ifdef subprocesses
Lisp_Object tail, proc;
- for (tail = Vprocess_alist; CONSP (tail); tail = XCDR (tail))
- {
- proc = XCDR (XCAR (tail));
- if (PROCESSP (proc)
- && (NILP (buffer) || EQ (XPROCESS (proc)->buffer, buffer)))
- {
- if (NETCONN_P (proc) || SERIALCONN_P (proc))
- Fdelete_process (proc);
- else if (XPROCESS (proc)->infd >= 0)
- process_send_signal (proc, SIGHUP, Qnil, 1);
- }
- }
+ FOR_EACH_PROCESS (tail, proc)
+ if (NILP (buffer) || EQ (XPROCESS (proc)->buffer, buffer))
+ {
+ if (NETCONN_P (proc) || SERIALCONN_P (proc))
+ Fdelete_process (proc);
+ else if (XPROCESS (proc)->infd >= 0)
+ process_send_signal (proc, SIGHUP, Qnil, 1);
+ }
#else /* subprocesses */
/* Since we have no subprocesses, this does nothing. */
#endif /* subprocesses */