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: waiting for asynchronous processes Date: Sat, 15 Oct 2011 12:20:44 -0500 Message-ID: NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 (Apple Message framework v1251.1) Content-Type: multipart/alternative; boundary="Apple-Mail=_5D911833-2B32-4A11-81DC-5250A64FF1CE" X-Trace: dough.gmane.org 1318699261 27436 80.91.229.12 (15 Oct 2011 17:21:01 GMT) X-Complaints-To: usenet@dough.gmane.org NNTP-Posting-Date: Sat, 15 Oct 2011 17:21:01 +0000 (UTC) To: help-gnu-emacs List Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Sat Oct 15 19:20:55 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 1RF7up-0004Vg-Ir for geh-help-gnu-emacs@m.gmane.org; Sat, 15 Oct 2011 19:20:55 +0200 Original-Received: from localhost ([::1]:50681 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RF7uo-0004q2-J1 for geh-help-gnu-emacs@m.gmane.org; Sat, 15 Oct 2011 13:20:54 -0400 Original-Received: from eggs.gnu.org ([140.186.70.92]:56553) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RF7uj-0004pv-W1 for help-gnu-emacs@gnu.org; Sat, 15 Oct 2011 13:20:50 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1RF7ui-0002AO-JV for help-gnu-emacs@gnu.org; Sat, 15 Oct 2011 13:20:49 -0400 Original-Received: from mail-yx0-f172.google.com ([209.85.213.172]:50918) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RF7ui-0002AK-Gy for help-gnu-emacs@gnu.org; Sat, 15 Oct 2011 13:20:48 -0400 Original-Received: by yxj19 with SMTP id 19so2106085yxj.31 for ; Sat, 15 Oct 2011 10:20:47 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=from:content-type:subject:date:message-id:to:mime-version:x-mailer; bh=cZ7yrrRj48s9oCf7fNeglp91feXL4ZsKlQevq8gOQfc=; b=TqViJGdLJ066RGSOMHGXpuNaTZoCB/U5O95ZAFTY5jEN0/NXyWCykZZzsxdU0B53px /nmU3jUN7wMuWh7exkw35qN1NBwCfH8jgFEJOnx1HLTcS/iR0o3ZT0FjZC4bk7yVTQx/ nnSmMmgvqyZPoGRUDGPSpjDvxyMzVDQKjw87g= Original-Received: by 10.150.31.5 with SMTP id e5mr12801372ybe.13.1318699247846; Sat, 15 Oct 2011 10:20:47 -0700 (PDT) Original-Received: from [10.0.0.4] ([64.128.19.234]) by mx.google.com with ESMTPS id 16sm20309210ant.10.2011.10.15.10.20.46 (version=TLSv1/SSLv3 cipher=OTHER); Sat, 15 Oct 2011 10:20:47 -0700 (PDT) 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.213.172 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:82565 Archived-At: --Apple-Mail=_5D911833-2B32-4A11-81DC-5250A64FF1CE Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset=us-ascii I was trying to write a keyboard macro that included using grep and the = first hit that it found. The problem was that I had to wait for the = grep to finish. I'm not sure why but (sit-for 1) didn't work. 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. > (defun wait-for-async-process ( proc ) > "Wait for PROC to finish" > (while (null (eq (process-status proc) 'exit)) > (accept-process-output))) I went ahead and looked for something like it in the distribution but = didn't see it. I'm curious if I overlooked it. pedz --Apple-Mail=_5D911833-2B32-4A11-81DC-5250A64FF1CE Content-Transfer-Encoding: quoted-printable Content-Type: text/html; charset=us-ascii I was = trying to write a keyboard macro that included using grep and the first = hit that it found.  The problem was that I had to wait for the grep = to finish.  I'm not sure why but (sit-for 1) didn't = work.

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.

(defun = wait-for-async-process ( proc )
  "Wait for PROC to = finish"
  (while (null (eq (process-status proc) = 'exit))
    = (accept-process-output)))

I went ahead and looked for something like it in the = distribution but didn't see it.

I'm curious if = I overlooked = it.

pedz

= --Apple-Mail=_5D911833-2B32-4A11-81DC-5250A64FF1CE--