all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* bug#42872: [PATCH] Add all-frames as arg for count windows.
@ 2020-08-15  8:03 Jen-Chieh Shen
  2020-08-16 12:28 ` Lars Ingebrigtsen
  0 siblings, 1 reply; 7+ messages in thread
From: Jen-Chieh Shen @ 2020-08-15  8:03 UTC (permalink / raw)
  To: 42872


[-- Attachment #1.1: Type: text/plain, Size: 125 bytes --]

Hi,

I think it is handy to have `all-frames` as an argument when using the
`count-windows` function?

Best,

Jen-Chieh Shen

[-- Attachment #1.2: Type: text/html, Size: 222 bytes --]

[-- Attachment #2: cnt-win-frames.patch --]
[-- Type: application/octet-stream, Size: 989 bytes --]

From 226154c0c338845af757a6893db9645870cb9a12 Mon Sep 17 00:00:00 2001
From: jenchieh <jcs090218@gmail.com>
Date: Sat, 15 Aug 2020 15:57:14 +0800
Subject: [PATCH] Add all-frames as arg for count windows.

---
 lisp/window.el | 9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)

diff --git a/lisp/window.el b/lisp/window.el
index f20940fa0e..591f019a7c 100644
--- a/lisp/window.el
+++ b/lisp/window.el
@@ -2644,9 +2644,14 @@ and no others."
 
 (defun count-windows (&optional minibuf)
    "Return the number of live windows on the selected frame.
+
 The optional argument MINIBUF specifies whether the minibuffer
-window shall be counted.  See `walk-windows' for the precise
-meaning of this argument."
+window shall be counted.  
+
+The optional argument ALL-FRAMES counted all windows instead of
+just the selected frame.
+
+See `walk-windows' for the precise meaning of this argument."
    (length (window-list-1 nil minibuf)))
 \f
 ;;; Resizing windows.
-- 
2.27.0.windows.1


^ permalink raw reply related	[flat|nested] 7+ messages in thread

* bug#42872: [PATCH] Add all-frames as arg for count windows.
  2020-08-15  8:03 bug#42872: [PATCH] Add all-frames as arg for count windows Jen-Chieh Shen
@ 2020-08-16 12:28 ` Lars Ingebrigtsen
  2020-08-16 14:43   ` Drew Adams
       [not found]   ` <CAMiGhTMRTtxQRQgiok55OuoAHiqz-=BfZQOJFVG+fPASO-TsEA@mail.gmail.com>
  0 siblings, 2 replies; 7+ messages in thread
From: Lars Ingebrigtsen @ 2020-08-16 12:28 UTC (permalink / raw)
  To: Jen-Chieh Shen; +Cc: 42872

Jen-Chieh Shen <jcs090218@gmail.com> writes:

> I think it is handy to have `all-frames` as an argument when using the
> `count-windows` function?

Sounds like a good addition.

