From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: martin rudalics Newsgroups: gmane.emacs.devel Subject: Re: Moving cursor on another window Date: Wed, 19 Jan 2011 14:59:15 +0100 Message-ID: <4D36EE33.10705@gmx.at> References: NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Trace: dough.gmane.org 1295445734 29589 80.91.229.12 (19 Jan 2011 14:02:14 GMT) X-Complaints-To: usenet@dough.gmane.org NNTP-Posting-Date: Wed, 19 Jan 2011 14:02:14 +0000 (UTC) Cc: emacs-devel@gnu.org To: Uday S Reddy Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Wed Jan 19 15:02:10 2011 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by lo.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1PfYbx-0006sU-Ka for ged-emacs-devel@m.gmane.org; Wed, 19 Jan 2011 15:02:09 +0100 Original-Received: from localhost ([127.0.0.1]:49977 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1PfYZV-0000TK-Lp for ged-emacs-devel@m.gmane.org; Wed, 19 Jan 2011 08:59:37 -0500 Original-Received: from [140.186.70.92] (port=57295 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1PfYZN-0000QC-GX for emacs-devel@gnu.org; Wed, 19 Jan 2011 08:59:32 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1PfYZJ-00069t-Or for emacs-devel@gnu.org; Wed, 19 Jan 2011 08:59:29 -0500 Original-Received: from mailout-de.gmx.net ([213.165.64.23]:60824) by eggs.gnu.org with smtp (Exim 4.71) (envelope-from ) id 1PfYZJ-00067L-CB for emacs-devel@gnu.org; Wed, 19 Jan 2011 08:59:25 -0500 Original-Received: (qmail invoked by alias); 19 Jan 2011 13:59:21 -0000 Original-Received: from 62-47-35-222.adsl.highway.telekom.at (EHLO [62.47.35.222]) [62.47.35.222] by mail.gmx.net (mp017) with SMTP; 19 Jan 2011 14:59:21 +0100 X-Authenticated: #14592706 X-Provags-ID: V01U2FsdGVkX1+hE+NgLHKhZ8rGtD3h7x9LpplcLW36ApP2bctdhI ORNMUjS6RUckKg User-Agent: Thunderbird 2.0.0.21 (Windows/20090302) In-Reply-To: X-Y-GMX-Trusted: 0 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 3) X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.devel:134735 Archived-At: > 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