From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Perry Smith Newsgroups: gmane.emacs.help Subject: Re: waiting for asynchronous processes Date: Sat, 15 Oct 2011 19:17:03 -0500 Message-ID: <9669B9E0-85E4-4025-9596-FA77C8754E84@gmail.com> References: <87hb39zydn.fsf@gmail.com> NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 (Apple Message framework v1251.1) Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-Trace: dough.gmane.org 1318724239 17324 80.91.229.12 (16 Oct 2011 00:17:19 GMT) X-Complaints-To: usenet@dough.gmane.org NNTP-Posting-Date: Sun, 16 Oct 2011 00:17:19 +0000 (UTC) Cc: help-gnu-emacs List To: =?utf-8?Q?=C5=A0t=C4=9Bp=C3=A1n_N=C4=9Bmec?= Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Sun Oct 16 02:17:16 2011 Return-path: Envelope-to: geh-help-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([140.186.70.17]) by lo.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1RFEPj-0001l5-Nw for geh-help-gnu-emacs@m.gmane.org; Sun, 16 Oct 2011 02:17:15 +0200 Original-Received: from localhost ([::1]:37924 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RFEPi-0007KB-Jn for geh-help-gnu-emacs@m.gmane.org; Sat, 15 Oct 2011 20:17:14 -0400 Original-Received: from eggs.gnu.org ([140.186.70.92]:44272) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RFEPd-0007Jx-UP for help-gnu-emacs@gnu.org; Sat, 15 Oct 2011 20:17:10 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1RFEPc-0000Ww-Qf for help-gnu-emacs@gnu.org; Sat, 15 Oct 2011 20:17:09 -0400 Original-Received: from mail-gx0-f169.google.com ([209.85.161.169]:45934) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RFEPc-0000Wq-Ng for help-gnu-emacs@gnu.org; Sat, 15 Oct 2011 20:17:08 -0400 Original-Received: by ggdk5 with SMTP id k5so2460300ggd.0 for ; Sat, 15 Oct 2011 17:17:08 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=subject:mime-version:content-type:from:in-reply-to:date:cc :content-transfer-encoding:message-id:references:to:x-mailer; bh=5R20uKfQAEeft6wpOt49NYDRdOac4NLgL1CsTkeI83o=; b=HHPw+JaQhuJ6byRFMx7Sz2/RYXXOMQ1oWt5Zf2pYTPH6CwhSQ7XHY5jsa2UT0Vrias e+2lzN5CXiI4pJ8U4ENYyfLZKePYFym8ikQHO2OV25KYWFSI+3MbFKKUHHopsBrnPVzn CtGN1ol7gtntoZM6QWIwfEHzWhrvdfCV/71Qs= Original-Received: by 10.150.244.20 with SMTP id r20mr13426060ybh.50.1318724227979; Sat, 15 Oct 2011 17:17:07 -0700 (PDT) Original-Received: from [10.0.0.4] ([64.128.19.234]) by mx.google.com with ESMTPS id j13sm22941776ani.19.2011.10.15.17.17.05 (version=TLSv1/SSLv3 cipher=OTHER); Sat, 15 Oct 2011 17:17:06 -0700 (PDT) In-Reply-To: <87hb39zydn.fsf@gmail.com> X-Mailer: Apple Mail (2.1251.1) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 2) X-Received-From: 209.85.161.169 X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: Users list for the GNU Emacs text editor List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Original-Sender: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.help:82568 Archived-At: On Oct 15, 2011, at 5:24 PM, =C5=A0t=C4=9Bp=C3=A1n N=C4=9Bmec wrote: > On Sat, 15 Oct 2011 19:20:44 +0200 > Perry Smith wrote: >=20 >> I started looking for a built in way to wait for an asynchronous = command to >> complete and discovered that I had written one long long time ago in = a galaxy >> far far away. >>=20 >>> (defun wait-for-async-process ( proc ) >>> "Wait for PROC to finish" >>> (while (null (eq (process-status proc) 'exit)) >>> (accept-process-output))) >=20 > Looks like a terrible hack to me. >=20 >> I went ahead and looked for something like it in the distribution but = didn't see it. >>=20 >> I'm curious if I overlooked it. >=20 > I doubt it. If you want to wait for the process in the way you seem to > want to wait for it, why don't you just use a synchronous process to > begin with? If you _do_ want the non-waiting advantage of asynchronous > processes, the usual way to handle state changes (s.a. when the = process > finishes) is to use sentinels, see e.g. (info "(elisp)Sentinels"). Well, as I said, what I really wanted to use is "grep" (the built in = emacs function). =20 I assumed I couldn't reach in and change him from asynchronous to = synchronous -- can I? pedz