GNU bug report logs - #7381
24.0.50; Provide a hook run when a window is selected

Previous Next

Package: emacs;

Reported by: Štěpán Němec <stepnem <at> gmail.com>

Date: Fri, 12 Nov 2010 00:12:02 UTC

Severity: wishlist

Merged with 16436

Found in version 24.0.50

Fixed in version 27.1

Done: Glenn Morris <rgm <at> gnu.org>

Bug is archived. No further changes may be made.

Full log


View this message in rfc822 format

From: martin rudalics <rudalics <at> gmx.at>
To: Štěpán Němec <stepnem <at> gmail.com>
Cc: 7381 <at> debbugs.gnu.org
Subject: bug#7381: 24.0.50; Provide a hook run when a window is selected
Date: Sat, 13 Nov 2010 09:32:39 +0100
> Hm. Would they? A lot of window configuration changes don't involve
> changing the selected window.

I suppose you want to use a variable, say old-window, where your
remember the previously selected window.  Now if
`window-configuration-change-hook' does not change the selected window,
the selected window and old-window are the same and you don't even care.

Your problem is with things like `save-window-excursion' where the
selected window changes temporarily.

>> Hooks can be dangerous.  It's very easy to crash Emacs by putting some
>> innocuously looking function on `window-configuration-change-hook'.
>
> Well, I don't find that very persuasive. It's not like Emacs lacks other
> ways to shoot yourself in the foot, and you can already achieve about
> the same (minus the "clean and simple" part) using advice.

Using advice is deprecated in the Emacs sources but functions running on
hooks are used.  That's why the latter have to be more robust by design.

> That'd be great, yeah (and including it in the trunk).

Meanwhile you can simply try out for yourself by adding

DEFUN ("window-use-time", Fwindow_use_time, Swindow_use_time, 0, 1, 0,
       doc: /* 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.  */)
     (window)
     Lisp_Object window;
{
  return decode_window (window)->use_time;
}

...

  defsubr (&Swindow_use_time);

to your window.c ;-)

martin




This bug report was last modified 6 years and 136 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.