aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMichael Albinus2024-10-11 12:07:03 +0200
committerMichael Albinus2024-10-11 12:07:03 +0200
commite44f98b71bfd1f93d9b443a34e01a523ec34d3bb (patch)
tree41ae3c51b0276d20c442a5e116a94620920f20f7
parent8032423239ae2df6970c208a1b0166dcda65a445 (diff)
parent3462b2b9d0ca6a483d5c3200ef71a8ca243225d1 (diff)
downloademacs-e44f98b71bfd1f93d9b443a34e01a523ec34d3bb.tar.gz
emacs-e44f98b71bfd1f93d9b443a34e01a523ec34d3bb.zip
Merge branch 'master' of git.sv.gnu.org:/srv/git/emacs
-rw-r--r--doc/lispref/windows.texi57
-rw-r--r--lisp/erc/erc-speedbar.el3
-rw-r--r--lisp/window.el111
3 files changed, 97 insertions, 74 deletions
diff --git a/doc/lispref/windows.texi b/doc/lispref/windows.texi
index d9e99d9ca5c..0b8d7d3b76d 100644
--- a/doc/lispref/windows.texi
+++ b/doc/lispref/windows.texi
@@ -427,13 +427,14 @@ window @var{window}. The argument @var{direction} must be one of
427argument @var{window} must denote a live window and defaults to the 427argument @var{window} must denote a live window and defaults to the
428selected one. 428selected one.
429 429
430This function does not return a window whose @code{no-other-window} 430This function does not return a window for which
431parameter is non-@code{nil} (@pxref{Window Parameters}). If the nearest 431@code{window-no-other-p} (@pxref{Cyclic Window Ordering}) returns
432window's @code{no-other-window} parameter is non-@code{nil}, this 432non-@code{nil}. If the nearest window's @code{no-other-window}
433function tries to find another window in the indicated direction whose 433parameter is non-@code{nil}, this function tries to find another window
434@code{no-other-window} parameter is @code{nil}. If the optional 434in the indicated direction whose @code{no-other-window} parameter is
435argument @var{ignore} is non-@code{nil}, a window may be returned even 435@code{nil}. However, if the optional argument @var{ignore} is
436if its @code{no-other-window} parameter is non-@code{nil}. 436non-@code{nil}, a window may be returned even if its
437@code{no-other-window} parameter is non-@code{nil}.
437 438
438If the optional argument @var{sign} is a negative number, it means to 439If the optional argument @var{sign} is a negative number, it means to
439use the right or bottom edge of @var{window} as reference position 440use the right or bottom edge of @var{window} as reference position
@@ -1585,9 +1586,10 @@ choose the first window (the window returned by
1585@code{frame-first-window}) on that frame. 1586@code{frame-first-window}) on that frame.
1586@end itemize 1587@end itemize
1587 1588
1588A window with a non-@code{nil} @code{no-other-window} parameter is 1589A window for which @code{window-no-other-p} (@pxref{Cyclic Window
1589chosen only if all other windows on that frame have that parameter set 1590Ordering}) returns non-@code{nil} is chosen only if all other windows on
1590to a non-@code{nil} value too. 1591that frame have their @code{no-other-window} parameter set to a
1592non-@code{nil} value too.
1591@end defopt 1593@end defopt
1592 1594
1593@deffn Command delete-other-windows &optional window 1595@deffn Command delete-other-windows &optional window
@@ -2129,16 +2131,33 @@ The optional argument @var{all-frames} has the same meaning as in
2129@code{next-window}, like a @code{nil} @var{minibuf} argument to 2131@code{next-window}, like a @code{nil} @var{minibuf} argument to
2130@code{next-window}. 2132@code{next-window}.
2131 2133
2132This function does not select a window that has a non-@code{nil}
2133@code{no-other-window} window parameter (@pxref{Window Parameters}),
2134provided that @code{ignore-window-parameters} is @code{nil}.
2135
2136If the @code{other-window} parameter of the selected window is a 2134If the @code{other-window} parameter of the selected window is a
2137function, and @code{ignore-window-parameters} is @code{nil}, that 2135function, and @code{ignore-window-parameters} is @code{nil}, that
2138function will be called with the arguments @var{count} and 2136function will be called with the arguments @var{count} and
2139@var{all-frames} instead of the normal operation of this function. 2137@var{all-frames} instead of the normal operation of this function.
2138
2139Otherwise, this function does not select a window for which the function
2140@code{window-no-other-p} (see next) returns @code{nil}.
2140@end deffn 2141@end deffn
2141 2142
2143@defun window-no-other-p &optional window
2144This function returns non-@code{nil} if @var{window} should not be used
2145as ``other'' window by commands like @code{other-window} or functions
2146like @code{get-lru-window} (see below). It's also called when deleting
2147the selected window (@pxref{Deleting Windows}) and a new selected window
2148has to be chosen.
2149
2150More precisely, this function returns non-@code{nil} if the
2151@code{no-other-window} parameter of @var{window} is non-@code{nil} and
2152@code{ignore-window-parameters} is @code{nil}. It returns @code{nil} in
2153any other case.
2154
2155Note that if this function returns @code{nil}, this does not necessarily
2156mean that @var{window} can be selected. A tooltip window (@pxref{Basic
2157Windows}), for example, has its @code{no-other-window} parameter set to
2158@code{t} by default but cannot be selected.
2159@end defun
2160
2142@defun walk-windows fun &optional minibuf all-frames 2161@defun walk-windows fun &optional minibuf all-frames
2143This function calls the function @var{fun} once for each live window, 2162This function calls the function @var{fun} once for each live window,
2144with the window as the argument. 2163with the window as the argument.
@@ -2186,8 +2205,9 @@ optional argument @var{dedicated} is non-@code{nil}. The selected
2186window is never returned, unless it is the only candidate. However, if 2205window is never returned, unless it is the only candidate. However, if
2187the optional argument @var{not-selected} is non-@code{nil}, this 2206the optional argument @var{not-selected} is non-@code{nil}, this
2188function returns @code{nil} in that case. The optional argument 2207function returns @code{nil} in that case. The optional argument
2189@var{no-other}, if non-@code{nil}, means to never return a window whose 2208@var{no-other}, if non-@code{nil}, means to never return a window for
2190@code{no-other-window} parameter is non-@code{nil}. 2209which @code{window-no-other-p} (@pxref{Cyclic Window Ordering}) returns
2210non-@code{nil}.
2191@end defun 2211@end defun
2192 2212
2193@cindex most recently used window 2213@cindex most recently used window
@@ -6784,7 +6804,10 @@ This parameter affects the execution of @code{other-window}
6784@item no-other-window 6804@item no-other-window
6785@vindex no-other-window@r{, a window parameter} 6805@vindex no-other-window@r{, a window parameter}
6786This parameter marks the window as not selectable by @code{other-window} 6806This parameter marks the window as not selectable by @code{other-window}
6787(@pxref{Cyclic Window Ordering}). 6807(@pxref{Cyclic Window Ordering}). It is by default @code{t} for tooltip
6808windows (@pxref{Basic Windows}). Use @code{window-no-other-p}
6809(@pxref{Cyclic Window Ordering}) to check whether it applies to a
6810specific window.
6788 6811
6789@item clone-of 6812@item clone-of
6790@vindex clone-of@r{, a window parameter} 6813@vindex clone-of@r{, a window parameter}
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 @@ unlock the window."
652 (when-let ((window (get-buffer-window speedbar-buffer))) 652 (when-let ((window (get-buffer-window speedbar-buffer)))
653 (let ((val (cond ((natnump arg) t) 653 (let ((val (cond ((natnump arg) t)
654 ((integerp arg) nil) 654 ((integerp arg) nil)
655 (t (not (window-parameter window 655 (t (not (window-no-other-p window))))))
656 'no-other-window))))))
657 (with-current-buffer speedbar-buffer 656 (with-current-buffer speedbar-buffer
658 (setq cursor-type (not val))) 657 (setq cursor-type (not val)))
659 (set-window-parameter window 'no-other-window val) 658 (set-window-parameter window 'no-other-window val)
diff --git a/lisp/window.el b/lisp/window.el
index 5822947f2fe..1b95b5c9500 100644
--- a/lisp/window.el
+++ b/lisp/window.el
@@ -428,6 +428,16 @@ The functions currently affected by this are `split-window',
428An application may bind this to a non-nil value around calls to 428An application may bind this to a non-nil value around calls to
429these functions to inhibit processing of window parameters.") 429these functions to inhibit processing of window parameters.")
430 430
431(defun window-no-other-p (&optional window)
432 "Return non-nil if WINDOW should not be used as \"other\" window.
433WINDOW must be a live window and defaults to the selected one.
434
435Return non-nil if the `no-other-window' parameter of WINDOW is non-nil
436and `ignore-window-parameters' is nil. Return nil in any other case."
437 (setq window (window-normalize-window window t))
438 (and (not ignore-window-parameters)
439 (window-parameter window 'no-other-window)))
440
431;; This must go to C, finally (or get removed). 441;; This must go to C, finally (or get removed).
432(defconst window-safe-min-height 1 442(defconst window-safe-min-height 1
433 "The absolute minimum number of lines of any window. 443 "The absolute minimum number of lines of any window.
@@ -2307,11 +2317,11 @@ as seen from the position of `window-point' in window WINDOW.
2307DIRECTION should be one of `above', `below', `left' or `right'. 2317DIRECTION should be one of `above', `below', `left' or `right'.
2308WINDOW must be a live window and defaults to the selected one. 2318WINDOW must be a live window and defaults to the selected one.
2309 2319
2310Do not return a window whose `no-other-window' parameter is 2320Do not return a window for which `window-no-other-p' returns non-nil.
2311non-nil. If the nearest window's `no-other-window' parameter is 2321If `window-no-other-p' returns non-nil for the nearest window, try to
2312non-nil, try to find another window in the indicated direction. 2322find another window in the indicated direction. If, however, the
2313If, however, the optional argument IGNORE is non-nil, return that 2323optional argument IGNORE is non-nil, return the nearest window even if
2314window even if its `no-other-window' parameter is non-nil. 2324`window-no-other-p' returns for it a non-nil value.
2315 2325
2316Optional argument SIGN a negative number means to use the right 2326Optional argument SIGN a negative number means to use the right
2317or bottom edge of WINDOW as reference position instead of 2327or bottom edge of WINDOW as reference position instead of
@@ -2375,7 +2385,7 @@ Return nil if no suitable window can be found."
2375 (cond 2385 (cond
2376 ((or (eq window w) 2386 ((or (eq window w)
2377 ;; Ignore ourselves. 2387 ;; Ignore ourselves.
2378 (and (window-parameter w 'no-other-window) 2388 (and (window-no-other-p w)
2379 ;; Ignore W unless IGNORE is non-nil. 2389 ;; Ignore W unless IGNORE is non-nil.
2380 (not ignore)))) 2390 (not ignore))))
2381 (hor 2391 (hor
@@ -2491,14 +2501,13 @@ and no others."
2491 2501
2492(defun get-lru-window (&optional all-frames dedicated not-selected no-other) 2502(defun get-lru-window (&optional all-frames dedicated not-selected no-other)
2493 "Return the least recently used window on frames specified by ALL-FRAMES. 2503 "Return the least recently used window on frames specified by ALL-FRAMES.
2494Return a full-width window if possible. A minibuffer window is 2504Return a full-width window if possible. A minibuffer window is never a
2495never a candidate. A dedicated window is never a candidate 2505candidate. A dedicated window is never a candidate unless DEDICATED is
2496unless DEDICATED is non-nil, so if all windows are dedicated, the 2506non-nil, so if all windows are dedicated, the value is nil. Avoid
2497value is nil. Avoid returning the selected window if possible. 2507returning the selected window if possible. Optional argument
2498Optional argument NOT-SELECTED non-nil means never return the 2508NOT-SELECTED non-nil means never return the selected window. Optional
2499selected window. Optional argument NO-OTHER non-nil means to 2509argument NO-OTHER non-nil means to never return a window for which
2500never return a window whose `no-other-window' parameter is 2510`window-no-other-p' returns non-nil.
2501non-nil.
2502 2511
2503The following non-nil values of the optional argument ALL-FRAMES 2512The following non-nil values of the optional argument ALL-FRAMES
2504have special meanings: 2513have special meanings:
@@ -2522,8 +2531,7 @@ selected frame and no others."
2522 (dolist (window windows) 2531 (dolist (window windows)
2523 (when (and (or dedicated (not (window-dedicated-p window))) 2532 (when (and (or dedicated (not (window-dedicated-p window)))
2524 (or (not not-selected) (not (eq window (selected-window)))) 2533 (or (not not-selected) (not (eq window (selected-window))))
2525 (or (not no-other) 2534 (or (not no-other) (not (window-no-other-p window))))
2526 (not (window-parameter window 'no-other-window))))
2527 (setq time (window-use-time window)) 2535 (setq time (window-use-time window))
2528 (if (or (eq window (selected-window)) 2536 (if (or (eq window (selected-window))
2529 (not (window-full-width-p window))) 2537 (not (window-full-width-p window)))
@@ -2537,12 +2545,11 @@ selected frame and no others."
2537 2545
2538(defun get-mru-window (&optional all-frames dedicated not-selected no-other) 2546(defun get-mru-window (&optional all-frames dedicated not-selected no-other)
2539 "Return the most recently used window on frames specified by ALL-FRAMES. 2547 "Return the most recently used window on frames specified by ALL-FRAMES.
2540A minibuffer window is never a candidate. A dedicated window is 2548A minibuffer window is never a candidate. A dedicated window is never a
2541never a candidate unless DEDICATED is non-nil, so if all windows 2549candidate unless DEDICATED is non-nil, so if all windows are dedicated,
2542are dedicated, the value is nil. Optional argument NOT-SELECTED 2550the value is nil. Optional argument NOT-SELECTED non-nil means never
2543non-nil means never return the selected window. Optional 2551return the selected window. Optional argument NO-OTHER non-nil means to
2544argument NO-OTHER non-nil means to never return a window whose 2552never return a window for which `window-no-other-p' returns non-nil.
2545`no-other-window' parameter is non-nil.
2546 2553
2547The following non-nil values of the optional argument ALL-FRAMES 2554The following non-nil values of the optional argument ALL-FRAMES
2548have special meanings: 2555have special meanings:
@@ -2564,8 +2571,7 @@ selected frame and no others."
2564 (setq time (window-use-time window)) 2571 (setq time (window-use-time window))
2565 (when (and (or dedicated (not (window-dedicated-p window))) 2572 (when (and (or dedicated (not (window-dedicated-p window)))
2566 (or (not not-selected) (not (eq window (selected-window)))) 2573 (or (not not-selected) (not (eq window (selected-window))))
2567 (or (not no-other) 2574 (or (not no-other) (not (window-no-other-p window)))
2568 (not (window-parameter window 'no-other-window)))
2569 (or (not best-time) (> time best-time))) 2575 (or (not best-time) (> time best-time)))
2570 (setq best-time time) 2576 (setq best-time time)
2571 (setq best-window window))) 2577 (setq best-window window)))
@@ -2573,12 +2579,11 @@ selected frame and no others."
2573 2579
2574(defun get-largest-window (&optional all-frames dedicated not-selected no-other) 2580(defun get-largest-window (&optional all-frames dedicated not-selected no-other)
2575 "Return the largest window on frames specified by ALL-FRAMES. 2581 "Return the largest window on frames specified by ALL-FRAMES.
2576A minibuffer window is never a candidate. A dedicated window is 2582A minibuffer window is never a candidate. A dedicated window is never a
2577never a candidate unless DEDICATED is non-nil, so if all windows 2583candidate unless DEDICATED is non-nil, so if all windows are dedicated,
2578are dedicated, the value is nil. Optional argument NOT-SELECTED 2584the value is nil. Optional argument NOT-SELECTED non-nil means never
2579non-nil means never return the selected window. Optional 2585return the selected window. Optional argument NO-OTHER non-nil means to
2580argument NO-OTHER non-nil means to never return a window whose 2586never return a window for which `window-no-other-p' returns non-nil.
2581`no-other-window' parameter is non-nil.
2582 2587
2583The following non-nil values of the optional argument ALL-FRAMES 2588The following non-nil values of the optional argument ALL-FRAMES
2584have special meanings: 2589have special meanings:
@@ -2602,8 +2607,7 @@ selected frame and no others."
2602 (dolist (window (window-list-1 nil 'nomini all-frames)) 2607 (dolist (window (window-list-1 nil 'nomini all-frames))
2603 (when (and (or dedicated (not (window-dedicated-p window))) 2608 (when (and (or dedicated (not (window-dedicated-p window)))
2604 (or (not not-selected) (not (eq window (selected-window)))) 2609 (or (not not-selected) (not (eq window (selected-window))))
2605 (or (not no-other) 2610 (or (not no-other) (window-no-other-p window)))
2606 (not (window-parameter window 'no-other-window))))
2607 (setq size (* (window-pixel-height window) 2611 (setq size (* (window-pixel-height window)
2608 (window-pixel-width window))) 2612 (window-pixel-width window)))
2609 (when (> size best-size) 2613 (when (> size best-size)
@@ -3963,12 +3967,10 @@ skip -COUNT windows backwards. COUNT zero means do not skip any
3963window, so select the selected window. In an interactive call, 3967window, so select the selected window. In an interactive call,
3964COUNT is the numeric prefix argument. Return nil. 3968COUNT is the numeric prefix argument. Return nil.
3965 3969
3966If the `other-window' parameter of the selected window is a 3970If the `other-window' parameter of the selected window is a function and
3967function and `ignore-window-parameters' is nil, call that 3971`ignore-window-parameters' is nil, call that function with the arguments
3968function with the arguments COUNT and ALL-FRAMES. 3972COUNT and ALL-FRAMES. Otherwise, do not return a window for which
3969 3973`window-no-other-p' returns non-nil.
3970This function does not select a window whose `no-other-window'
3971window parameter is non-nil.
3972 3974
3973This function uses `next-window' for finding the window to 3975This function uses `next-window' for finding the window to
3974select. The argument ALL-FRAMES has the same meaning as in 3976select. The argument ALL-FRAMES has the same meaning as in
@@ -3994,7 +3996,7 @@ always effectively nil."
3994 ;; Keep out of infinite loops. When COUNT has not changed 3996 ;; Keep out of infinite loops. When COUNT has not changed
3995 ;; since we last looked at `window' we're probably in one. 3997 ;; since we last looked at `window' we're probably in one.
3996 (throw 'exit nil))) 3998 (throw 'exit nil)))
3997 ((window-parameter window 'no-other-window) 3999 ((window-no-other-p window)
3998 (unless old-window 4000 (unless old-window
3999 ;; The first non-selectable window `next-window' got us: 4001 ;; The first non-selectable window `next-window' got us:
4000 ;; Remember it and the current value of COUNT. 4002 ;; Remember it and the current value of COUNT.
@@ -4010,7 +4012,7 @@ always effectively nil."
4010 ;; Keep out of infinite loops. When COUNT has not changed 4012 ;; Keep out of infinite loops. When COUNT has not changed
4011 ;; since we last looked at `window' we're probably in one. 4013 ;; since we last looked at `window' we're probably in one.
4012 (throw 'exit nil))) 4014 (throw 'exit nil)))
4013 ((window-parameter window 'no-other-window) 4015 ((window-no-other-p window)
4014 (unless old-window 4016 (unless old-window
4015 ;; The first non-selectable window `previous-window' got 4017 ;; The first non-selectable window `previous-window' got
4016 ;; us: Remember it and the current value of COUNT. 4018 ;; us: Remember it and the current value of COUNT.
@@ -4183,10 +4185,10 @@ Tool-bar and tab-bar pseudo-windows are ignored by this function:
4183if the specified coordinates are in any of these two windows, this 4185if the specified coordinates are in any of these two windows, this
4184function returns nil. 4186function returns nil.
4185 4187
4186Optional argument FRAME must specify a live frame and defaults to 4188Optional argument FRAME must specify a live frame and defaults to the
4187the selected one. Optional argument NO-OTHER non-nil means to 4189selected one. Optional argument NO-OTHER non-nil means to return nil if
4188return nil if the window located at the specified coordinates has 4190`window-no-other-p' returns non-nil for the window located at the
4189a non-nil `no-other-window' parameter." 4191specified coordinates."
4190 (setq frame (window-normalize-frame frame)) 4192 (setq frame (window-normalize-frame frame))
4191 (let* ((root-edges (window-edges (frame-root-window frame) nil nil t)) 4193 (let* ((root-edges (window-edges (frame-root-window frame) nil nil t))
4192 (root-left (nth 2 root-edges)) 4194 (root-left (nth 2 root-edges))
@@ -4199,7 +4201,7 @@ a non-nil `no-other-window' parameter."
4199 (or (< x (nth 2 edges)) (= x root-left)) 4201 (or (< x (nth 2 edges)) (= x root-left))
4200 (>= y (nth 1 edges)) 4202 (>= y (nth 1 edges))
4201 (or (< y (nth 3 edges)) (= y root-bottom))) 4203 (or (< y (nth 3 edges)) (= y root-bottom)))
4202 (if (and no-other (window-parameter window 'no-other-window)) 4204 (if (and no-other (window-no-other-p window))
4203 (throw 'window nil) 4205 (throw 'window nil)
4204 (throw 'window window))))) 4206 (throw 'window window)))))
4205 frame)))) 4207 frame))))
@@ -4211,13 +4213,13 @@ another live window on that frame to serve as its selected
4211window. This option controls the window that is selected in such 4213window. This option controls the window that is selected in such
4212a situation. 4214a situation.
4213 4215
4214The possible choices are `mru' (the default) to select the most 4216The possible choices are `mru' (the default) to select the most recently
4215recently used window on that frame, and `pos' to choose the 4217used window on that frame, and `pos' to choose the window at the frame
4216window at the frame coordinates of point of the previously 4218coordinates of point of the previously selected window. If this is nil,
4217selected window. If this is nil, choose the frame's first window 4219choose the frame's first window instead. A window for which
4218instead. A window with a non-nil `no-other-window' parameter is 4220`window-no-other-p' returns non-nil is chosen only if all windows on
4219chosen only if all windows on that frame have that parameter set 4221that frame have their `no-other-window' parameter set to a non-nil
4220to a non-nil value." 4222value."
4221 :type '(choice (const :tag "Most recently used" mru) 4223 :type '(choice (const :tag "Most recently used" mru)
4222 (const :tag "At position of deleted" pos) 4224 (const :tag "At position of deleted" pos)
4223 (const :tag "Frame's first " nil)) 4225 (const :tag "Frame's first " nil))
@@ -4340,15 +4342,14 @@ the option `delete-window-choose-selected'."
4340 (let ((mru-window (get-mru-window frame nil nil t))) 4342 (let ((mru-window (get-mru-window frame nil nil t)))
4341 (and mru-window 4343 (and mru-window
4342 (set-frame-selected-window frame mru-window))))) 4344 (set-frame-selected-window frame mru-window)))))
4343 ((and (window-parameter 4345 ((and (window-no-other-p (frame-selected-window frame))
4344 (frame-selected-window frame) 'no-other-window)
4345 ;; If `delete-window-internal' selected a window with a 4346 ;; If `delete-window-internal' selected a window with a
4346 ;; non-nil 'no-other-window' parameter as its frame's 4347 ;; non-nil 'no-other-window' parameter as its frame's
4347 ;; selected window, try to choose another one. 4348 ;; selected window, try to choose another one.
4348 (catch 'found 4349 (catch 'found
4349 (walk-window-tree 4350 (walk-window-tree
4350 (lambda (other) 4351 (lambda (other)
4351 (unless (window-parameter other 'no-other-window) 4352 (unless (window-no-other-p other)
4352 (set-frame-selected-window frame other) 4353 (set-frame-selected-window frame other)
4353 (throw 'found t))) 4354 (throw 'found t)))
4354 frame)))) 4355 frame))))