comparison src/process.c @ 56701:e327231e4361

(Faccept_process_output): Add arg JUST-THIS-ONE; forward to wait_reading_process_input via DO_DISPLAY arg. (wait_reading_process_input): If DO_DISPLAY < 0 for a process object, only process output from that process; also inhibit running timers if DO_DISPLAY==-2.
author Kim F. Storm <storm@cua.dk>
date Tue, 17 Aug 2004 22:24:29 +0000
parents 33e68be5c251
children 7e315ff338bf b15f799f66b5
comparison
equal deleted inserted replaced
56700:33e68be5c251 56701:e327231e4361
3716 } 3716 }
3717 #endif 3717 #endif
3718 } 3718 }
3719 3719
3720 DEFUN ("accept-process-output", Faccept_process_output, Saccept_process_output, 3720 DEFUN ("accept-process-output", Faccept_process_output, Saccept_process_output,
3721 0, 3, 0, 3721 0, 4, 0,
3722 doc: /* Allow any pending output from subprocesses to be read by Emacs. 3722 doc: /* Allow any pending output from subprocesses to be read by Emacs.
3723 It is read into the process' buffers or given to their filter functions. 3723 It is read into the process' buffers or given to their filter functions.
3724 Non-nil arg PROCESS means do not return until some output has been received 3724 Non-nil arg PROCESS means do not return until some output has been received
3725 from PROCESS. 3725 from PROCESS.
3726 Non-nil second arg TIMEOUT and third arg TIMEOUT-MSECS are number of 3726 Non-nil second arg TIMEOUT and third arg TIMEOUT-MSECS are number of
3727 seconds and microseconds to wait; return after that much time whether 3727 seconds and microseconds to wait; return after that much time whether
3728 or not there is input. 3728 or not there is input.
3729 If optional fourth arg JUST-THIS-ONE is non-nil, only accept output
3730 from PROCESS, suspending reading output from other processes.
3731 If JUST-THIS-ONE is an integer, don't run any timers either.
3729 Return non-nil iff we received any output before the timeout expired. */) 3732 Return non-nil iff we received any output before the timeout expired. */)
3730 (process, timeout, timeout_msecs) 3733 (process, timeout, timeout_msecs, just_this_one)
3731 register Lisp_Object process, timeout, timeout_msecs; 3734 register Lisp_Object process, timeout, timeout_msecs, just_this_one;
3732 { 3735 {
3733 int seconds; 3736 int seconds;
3734 int useconds; 3737 int useconds;
3735 3738
3736 if (! NILP (process)) 3739 if (! NILP (process))
3737 CHECK_PROCESS (process); 3740 CHECK_PROCESS (process);
3741 else
3742 just_this_one = Qnil;
3738 3743
3739 if (! NILP (timeout_msecs)) 3744 if (! NILP (timeout_msecs))
3740 { 3745 {
3741 CHECK_NUMBER (timeout_msecs); 3746 CHECK_NUMBER (timeout_msecs);
3742 useconds = XINT (timeout_msecs); 3747 useconds = XINT (timeout_msecs);
3774 3779
3775 if (NILP (process)) 3780 if (NILP (process))
3776 XSETFASTINT (process, 0); 3781 XSETFASTINT (process, 0);
3777 3782
3778 return 3783 return
3779 (wait_reading_process_input (seconds, useconds, process, 0) 3784 (wait_reading_process_input (seconds, useconds, process,
3785 NILP (just_this_one) ? 0 :
3786 !INTEGERP (just_this_one) ? -1 : -2)
3780 ? Qt : Qnil); 3787 ? Qt : Qnil);
3781 } 3788 }
3782 3789
3783 /* Accept a connection for server process SERVER on CHANNEL. */ 3790 /* Accept a connection for server process SERVER on CHANNEL. */
3784 3791
4007 (and gobble terminal input into the buffer if any arrives), or 4014 (and gobble terminal input into the buffer if any arrives), or
4008 a process object, meaning wait until something arrives from that 4015 a process object, meaning wait until something arrives from that
4009 process. The return value is true iff we read some input from 4016 process. The return value is true iff we read some input from
4010 that process. 4017 that process.
4011 4018
4012 DO_DISPLAY != 0 means redisplay should be done to show subprocess 4019 If READ_KBD is a process object, DO_DISPLAY < 0 means handle only
4013 output that arrives. 4020 output from that process (suspending output from other processes)
4021 and DO_DISPLAY == -2 specifically means don't run any timers either.
4022 Otherwise, != 0 means redisplay should be done to show subprocess
4023 output that arrives.
4014 4024
4015 If READ_KBD is a pointer to a struct Lisp_Process, then the 4025 If READ_KBD is a pointer to a struct Lisp_Process, then the
4016 function returns true iff we received input from that process 4026 function returns true iff we received input from that process
4017 before the timeout elapsed. 4027 before the timeout elapsed.
4018 Otherwise, return true iff we received input from any process. */ 4028 Otherwise, return true iff we received input from any process. */
4030 int xerrno; 4040 int xerrno;
4031 Lisp_Object proc; 4041 Lisp_Object proc;
4032 EMACS_TIME timeout, end_time; 4042 EMACS_TIME timeout, end_time;
4033 int wait_channel = -1; 4043 int wait_channel = -1;
4034 struct Lisp_Process *wait_proc = 0; 4044 struct Lisp_Process *wait_proc = 0;
4045 int just_wait_proc = 0;
4035 int got_some_input = 0; 4046 int got_some_input = 0;
4036 /* Either nil or a cons cell, the car of which is of interest and 4047 /* Either nil or a cons cell, the car of which is of interest and
4037 may be changed outside of this routine. */ 4048 may be changed outside of this routine. */
4038 Lisp_Object wait_for_cell = Qnil; 4049 Lisp_Object wait_for_cell = Qnil;
4039 int saved_waiting_for_user_input_p = waiting_for_user_input_p; 4050 int saved_waiting_for_user_input_p = waiting_for_user_input_p;
4046 if (PROCESSP (read_kbd)) 4057 if (PROCESSP (read_kbd))
4047 { 4058 {
4048 wait_proc = XPROCESS (read_kbd); 4059 wait_proc = XPROCESS (read_kbd);
4049 wait_channel = XINT (wait_proc->infd); 4060 wait_channel = XINT (wait_proc->infd);
4050 XSETFASTINT (read_kbd, 0); 4061 XSETFASTINT (read_kbd, 0);
4062 if (do_display < 0)
4063 {
4064 just_wait_proc = do_display;
4065 do_display = 0;
4066 }
4051 } 4067 }
4052 4068
4053 /* If waiting for non-nil in a cell, record where. */ 4069 /* If waiting for non-nil in a cell, record where. */
4054 if (CONSP (read_kbd)) 4070 if (CONSP (read_kbd))
4055 { 4071 {
4120 4136
4121 /* Normally we run timers here. 4137 /* Normally we run timers here.
4122 But not if wait_for_cell; in those cases, 4138 But not if wait_for_cell; in those cases,
4123 the wait is supposed to be short, 4139 the wait is supposed to be short,
4124 and those callers cannot handle running arbitrary Lisp code here. */ 4140 and those callers cannot handle running arbitrary Lisp code here. */
4125 if (NILP (wait_for_cell)) 4141 if (NILP (wait_for_cell)
4142 && just_wait_proc != -2)
4126 { 4143 {
4127 EMACS_TIME timer_delay; 4144 EMACS_TIME timer_delay;
4128 4145
4129 do 4146 do
4130 { 4147 {
4256 break; 4273 break;
4257 } 4274 }
4258 4275
4259 /* Wait till there is something to do */ 4276 /* Wait till there is something to do */
4260 4277
4261 if (!NILP (wait_for_cell)) 4278 if (just_wait_proc)
4279 {
4280 FD_SET (XINT (wait_proc->infd), &Available);
4281 check_connect = check_delay = 0;
4282 }
4283 else if (!NILP (wait_for_cell))
4262 { 4284 {
4263 Available = non_process_wait_mask; 4285 Available = non_process_wait_mask;
4264 check_connect = check_delay = 0; 4286 check_connect = check_delay = 0;
4265 } 4287 }
4266 else 4288 else