From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: martin rudalics Newsgroups: gmane.emacs.bugs Subject: bug#7381: 24.0.50; Provide a hook run when a window is selected Date: Fri, 12 Nov 2010 09:16:32 +0100 Message-ID: <4CDCF7E0.40406@gmx.at> References: <87k4kjfldo.fsf@gmail.com> NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Trace: dough.gmane.org 1289551462 14882 80.91.229.12 (12 Nov 2010 08:44:22 GMT) X-Complaints-To: usenet@dough.gmane.org NNTP-Posting-Date: Fri, 12 Nov 2010 08:44:22 +0000 (UTC) Cc: 7381@debbugs.gnu.org To: =?UTF-8?Q?=C5=A0t=C4=9Bp=C3=A1n_?= =?UTF-8?Q?N=C4=9Bmec?= Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Fri Nov 12 09:44:17 2010 Return-path: Envelope-to: geb-bug-gnu-emacs@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 1PGpF2-00045L-Lp for geb-bug-gnu-emacs@m.gmane.org; Fri, 12 Nov 2010 09:44:16 +0100 Original-Received: from localhost ([127.0.0.1]:54818 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1PGpF1-0000NC-Hr for geb-bug-gnu-emacs@m.gmane.org; Fri, 12 Nov 2010 03:44:16 -0500 Original-Received: from [140.186.70.92] (port=47509 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1PGpEo-0000Is-9w for bug-gnu-emacs@gnu.org; Fri, 12 Nov 2010 03:44:03 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1PGpEl-0003oQ-HD for bug-gnu-emacs@gnu.org; Fri, 12 Nov 2010 03:44:02 -0500 Original-Received: from debbugs.gnu.org ([140.186.70.43]:35986) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1PGpEl-0003oF-FN for bug-gnu-emacs@gnu.org; Fri, 12 Nov 2010 03:43:59 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.69) (envelope-from ) id 1PGojq-0002Ui-2O; Fri, 12 Nov 2010 03:12:02 -0500 X-Loop: help-debbugs@gnu.org Resent-From: martin rudalics Original-Sender: debbugs-submit-bounces@debbugs.gnu.org Resent-To: owner@debbugs.gnu.org Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Fri, 12 Nov 2010 08:12:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 7381 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: Original-Received: via spool by 7381-submit@debbugs.gnu.org id=B7381.12895495099582 (code B ref 7381); Fri, 12 Nov 2010 08:12:02 +0000 Original-Received: (at 7381) by debbugs.gnu.org; 12 Nov 2010 08:11:49 +0000 Original-Received: from localhost ([127.0.0.1] helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1PGojd-0002UU-Ba for submit@debbugs.gnu.org; Fri, 12 Nov 2010 03:11:49 -0500 Original-Received: from mailout-de.gmx.net ([213.165.64.23] helo=mail.gmx.net) by debbugs.gnu.org with smtp (Exim 4.69) (envelope-from ) id 1PGojb-0002UP-7z for 7381@debbugs.gnu.org; Fri, 12 Nov 2010 03:11:48 -0500 Original-Received: (qmail invoked by alias); 12 Nov 2010 08:16:34 -0000 Original-Received: from 62-47-61-179.adsl.highway.telekom.at (EHLO [62.47.61.179]) [62.47.61.179] by mail.gmx.net (mp009) with SMTP; 12 Nov 2010 09:16:34 +0100 X-Authenticated: #14592706 X-Provags-ID: V01U2FsdGVkX1+jfoIGqWKjTrsZLokfUFtRIZLmLmh1d63bI3Slx0 7w3n9nNLxp2jqE User-Agent: Thunderbird 2.0.0.21 (Windows/20090302) In-Reply-To: <87k4kjfldo.fsf@gmail.com> X-Y-GMX-Trusted: 0 X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.11 Precedence: list Resent-Date: Fri, 12 Nov 2010 03:12:02 -0500 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 3) X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.bugs:41504 Archived-At: > Use case: I wanted to make myself a command to select the last selected > window (i.e., repeating the command would toggle between two windows). > > After some head-scratching, the best I could come up with is this: > > (defun .goto-mru-window () > (interactive) > (select-window (frame-parameter nil '.last-selected-window))) > > (defadvice select-window (before .save-selected-window activate) > (set-frame-parameter nil '.last-selected-window (selected-window))) > > ...which seems to work most of the time, but using an advice doesn't > feel that great, esp. with C functions. You might want to have a look at my window-pub branch. It has window-use-time is a built-in function in `window.c'. (window-use-time &optional WINDOW) Return WINDOW's use time. WINDOW defaults to the selected window. The window with the highest use time is the most recently selected one. The window with the lowest use time is the least recently selected one. and get-mru-window is a compiled Lisp function in `window.el'. (get-mru-window &optional ALL-FRAMES) Return the most recently used window on frames specified by ALL-FRAMES. Do not return a minibuffer window. The following non-nil values of the optional argument ALL-FRAMES have special meanings: - t means consider all windows on all existing frames. - `visible' means consider all windows on all visible frames. - 0 (the number zero) means consider all windows on all visible and iconified frames. - A frame means consider all windows on that frame only. Any other value of ALL-FRAMES means consider all windows on the selected frame and no others. martin