[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: call-process and incremental display of output

From: Stefan Monnier
Subject: Re: call-process and incremental display of output
Date: Tue, 16 Oct 2018 10:36:48 -0400
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/27.0.50 (gnu/linux)

> (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 (= 0 status)
>       (switch-to-buffer buffer)
>       (error "mbsync exit with status %d" status))))
> When I run this using ‘M-x fw/get-new-mail RET’, the buffer 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.

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.


reply via email to

[Prev in Thread] Current Thread [Next in Thread]