From 1123400eaebdbe68dab527f9fe4397050f112890 Mon Sep 17 00:00:00 2001 From: Arthur Miller Date: Thu, 15 Jun 2023 14:17:08 +0200 Subject: [PATCH] Return window-list for all frames Add option to window-list to return windows for all frames. * src/window.c Modify to return all windows when FRAME is 't. * doc/elisp/window.text Document the change. --- doc/lispref/windows.texi | 3 ++- src/window.c | 8 +++++--- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/doc/lispref/windows.texi b/doc/lispref/windows.texi index 0196ed0e813..bbb60403a86 100644 --- a/doc/lispref/windows.texi +++ b/doc/lispref/windows.texi @@ -227,7 +227,8 @@ Windows and Frames @defun window-list &optional frame minibuffer window This function returns a list of all live windows owned by the specified @var{frame}. If @var{frame} is omitted or @code{nil}, it defaults to -the selected frame (@pxref{Input Focus}). +the selected frame (@pxref{Input Focus}). If @var{frame} is @code{t}, +the list of windows for all frames is returned. The optional argument @var{minibuffer} specifies whether to include the minibuffer window (@pxref{Minibuffer Windows}) in that list. If diff --git a/src/window.c b/src/window.c index e22fea0bb7a..7d1fa5deef6 100644 --- a/src/window.c +++ b/src/window.c @@ -2989,9 +2989,10 @@ window_list_1 (Lisp_Object window, Lisp_Object minibuf, Lisp_Object all_frames) } -DEFUN ("window-list", Fwindow_list, Swindow_list, 0, 3, 0, - doc: /* Return a list of windows on FRAME, starting with WINDOW. +DEFUN ("window-list", Fwindow_list, Swindow_list, 0, 3, 0, doc + : /* Return a list of windows on FRAME, starting with WINDOW. FRAME nil or omitted means use the selected frame. +FRAME t means return list of live windows for all frames. WINDOW nil or omitted means use the window selected within FRAME. MINIBUF t means include the minibuffer window, even if it isn't active. MINIBUF nil or omitted means include the minibuffer window only @@ -3002,10 +3003,11 @@ DEFUN ("window-list", Fwindow_list, Swindow_list, 0, 3, 0, if (NILP (window)) window = FRAMEP (frame) ? XFRAME (frame)->selected_window : selected_window; CHECK_WINDOW (window); + if (NILP (frame)) frame = selected_frame; - if (!EQ (frame, XWINDOW (window)->frame)) + if (!EQ (frame, XWINDOW (window)->frame) && !(BASE_EQ (frame, Qt))) error ("Window is on a different frame"); return window_list_1 (window, minibuf, frame); -- 2.40.0