bug-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

bug#7381: 24.0.50; Provide a hook run when a window is selected


From: martin rudalics
Subject: bug#7381: 24.0.50; Provide a hook run when a window is selected
Date: Sat, 13 Nov 2010 09:32:39 +0100
User-agent: Thunderbird 2.0.0.21 (Windows/20090302)

> 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





reply via email to

[Prev in Thread] Current Thread [Next in Thread]