emacs-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Make window-list return windows for all frames


From: Arthur Miller
Subject: Re: Make window-list return windows for all frames
Date: Thu, 15 Jun 2023 16:01:51 +0200
User-agent: Gnus/5.13 (Gnus v5.13)

Eli Zaretskii <eliz@gnu.org> writes:

>> From: Arthur Miller <arthur.miller@live.com>
>> Date: Thu, 15 Jun 2023 14:41:55 +0200
>> 
>> 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:
>
> Please describe in more details why you needed the list of all the

I need list of all windows with displaing buffers in info-mode, so I just get
all windows and cull any non-info windows.

>   E.g., why walk-windows won't do whatever you needed to do?

I didn't know about it :). Well yes, it does indeed. It is a bit ugly, since I
have to use let and push, but I can save on one mapping to print names for
completing read:

(defun window-list-by-mode (mode &optional all-frames)
  (let ((window-list))
    (walk-windows
     (lambda (w)
       (with-current-buffer (window-buffer w)
         (when (eq major-mode mode)
           (push (cons (prin1-to-string w) w) window-list))))
     nil all-frames)
    window-list))

I would still argue that letting 't option be available through window list is
basically free and resembles more get-buffer-window and it's all-frames argument
and is overall more elegant and less repetitive, would be something like this:

As Gregory points out, there is window-list-1 which basically is same thing as
window-list but with arguments in different order. I was a bit blind, but it
feels a bit asymetric and strange not allow window-list have same semmantic for
frame parameter as in other functions, when it is already there, just one
comparison short :).

>> --- 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.
>
> Passive voice alert!



reply via email to

[Prev in Thread] Current Thread [Next in Thread]