[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: |
Štěpán Němec |
Subject: |
bug#7381: 24.0.50; Provide a hook run when a window is selected |
Date: |
Fri, 12 Nov 2010 12:31:52 +0100 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/24.0.50 (gnu/linux) |
martin rudalics <rudalics@gmx.at> 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.)
Štěpán
- bug#7381: 24.0.50; Provide a hook run when a window is selected, Štěpán Němec, 2010/11/11
- bug#7381: 24.0.50; Provide a hook run when a window is selected, Lennart Borgman, 2010/11/11
- bug#7381: 24.0.50; Provide a hook run when a window is selected, martin rudalics, 2010/11/12
- bug#7381: 24.0.50; Provide a hook run when a window is selected,
Štěpán Němec <=
- bug#7381: 24.0.50; Provide a hook run when a window is selected, martin rudalics, 2010/11/12
- bug#7381: 24.0.50; Provide a hook run when a window is selected, Štěpán Němec, 2010/11/12
- bug#7381: 24.0.50; Provide a hook run when a window is selected, martin rudalics, 2010/11/12
- bug#7381: 24.0.50; Provide a hook run when a window is selected, Štěpán Němec, 2010/11/12
- bug#7381: 24.0.50; Provide a hook run when a window is selected, martin rudalics, 2010/11/12
- bug#7381: 24.0.50; Provide a hook run when a window is selected, Štěpán Němec, 2010/11/12
- bug#7381: 24.0.50; Provide a hook run when a window is selected, martin rudalics, 2010/11/13
- bug#7381: 24.0.50; Provide a hook run when a window is selected, Štěpán Němec, 2010/11/13
- bug#7381: 24.0.50; Provide a hook run when a window is selected, martin rudalics, 2010/11/13
- bug#7381: 24.0.50; Provide a hook run when a window is selected, Štěpán Němec, 2010/11/13