Created
August 30, 2012 23:30
-
-
Save jsvnm/3544998 to your computer and use it in GitHub Desktop.
wanted "most recent before current"-window. get-mru-window gives current. instead of simplest, i did the most complex thing that could work. almost.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(defun windows-in-use-time-order (&optional old-to-new windows) | |
"Windows sorted by their `window-use-time'. | |
Without arguments windows on current frame ordered from most to least recent. | |
Optional argument OLD-TO-NEW with non-nil value reverses the order. | |
Optional argument WINDOWS specifies which windows to sort by use time: | |
- a list is assumed to contain windows and sorted | |
- a function is called, should return list of windows to sort | |
- any other value is passed to `window-list-1' as ALL-FRAMES parameter" | |
(sort* (cond ((and windows (listp windows)) windows) | |
((functionp windows) (funcall windows)) | |
((window-list-1 nil 'nomini windows))) | |
(if old-to-new '< '>) | |
:key 'window-use-time)) | |
;; to get the window that was used before current on, in current frame: | |
(nth 1 (windows-in-use-time-order)) | |
;; in all frames: | |
(nth 1 (windows-in-use-time-order nil t)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment