changeset 27869:1322db65a230

(select_window_1): If selected_window is nil, don't "swap out" the buffer's point. (Fset_window_configuration): Set selected_window to nil before calling Fselect_window. (unshow_buffer): Don't set point in buffer from window's point if another more recently selected window also shows the buffer.
author Gerd Moellmann <gerd@gnu.org>
date Fri, 25 Feb 2000 15:41:43 +0000
parents b5dc290eb929
children a36c3e02f43b
files src/window.c
diffstat 1 files changed, 28 insertions(+), 9 deletions(-) [+]
line wrap: on
line diff
--- a/src/window.c	Fri Feb 25 14:05:59 2000 +0000
+++ b/src/window.c	Fri Feb 25 15:41:43 2000 +0000
@@ -882,9 +882,6 @@
   if (b != XMARKER (w->pointm)->buffer)
     abort ();
 
-  if (w == XWINDOW (b->last_selected_window))
-    b->last_selected_window = Qnil;
-
 #if 0
   if (w == XWINDOW (selected_window)
       || ! EQ (buf, XWINDOW (selected_window)->buffer))
@@ -903,7 +900,10 @@
   /* Point in the selected window's buffer
      is actually stored in that buffer, and the window's pointm isn't used.
      So don't clobber point in that buffer.  */
-  if (! EQ (buf, XWINDOW (selected_window)->buffer))
+  if (! EQ (buf, XWINDOW (selected_window)->buffer)
+      /* This line helps to fix Horsley's testbug.el bug.  */
+      && !(w != XWINDOW (b->last_selected_window)
+	   && EQ (buf, XWINDOW (b->last_selected_window)->buffer)))
     temp_set_point_both (b,
 			 clip_to_bounds (BUF_BEGV (b),
 					 XMARKER (w->pointm)->charpos,
@@ -911,6 +911,9 @@
 			 clip_to_bounds (BUF_BEGV_BYTE (b),
 					 marker_byte_position (w->pointm),
 					 BUF_ZV_BYTE (b)));
+  
+  if (w == XWINDOW (b->last_selected_window))
+    b->last_selected_window = Qnil;
 }
 
 /* Put replacement into the window structure in place of old. */
@@ -2476,13 +2479,16 @@
   return select_window_1 (window, 1);
 }
 
+/* Note that selected_window can be nil
+   when this is called from Fset_window_configuration.  */
+ 
 static Lisp_Object
 select_window_1 (window, recordflag)
      register Lisp_Object window;
      int recordflag;
 {
   register struct window *w;
-  register struct window *ow = XWINDOW (selected_window);
+  register struct window *ow;
   struct frame *sf;
 
   CHECK_LIVE_WINDOW (window, 0);
@@ -2496,10 +2502,14 @@
   if (EQ (window, selected_window))
     return window;
 
-  if (! NILP (ow->buffer))
-    set_marker_both (ow->pointm, ow->buffer,
-		     BUF_PT (XBUFFER (ow->buffer)),
-		     BUF_PT_BYTE (XBUFFER (ow->buffer)));
+  if (!NILP (selected_window))
+    {
+      ow = XWINDOW (selected_window);
+      if (! NILP (ow->buffer))
+	set_marker_both (ow->pointm, ow->buffer,
+			 BUF_PT (XBUFFER (ow->buffer)),
+			 BUF_PT_BYTE (XBUFFER (ow->buffer)));
+    }
 
   selected_window = window;
   sf = SELECTED_FRAME ();
@@ -4383,6 +4393,10 @@
 #endif
 #endif
 
+      /* "Swap out" point from the selected window
+	 into its buffer.  We do this now, before
+	 restoring the window contents, and prevent it from
+	 being done later on when we select a new window.  */
       if (! NILP (XWINDOW (selected_window)->buffer))
 	{
 	  w = XWINDOW (selected_window);
@@ -4518,6 +4532,11 @@
 	}
 
       FRAME_ROOT_WINDOW (f) = data->root_window;
+      /* Prevent "swapping out point" in the old selected window
+	 using the buffer that has been restored into it.
+	 That swapping out has already been done,
+	 near the beginning of this function.  */
+      selected_window = Qnil;
       Fselect_window (data->current_window);
       XBUFFER (XWINDOW (selected_window)->buffer)->last_selected_window
 	= selected_window;