>From 2277a0e80a89b5f34812e2c8e781bd3a7c81c392 Mon Sep 17 00:00:00 2001 From: Arthur Miller Date: Mon, 19 Jun 2023 08:52:23 +0200 Subject: [PATCH] Allow t for FRAME in window-list * src/window.c (window-list): Let window-list pass t as FRAME parameter further to window_list_1. * test/src/window-tests.el: New file. * test/src/window-tests.el (window-tests-window-list): Few tests to test that 't for all-frames works as in window-list-1. --- src/window.c | 3 ++- test/src/window-tests.el | 45 ++++++++++++++++++++++++++++++++++++++++ 2 files changed, 47 insertions(+), 1 deletion(-) create mode 100644 test/src/window-tests.el diff --git a/src/window.c b/src/window.c index f4e09f49eae..87a80cacadc 100644 --- a/src/window.c +++ b/src/window.c @@ -2992,6 +2992,7 @@ 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. FRAME nil or omitted means use the selected frame. +FRAME t means consider all windows on all existing 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 @@ -3005,7 +3006,7 @@ DEFUN ("window-list", Fwindow_list, Swindow_list, 0, 3, 0, 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); diff --git a/test/src/window-tests.el b/test/src/window-tests.el new file mode 100644 index 00000000000..b062318dd25 --- /dev/null +++ b/test/src/window-tests.el @@ -0,0 +1,45 @@ +;;; window-tests.el --- Tests for src/window.c -*- lexical-binding: t; -*- + +;; Copyright (C) 2023 Arthur Miller + +;; Author: Arthur Miller +;; Keywords: + +;; This program is free software; you can redistribute it and/or modify +;; it under the terms of the GNU General Public License as published by +;; the Free Software Foundation, either version 3 of the License, or +;; (at your option) any later version. + +;; This program is distributed in the hope that it will be useful, +;; but WITHOUT ANY WARRANTY; without even the implied warranty of +;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +;; GNU General Public License for more details. + +;; You should have received a copy of the GNU General Public License +;; along with this program. If not, see . + +;;; Commentary: + +;; + +;;; Code: + +(require 'ert) + +(ert-deftest window-tests-window-list () + (let ((windows-orig (window-list-1 nil nil t)) + (test-frame (make-frame '(visibility . nil)))) + (with-selected-frame test-frame + (split-window-right) + (should (= (length (window-list)) 2)) + (should (= (length (window-list t)) + (+ (length windows-orig) 2))) + (should (= (length (window-list)) + (length (window-list-1 + nil nil (selected-frame))))) + (should (= (length (window-list t)) + (length (window-list-1 nil nil t)))) + (delete-frame)))) + +(provide 'window-tests) +;;; window-tests.el ends here -- 2.41.0