]> code.delx.au - gnu-emacs/commitdiff
Allow setting the filter masks later
authorLars Ingebrigtsen <larsi@gnus.org>
Tue, 16 Feb 2016 02:37:33 +0000 (13:37 +1100)
committerLars Ingebrigtsen <larsi@gnus.org>
Tue, 16 Feb 2016 02:37:33 +0000 (13:37 +1100)
* src/process.c (Fset_process_filter): Don't set the socket
masks here, because we may not have a socket yet.
(set_process_filter_masks): New function.
(connect_network_socket): Set the filter masks here.

src/process.c

index 02e19c3a84e85400d5aa4c27ea7cc50a186902c6..b4a2de98e12561ff4715c65cbbdd1411aafbc1dd 100644 (file)
@@ -1034,6 +1034,23 @@ DEFUN ("process-mark", Fprocess_mark, Sprocess_mark,
   return XPROCESS (process)->mark;
 }
 
+static void
+set_process_filter_masks (struct Lisp_Process *p)
+{
+  if (EQ (p->filter, Qt) && !EQ (p->status, Qlisten))
+    {
+      FD_CLR (p->infd, &input_wait_mask);
+      FD_CLR (p->infd, &non_keyboard_wait_mask);
+    }
+  else if (EQ (p->filter, Qt)
+          /* Network or serial process not stopped:  */
+          && !EQ (p->command, Qt))
+    {
+      FD_SET (p->infd, &input_wait_mask);
+      FD_SET (p->infd, &non_keyboard_wait_mask);
+    }
+}
+
 DEFUN ("set-process-filter", Fset_process_filter, Sset_process_filter,
        2, 2, 0,
        doc: /* Give PROCESS the filter function FILTER; nil means default.
@@ -1069,23 +1086,11 @@ The string argument is normally a multibyte string, except:
   if (NILP (filter))
     filter = Qinternal_default_process_filter;
 
+  pset_filter (p, filter);
+
   if (p->infd >= 0)
-    {
-      if (EQ (filter, Qt) && !EQ (p->status, Qlisten))
-       {
-         FD_CLR (p->infd, &input_wait_mask);
-         FD_CLR (p->infd, &non_keyboard_wait_mask);
-       }
-      else if (EQ (p->filter, Qt)
-              /* Network or serial process not stopped:  */
-              && !EQ (p->command, Qt))
-       {
-         FD_SET (p->infd, &input_wait_mask);
-         FD_SET (p->infd, &non_keyboard_wait_mask);
-       }
-    }
+    set_process_filter_masks (p);
 
-  pset_filter (p, filter);
   if (NETCONN1_P (p) || SERIALCONN1_P (p) || PIPECONN1_P (p))
     pset_childp (p, Fplist_put (p->childp, QCfilter, filter));
   setup_process_coding_systems (process);
@@ -3342,6 +3347,9 @@ void connect_network_socket (Lisp_Object proc, Lisp_Object ip_addresses)
   if (inch > max_process_desc)
     max_process_desc = inch;
 
+  /* Set up the masks based on the process filter. */
+  set_process_filter_masks (p);
+
   setup_process_coding_systems (proc);
 
 #ifdef HAVE_GNUTLS