From: martin rudalics <rudalics@gmx.at>
To: Uday S Reddy <u.s.reddy@cs.bham.ac.uk>
Cc: emacs-devel@gnu.org
Subject: Re: Moving cursor on another window
Date: Wed, 19 Jan 2011 14:59:15 +0100 [thread overview]
Message-ID: <4D36EE33.10705@gmx.at> (raw)
In-Reply-To: <ih6oev$fg5$1@dough.gmane.org>
> 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))
If the pattern did work as you intended, showing the same buffer
simultaneously in two windows would not make sense: Whenever you moved
the cursor in one window it would move in the other window to the same
position.
> 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.
It depends on what you want. To move point in a specific window W use
(set-window-point W (point-min)). To move it in all windows showing a
buffer B use
(dolist (W (get-buffer-window-list B nil t))
(set-window-point W (point-min)))
Any of these will move the buffer's point if and only if W is the
selected window when you call `set-window-point'. If you want to make
sure that the buffer's point moves too use
(with-current-buffer B
(goto-char (point-min))
since the doc-string of `beginning-of-buffer' tells you
"Don't use this command in Lisp programs!" ;-)
martin
next prev parent reply other threads:[~2011-01-19 13:59 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-01-19 13:20 Moving cursor on another window Uday S Reddy
2011-01-19 13:59 ` martin rudalics [this message]
2011-01-19 14:24 ` Stephen J. Turnbull
2011-01-19 14:36 ` martin rudalics
2011-01-19 15:02 ` Stefan Monnier
2011-01-20 12:13 ` Uday S Reddy
2011-01-20 12:52 ` Thierry Volpiatto
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=4D36EE33.10705@gmx.at \
--to=rudalics@gmx.at \
--cc=emacs-devel@gnu.org \
--cc=u.s.reddy@cs.bham.ac.uk \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this external index
https://git.savannah.gnu.org/cgit/emacs.git
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.