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: save-window-excursion and window-configuration-change-hook interaction Date: Tue, 18 May 2010 14:06:56 +0200 Message-ID: <4BF282E0.8000001@gmx.at> References: <87mxvy5mly.fsf@vh213601.truman.edu> 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 1274184693 12041 80.91.229.12 (18 May 2010 12:11:33 GMT) X-Complaints-To: usenet@dough.gmane.org NNTP-Posting-Date: Tue, 18 May 2010 12:11:33 +0000 (UTC) Cc: emacs-devel@gnu.org To: jay.p.belanger@gmail.com Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Tue May 18 14:11:31 2010 connect(): No such file or directory 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 1OELdz-0000LJ-8P for ged-emacs-devel@m.gmane.org; Tue, 18 May 2010 14:11:31 +0200 Original-Received: from localhost ([127.0.0.1]:33270 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1OELdy-0005uc-AZ for ged-emacs-devel@m.gmane.org; Tue, 18 May 2010 08:11:30 -0400 Original-Received: from [140.186.70.92] (port=54365 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1OELZf-0003Lr-Sy for emacs-devel@gnu.org; Tue, 18 May 2010 08:07:07 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.69) (envelope-from ) id 1OELZe-00074t-4a for emacs-devel@gnu.org; Tue, 18 May 2010 08:07:03 -0400 Original-Received: from mail.gmx.net ([213.165.64.20]:35359) by eggs.gnu.org with smtp (Exim 4.69) (envelope-from ) id 1OELZd-00074T-Oa for emacs-devel@gnu.org; Tue, 18 May 2010 08:07:02 -0400 Original-Received: (qmail invoked by alias); 18 May 2010 12:06:58 -0000 Original-Received: from 62-47-57-229.adsl.highway.telekom.at (EHLO [62.47.57.229]) [62.47.57.229] by mail.gmx.net (mp007) with SMTP; 18 May 2010 14:06:58 +0200 X-Authenticated: #14592706 X-Provags-ID: V01U2FsdGVkX1/yTeBuqanyWWi1T2TFNVMC4t0cdPywB3x+IRuz6z nNPkASjJ/i+mUU User-Agent: Thunderbird 2.0.0.21 (Windows/20090302) In-Reply-To: <87mxvy5mly.fsf@vh213601.truman.edu> X-Y-GMX-Trusted: 0 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. 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:124890 Archived-At: > Suppose I have two windows; say the top window is active > and the bottom window (window WIN, buffer BUF) has > === > a > b > c > === > in it, with point before the "a". > If I run the command aaa: > > (defun aaa () > (interactive) > (with-current-buffer BUF > (save-window-excursion > (select-window WIN) > (search-forward "b")) > (set-window-point WIN (point)))) > > then the point in the bottom window moves to after the "b", which is > what I would expect. However, if the bottom window (with point again > before the "a") has a non-nil window-configuration-change-hook, > then running aaa does not move the point in the bottom window. I would > expected the point in the bottom window to move as before. > (To add the hook, with the bottom window active I did > M-: (add-hook 'window-configuration-change-hook (lambda () ()) nil t) > ) IIUC this happens for the following reason: (1) When you quit the excursion, `set-window-configuration' sets `window-point' of WIN to the value it had before since WIN is _not_ the selected window. (2) When you now run the buffer local `window-configuration-change-hook' it selects WIN to run the hook with WIN selected and BUF current. Selecting WIN sets the `point' of BUF to the `window-point' recorded for WIN which, however, was reset in step (1) to the value it had before entering the excursion. So the only reasonable solution in your case is to save the the position after the search and do a `set-window-point' with that saved position. martin, who never liked the idea of running `window-configuration-change-hook' locally.