[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: call-process and incremental display of output
From: |
John Shahid |
Subject: |
Re: call-process and incremental display of output |
Date: |
Fri, 19 Oct 2018 19:52:23 -0400 |
User-agent: |
mu4e 1.1.0; emacs 27.0.50 |
Stefan Monnier <monnier@iro.umontreal.ca> writes:
>>> You might like to (setq-local window-point-insertion-type t) in your
>>> buffer (make sure you do it before the buffer is displayed in a window).
>> I'm curious why `save-excursion' doesn't respect the value of
>> `window-point-insertion-type' ? I was wondering about this for some
>> time now. The behavior I want is to always append the output to the end
>> of the buffer but not annoy the user if they decide to move the point
>> somewhere else to look at previous output. In this case the point
>> should stay where it is. This sounds exactly like what markers are
>> supposed to do. Unfortunately the marker created by `save-excursion'
>> always has a `nil' insertion type. This means I have to maintain my own
>> marker in an `unwind-protect' similar to what the compilation mode does.
>> Are there any objections to changing `save-excursion' behavior ?
>
> I lost you: where do you save-excursion?
Sorry, I should have explained a little bit what I'm trying to do. I
spin up a curl process that connects to our CI server and display the
log output of a build. The server stream the log output as a sequence
of json messages that have to be parsed and appended to the buffer. I
used to do that with the following snippet of code:
(with-current-buffer log-buffer
(save-excursion
(goto-char (point-max))
(insert log-line)))
This caused the data to be inserted at the end of the buffer, but I
constantly had to scroll to the end of the buffer in order to follow the
output.
I was aware of this problem for a while but never got chance to tackle
it. Then, I saw your earlier message about
`window-point-insertion-type' and I decided to try it. That didn't work
and I think the reason is `save-excursion' creates a marker with
insertion type set to `nil'.
In my earlier message, I was trying to propose making `save-excursion'
set the marker insertion type to `t' if `window-point-insertion-type' is
set to t.
FYI, what I currently have is something like this:
(let ((pos (copy-marker (point) t)))
(ignore-errors
(goto-char (point-max))
(insert payload))
(goto-char pos))
- Re: call-process and incremental display of output, (continued)
- Re: call-process and incremental display of output, Stefan Monnier, 2018/10/16
- 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 <=
- 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