Upgraded to mh-e version 6.1.1.
[bpt/emacs.git] / src / window.c
index d8e0893..e7b1ba4 100644 (file)
@@ -958,7 +958,7 @@ if it isn't already recorded.  */)
       struct buffer *old_buffer = NULL, *b = XBUFFER (buf);
 
       /* In case W->start is out of the range, use something
-         reasonable.  This situation occured when loading a file with
+         reasonable.  This situation occurred when loading a file with
          `-l' containing a call to `rmail' with subsequent other
          commands.  At the end, W->start happened to be BEG, while
          rmail had already narrowed the buffer.  */
@@ -2664,7 +2664,7 @@ set_window_buffer (window, buffer, run_hooks_p)
 {
   struct window *w = XWINDOW (window);
   struct buffer *b = XBUFFER (buffer);
-  int count = specpdl_ptr - specpdl;
+  int count = SPECPDL_INDEX ();
 
   w->buffer = buffer;
 
@@ -2747,7 +2747,7 @@ BUFFER can be a buffer or buffer name.  */)
     {
       if (!NILP (w->dedicated) && !EQ (tem, buffer))
        error ("Window is dedicated to `%s'",
-              XSTRING (XBUFFER (tem)->name)->data);
+              SDATA (XBUFFER (tem)->name));
 
       unshow_buffer (w);
     }
@@ -2759,6 +2759,9 @@ BUFFER can be a buffer or buffer name.  */)
 DEFUN ("select-window", Fselect_window, Sselect_window, 1, 1, 0,
        doc: /* Select WINDOW.  Most editing will apply to WINDOW's buffer.
 If WINDOW is not already selected, also make WINDOW's buffer current.
+If WINDOW's frame is the selected frame, also make WINDOW the frame's
+selected window.
+
 Note that the main editor command loop
 selects the buffer of the selected window before each command.  */)
      (window)
@@ -2799,16 +2802,7 @@ select_window_1 (window, recordflag)
 
   selected_window = window;
   sf = SELECTED_FRAME ();
-  if (XFRAME (WINDOW_FRAME (w)) != sf)
-    {
-      XFRAME (WINDOW_FRAME (w))->selected_window = window;
-      /* Use this rather than Fhandle_switch_frame
-        so that FRAME_FOCUS_FRAME is moved appropriately as we
-        move around in the state where a minibuffer in a separate
-        frame is active.  */
-      Fselect_frame (WINDOW_FRAME (w), Qnil);
-    }
-  else
+  if (XFRAME (WINDOW_FRAME (w)) == sf)
     sf->selected_window = window;
 
   if (recordflag)
@@ -3145,7 +3139,9 @@ temp_output_buffer_show (buf)
   BEGV = BEG;
   ZV = Z;
   SET_PT (BEG);
+#if 0  /* rms: there should be no reason for this.  */
   XBUFFER (buf)->prevent_redisplay_optimizations_p = 1;
+#endif
   set_buffer_internal (old);
 
   if (!EQ (Vtemp_buffer_show_function, Qnil))
@@ -3174,7 +3170,7 @@ temp_output_buffer_show (buf)
              tem = Fsymbol_value (Qtemp_buffer_show_hook);
              if (!NILP (tem))
                {
-                 int count = specpdl_ptr - specpdl;
+                 int count = SPECPDL_INDEX ();
                  Lisp_Object prev_window;
                  prev_window = selected_window;
 
@@ -4398,7 +4394,7 @@ scroll_command (n, direction)
      Lisp_Object n;
      int direction;
 {
-  int count = BINDING_STACK_SIZE ();
+  int count = SPECPDL_INDEX ();
 
   xassert (abs (direction) == 1);
 
@@ -4512,7 +4508,7 @@ showing that buffer, popping the buffer up if necessary.  */)
 {
   Lisp_Object window;
   struct window *w;
-  int count = BINDING_STACK_SIZE ();
+  int count = SPECPDL_INDEX ();
 
   window = Fother_window_for_scrolling ();
   w = XWINDOW (window);
@@ -4651,6 +4647,15 @@ displayed_window_lines (w)
   move_it_vertically (&it, height);
   bottom_y = line_bottom_y (&it);
 
+  /* rms: On a non-window display,
+     the value of it.vpos at the bottom of the screen
+     seems to be 1 larger than window_box_height (w).
+     This kludge fixes a bug whereby (move-to-window-line -1)
+     when ZV is on the last screen line
+     moves to the previous screen line instead of the last one.  */
+  if (! FRAME_WINDOW_P (XFRAME (w->frame)))
+    height++;
+
   /* Add in empty lines at the bottom of the window.  */
   if (bottom_y < height)
     {
@@ -5462,7 +5467,7 @@ usage: (save-window-excursion BODY ...)  */)
      Lisp_Object args;
 {
   register Lisp_Object val;
-  register int count = specpdl_ptr - specpdl;
+  register int count = SPECPDL_INDEX ();
 
   record_unwind_protect (Fset_window_configuration,
                         Fcurrent_window_configuration (Qnil));