]> code.delx.au - gnu-emacs/blobdiff - src/window.c
Merge from emacs-23 branch, up to 2010-05-20T21:33:58Z!juri@jurta.org.
[gnu-emacs] / src / window.c
index 1487f3033fe188626e09af05f1be7c450c03092c..e583e5ba6151ae26a909293a0ad75e41fcb24196 100644 (file)
@@ -158,6 +158,11 @@ static int sequence_number;
 
 static int window_initialized;
 
+/* Set in `set-window-configuration' to prevent "swapping out point"
+   in the old selected window.  */
+
+static int inhibit_point_swap;
+
 /* Hook to run when window config changes.  */
 
 static Lisp_Object Qwindow_configuration_change_hook;
@@ -191,6 +196,10 @@ static int window_scroll_preserve_vpos;
 static int inhibit_frame_unsplittable;
 #endif /* 0 */
 
+extern EMACS_INT scroll_margin;
+
+extern Lisp_Object Qwindow_scroll_functions, Vwindow_scroll_functions;
+
 /* If non-nil, then the `recenter' command with a nil argument
    the entire frame to be redrawn; the special value `tty' causes the
    frame to be redrawn only if it is a tty frame.  */
@@ -3594,7 +3603,9 @@ selected window before each command.  */)
   /* Store the current buffer's actual point into the
      old selected window.  It belongs to that window,
      and when the window is not selected, must be in the window.  */
-  if (!NILP (selected_window))
+  if (inhibit_point_swap)
+    inhibit_point_swap = 0;
+  else
     {
       ow = XWINDOW (selected_window);
       if (! NILP (ow->buffer))
@@ -5767,7 +5778,7 @@ zero means top of window, negative means relative to bottom of window.  */)
     /* This test is needed to make sure PT/PT_BYTE make sense in w->buffer
        when passed below to set_marker_both.  */
     error ("move-to-window-line called from unrelated buffer");
-  
+
   window = selected_window;
   start = marker_position (w->start);
   if (start < BEGV || start > ZV)
@@ -6144,10 +6155,6 @@ the return value is nil.  Otherwise the value is t.  */)
        }
 
       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.
-        We already swapped out point that from that window's old buffer.  */
-      selected_window = Qnil;
 
       /* Arrange *not* to restore point in the buffer that was
         current when the window configuration was saved.  */
@@ -6156,6 +6163,11 @@ the return value is nil.  Otherwise the value is t.  */)
                               make_number (old_point),
                               XWINDOW (data->current_window)->buffer);
 
+      /* In the following call to `select-window, prevent "swapping
+        out point" in the old selected window using the buffer that
+        has been restored into it.  We already swapped out that point
+        from that window's old buffer.  */
+      inhibit_point_swap = 1;
       Fselect_window (data->current_window, Qnil);
       XBUFFER (XWINDOW (selected_window)->buffer)->last_selected_window
        = selected_window;
@@ -6165,13 +6177,6 @@ the return value is nil.  Otherwise the value is t.  */)
              && FRAME_LIVE_P (XFRAME (data->focus_frame))))
        Fredirect_frame_focus (frame, data->focus_frame);
 
-#if 0 /* I don't understand why this is needed, and it causes problems
-         when the frame's old selected window has been deleted.  */
-      if (f != selected_frame && FRAME_WINDOW_P (f))
-       do_switch_frame (WINDOW_FRAME (XWINDOW (data->root_window)),
-                        0, 0, Qnil);
-#endif
-
       /* Set the screen height to the value it had before this function.  */
       if (previous_frame_lines != FRAME_LINES (f)
          || previous_frame_cols != FRAME_COLS (f))
@@ -7094,6 +7099,8 @@ syms_of_window (void)
   window_scroll_preserve_hpos = -1;
   window_scroll_preserve_vpos = -1;
 
+  inhibit_point_swap = 0;
+
   DEFVAR_LISP ("temp-buffer-show-function", &Vtemp_buffer_show_function,
               doc: /* Non-nil means call as function to display a help buffer.
 The function is called with one argument, the buffer to be displayed.