From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED!not-for-mail From: Florian Weimer Newsgroups: gmane.emacs.help Subject: Re: call-process and incremental display of output Date: Wed, 17 Oct 2018 10:32:04 +0200 Message-ID: <87ftx5x9bv.fsf@oldenburg.str.redhat.com> References: <87y3ay2fcy.fsf@oldenburg.str.redhat.com> NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-Trace: blaine.gmane.org 1539767253 5646 195.159.176.226 (17 Oct 2018 09:07:33 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Wed, 17 Oct 2018 09:07:33 +0000 (UTC) User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/25.3 (gnu/linux) Cc: help-gnu-emacs@gnu.org To: Stefan Monnier Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Wed Oct 17 11:07:29 2018 Return-path: Envelope-to: geh-help-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by blaine.gmane.org with esmtp (Exim 4.84_2) (envelope-from ) id 1gChnc-0001Nv-4h for geh-help-gnu-emacs@m.gmane.org; Wed, 17 Oct 2018 11:07:28 +0200 Original-Received: from localhost ([::1]:34746 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gChpi-0001z2-5y for geh-help-gnu-emacs@m.gmane.org; Wed, 17 Oct 2018 05:09:38 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:52772) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gChFb-0004Fr-F6 for help-gnu-emacs@gnu.org; Wed, 17 Oct 2018 04:32:20 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gChFX-0006tz-K7 for help-gnu-emacs@gnu.org; Wed, 17 Oct 2018 04:32:18 -0400 Original-Received: from mx1.redhat.com ([209.132.183.28]:57906) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1gChFX-0006tg-Dz for help-gnu-emacs@gnu.org; Wed, 17 Oct 2018 04:32:15 -0400 Original-Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 80FCB31500AB; Wed, 17 Oct 2018 08:32:14 +0000 (UTC) Original-Received: from oldenburg.str.redhat.com (ovpn-120-186.rdu2.redhat.com [10.10.120.186]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 430DC5F7C6; Wed, 17 Oct 2018 08:32:12 +0000 (UTC) In-Reply-To: (Stefan Monnier's message of "Tue, 16 Oct 2018 10:36:48 -0400") X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.41]); Wed, 17 Oct 2018 08:32:14 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 209.132.183.28 X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.21 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" Xref: news.gmane.org gmane.emacs.help:118296 Archived-At: * Stefan Monnier: >> (defun fw/get-new-mail () >> (interactive) >> (let* ((buffer (get-buffer-create "*mbsync*")) >> (status (with-current-buffer buffer >> (delete-region (point-min) (point-max)) >> (call-process "bash" nil (list buffer t) t >> "-c" " >> for x in {1..5} ; do >> date >> sleep 1 >> done >> ")))) >> (unless (=3D 0 status) >> (switch-to-buffer buffer) >> (error "mbsync exit with status %d" status)))) >> >> When I run this using =E2=80=98M-x fw/get-new-mail RET=E2=80=99, the buf= fer is not >> displayed, even though I passed t for the display argument. > > The argument to call-process controls whether redisplay will take place > while the process is running, so you indeed need to set it to t in your > case, but it doesn't affect which buffer is shown in which window, and > you only display the buffer in the switch-to-buffer which is performed > after call-process is over. Ahh, that explains it. > IOW, just move your switch-to-buffer (which you should also change to > pop-to-buffer or something like that if you want your code to be robust) > to before the call to call-process. I see. Further questions: How can I restore the window configuration after the process terminates? Is there something similar to save-excursion? How can I make the displayed buffer to scroll to the end? I probably shuld rethink this approach and just launch an xterm or something. 8-) Thanks, Florian