unofficial mirror of help-gnu-emacs@gnu.org
 help / color / mirror / Atom feed
* goto-char with set-buffer operations take only effect when buffer is not visible!
@ 2006-12-09 19:32 Dieter Wilhelm
  0 siblings, 0 replies; 5+ messages in thread
From: Dieter Wilhelm @ 2006-12-09 19:32 UTC (permalink / raw)



Hi

I catch the output from a program which runs under `start-process' in
a buffer called *Ansys*.  I'd like to have that the buffer scrolls
always to the end of the latest output (like tail -f).  This works
automatically when the cursor in this buffer is below the current
output.  Then I can work in a certain buffer and see the output scroll
by in the neighbouring *Ansys* buffer. 

Unfortunately when the process is created the cursor is not at the end
of the output but remains at (point-min).  So I wrote this snippet:

  (let ((cb (buffer-name)))
    (set-buffer "*Ansys*")	       ;make buffer scroll with output
    (goto-char (point-max))
    (set-buffer cb))

To my astonishment this works only when the buffer *Ansys* is not
visible!  When the buffer is visible and I call this snippet in
another one the cursor in *Ansys* won't budge a single character.

This seems like a bug to me, isn't it?

-- 
    Best wishes

    H. Dieter Wilhelm
    Darmstadt, Germany

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

* Re: goto-char with set-buffer operations take only effect when buffer is not visible!
       [not found] <mailman.1701.1165697627.2155.help-gnu-emacs@gnu.org>
@ 2006-12-09 21:51 ` Markus Triska
  2006-12-10 15:57   ` Dieter Wilhelm
  2006-12-10 14:01 ` Johan Bockgård
  1 sibling, 1 reply; 5+ messages in thread
From: Markus Triska @ 2006-12-09 21:51 UTC (permalink / raw)


Dieter Wilhelm <dieter@duenenhof-wilhelm.de> writes:

>
>   (let ((cb (buffer-name)))
>     (set-buffer "*Ansys*")	       ;make buffer scroll with output
>     (goto-char (point-max))
>     (set-buffer cb))

Using with-current-buffer, this becomes:

(with-current-buffer "*Ansys*" (goto-char (point-max)))

> To my astonishment this works only when the buffer *Ansys* is not
> visible!  When the buffer is visible and I call this snippet in
> another one the cursor in *Ansys* won't budge a single character.

Add:

(walk-windows (lambda (w)
		(when (string= (buffer-name (window-buffer w)) "*Ansys*")
		  (with-selected-window w (goto-char (point-max))))))

to move the point permanently also if the buffer's window is visible
and not selected.


All the best,
Markus Triska

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

* Re: goto-char with set-buffer operations take only effect when buffer is not visible!
       [not found] <mailman.1701.1165697627.2155.help-gnu-emacs@gnu.org>
  2006-12-09 21:51 ` goto-char with set-buffer operations take only effect when buffer is not visible! Markus Triska
@ 2006-12-10 14:01 ` Johan Bockgård
  2006-12-10 15:52   ` Dieter Wilhelm
  1 sibling, 1 reply; 5+ messages in thread
From: Johan Bockgård @ 2006-12-10 14:01 UTC (permalink / raw)


Dieter Wilhelm <dieter@duenenhof-wilhelm.de> writes:

> This seems like a bug to me, isn't it?

See (info "(elisp)Window Point")

-- 
Johan Bockgård

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

* Re: goto-char with set-buffer operations take only effect when buffer is not visible!
  2006-12-10 14:01 ` Johan Bockgård
@ 2006-12-10 15:52   ` Dieter Wilhelm
  0 siblings, 0 replies; 5+ messages in thread
From: Dieter Wilhelm @ 2006-12-10 15:52 UTC (permalink / raw)


bojohan+news@dd.chalmers.se (Johan Bockgård) writes:

> Dieter Wilhelm <dieter@duenenhof-wilhelm.de> writes:
>
>> This seems like a bug to me, isn't it?
>
> See (info "(elisp)Window Point")

Ahh, now I understand that there is a difference between a window
point and a buffer point and only when the window is selected they are
the same.  Thanks for the pointer.

-- 
    Best wishes

    H. Dieter Wilhelm
    Darmstadt, Germany

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

* Re: goto-char with set-buffer operations take only effect when buffer is not visible!
  2006-12-09 21:51 ` goto-char with set-buffer operations take only effect when buffer is not visible! Markus Triska
@ 2006-12-10 15:57   ` Dieter Wilhelm
  0 siblings, 0 replies; 5+ messages in thread
From: Dieter Wilhelm @ 2006-12-10 15:57 UTC (permalink / raw)
  Cc: hans-dieter.wilhelm, help-gnu-emacs

Markus Triska <triska@gmx.at> writes:

> Dieter Wilhelm <dieter@duenenhof-wilhelm.de> writes:
>
>>
>>   (let ((cb (buffer-name)))
>>     (set-buffer "*Ansys*")	       ;make buffer scroll with output
>>     (goto-char (point-max))
>>     (set-buffer cb))
>
> Using with-current-buffer, this becomes:
>
> (with-current-buffer "*Ansys*" (goto-char (point-max)))

Ahhh, with-current-buffer it's far more elegant.

>
>> To my astonishment this works only when the buffer *Ansys* is not
>> visible!  When the buffer is visible and I call this snippet in
>> another one the cursor in *Ansys* won't budge a single character.
>
> Add:
>
> (walk-windows (lambda (w)
> 		(when (string= (buffer-name (window-buffer w)) "*Ansys*")
> 		  (with-selected-window w (goto-char (point-max))))))
>

Great! Thank you for the template, I'll implement it in this way.

-- 
    Best wishes

    H. Dieter Wilhelm
    Darmstadt, Germany

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

end of thread, other threads:[~2006-12-10 15:57 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
     [not found] <mailman.1701.1165697627.2155.help-gnu-emacs@gnu.org>
2006-12-09 21:51 ` goto-char with set-buffer operations take only effect when buffer is not visible! Markus Triska
2006-12-10 15:57   ` Dieter Wilhelm
2006-12-10 14:01 ` Johan Bockgård
2006-12-10 15:52   ` Dieter Wilhelm
2006-12-09 19:32 Dieter Wilhelm

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).