emacs-devel
[Top][All Lists]
Advanced

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

RE: [External] : Re: Make window-list return windows for all frames


From: Drew Adams
Subject: RE: [External] : Re: Make window-list return windows for all frames
Date: Thu, 15 Jun 2023 16:11:52 +0000

> (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))

It's also possible to filter the buffers first.
 
(defun windows-with-mode (mode &optional minibuf all-frames)
  (let ((wins  ()))
    (dolist (buf  (seq-filter
                   (lambda (buf)
                     (with-current-buffer buf
                       (eq major-mode mode)))
                   (buffer-list)))
      (setq wins  (nconc (get-buffer-window-list
                          buf minibuf all-frames)
                         wins)))
    wins))

(windows-with-mode 'Info-mode nil 'visible)

But it's no doubt faster to filter the `window-list',
just as you've done, because there are typically many
buffers that are not displayed.



reply via email to

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