GNU bug report logs - #42872
[PATCH] Add all-frames as arg for count windows.

Previous Next

Package: emacs;

Reported by: Jen-Chieh Shen <jcs090218 <at> gmail.com>

Date: Sat, 15 Aug 2020 15:14:01 UTC

Severity: normal

Tags: fixed, moreinfo, patch

Fixed in version 28.1

Done: Lars Ingebrigtsen <larsi <at> gnus.org>

Bug is archived. No further changes may be made.

Full log


Message #16 received at 42872 <at> debbugs.gnu.org (full text, mbox):

From: Drew Adams <drew.adams <at> oracle.com>
To: Lars Ingebrigtsen <larsi <at> gnus.org>, Jen-Chieh Shen <jcs090218 <at> gmail.com>
Cc: 42872 <at> debbugs.gnu.org
Subject: RE: bug#42872: [PATCH] Add all-frames as arg for count windows.
Date: Sun, 16 Aug 2020 07:50:15 -0700 (PDT)
In addition, you might consider this improvement, for
the current-frame behavior (which should remain the
default behavior): use arg MINIBUF only if the current
frame has a minibuffer.

I've had that in my version of `count-windows' since
1996, if not before that.  This is the code I have:

(defun count-windows (&optional minibuf)
  "Return the number of visible windows in selected frame.
Optional arg MINIBUF is used only if selected frame has a minibuffer.

MINIBUF = t means count the minibuffer window even if *not* active.
MINIBUF = nil or omitted means count the minibuffer iff it is active.
If MINIBUF is neither t nor nil it means not to count the minibuffer
even if it is active.  (See function `walk-windows'.)"
  (let ((count 0))
    (walk-windows 
     (function (lambda (w) (setq count (+ count 1))))
     (and (memq (cdr (assoc 'minibuffer (frame-parameters)))
                '(only t))           ; If this frame has a minibuffer,
          minibuf))                  ; pass the arg.  (Else pass nil.)
    count))




This bug report was last modified 4 years and 279 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.