]> code.delx.au - gnu-emacs/blobdiff - src/callproc.c
Revision: miles@gnu.org--gnu-2005/emacs--unicode--0--patch-25
[gnu-emacs] / src / callproc.c
index 7632d4919448dee6a79bc85e0fe25b988eb407ec..623509ce199e33a95c9d66393070be313fe062af 100644 (file)
@@ -83,6 +83,7 @@ extern int errno;
 #include "process.h"
 #include "syssignal.h"
 #include "systty.h"
+#include "blockinput.h"
 
 #ifdef MSDOS
 #include "msdos.h"
@@ -216,7 +217,8 @@ usage: (call-process PROGRAM &optional INFILE BUFFER DISPLAY &rest ARGS)  */)
      int nargs;
      register Lisp_Object *args;
 {
-  Lisp_Object infile, buffer, current_dir, display, path;
+  Lisp_Object infile, buffer, current_dir, path;
+  int display_p;
   int fd[2];
   int filefd;
   register int pid;
@@ -372,7 +374,7 @@ usage: (call-process PROGRAM &optional INFILE BUFFER DISPLAY &rest ARGS)  */)
     UNGCPRO;
   }
 
-  display = nargs >= 4 ? args[3] : Qnil;
+  display_p = INTERACTIVE && nargs >= 4 && !NILP (args[3]);
 
   filefd = emacs_open (SDATA (infile), O_RDONLY, 0);
   if (filefd < 0)
@@ -619,6 +621,8 @@ usage: (call-process PROGRAM &optional INFILE BUFFER DISPLAY &rest ARGS)  */)
     pid = child_setup (filefd, fd1, fd_error, (char **) new_argv,
                       0, current_dir);
 #else  /* not WINDOWSNT */
+    BLOCK_INPUT;
+
     pid = vfork ();
 
     if (pid == 0)
@@ -636,6 +640,8 @@ usage: (call-process PROGRAM &optional INFILE BUFFER DISPLAY &rest ARGS)  */)
        child_setup (filefd, fd1, fd_error, (char **) new_argv,
                     0, current_dir);
       }
+
+    UNBLOCK_INPUT;
 #endif /* not WINDOWSNT */
 
     /* The MSDOS case did this already.  */
@@ -739,7 +745,7 @@ usage: (call-process PROGRAM &optional INFILE BUFFER DISPLAY &rest ARGS)  */)
     int first = 1;
     int total_read = 0;
     int carryover = 0;
-    int display_on_the_fly = !NILP (display) && INTERACTIVE;
+    int display_on_the_fly = display_p;
     struct coding_system saved_coding;
 
     saved_coding = process_coding;
@@ -803,6 +809,10 @@ usage: (call-process PROGRAM &optional INFILE BUFFER DISPLAY &rest ARGS)  */)
                    display_on_the_fly = 0;
                    process_coding = saved_coding;
                    carryover = nread;
+                   /* This is to make the above condition always
+                      fails in the future.  */
+                   saved_coding.common_flags
+                     &= ~CODING_REQUIRE_DETECTION_MASK;
                    continue;
                  }
 
@@ -832,12 +842,16 @@ usage: (call-process PROGRAM &optional INFILE BUFFER DISPLAY &rest ARGS)  */)
            bufptr = tempptr;
          }
 
-       if (!NILP (display) && INTERACTIVE)
+       if (display_p)
          {
            if (first)
              prepare_menu_bars ();
            first = 0;
            redisplay_preserve_echo_area (1);
+           /* This variable might have been set to 0 for code
+              detection.  In that case, we set it back to 1 because
+              we should have already detected a coding system.  */
+           display_on_the_fly = 1;
          }
        immediate_quit = 1;
        QUIT;