Subject: 28.0.50; allow windmove to select windows with the 'no-other-window parameter

From: pillule <[email-masked]>
Date: Tue, 08 Jun 2021 12:09:21 +0200

Hi,

One may want to customize its `display-buffer-alist' carefully to 
apply the 'no-other-window parameter to eg side windows so they 
are not selected by the `other-window' command and to create 
custom functions of the family (eg creating a 
`find-file-in-other-window' that does not select windows with the 
no-other-window parameter)

Unfortunately by doing so, we actually limit the use of the 
windmove commands since `windmove-find-other-window' always ignore 
windows with this parameter.
It is not a fatality since `window-in-direction' can receive an 
argument to choose if we want to ignore this parameter or not.

This draft implements an user option to let the user choose that 
behavior.

Because it applies to `windmove-find-other-window', it allows the 
commands windmove-right, windmove-left, windmove-down, windmove-up 
to select windows with the no-other-window parameter, but not for 
the `windmove-display-*' functions. I suppose it is the desired 
behavior.

>From 8997dcd61e68cb0cd6251987fbc8c291ef0c7bbe Mon Sep 17 00:00:00 2001
From: Trust me I am a doctor <[email-masked]>
Date: Tue, 8 Jun 2021 11:51:55 +0200
Subject: [PATCH] User option to select 'no-other-window with windmove

* lisp/windmove.el
   (windmove-ignore-no-other-window): add this new user option
   (windmove-find-other-window): uses windmove-ignore-no-other-window
to choose whether windmove can access to the window with the
'no-other-window property.
---
 lisp/windmove.el | 11 ++++++++++-
 1 file changed, 10 insertions(+), 1 deletion(-)

diff --git a/lisp/windmove.el b/lisp/windmove.el
index d648613e10..23bbc0908e 100644
--- a/lisp/windmove.el
+++ b/lisp/windmove.el
@@ -165,6 +165,14 @@ windmove-window-distance-delta
 (make-obsolete-variable 'windmove-window-distance-delta
                         "no longer used." "27.1")
 
+(defcustom windmove-ignore-no-other-window nil
+  "Whether the windmove commands are allowed to target all type of windows,
+If this variable is set to t, `windmove-find-other-window--side' and
+subsequently all interactive windmove commandswill ignore the
+no-other-window parameter."
+  :type 'boolean
+  :group 'windmove)
+
 
 ;; Note:
 ;;
@@ -345,7 +353,8 @@ windmove-find-other-window
 Optional ARG, if negative, means to use the right or bottom edge of
 WINDOW as reference position, instead of `window-point'; if positive,
 use the left or top edge of WINDOW as reference point."
-  (window-in-direction dir window nil arg windmove-wrap-around t))
+  (window-in-direction dir window windmove-ignore-no-other-window
+                       arg windmove-wrap-around t))
 
 ;; Selects the window that's hopefully at the location returned by
 ;; `windmove-find-other-window', or screams if there's no window there.
-- 
2.20.1