From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: =?UTF-8?Q?=C5=A0t=C4=9Bp=C3=A1n_?= =?UTF-8?Q?N=C4=9Bmec?= Newsgroups: gmane.emacs.bugs Subject: bug#7381: 24.0.50; Provide a hook run when a window is selected Date: Fri, 12 Nov 2010 12:31:52 +0100 Message-ID: <87bp5ug4lz.fsf@gmail.com> References: <87k4kjfldo.fsf@gmail.com> <4CDCF7E0.40406@gmx.at> NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-Trace: dough.gmane.org 1289562275 30517 80.91.229.12 (12 Nov 2010 11:44:35 GMT) X-Complaints-To: usenet@dough.gmane.org NNTP-Posting-Date: Fri, 12 Nov 2010 11:44:35 +0000 (UTC) Cc: 7381@debbugs.gnu.org To: martin rudalics Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Fri Nov 12 12:44:31 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 1PGs3S-0002C9-3V for geb-bug-gnu-emacs@m.gmane.org; Fri, 12 Nov 2010 12:44:30 +0100 Original-Received: from localhost ([127.0.0.1]:45874 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1PGs3R-0003cf-OJ for geb-bug-gnu-emacs@m.gmane.org; Fri, 12 Nov 2010 06:44:29 -0500 Original-Received: from [140.186.70.92] (port=41106 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1PGs30-0003PU-KW for bug-gnu-emacs@gnu.org; Fri, 12 Nov 2010 06:44:03 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1PGs2y-0006MA-S8 for bug-gnu-emacs@gnu.org; Fri, 12 Nov 2010 06:44:02 -0500 Original-Received: from debbugs.gnu.org ([140.186.70.43]:57424) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1PGs2y-0006M6-MU for bug-gnu-emacs@gnu.org; Fri, 12 Nov 2010 06:44:00 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.69) (envelope-from ) id 1PGroU-0003lX-8j; Fri, 12 Nov 2010 06:29:02 -0500 X-Loop: help-debbugs@gnu.org Resent-From: =?UTF-8?Q?=C5=A0t=C4=9Bp=C3=A1n_?= =?UTF-8?Q?N=C4=9Bmec?= 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 11:29: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.128956132014468 (code B ref 7381); Fri, 12 Nov 2010 11:29:02 +0000 Original-Received: (at 7381) by debbugs.gnu.org; 12 Nov 2010 11:28:40 +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 1PGro7-0003lJ-Os for submit@debbugs.gnu.org; Fri, 12 Nov 2010 06:28:39 -0500 Original-Received: from mail-bw0-f44.google.com ([209.85.214.44]) by debbugs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1PGro5-0003lD-K0 for 7381@debbugs.gnu.org; Fri, 12 Nov 2010 06:28:39 -0500 Original-Received: by bwz12 with SMTP id 12so2929509bwz.3 for <7381@debbugs.gnu.org>; Fri, 12 Nov 2010 03:33:25 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:received:from:to:cc:subject :in-reply-to:references:user-agent:date:message-id:mime-version :content-type:content-transfer-encoding; bh=GVkyaxkE17cJSI+sF0snlF7xAfS4QrkKxrE3iOrDpek=; b=UGnzF4n4iJv7EmpXm9yyKvmXQiH6OzEm2suVXx5NFCm9wYCnu32Cv7AfvBO77ITFqY UgLSESJrw4MFm/mYv59CENtuXsv3G4o8wc4hao7gpWf+j8LV9FUWxWdfIhRFGj9JfcSO 9ZeHuqfz1Ltp0hpqBsGIxLFDdOlmk/AWxaZJ0= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=from:to:cc:subject:in-reply-to:references:user-agent:date :message-id:mime-version:content-type:content-transfer-encoding; b=Rp+wtROPmzTjqunLI4kOJkKJdiWuZNlkvYO9JSxmwsqAqrt0IX5eTGgmch1xHyimP9 B0a1umvk4Fo4xSplNGl5DgIdUc/458zRqUsPFznCMyxH72rNQXcF7qq0LmTD5b3L+X+r OtanUjHQXVkNrWxJVIwdQg0vUh9uJeTs6cMuc= Original-Received: by 10.204.27.20 with SMTP id g20mr2620937bkc.114.1289561605693; Fri, 12 Nov 2010 03:33:25 -0800 (PST) Original-Received: from localhost (176.119.broadband10.iol.cz [90.177.119.176]) by mx.google.com with ESMTPS id l3sm301927fan.0.2010.11.12.03.33.23 (version=TLSv1/SSLv3 cipher=RC4-MD5); Fri, 12 Nov 2010 03:33:24 -0800 (PST) In-Reply-To: <4CDCF7E0.40406@gmx.at> (martin rudalics's message of "Fri, 12 Nov 2010 09:16:32 +0100") User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.0.50 (gnu/linux) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.11 Precedence: list Resent-Date: Fri, 12 Nov 2010 06:29: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:41508 Archived-At: martin rudalics writes: >> 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. This is great, thank you! I'll have a look. Any reason not to have `get-mru-window' in the trunk (I actually searched for exactly that before resorting to the advice hack)? (And I guess the hook proposal still stands as well, or are there any arguments against that? One might want to do other things triggered by window selection.) =C5=A0t=C4=9Bp=C3=A1n