help-gnu-emacs
[Top][All Lists]
Advanced

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

Re: goto-char with set-buffer operations take only effect when buffer is


From: Dieter Wilhelm
Subject: Re: goto-char with set-buffer operations take only effect when buffer is not visible!
Date: Sun, 10 Dec 2006 16:57:50 +0100
User-agent: Gnus/5.11 (Gnus v5.11) Emacs/22.0.91 (gnu/linux)

Markus Triska <address@hidden> writes:

> Dieter Wilhelm <address@hidden> 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




reply via email to

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