* bug#73706: 31.0.50; ignore-window-parameters not working
2024-10-08 14:16 ` Eli Zaretskii
@ 2024-10-08 16:19 ` martin rudalics via Bug reports for GNU Emacs, the Swiss army knife of text editors
2024-10-08 16:50 ` Gerd Möllmann
2024-10-08 17:54 ` Eli Zaretskii
0 siblings, 2 replies; 8+ messages in thread
From: martin rudalics via Bug reports for GNU Emacs, the Swiss army knife of text editors @ 2024-10-08 16:19 UTC (permalink / raw)
To: Eli Zaretskii, Gerd Möllmann; +Cc: 73706
[-- Attachment #1: Type: text/plain, Size: 781 bytes --]
>> Recipe with emacs -q
>>
>> - C-x 2
>> - Eval (set-window-parameter nil 'no-other-window t)
>> - Eval (setq ignore-window-parameters t)
>> - C-x o
>> - C-x o
>>
>> => No other window to select
>>
>> In GNU Emacs 31.0.50 (build 1, aarch64-apple-darwin24.0.0) of 2024-10-07
>> built on pro2
>> Repository revision: 8c5d69998e65d3ecf5f599bd828bf3330f4f118a
>> Repository branch: master
>> System Description: macOS 15.0.1
>
> This can also be reproduced in Emacs 30.
>
> Adding Martin to the discussion.
A fix against the release version is attached (fixes for the manual not
included). But I would have to run it here for a month at least in
order to make sure that it never selects tooltip windows or the like.
So it's by all means for master only.
martin
[-- Attachment #2: window-no-other-p.diff --]
[-- Type: text/x-patch, Size: 12493 bytes --]
diff --git a/lisp/erc/erc-speedbar.el b/lisp/erc/erc-speedbar.el
index e45fb9a7adf..a281e13734c 100644
--- a/lisp/erc/erc-speedbar.el
+++ b/lisp/erc/erc-speedbar.el
@@ -652,8 +652,7 @@ erc-speedbar-toggle-nicknames-window-lock
(when-let ((window (get-buffer-window speedbar-buffer)))
(let ((val (cond ((natnump arg) t)
((integerp arg) nil)
- (t (not (window-parameter window
- 'no-other-window))))))
+ (t (not (window-no-other-p window))))))
(with-current-buffer speedbar-buffer
(setq cursor-type (not val)))
(set-window-parameter window 'no-other-window val)
diff --git a/lisp/window.el b/lisp/window.el
index 006cfa19525..6ed2601b635 100644
--- a/lisp/window.el
+++ b/lisp/window.el
@@ -428,6 +428,16 @@ ignore-window-parameters
An application may bind this to a non-nil value around calls to
these functions to inhibit processing of window parameters.")
+(defun window-no-other-p (&optional window)
+ "Return non-nil if WINDOW should not be used as \"other\" window.
+WINDOW must be a live window and defaults to the selected one.
+
+Return non-nil if the `no-other-window' parameter of WINDOW is non-nil
+and `ignore-window-parameters' is nil. In any other case return nil."
+ (setq window (window-normalize-window window t))
+ (and (not ignore-window-parameters)
+ (window-parameter window 'no-other-window)))
+
;; This must go to C, finally (or get removed).
(defconst window-safe-min-height 1
"The absolute minimum number of lines of any window.
@@ -2307,11 +2317,11 @@ window-in-direction
DIRECTION should be one of `above', `below', `left' or `right'.
WINDOW must be a live window and defaults to the selected one.
-Do not return a window whose `no-other-window' parameter is
-non-nil. If the nearest window's `no-other-window' parameter is
-non-nil, try to find another window in the indicated direction.
-If, however, the optional argument IGNORE is non-nil, return that
-window even if its `no-other-window' parameter is non-nil.
+Do not return a window for which `window-no-other-p' returns non-nil.
+If `window-no-other-p' returns non-nil for the nearest window, try to
+find another window in the indicated direction. If, however, the
+optional argument IGNORE is non-nil, return the nearest window even if
+`window-no-other-p' returns for it a non-nil value.
Optional argument SIGN a negative number means to use the right
or bottom edge of WINDOW as reference position instead of
@@ -2375,7 +2385,7 @@ window-in-direction
(cond
((or (eq window w)
;; Ignore ourselves.
- (and (window-parameter w 'no-other-window)
+ (and (window-no-other-p w)
;; Ignore W unless IGNORE is non-nil.
(not ignore))))
(hor
@@ -2491,14 +2501,13 @@ 'some-window
(defun get-lru-window (&optional all-frames dedicated not-selected no-other)
"Return the least recently used window on frames specified by ALL-FRAMES.
-Return a full-width window if possible. A minibuffer window is
-never a candidate. A dedicated window is never a candidate
-unless DEDICATED is non-nil, so if all windows are dedicated, the
-value is nil. Avoid returning the selected window if possible.
-Optional argument NOT-SELECTED non-nil means never return the
-selected window. Optional argument NO-OTHER non-nil means to
-never return a window whose `no-other-window' parameter is
-non-nil.
+Return a full-width window if possible. A minibuffer window is never a
+candidate. A dedicated window is never a candidate unless DEDICATED is
+non-nil, so if all windows are dedicated, the value is nil. Avoid
+returning the selected window if possible. Optional argument
+NOT-SELECTED non-nil means never return the selected window. Optional
+argument NO-OTHER non-nil means to never return a window for which
+`window-no-other-p' returns non-nil.
The following non-nil values of the optional argument ALL-FRAMES
have special meanings:
@@ -2522,8 +2531,7 @@ get-lru-window
(dolist (window windows)
(when (and (or dedicated (not (window-dedicated-p window)))
(or (not not-selected) (not (eq window (selected-window))))
- (or (not no-other)
- (not (window-parameter window 'no-other-window))))
+ (or (not no-other) (not (window-no-other-p window))))
(setq time (window-use-time window))
(if (or (eq window (selected-window))
(not (window-full-width-p window)))
@@ -2537,12 +2545,11 @@ get-lru-window
(defun get-mru-window (&optional all-frames dedicated not-selected no-other)
"Return the most recently used window on frames specified by ALL-FRAMES.
-A minibuffer window is never a candidate. A dedicated window is
-never a candidate unless DEDICATED is non-nil, so if all windows
-are dedicated, the value is nil. Optional argument NOT-SELECTED
-non-nil means never return the selected window. Optional
-argument NO-OTHER non-nil means to never return a window whose
-`no-other-window' parameter is non-nil.
+A minibuffer window is never a candidate. A dedicated window is never a
+candidate unless DEDICATED is non-nil, so if all windows are dedicated,
+the value is nil. Optional argument NOT-SELECTED non-nil means never
+return the selected window. Optional argument NO-OTHER non-nil means to
+never return a window for which `window-no-other-p' returns non-nil.
The following non-nil values of the optional argument ALL-FRAMES
have special meanings:
@@ -2564,8 +2571,7 @@ get-mru-window
(setq time (window-use-time window))
(when (and (or dedicated (not (window-dedicated-p window)))
(or (not not-selected) (not (eq window (selected-window))))
- (or (not no-other)
- (not (window-parameter window 'no-other-window)))
+ (or (not no-other) (not (window-no-other-p window)))
(or (not best-time) (> time best-time)))
(setq best-time time)
(setq best-window window)))
@@ -2573,12 +2579,11 @@ get-mru-window
(defun get-largest-window (&optional all-frames dedicated not-selected no-other)
"Return the largest window on frames specified by ALL-FRAMES.
-A minibuffer window is never a candidate. A dedicated window is
-never a candidate unless DEDICATED is non-nil, so if all windows
-are dedicated, the value is nil. Optional argument NOT-SELECTED
-non-nil means never return the selected window. Optional
-argument NO-OTHER non-nil means to never return a window whose
-`no-other-window' parameter is non-nil.
+A minibuffer window is never a candidate. A dedicated window is never a
+candidate unless DEDICATED is non-nil, so if all windows are dedicated,
+the value is nil. Optional argument NOT-SELECTED non-nil means never
+return the selected window. Optional argument NO-OTHER non-nil means to
+never return a window for which `window-no-other-p' returns non-nil.
The following non-nil values of the optional argument ALL-FRAMES
have special meanings:
@@ -2602,8 +2607,7 @@ get-largest-window
(dolist (window (window-list-1 nil 'nomini all-frames))
(when (and (or dedicated (not (window-dedicated-p window)))
(or (not not-selected) (not (eq window (selected-window))))
- (or (not no-other)
- (not (window-parameter window 'no-other-window))))
+ (or (not no-other) (window-no-other-p window)))
(setq size (* (window-pixel-height window)
(window-pixel-width window)))
(when (> size best-size)
@@ -3963,12 +3967,10 @@ other-window
window, so select the selected window. In an interactive call,
COUNT is the numeric prefix argument. Return nil.
-If the `other-window' parameter of the selected window is a
-function and `ignore-window-parameters' is nil, call that
-function with the arguments COUNT and ALL-FRAMES.
-
-This function does not select a window whose `no-other-window'
-window parameter is non-nil.
+If the `other-window' parameter of the selected window is a function and
+`ignore-window-parameters' is nil, call that function with the arguments
+COUNT and ALL-FRAMES. Otherwise, do not return a window for which
+`window-no-other-p' returns non-nil.
This function uses `next-window' for finding the window to
select. The argument ALL-FRAMES has the same meaning as in
@@ -3994,7 +3996,7 @@ other-window
;; Keep out of infinite loops. When COUNT has not changed
;; since we last looked at `window' we're probably in one.
(throw 'exit nil)))
- ((window-parameter window 'no-other-window)
+ ((window-no-other-p window)
(unless old-window
;; The first non-selectable window `next-window' got us:
;; Remember it and the current value of COUNT.
@@ -4010,7 +4012,7 @@ other-window
;; Keep out of infinite loops. When COUNT has not changed
;; since we last looked at `window' we're probably in one.
(throw 'exit nil)))
- ((window-parameter window 'no-other-window)
+ ((window-no-other-p window)
(unless old-window
;; The first non-selectable window `previous-window' got
;; us: Remember it and the current value of COUNT.
@@ -4159,10 +4161,10 @@ window-at-x-y
if the specified coordinates are in any of these two windows, this
function returns nil.
-Optional argument FRAME must specify a live frame and defaults to
-the selected one. Optional argument NO-OTHER non-nil means to
-return nil if the window located at the specified coordinates has
-a non-nil `no-other-window' parameter."
+Optional argument FRAME must specify a live frame and defaults to the
+selected one. Optional argument NO-OTHER non-nil means to return nil if
+`window-no-other-p' returns non-nil for the window located at the
+specified coordinates."
(setq frame (window-normalize-frame frame))
(let* ((root-edges (window-edges (frame-root-window frame) nil nil t))
(root-left (nth 2 root-edges))
@@ -4175,7 +4177,7 @@ window-at-x-y
(or (< x (nth 2 edges)) (= x root-left))
(>= y (nth 1 edges))
(or (< y (nth 3 edges)) (= y root-bottom)))
- (if (and no-other (window-parameter window 'no-other-window))
+ (if (and no-other (window-no-other-p window))
(throw 'window nil)
(throw 'window window)))))
frame))))
@@ -4187,13 +4189,13 @@ delete-window-choose-selected
window. This option controls the window that is selected in such
a situation.
-The possible choices are `mru' (the default) to select the most
-recently used window on that frame, and `pos' to choose the
-window at the frame coordinates of point of the previously
-selected window. If this is nil, choose the frame's first window
-instead. A window with a non-nil `no-other-window' parameter is
-chosen only if all windows on that frame have that parameter set
-to a non-nil value."
+The possible choices are `mru' (the default) to select the most recently
+used window on that frame, and `pos' to choose the window at the frame
+coordinates of point of the previously selected window. If this is nil,
+choose the frame's first window instead. A window for which
+`window-no-other-p' returns non-nil is chosen only if all windows on
+that frame have their `no-other-window' parameter set to a non-nil
+value."
:type '(choice (const :tag "Most recently used" mru)
(const :tag "At position of deleted" pos)
(const :tag "Frame's first " nil))
@@ -4316,15 +4318,14 @@ delete-window
(let ((mru-window (get-mru-window frame nil nil t)))
(and mru-window
(set-frame-selected-window frame mru-window)))))
- ((and (window-parameter
- (frame-selected-window frame) 'no-other-window)
+ ((and (window-no-other-p (frame-selected-window frame))
;; If `delete-window-internal' selected a window with a
;; non-nil 'no-other-window' parameter as its frame's
;; selected window, try to choose another one.
(catch 'found
(walk-window-tree
(lambda (other)
- (unless (window-parameter other 'no-other-window)
+ (unless (window-no-other-p other)
(set-frame-selected-window frame other)
(throw 'found t)))
frame))))
^ permalink raw reply related [flat|nested] 8+ messages in thread