[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: call-process and incremental display of output
From: |
Florian Weimer |
Subject: |
Re: call-process and incremental display of output |
Date: |
Wed, 17 Oct 2018 10:32:04 +0200 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/25.3 (gnu/linux) |
* 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 (= 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.
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
- call-process and incremental display of output, Florian Weimer, 2018/10/16
- Re: call-process and incremental display of output, Michael Albinus, 2018/10/16
- Re: call-process and incremental display of output, Stefan Monnier, 2018/10/16
- Re: call-process and incremental display of output,
Florian Weimer <=
- Re: call-process and incremental display of output, Stefan Monnier, 2018/10/17
- Re: call-process and incremental display of output, John Shahid, 2018/10/19
- Re: call-process and incremental display of output, Stefan Monnier, 2018/10/19
- Re: call-process and incremental display of output, John Shahid, 2018/10/19
- Re: call-process and incremental display of output, Stefan Monnier, 2018/10/19
- Re: call-process and incremental display of output, John Shahid, 2018/10/21