Refactor window-system configuration
[bpt/emacs.git] / src / process.c
index 66cc6a1..bfac054 100644 (file)
@@ -116,12 +116,13 @@ along with GNU Emacs.  If not, see <http://www.gnu.org/licenses/>.  */
 #include "gnutls.h"
 #endif
 
+#ifdef HAVE_WINDOW_SYSTEM
+#include TERM_HEADER
+#endif /* HAVE_WINDOW_SYSTEM */
+
 #if defined (USE_GTK) || defined (HAVE_GCONF) || defined (HAVE_GSETTINGS)
 #include "xgselect.h"
 #endif
-#ifdef HAVE_NS
-#include "nsterm.h"
-#endif
 
 /* Work around GCC 4.7.0 bug with strict overflow checking; see
    <http://gcc.gnu.org/bugzilla/show_bug.cgi?id=52904>.
@@ -1623,9 +1624,6 @@ create_process (Lisp_Object process, char **new_argv, Lisp_Object current_dir)
   /* Use volatile to protect variables from being clobbered by longjmp.  */
   volatile int forkin, forkout;
   volatile int pty_flag = 0;
-#ifndef USE_CRT_DLL
-  extern char **environ;
-#endif
 
   inchannel = outchannel = -1;
 
@@ -4873,15 +4871,13 @@ wait_reading_process_output (intmax_t time_limit, int nsecs, int read_kbd,
       for (channel = 0; channel <= max_input_desc; ++channel)
         {
           struct fd_callback_data *d = &fd_callback_info[channel];
-          if (FD_ISSET (channel, &Available)
-              && d->func != 0
-              && (d->condition & FOR_READ) != 0)
-            d->func (channel, d->data, 1);
-          if (FD_ISSET (channel, &write_mask)
-              && d->func != 0
-              && (d->condition & FOR_WRITE) != 0)
-            d->func (channel, d->data, 0);
-          }
+          if (d->func
+             && ((d->condition & FOR_READ
+                  && FD_ISSET (channel, &Available))
+                 || (d->condition & FOR_WRITE
+                     && FD_ISSET (channel, &write_mask))))
+            d->func (channel, d->data);
+       }
 
       for (channel = 0; channel <= max_process_desc; channel++)
        {
@@ -5201,7 +5197,7 @@ read_process_output (Lisp_Object proc, register int channel)
   /* There's no good reason to let process filters change the current
      buffer, and many callers of accept-process-output, sit-for, and
      friends don't expect current-buffer to be changed from under them.  */
-  record_unwind_protect (set_buffer_if_live, Fcurrent_buffer ());
+  record_unwind_current_buffer ();
 
   /* Read and dispose of the process output.  */
   outstream = p->filter;
@@ -5330,7 +5326,7 @@ read_process_output (Lisp_Object proc, register int channel)
       old_begv_byte = BEGV_BYTE;
       old_zv_byte = ZV_BYTE;
 
-      BSET (current_buffer, read_only, Qnil);
+      bset_read_only (current_buffer, Qnil);
 
       /* Insert new output into buffer
         at the current end-of-output marker,
@@ -5421,7 +5417,7 @@ read_process_output (Lisp_Object proc, register int channel)
        Fnarrow_to_region (make_number (old_begv), make_number (old_zv));
 
 
-      BSET (current_buffer, read_only, old_read_only);
+      bset_read_only (current_buffer, old_read_only);
       SET_PT_BOTH (opoint, opoint_byte);
     }
   /* Handling the process output should not deactivate the mark.  */
@@ -6592,7 +6588,7 @@ exec_sentinel (Lisp_Object proc, Lisp_Object reason)
   /* There's no good reason to let sentinels change the current
      buffer, and many callers of accept-process-output, sit-for, and
      friends don't expect current-buffer to be changed from under them.  */
-  record_unwind_protect (set_buffer_if_live, Fcurrent_buffer ());
+  record_unwind_current_buffer ();
 
   sentinel = p->sentinel;
   if (NILP (sentinel))
@@ -6755,13 +6751,13 @@ status_notify (struct Lisp_Process *deleting_process)
              before_byte = PT_BYTE;
 
              tem = BVAR (current_buffer, read_only);
-             BSET (current_buffer, read_only, Qnil);
+             bset_read_only (current_buffer, Qnil);
              insert_string ("\nProcess ");
              { /* FIXME: temporary kludge */
                Lisp_Object tem2 = p->name; Finsert (1, &tem2); }
              insert_string (" ");
              Finsert (1, &msg);
-             BSET (current_buffer, read_only, tem);
+             bset_read_only (current_buffer, tem);
              set_marker_both (p->mark, p->buffer, PT, PT_BYTE);
 
              if (opoint >= before)