Prefer list1 (X) to Fcons (X, Qnil) when building lists.
[bpt/emacs.git] / src / nsterm.m
index c88e503..5cbddd2 100644 (file)
@@ -362,7 +362,7 @@ append2 (Lisp_Object list, Lisp_Object item)
 {
   Lisp_Object array[2];
   array[0] = list;
-  array[1] = Fcons (item, Qnil);
+  array[1] = list1 (item);
   return Fnconc (2, &array[0]);
 }
 
@@ -3603,7 +3603,7 @@ ns_select (int nfds, fd_set *readfds, fd_set *writefds,
 
       /* Inform fd_handler that select should be called */
       c = 'g';
-      emacs_write (selfds[1], &c, 1);
+      emacs_write_sig (selfds[1], &c, 1);
     }
   else if (nr == 0 && timeout)
     {
@@ -3636,7 +3636,7 @@ ns_select (int nfds, fd_set *readfds, fd_set *writefds,
   if (nr > 0 && readfds)
     {
       c = 's';
-      emacs_write (selfds[1], &c, 1);
+      emacs_write_sig (selfds[1], &c, 1);
     }
   unblock_input ();
 
@@ -4142,7 +4142,7 @@ ns_term_init (Lisp_Object display_name)
 
   if (selfds[0] == -1)
     {
-      if (pipe (selfds) == -1)
+      if (pipe2 (selfds, O_CLOEXEC) != 0)
         {
           fprintf (stderr, "Failed to create pipe: %s\n",
                    emacs_strerror (errno));
@@ -4360,6 +4360,12 @@ ns_term_init (Lisp_Object display_name)
 
   [NSApp run];
   ns_do_open_file = YES;
+
+#ifdef NS_IMPL_GNUSTEP
+  /* GNUstep steals SIGCHLD for use in NSTask, but we don't use NSTask.
+     We must re-catch it so subprocess works.  */
+  catch_child_signal ();
+#endif
   return dpyinfo;
 }
 
@@ -4413,16 +4419,33 @@ ns_term_shutdown (int sig)
 /*  NSTRACE (sendEvent); */
 /*fprintf (stderr, "received event of type %d\t%d\n", type);*/
 
-#ifdef NS_IMPL_COCOA
-  if (type == NSApplicationDefined
-      && [theEvent data2] == NSAPP_DATA2_RUNASSCRIPT)
+#ifdef NS_IMPL_GNUSTEP
+  // Keyboard events aren't propagated to file dialogs for some reason.
+  if ([NSApp modalWindow] != nil &&
+      (type == NSKeyDown || type == NSKeyUp || type == NSFlagsChanged))
     {
-      ns_run_ascript ();
-      [self stop: self];
+      [[NSApp modalWindow] sendEvent: theEvent];
       return;
     }
 #endif
 
+  if (type == NSApplicationDefined)
+    {
+      switch ([theEvent data2])
+        {
+#ifdef NS_IMPL_COCOA
+        case NSAPP_DATA2_RUNASSCRIPT:
+          ns_run_ascript ();
+          [self stop: self];
+          return;
+#endif
+        case NSAPP_DATA2_RUNFILEDIALOG:
+          ns_run_file_dialog ();
+          [self stop: self];
+          return;
+        }
+    }
+
   if (type == NSCursorUpdate && window == nil)
     {
       fprintf (stderr, "Dropping external cursor update event.\n");