[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Make window-list return windows for all frames
From: |
Arthur Miller |
Subject: |
Make window-list return windows for all frames |
Date: |
Thu, 15 Jun 2023 14:41:55 +0200 |
User-agent: |
Gnus/5.13 (Gnus v5.13) |
While working on info.el I needed a function to return info windows on all
frames. I was a bit surprised to discover there is no built-in option in
window-list or elsewhere as far as I can see to get all windows for all frames,
or a filtered list containing interesting windows for all frames. I ended up
with this:
#+begin_src emacs-lisp
(defun window-list-by-mode (mode &optional all-frames)
"Return list of windows displaying buffers whose major mode is MODE.
If ALL-FRAMES is non-nil, consider all frames, otherwise just selected
frame."
(mapcar
(lambda (window) (cons (prin1-to-string window) window))
(cl-remove-if-not
(lambda (window)
(with-current-buffer (window-buffer window)
(eq major-mode mode)))
(if all-frames
(apply #'nconc (mapcar (lambda (f) (window-list f)) (frame-list)))
(window-list)))))
#+end_src
Anyway, looking at window.c, I can see that window_candidate_p actually does
consider windows on all frames, but 't option is never passed through from
window-list. To save gymnastics via apply and nconc and doing the double work, I
have patched window-list function to let 't option further and documented the
change. It seems to me that it works as intended. I have tested myself, I hope I
haven't missed some possible case, but I'm a little suspisious: what was the
reason why this wasn't documented and used? I mean, it is already there, but
cut-off for some reason?
0001-Return-window-list-for-all-frames.patch
Description: Text Data
- Make window-list return windows for all frames,
Arthur Miller <=
- Re: Make window-list return windows for all frames, Eli Zaretskii, 2023/06/15
- Re: Make window-list return windows for all frames, Arthur Miller, 2023/06/15
- Re: Make window-list return windows for all frames, Eli Zaretskii, 2023/06/15
- Re: Make window-list return windows for all frames, Arthur Miller, 2023/06/16
- Re: Make window-list return windows for all frames, Gregory Heytings, 2023/06/16
- Re: Make window-list return windows for all frames, Arthur Miller, 2023/06/16
- Re: Make window-list return windows for all frames, Eli Zaretskii, 2023/06/16
- Re: Make window-list return windows for all frames, martin rudalics, 2023/06/16
- Re: Make window-list return windows for all frames, Eli Zaretskii, 2023/06/17
- Re: Make window-list return windows for all frames, martin rudalics, 2023/06/17