Subject: bug#21305: 25.0.50; `get-buffer-window-list' doc - what order?

From: Drew Adams <[email-masked]>
Date: Fri, 21 Aug 2015 10:42:18 -0700 (PDT)

> (defun mru-window-for-buffer (buffer &optional minibuf all-frames)
>   "Return the most recently used window for BUFFER.
> Optional args MINIBUF and ALL-FRAMES are as for `get-buffer-window-
> list'."
>   (let* ((wins     (get-buffer-window-list buffer minibuf all-frames))
>          (mru-win  (car wins)))
>     (dolist (win  (cdr wins))
>       (unless  (time-less-p win mru-win) (setq mru-win  win)))
>     mru-win))
> 
> Similarly, `lru-window-for-buffer'.

Sorry, I meant something like this:

(defun mru-window-for-buffer (buffer &optional minibuf all-frames)
  "Return the most recently used window for BUFFER.
Optional args MINIBUF and ALL-FRAMES are as for `get-buffer-window-list'."
  (let* ((wins      (get-buffer-window-list buffer minibuf all-frames))
         (mru-win   (car wins))
         (mru-time  (window-use-time mru-win))
         wtime)
    (dolist (win  (cdr wins))
      (when  (time-less-p (setq wtime  (window-use-time win)) mru-time)
        (setq mru-time  wtime
              mru-win   win)))
    mru-win))