unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
* Recenter automatically the window showing output buffer
@ 2018-07-08  4:21 Tino Calancha
  2018-07-08 13:22 ` Tino Calancha
  0 siblings, 1 reply; 2+ messages in thread
From: Tino Calancha @ 2018-07-08  4:21 UTC (permalink / raw)
  To: Emacs developers; +Cc: Tino Calancha


Dear Emacs,

I am trying to do something apparently simple, but I cannot make it
work consistenly.

* Start a shell process which print out the string 'Hello!\n'.
* Set a simple sentinel to prevent the buffer from showing
   'Process *shell* finished'.

The output buffer consists of just 2 lines (second is empty).
The window doesn't display 'Hello!': it shows the output buffer 
from line 2.

--8<-----------------------------cut here---------------start------------->8---
(let* ((buf (generate-new-buffer "*foo*"))
       (proc (start-process-shell-command
              "*shell*" buf "printf 'Hello!\n'"))
       (sentinel (lambda (process status)
                   (message "process '%s' %s" (process-name process) status))))
   (set-process-sentinel proc sentinel)
   (display-buffer buf))
--8<-----------------------------cut here---------------start------------->8---

I've tried adding after `display-buffer' the following:
   (let ((recenter-redisplay t)) ; Force a redisplay
     (with-selected-window (get-buffer-window buf) (recenter))))

But it doesn't really make a difference.

How can I achieve the recenter in buf?

Thank you,
Tino



^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: Recenter automatically the window showing output buffer
  2018-07-08  4:21 Recenter automatically the window showing output buffer Tino Calancha
@ 2018-07-08 13:22 ` Tino Calancha
  0 siblings, 0 replies; 2+ messages in thread
From: Tino Calancha @ 2018-07-08 13:22 UTC (permalink / raw)
  To: Emacs developers; +Cc: Tino Calancha



On Sun, 8 Jul 2018, Tino Calancha wrote:

> I am trying to do something apparently simple, but I cannot make it
> work consistenly.
>
> * Start a shell process which print out the string 'Hello!\n'.
> * Set a simple sentinel to prevent the buffer from showing
>  'Process *shell* finished'.
>
> The output buffer consists of just 2 lines (second is empty).
> The window doesn't display 'Hello!': it shows the output buffer from line 2.

I realized I just need to call `recenter' inside the sentinel; that 
ensures `recenter' is called after the output have arrived.



^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2018-07-08 13:22 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2018-07-08  4:21 Recenter automatically the window showing output buffer Tino Calancha
2018-07-08 13:22 ` Tino Calancha

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).