>  (defun count-windows (&optional minibuf)
>     "Return the number of live windows on the selected frame.
> +
>  The optional argument MINIBUF specifies whether the minibuffer
> -window shall be counted.  See `walk-windows' for the precise
> -meaning of this argument."
> +window shall be counted.  
> +
> +The optional argument ALL-FRAMES counted all windows instead of
> +just the selected frame.
> +
> +See `walk-windows' for the precise meaning of this argument."

But your patch doesn't actually add this -- it just changes the doc string?

-- 
(domestic pets only, the antidote for overdose, milk.)
   bloggy blog: http://lars.ingebrigtsen.no





^ permalink raw reply	[flat|nested] 7+ messages in thread

* bug#42872: [PATCH] Add all-frames as arg for count windows.
  2020-08-16 12:28 ` Lars Ingebrigtsen
@ 2020-08-16 14:43   ` Drew Adams
  2020-08-16 14:50     ` Drew Adams
  2020-08-18 13:27     ` Lars Ingebrigtsen
       [not found]   ` <CAMiGhTMRTtxQRQgiok55OuoAHiqz-=BfZQOJFVG+fPASO-TsEA@mail.gmail.com>
  1 sibling, 2 replies; 7+ messages in thread
From: Drew Adams @ 2020-08-16 14:43 UTC (permalink / raw)
  To: Lars Ingebrigtsen, Jen-Chieh Shen; +Cc: 42872

+1 to adding optional arg ALL-FRAMES.

Its behavior should be the same as for `walk-windows',
which `count-windows' uses.  This is also the same as
for `get-buffer-window'.





^ permalink raw reply	[flat|nested] 7+ messages in thread

* bug#42872: [PATCH] Add all-frames as arg for count windows.
  2020-08-16 14:43   ` Drew Adams
@ 2020-08-16 14:50     ` Drew Adams
  2020-08-18 13:29       ` Lars Ingebrigtsen
  2020-08-18 13:27     ` Lars Ingebrigtsen
  1 sibling, 1 reply; 7+ messages in thread
From: Drew Adams @ 2020-08-16 14:50 UTC (permalink / raw)
  To: Lars Ingebrigtsen, Jen-Chieh Shen; +Cc: 42872

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





^ permalink raw reply	[flat|nested] 7+ messages in thread

* bug#42872: [PATCH] Add all-frames as arg for count windows.
       [not found]   ` <CAMiGhTMRTtxQRQgiok55OuoAHiqz-=BfZQOJFVG+fPASO-TsEA@mail.gmail.com>
@ 2020-08-16 20:36     ` Lars Ingebrigtsen
  0 siblings, 0 replies; 7+ messages in thread
From: Lars Ingebrigtsen @ 2020-08-16 20:36 UTC (permalink / raw)
  To: Jen-Chieh Shen; +Cc: 42872

(Please keep the debbugs address in the Cc header.)

Jen-Chieh Shen <jcs090218@gmail.com> writes:

> Oops, I guess I mess it up somehow.
>
> Here is the updated patch!

[...]

>  (defun count-windows (&optional minibuf)
>     "Return the number of live windows on the selected frame.
> +
>  The optional argument MINIBUF specifies whether the minibuffer
> -window shall be counted.  See `walk-windows' for the precise
> -meaning of this argument."

There's still no actual all-frames parameter in the count-windows
function signature.  :-)





^ permalink raw reply	[flat|nested] 7+ messages in thread

* bug#42872: [PATCH] Add all-frames as arg for count windows.
  2020-08-16 14:43   ` Drew Adams
  2020-08-16 14:50     ` Drew Adams
@ 2020-08-18 13:27     ` Lars Ingebrigtsen
  1 sibling, 0 replies; 7+ messages in thread
From: Lars Ingebrigtsen @ 2020-08-18 13:27 UTC (permalink / raw)
  To: Drew Adams; +Cc: Jen-Chieh Shen, 42872

Drew Adams <drew.adams@oracle.com> writes:

> +1 to adding optional arg ALL-FRAMES.
>
> Its behavior should be the same as for `walk-windows',
> which `count-windows' uses.  This is also the same as
> for `get-buffer-window'.

Yup, it just passes the argument to window-list-1, which has the same
semantics for that parameter, as far as I can see.

-- 
(domestic pets only, the antidote for overdose, milk.)
   bloggy blog: http://lars.ingebrigtsen.no





^ permalink raw reply	[flat|nested] 7+ messages in thread

* bug#42872: [PATCH] Add all-frames as arg for count windows.
  2020-08-16 14:50     ` Drew Adams
@ 2020-08-18 13:29       ` Lars Ingebrigtsen
  0 siblings, 0 replies; 7+ messages in thread
From: Lars Ingebrigtsen @ 2020-08-18 13:29 UTC (permalink / raw)
  To: Drew Adams; +Cc: Jen-Chieh Shen, 42872

Drew Adams <drew.adams@oracle.com> writes:

> 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.

Hm...  I don't quite see the use case for that.

-- 
(domestic pets only, the antidote for overdose, milk.)
   bloggy blog: http://lars.ingebrigtsen.no





^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2020-08-18 13:29 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2020-08-15  8:03 bug#42872: [PATCH] Add all-frames as arg for count windows Jen-Chieh Shen
2020-08-16 12:28 ` Lars Ingebrigtsen
2020-08-16 14:43   ` Drew Adams
2020-08-16 14:50     ` Drew Adams
2020-08-18 13:29       ` Lars Ingebrigtsen
2020-08-18 13:27     ` Lars Ingebrigtsen
     [not found]   ` <CAMiGhTMRTtxQRQgiok55OuoAHiqz-=BfZQOJFVG+fPASO-TsEA@mail.gmail.com>
2020-08-16 20:36     ` Lars Ingebrigtsen

Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.