[Top][All Lists]

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

Re: Moving cursor on another window

From: Stefan Monnier
Subject: Re: Moving cursor on another window
Date: Wed, 19 Jan 2011 10:02:02 -0500
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/24.0.50 (gnu/linux)

> If I have multiple windows showing (with different buffers in them), and
> I want to move the cursor in a window other than the current one, how is
> that supposed to be done?  The following pattern of code doesn't seem to
> work:

>   (with-current-buffer other-buffer
>      (beginning-of-buffer))

You might like to try

  (with-selected-window (buffer-window other-buffer)
    (goto-char (point-min)))


> It works if the other-buffer is not currently displayed in a window.
> But if it is displayed, the cursor remains unchanged.  I guess there
> is some implicit save-excursion at the top level somewhere.  I can't
> see how to get around it.

Every window has its own `point' (to which you have access via
(set-)window-point and that is also influenced by
window-point-insertion-type).  When current-buffer is the buffer shown
by the selected-window, moving the buffer's point also moves the
window's point, but otherwise no.


reply via email to

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