Subject: bug#1237: 23.0.60; `switch-to-buffer-other-window' sometimes uses selected window

From: Markus Triska <[email-masked]>
Date: Sat, 25 Oct 2008 18:09:28 +0200

martin rudalics <[email-masked]> writes:

> 		(set-frame-selected-window (car elt) (cdr elt)))) ; <--- here
> 	 (if (window-live-p save-selected-window-window)
> 	     (select-window save-selected-window-window)))))) <--- and here
>
> Fixing these two fixes the bug.  I have to find out how to do this in an
> unobtrusive way though.

Would it suffice if `run_window_configuration_change_hook' re-selected
the selected window at the end? i.e.,

2008-10-25  Markus Triska  <[email-masked]>

	* window.c (run_window_configuration_change_hook): Re-select the
	selected window, to get the most recently used window right.

diff --git a/src/window.c b/src/window.c
index 5931955..28e089a 100644
--- a/src/window.c
+++ b/src/window.c
@@ -3382,6 +3382,9 @@ run_window_configuration_change_hook (struct frame *f)
       }
   }
 
+  /* Make sure that the selected window remains most recently used. */
+  Fselect_window (Fselected_window (), Qnil);
+
   run_funs (global_wcch);
   unbind_to (count, Qnil);
 }