From mboxrd@z Thu Jan 1 00:00:00 1970 Path: main.gmane.org!not-for-mail From: storm@cua.dk (Kim F. Storm) Newsgroups: gmane.emacs.devel Subject: Re: Single process output reading Date: 16 Aug 2004 16:37:07 +0200 Sender: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Message-ID: References: <874qn35tgf.fsf@zamazal.org> NNTP-Posting-Host: deer.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: sea.gmane.org 1092667005 19167 80.91.224.253 (16 Aug 2004 14:36:45 GMT) X-Complaints-To: usenet@sea.gmane.org NNTP-Posting-Date: Mon, 16 Aug 2004 14:36:45 +0000 (UTC) Cc: emacs-devel@gnu.org Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Mon Aug 16 16:36:31 2004 Return-path: Original-Received: from lists.gnu.org ([199.232.76.165]) by deer.gmane.org with esmtp (Exim 3.35 #1 (Debian)) id 1Bwib8-0003NQ-00 for ; Mon, 16 Aug 2004 16:36:31 +0200 Original-Received: from localhost ([127.0.0.1] helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.33) id 1BwifF-0007f5-DC for ged-emacs-devel@m.gmane.org; Mon, 16 Aug 2004 10:40:45 -0400 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.33) id 1Bwif5-0007cy-I0 for emacs-devel@gnu.org; Mon, 16 Aug 2004 10:40:35 -0400 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.33) id 1Bwif3-0007bK-K0 for emacs-devel@gnu.org; Mon, 16 Aug 2004 10:40:35 -0400 Original-Received: from [199.232.76.173] (helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.33) id 1Bwif3-0007bC-FJ for emacs-devel@gnu.org; Mon, 16 Aug 2004 10:40:33 -0400 Original-Received: from [212.88.64.25] (helo=mail-relay.sonofon.dk) by monty-python.gnu.org with smtp (Exim 4.34) id 1Bwias-0004nD-Vm for emacs-devel@gnu.org; Mon, 16 Aug 2004 10:36:15 -0400 Original-Received: (qmail 73759 invoked from network); 16 Aug 2004 14:36:12 -0000 Original-Received: from unknown (HELO kfs-l.imdomain.dk.cua.dk) (213.83.150.2) by 0 with SMTP; 16 Aug 2004 14:36:12 -0000 Original-To: Milan Zamazal In-Reply-To: <874qn35tgf.fsf@zamazal.org> Original-Lines: 151 User-Agent: Gnus/5.09 (Gnus v5.9.0) Emacs/21.3.50 X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Xref: main.gmane.org gmane.emacs.devel:26275 X-Report-Spam: http://spam.gmane.org/gmane.emacs.devel:26275 Milan Zamazal writes: > I think a way to read an output of just a single asynchronous process in > Emacs is needed. I.e. a way to invoke accept-process-output without > possible invocation of another process filter function or a timer. Your reasons sound valid to me, but blocking everything including timers isn't very good, but may be acceptable for very short periods of time. > IMO a better way would be to allow restricting accept-process-output to > just a single process output reading. Then the speech output system, > aware of possible consequences of advising 'message' etc., could invoke > accept-process-output in the restricted form, without the danger of > unwanted side effects. Here's an (untested) patch that adds a "just-this-one" arg to accept-process-output To avoid running timers, specify an integer as fourth arg, e.g. (accept-process-output your-process nil nil 1) *** process.c 29 Jul 2004 16:46:31 +0200 1.434 --- process.c 16 Aug 2004 16:25:16 +0200 *************** *** 3718,3734 **** } DEFUN ("accept-process-output", Faccept_process_output, Saccept_process_output, ! 0, 3, 0, doc: /* Allow any pending output from subprocesses to be read by Emacs. It is read into the process' buffers or given to their filter functions. Non-nil arg PROCESS means do not return until some output has been received from PROCESS. Non-nil second arg TIMEOUT and third arg TIMEOUT-MSECS are number of seconds and microseconds to wait; return after that much time whether or not there is input. Return non-nil iff we received any output before the timeout expired. */) ! (process, timeout, timeout_msecs) ! register Lisp_Object process, timeout, timeout_msecs; { int seconds; int useconds; --- 3718,3737 ---- } DEFUN ("accept-process-output", Faccept_process_output, Saccept_process_output, ! 0, 4, 0, doc: /* Allow any pending output from subprocesses to be read by Emacs. It is read into the process' buffers or given to their filter functions. Non-nil arg PROCESS means do not return until some output has been received from PROCESS. + If optional fourth arg JUST-THIS-ONE is non-nil, only accept output + from PROCESS, suspending reading output from other processes. + If JUST-THIS-ONE is an integer, don't run any timers either. Non-nil second arg TIMEOUT and third arg TIMEOUT-MSECS are number of seconds and microseconds to wait; return after that much time whether or not there is input. Return non-nil iff we received any output before the timeout expired. */) ! (process, timeout, timeout_msecs, just_this_one) ! register Lisp_Object process, timeout, timeout_msecs, just_this_one; { int seconds; int useconds; *************** *** 3776,3782 **** XSETFASTINT (process, 0); return ! (wait_reading_process_input (seconds, useconds, process, 0) ? Qt : Qnil); } --- 3779,3787 ---- XSETFASTINT (process, 0); return ! (wait_reading_process_input (seconds, useconds, process, ! NILP (just_this_one) ? 0 : ! !INTEGERP (just_this_one) ? -1 : -2) ? Qt : Qnil); } *************** *** 4032,4037 **** --- 4037,4043 ---- EMACS_TIME timeout, end_time; int wait_channel = -1; struct Lisp_Process *wait_proc = 0; + int just_the_wait_proc = 0; int got_some_input = 0; /* Either nil or a cons cell, the car of which is of interest and may be changed outside of this routine. */ *************** *** 4048,4053 **** --- 4054,4064 ---- wait_proc = XPROCESS (read_kbd); wait_channel = XINT (wait_proc->infd); XSETFASTINT (read_kbd, 0); + if (do_display < 0) + { + just_the_wait_proc = do_display; + do_display = 0; + } } /* If waiting for non-nil in a cell, record where. */ *************** *** 4122,4128 **** But not if wait_for_cell; in those cases, the wait is supposed to be short, and those callers cannot handle running arbitrary Lisp code here. */ ! if (NILP (wait_for_cell)) { EMACS_TIME timer_delay; --- 4133,4140 ---- But not if wait_for_cell; in those cases, the wait is supposed to be short, and those callers cannot handle running arbitrary Lisp code here. */ ! if (NILP (wait_for_cell) ! && just_the_wait_proc != -2) { EMACS_TIME timer_delay; *************** *** 4258,4264 **** /* Wait till there is something to do */ ! if (!NILP (wait_for_cell)) { Available = non_process_wait_mask; check_connect = check_delay = 0; --- 4270,4281 ---- /* Wait till there is something to do */ ! if (just_the_wait_proc) ! { ! FD_SET (wait_channel, &Available); ! check_connect = check_delay = 0; ! } ! else if (!NILP (wait_for_cell)) { Available = non_process_wait_mask; check_connect = check_delay = 0; -- Kim F. Storm http://www.cua.dk