emacs-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Emacs-diffs] Changes to emacs/src/xdisp.c


From: Thien-Thi Nguyen
Subject: [Emacs-diffs] Changes to emacs/src/xdisp.c
Date: Sun, 02 Jun 2002 21:50:02 -0400

Index: emacs/src/xdisp.c
diff -c emacs/src/xdisp.c:1.750 emacs/src/xdisp.c:1.751
*** emacs/src/xdisp.c:1.750     Fri Apr 26 19:39:05 2002
--- emacs/src/xdisp.c   Sun Jun  2 21:50:02 2002
***************
*** 47,53 ****
     you will encounter bugs which are very hard to explain.
  
             (Direct functions, see below)
!              direct_output_for_insert, 
               direct_forward_char (dispnew.c)
          +---------------------------------+
            |                                 |
--- 47,53 ----
     you will encounter bugs which are very hard to explain.
  
             (Direct functions, see below)
!              direct_output_for_insert,
               direct_forward_char (dispnew.c)
          +---------------------------------+
            |                                 |
***************
*** 106,112 ****
     `direct_output_for_insert' and `direct_output_forward_char' in
     dispnew.c.
  
!    
     Desired matrices.
  
     Desired matrices are always built per Emacs window.  The function
--- 106,112 ----
     `direct_output_for_insert' and `direct_output_forward_char' in
     dispnew.c.
  
! 
     Desired matrices.
  
     Desired matrices are always built per Emacs window.  The function
***************
*** 338,344 ****
  /* A flag to control how to display unibyte 8-bit character.  */
  
  int unibyte_display_via_language_environment;
!  
  /* Nonzero means we have more than one non-mini-buffer-only frame.
     Not guaranteed to be accurate except while parsing
     frame-title-format.  */
--- 338,344 ----
  /* A flag to control how to display unibyte 8-bit character.  */
  
  int unibyte_display_via_language_environment;
! 
  /* Nonzero means we have more than one non-mini-buffer-only frame.
     Not guaranteed to be accurate except while parsing
     frame-title-format.  */
***************
*** 555,561 ****
  int current_mode_line_height, current_header_line_height;
  
  /* The maximum distance to look ahead for text properties.  Values
!    that are too small let us call compute_char_face and similar 
     functions too often which is expensive.  Values that are too large
     let us call compute_char_face and alike too often because we
     might not be interested in text properties that far away.  */
--- 555,561 ----
  int current_mode_line_height, current_header_line_height;
  
  /* The maximum distance to look ahead for text properties.  Values
!    that are too small let us call compute_char_face and similar
     functions too often which is expensive.  Values that are too large
     let us call compute_char_face and alike too often because we
     might not be interested in text properties that far away.  */
***************
*** 584,590 ****
  #else
  #define TRACE_MOVE(x) (void) 0
  #endif
!  
  /* Non-zero means automatically scroll windows horizontally to make
     point visible.  */
  
--- 584,590 ----
  #else
  #define TRACE_MOVE(x) (void) 0
  #endif
! 
  /* Non-zero means automatically scroll windows horizontally to make
     point visible.  */
  
***************
*** 680,686 ****
    /* Move within a line ended at the end of a line that must be
       continued.  */
    MOVE_LINE_CONTINUED,
!   
    /* Move within a line ended at the end of a line that would
       be displayed truncated.  */
    MOVE_LINE_TRUNCATED,
--- 680,686 ----
    /* Move within a line ended at the end of a line that must be
       continued.  */
    MOVE_LINE_CONTINUED,
! 
    /* Move within a line ended at the end of a line that would
       be displayed truncated.  */
    MOVE_LINE_TRUNCATED,
***************
*** 859,869 ****
  {
    struct frame *f = XFRAME (w->frame);
    int width = XFASTINT (w->width);
!   
    if (!w->pseudo_window_p)
      {
        width -= FRAME_SCROLL_BAR_WIDTH (f) + FRAME_FRINGE_COLS (f);
!       
        if (area == TEXT_AREA)
        {
          if (INTEGERP (w->left_margin_width))
--- 859,869 ----
  {
    struct frame *f = XFRAME (w->frame);
    int width = XFASTINT (w->width);
! 
    if (!w->pseudo_window_p)
      {
        width -= FRAME_SCROLL_BAR_WIDTH (f) + FRAME_FRINGE_COLS (f);
! 
        if (area == TEXT_AREA)
        {
          if (INTEGERP (w->left_margin_width))
***************
*** 894,900 ****
    int height = XFASTINT (w->height) * CANON_Y_UNIT (f);
  
    xassert (height >= 0);
!   
    /* Note: the code below that determines the mode-line/header-line
       height is essentially the same as that contained in the macro
       CURRENT_{MODE,HEADER}_LINE_HEIGHT, except that it checks whether
--- 894,900 ----
    int height = XFASTINT (w->height) * CANON_Y_UNIT (f);
  
    xassert (height >= 0);
! 
    /* Note: the code below that determines the mode-line/header-line
       height is essentially the same as that contained in the macro
       CURRENT_{MODE,HEADER}_LINE_HEIGHT, except that it checks whether
***************
*** 947,953 ****
      {
        x += (WINDOW_LEFT_MARGIN (w) * CANON_X_UNIT (f)
            + FRAME_LEFT_FRINGE_WIDTH (f));
!       
        if (area == TEXT_AREA)
        x += window_box_width (w, LEFT_MARGIN_AREA);
        else if (area == RIGHT_MARGIN_AREA)
--- 947,953 ----
      {
        x += (WINDOW_LEFT_MARGIN (w) * CANON_X_UNIT (f)
            + FRAME_LEFT_FRINGE_WIDTH (f));
! 
        if (area == TEXT_AREA)
        x += window_box_width (w, LEFT_MARGIN_AREA);
        else if (area == RIGHT_MARGIN_AREA)
***************
*** 956,962 ****
      }
  
    return x;
! }     
  
  
  /* Return the frame-relative coordinate of the right edge of display
--- 956,962 ----
      }
  
    return x;
! }
  
  
  /* Return the frame-relative coordinate of the right edge of display
***************
*** 969,976 ****
       int area;
  {
    return window_box_left (w, area) + window_box_width (w, area);
! }     
!      
  
  /* Get the bounding box of the display area AREA of window W, without
     mode lines, in frame-relative coordinates.  AREA < 0 means the
--- 969,976 ----
       int area;
  {
    return window_box_left (w, area) + window_box_width (w, area);
! }
! 
  
  /* Get the bounding box of the display area AREA of window W, without
     mode lines, in frame-relative coordinates.  AREA < 0 means the
***************
*** 986,992 ****
       int *box_x, *box_y, *box_width, *box_height;
  {
    struct frame *f = XFRAME (w->frame);
!   
    *box_width = window_box_width (w, area);
    *box_height = window_box_height (w);
    *box_x = window_box_left (w, area);
--- 986,992 ----
       int *box_x, *box_y, *box_width, *box_height;
  {
    struct frame *f = XFRAME (w->frame);
! 
    *box_width = window_box_width (w, area);
    *box_height = window_box_height (w);
    *box_x = window_box_left (w, area);
***************
*** 1033,1039 ****
  {
    int line_height = it->max_ascent + it->max_descent;
    int line_top_y = it->current_y;
!   
    if (line_height == 0)
      {
        if (last_height)
--- 1033,1039 ----
  {
    int line_height = it->max_ascent + it->max_descent;
    int line_top_y = it->current_y;
! 
    if (line_height == 0)
      {
        if (last_height)
***************
*** 1048,1054 ****
        else
        {
          struct glyph_row *row = it->glyph_row;
!         
          /* Use the default character height.  */
          it->glyph_row = NULL;
          it->what = IT_CHARACTER;
--- 1048,1054 ----
        else
        {
          struct glyph_row *row = it->glyph_row;
! 
          /* Use the default character height.  */
          it->glyph_row = NULL;
          it->what = IT_CHARACTER;
***************
*** 1087,1093 ****
  
    *fully = visible_p = 0;
    SET_TEXT_POS_FROM_MARKER (top, w->start);
!   
    /* Compute exact mode line heights, if requested.  */
    if (exact_mode_line_heights_p)
      {
--- 1087,1093 ----
  
    *fully = visible_p = 0;
    SET_TEXT_POS_FROM_MARKER (top, w->start);
! 
    /* Compute exact mode line heights, if requested.  */
    if (exact_mode_line_heights_p)
      {
***************
*** 1095,1101 ****
        current_mode_line_height
          = display_mode_line (w, CURRENT_MODE_LINE_FACE_ID (w),
                               current_buffer->mode_line_format);
!   
        if (WINDOW_WANTS_HEADER_LINE_P (w))
        current_header_line_height
          = display_mode_line (w, HEADER_LINE_FACE_ID,
--- 1095,1101 ----
        current_mode_line_height
          = display_mode_line (w, CURRENT_MODE_LINE_FACE_ID (w),
                               current_buffer->mode_line_format);
! 
        if (WINDOW_WANTS_HEADER_LINE_P (w))
        current_header_line_height
          = display_mode_line (w, HEADER_LINE_FACE_ID,
***************
*** 1112,1118 ****
        int top_y = it.current_y;
        int bottom_y = line_bottom_y (&it);
        int window_top_y = WINDOW_DISPLAY_HEADER_LINE_HEIGHT (w);
!       
        if (top_y < window_top_y)
        visible_p = bottom_y > window_top_y;
        else if (top_y < it.last_visible_y)
--- 1112,1118 ----
        int top_y = it.current_y;
        int bottom_y = line_bottom_y (&it);
        int window_top_y = WINDOW_DISPLAY_HEADER_LINE_HEIGHT (w);
! 
        if (top_y < window_top_y)
        visible_p = bottom_y > window_top_y;
        else if (top_y < it.last_visible_y)
***************
*** 1258,1264 ****
       int multibyte_p;
  {
    int nchars;
!   
    if (multibyte_p)
      {
        int rest = strlen (s), len;
--- 1258,1264 ----
       int multibyte_p;
  {
    int nchars;
! 
    if (multibyte_p)
      {
        int rest = strlen (s), len;
***************
*** 1276,1282 ****
    return nchars;
  }
  
!      
  /* Compute byte position NEWPOS->bytepos corresponding to
     NEWPOS->charpos.  POS is a known position in string STRING.
     NEWPOS->charpos must be >= POS.charpos.  */
--- 1276,1282 ----
    return nchars;
  }
  
! 
  /* Compute byte position NEWPOS->bytepos corresponding to
     NEWPOS->charpos.  POS is a known position in string STRING.
     NEWPOS->charpos must be >= POS.charpos.  */
***************
*** 1288,1294 ****
  {
    xassert (STRINGP (string));
    xassert (CHARPOS (*newpos) >= CHARPOS (pos));
!   
    if (STRING_MULTIBYTE (string))
      *newpos = string_pos_nchars_ahead (pos, string,
                                       CHARPOS (*newpos) - CHARPOS (pos));
--- 1288,1294 ----
  {
    xassert (STRINGP (string));
    xassert (CHARPOS (*newpos) >= CHARPOS (pos));
! 
    if (STRING_MULTIBYTE (string))
      *newpos = string_pos_nchars_ahead (pos, string,
                                       CHARPOS (*newpos) - CHARPOS (pos));
***************
*** 1321,1327 ****
       Lisp_Object sexpr;
  {
    Lisp_Object val;
!   
    if (inhibit_eval_during_redisplay)
      val = Qnil;
    else
--- 1321,1327 ----
       Lisp_Object sexpr;
  {
    Lisp_Object val;
! 
    if (inhibit_eval_during_redisplay)
      val = Qnil;
    else
***************
*** 1338,1344 ****
        UNGCPRO;
        val = unbind_to (count, val);
      }
!   
    return val;
  }
  
--- 1338,1344 ----
        UNGCPRO;
        val = unbind_to (count, val);
      }
! 
    return val;
  }
  
***************
*** 1353,1359 ****
       Lisp_Object *args;
  {
    Lisp_Object val;
!   
    if (inhibit_eval_during_redisplay)
      val = Qnil;
    else
--- 1353,1359 ----
       Lisp_Object *args;
  {
    Lisp_Object val;
! 
    if (inhibit_eval_during_redisplay)
      val = Qnil;
    else
***************
*** 1478,1484 ****
     DEFAULT_FACE_ID for normal text, MODE_LINE_FACE_ID,
     MODE_LINE_INACTIVE_FACE_ID, or HEADER_LINE_FACE_ID for displaying
     mode lines, or TOOL_BAR_FACE_ID for displaying the tool-bar.
!    
     If ROW is null and BASE_FACE_ID is equal to MODE_LINE_FACE_ID,
     MODE_LINE_INACTIVE_FACE_ID, or HEADER_LINE_FACE_ID, the iterator
     will be initialized to use the corresponding mode line glyph row of
--- 1478,1484 ----
     DEFAULT_FACE_ID for normal text, MODE_LINE_FACE_ID,
     MODE_LINE_INACTIVE_FACE_ID, or HEADER_LINE_FACE_ID for displaying
     mode lines, or TOOL_BAR_FACE_ID for displaying the tool-bar.
! 
     If ROW is null and BASE_FACE_ID is equal to MODE_LINE_FACE_ID,
     MODE_LINE_INACTIVE_FACE_ID, or HEADER_LINE_FACE_ID, the iterator
     will be initialized to use the corresponding mode line glyph row of
***************
*** 1518,1524 ****
        else if (base_face_id == HEADER_LINE_FACE_ID)
        row = MATRIX_HEADER_LINE_ROW (w->desired_matrix);
      }
!   
    /* Clear IT.  */
    bzero (it, sizeof *it);
    it->current.overlay_string_index = -1;
--- 1518,1524 ----
        else if (base_face_id == HEADER_LINE_FACE_ID)
        row = MATRIX_HEADER_LINE_ROW (w->desired_matrix);
      }
! 
    /* Clear IT.  */
    bzero (it, sizeof *it);
    it->current.overlay_string_index = -1;
***************
*** 1556,1562 ****
    /* Current value of the `space-width', and 'height' properties.  */
    it->space_width = Qnil;
    it->font_height = Qnil;
!   
    /* Are control characters displayed as `^C'?  */
    it->ctl_arrow_p = !NILP (current_buffer->ctl_arrow);
  
--- 1556,1562 ----
    /* Current value of the `space-width', and 'height' properties.  */
    it->space_width = Qnil;
    it->font_height = Qnil;
! 
    /* Are control characters displayed as `^C'?  */
    it->ctl_arrow_p = !NILP (current_buffer->ctl_arrow);
  
***************
*** 1565,1571 ****
       invisible.  */
    it->selective = (INTEGERP (current_buffer->selective_display)
                   ? XFASTINT (current_buffer->selective_display)
!                  : (!NILP (current_buffer->selective_display) 
                      ? -1 : 0));
    it->selective_display_ellipsis_p
      = !NILP (current_buffer->selective_display_ellipses);
--- 1565,1571 ----
       invisible.  */
    it->selective = (INTEGERP (current_buffer->selective_display)
                   ? XFASTINT (current_buffer->selective_display)
!                  : (!NILP (current_buffer->selective_display)
                      ? -1 : 0));
    it->selective_display_ellipsis_p
      = !NILP (current_buffer->selective_display_ellipses);
***************
*** 1587,1593 ****
       -1 to indicate no region.  */
    if (highlight_region_p
        /* Maybe highlight only in selected window.  */
!       && (/* Either show region everywhere.  */ 
          highlight_nonselected_windows
          /* Or show region in the selected window.  */
          || w == XWINDOW (selected_window)
--- 1587,1593 ----
       -1 to indicate no region.  */
    if (highlight_region_p
        /* Maybe highlight only in selected window.  */
!       && (/* Either show region everywhere.  */
          highlight_nonselected_windows
          /* Or show region in the selected window.  */
          || w == XWINDOW (selected_window)
***************
*** 1703,1709 ****
    if (base_face_id != DEFAULT_FACE_ID)
      {
        struct face *face;
!       
        it->face_id = base_face_id;
  
        /* If we have a boxed mode line, make the first character appear
--- 1703,1709 ----
    if (base_face_id != DEFAULT_FACE_ID)
      {
        struct face *face;
! 
        it->face_id = base_face_id;
  
        /* If we have a boxed mode line, make the first character appear
***************
*** 1720,1726 ****
        it->end_charpos = ZV;
        it->face_id = -1;
        IT_CHARPOS (*it) = charpos;
!       
        /* Compute byte position if not specified.  */
        if (bytepos < charpos)
        IT_BYTEPOS (*it) = CHAR_TO_BYTE (charpos);
--- 1720,1726 ----
        it->end_charpos = ZV;
        it->face_id = -1;
        IT_CHARPOS (*it) = charpos;
! 
        /* Compute byte position if not specified.  */
        if (bytepos < charpos)
        IT_BYTEPOS (*it) = CHAR_TO_BYTE (charpos);
***************
*** 1730,1736 ****
        /* Compute faces etc.  */
        reseat (it, it->current.pos, 1);
      }
!   
    CHECK_IT (it);
  }
  
--- 1730,1736 ----
        /* Compute faces etc.  */
        reseat (it, it->current.pos, 1);
      }
! 
    CHECK_IT (it);
  }
  
***************
*** 1753,1759 ****
      {
        int start_at_line_beg_p;
        int first_y = it->current_y;
!   
        /* If window start is not at a line start, skip forward to POS to
         get the correct continuation lines width.  */
        start_at_line_beg_p = (CHARPOS (pos) == BEGV
--- 1753,1759 ----
      {
        int start_at_line_beg_p;
        int first_y = it->current_y;
! 
        /* If window start is not at a line start, skip forward to POS to
         get the correct continuation lines width.  */
        start_at_line_beg_p = (CHARPOS (pos) == BEGV
***************
*** 1777,1783 ****
                  set_iterator_to_next (it, 1);
                  move_it_in_display_line_to (it, -1, -1, 0);
                }
!             
              it->continuation_lines_width += it->current_x;
            }
  
--- 1777,1783 ----
                  set_iterator_to_next (it, 1);
                  move_it_in_display_line_to (it, -1, -1, 0);
                }
! 
              it->continuation_lines_width += it->current_x;
            }
  
***************
*** 1786,1792 ****
             fields in the iterator structure.  */
          it->max_ascent = it->max_descent = 0;
          it->max_phys_ascent = it->max_phys_descent = 0;
!       
          it->current_y = first_y;
          it->vpos = 0;
          it->current_x = it->hpos = 0;
--- 1786,1792 ----
             fields in the iterator structure.  */
          it->max_ascent = it->max_descent = 0;
          it->max_phys_ascent = it->max_phys_descent = 0;
! 
          it->current_y = first_y;
          it->vpos = 0;
          it->current_x = it->hpos = 0;
***************
*** 1796,1802 ****
  #if 0 /* Don't assert the following because start_display is sometimes
           called intentionally with a window start that is not at a
         line start.  Please leave this code in as a comment.  */
!   
    /* Window start should be on a line start, now.  */
    xassert (it->continuation_lines_width
           || IT_CHARPOS (it) == BEGV
--- 1796,1802 ----
  #if 0 /* Don't assert the following because start_display is sometimes
           called intentionally with a window start that is not at a
         line start.  Please leave this code in as a comment.  */
! 
    /* Window start should be on a line start, now.  */
    xassert (it->continuation_lines_width
           || IT_CHARPOS (it) == BEGV
***************
*** 1816,1822 ****
    Lisp_Object prop, window;
    int ellipses_p = 0;
    int charpos = CHARPOS (pos->pos);
!   
    /* If POS specifies a position in a display vector, this might
       be for an ellipsis displayed for invisible text.  We won't
       get the iterator set up for delivering that ellipsis unless
--- 1816,1822 ----
    Lisp_Object prop, window;
    int ellipses_p = 0;
    int charpos = CHARPOS (pos->pos);
! 
    /* If POS specifies a position in a display vector, this might
       be for an ellipsis displayed for invisible text.  We won't
       get the iterator set up for delivering that ellipsis unless
***************
*** 1852,1858 ****
  {
    int charpos = CHARPOS (pos->pos), bytepos = BYTEPOS (pos->pos);
    int i, overlay_strings_with_newlines = 0;
!   
    /* If POS specifies a position in a display vector, this might
       be for an ellipsis displayed for invisible text.  We won't
       get the iterator set up for delivering that ellipsis unless
--- 1852,1858 ----
  {
    int charpos = CHARPOS (pos->pos), bytepos = BYTEPOS (pos->pos);
    int i, overlay_strings_with_newlines = 0;
! 
    /* If POS specifies a position in a display vector, this might
       be for an ellipsis displayed for invisible text.  We won't
       get the iterator set up for delivering that ellipsis unless
***************
*** 1862,1868 ****
        --charpos;
        bytepos = 0;
      }
!     
    /* Keep in mind: the call to reseat in init_iterator skips invisible
       text, so we might end up at a position different from POS.  This
       is only a problem when POS is a row start after a newline and an
--- 1862,1868 ----
        --charpos;
        bytepos = 0;
      }
! 
    /* Keep in mind: the call to reseat in init_iterator skips invisible
       text, so we might end up at a position different from POS.  This
       is only a problem when POS is a row start after a newline and an
***************
*** 1878,1884 ****
      {
        char *s = SDATA (it->overlay_strings[i]);
        char *e = s + SBYTES (it->overlay_strings[i]);
!       
        while (s < e && *s != '\n')
        ++s;
  
--- 1878,1884 ----
      {
        char *s = SDATA (it->overlay_strings[i]);
        char *e = s + SBYTES (it->overlay_strings[i]);
! 
        while (s < e && *s != '\n')
        ++s;
  
***************
*** 1901,1907 ****
         correct the overlay string index.  */
        if (it->method == next_element_from_image)
        pop_it (it);
!       
        /* We already have the first chunk of overlay strings in
         IT->overlay_strings.  Load more until the one for
         pos->overlay_string_index is in IT->overlay_strings.  */
--- 1901,1907 ----
         correct the overlay string index.  */
        if (it->method == next_element_from_image)
        pop_it (it);
! 
        /* We already have the first chunk of overlay strings in
         IT->overlay_strings.  Load more until the one for
         pos->overlay_string_index is in IT->overlay_strings.  */
***************
*** 1915,1921 ****
              it->current.overlay_string_index += OVERLAY_STRING_CHUNK_SIZE;
            }
        }
!       
        it->current.overlay_string_index = pos->overlay_string_index;
        relative_index = (it->current.overlay_string_index
                        % OVERLAY_STRING_CHUNK_SIZE);
--- 1915,1921 ----
              it->current.overlay_string_index += OVERLAY_STRING_CHUNK_SIZE;
            }
        }
! 
        it->current.overlay_string_index = pos->overlay_string_index;
        relative_index = (it->current.overlay_string_index
                        % OVERLAY_STRING_CHUNK_SIZE);
***************
*** 1924,1930 ****
        it->current.string_pos = pos->string_pos;
        it->method = next_element_from_string;
      }
!   
  #if 0 /* This is bogus because POS not having an overlay string
         position does not mean it's after the string.  Example: A
         line starting with a before-string and initialization of IT
--- 1924,1930 ----
        it->current.string_pos = pos->string_pos;
        it->method = next_element_from_string;
      }
! 
  #if 0 /* This is bogus because POS not having an overlay string
         position does not mean it's after the string.  Example: A
         line starting with a before-string and initialization of IT
***************
*** 1943,1949 ****
        it->overlay_strings_at_end_processed_p = 1;
      }
  #endif /* 0 */
!   
    if (CHARPOS (pos->string_pos) >= 0)
      {
        /* Recorded position is not in an overlay string, but in another
--- 1943,1949 ----
        it->overlay_strings_at_end_processed_p = 1;
      }
  #endif /* 0 */
! 
    if (CHARPOS (pos->string_pos) >= 0)
      {
        /* Recorded position is not in an overlay string, but in another
***************
*** 1962,1968 ****
        xassert (it->dpvec && it->current.dpvec_index == 0);
        it->current.dpvec_index = pos->dpvec_index;
      }
!   
    CHECK_IT (it);
    return !overlay_strings_with_newlines;
  }
--- 1962,1968 ----
        xassert (it->dpvec && it->current.dpvec_index == 0);
        it->current.dpvec_index = pos->dpvec_index;
      }
! 
    CHECK_IT (it);
    return !overlay_strings_with_newlines;
  }
***************
*** 1982,1988 ****
    CHECK_IT (it);
  }
  
!      
  /* Initialize IT for stepping through current_buffer in window W
     starting in the line following ROW, i.e. starting at ROW->end.
     Value is zero if there are overlay strings with newlines at ROW's
--- 1982,1988 ----
    CHECK_IT (it);
  }
  
! 
  /* Initialize IT for stepping through current_buffer in window W
     starting in the line following ROW, i.e. starting at ROW->end.
     Value is zero if there are overlay strings with newlines at ROW's
***************
*** 1995,2001 ****
       struct glyph_row *row;
  {
    int success = 0;
!   
    if (init_from_display_pos (it, w, &row->end))
      {
        if (row->continued_p)
--- 1995,2001 ----
       struct glyph_row *row;
  {
    int success = 0;
! 
    if (init_from_display_pos (it, w, &row->end))
      {
        if (row->continued_p)
***************
*** 2004,2010 ****
        CHECK_IT (it);
        success = 1;
      }
!   
    return success;
  }
  
--- 2004,2010 ----
        CHECK_IT (it);
        success = 1;
      }
! 
    return success;
  }
  
***************
*** 2033,2039 ****
    do
      {
        handled = HANDLED_NORMALLY;
!       
        /* Call text property handlers.  */
        for (p = it_props; p->handler; ++p)
        {
--- 2033,2039 ----
    do
      {
        handled = HANDLED_NORMALLY;
! 
        /* Call text property handlers.  */
        for (p = it_props; p->handler; ++p)
        {
***************
*** 2057,2063 ****
          /* Handle overlay changes.  */
          if (handle_overlay_change_p)
            handled = handle_overlay_change (it);
!       
          /* Determine where to stop next.  */
          if (handled == HANDLED_NORMALLY)
            compute_stop_pos (it);
--- 2057,2063 ----
          /* Handle overlay changes.  */
          if (handle_overlay_change_p)
            handled = handle_overlay_change (it);
! 
          /* Determine where to stop next.  */
          if (handled == HANDLED_NORMALLY)
            compute_stop_pos (it);
***************
*** 2079,2085 ****
  
    /* If nowhere else, stop at the end.  */
    it->stop_charpos = it->end_charpos;
!   
    if (STRINGP (it->string))
      {
        /* Strings are usually short, so don't limit the search for
--- 2079,2085 ----
  
    /* If nowhere else, stop at the end.  */
    it->stop_charpos = it->end_charpos;
! 
    if (STRINGP (it->string))
      {
        /* Strings are usually short, so don't limit the search for
***************
*** 2109,2115 ****
          else if (IT_CHARPOS (*it) < it->region_end_charpos)
            it->stop_charpos = min (it->stop_charpos, it->region_end_charpos);
        }
!       
        /* Set up variables for computing the stop position from text
           property changes.  */
        XSETBUFFER (object, current_buffer);
--- 2109,2115 ----
          else if (IT_CHARPOS (*it) < it->region_end_charpos)
            it->stop_charpos = min (it->stop_charpos, it->region_end_charpos);
        }
! 
        /* Set up variables for computing the stop position from text
           property changes.  */
        XSETBUFFER (object, current_buffer);
***************
*** 2146,2152 ****
              if (!EQ (values_here[p->idx], new_value))
                break;
            }
!         
          if (p->handler)
            break;
        }
--- 2146,2152 ----
              if (!EQ (values_here[p->idx], new_value))
                break;
            }
! 
          if (p->handler)
            break;
        }
***************
*** 2244,2250 ****
  
        val = Vfontification_functions;
        specbind (Qfontification_functions, Qnil);
!   
        if (!CONSP (val) || EQ (XCAR (val), Qlambda))
        safe_call1 (val, pos);
        else
--- 2244,2250 ----
  
        val = Vfontification_functions;
        specbind (Qfontification_functions, Qnil);
! 
        if (!CONSP (val) || EQ (XCAR (val), Qlambda))
        safe_call1 (val, pos);
        else
***************
*** 2254,2264 ****
  
          globals = Qnil;
          GCPRO2 (val, globals);
!         
          for (; CONSP (val); val = XCDR (val))
            {
              fn = XCAR (val);
!             
              if (EQ (fn, Qt))
                {
                  /* A value of t indicates this hook has a local
--- 2254,2264 ----
  
          globals = Qnil;
          GCPRO2 (val, globals);
! 
          for (; CONSP (val); val = XCDR (val))
            {
              fn = XCAR (val);
! 
              if (EQ (fn, Qt))
                {
                  /* A value of t indicates this hook has a local
***************
*** 2308,2314 ****
       struct it *it;
  {
    int new_face_id, next_stop;
!   
    if (!STRINGP (it->string))
      {
        new_face_id
--- 2308,2314 ----
       struct it *it;
  {
    int new_face_id, next_stop;
! 
    if (!STRINGP (it->string))
      {
        new_face_id
***************
*** 2320,2326 ****
                                   (IT_CHARPOS (*it)
                                    + TEXT_PROP_DISTANCE_LIMIT),
                                   0);
!       
        /* Is this a start of a run of characters with box face?
         Caveat: this can be called for a freshly initialized
         iterator; face_id is -1 in this case.  We know that the new
--- 2320,2326 ----
                                   (IT_CHARPOS (*it)
                                    + TEXT_PROP_DISTANCE_LIMIT),
                                   0);
! 
        /* Is this a start of a run of characters with box face?
         Caveat: this can be called for a freshly initialized
         iterator; face_id is -1 in this case.  We know that the new
***************
*** 2330,2336 ****
        if (new_face_id != it->face_id)
        {
          struct face *new_face = FACE_FROM_ID (it->f, new_face_id);
!         
          /* If new face has a box but old face has not, this is
             the start of a run of characters with box, i.e. it has
             a shadow on the left side.  The value of face_id of the
--- 2330,2336 ----
        if (new_face_id != it->face_id)
        {
          struct face *new_face = FACE_FROM_ID (it->f, new_face_id);
! 
          /* If new face has a box but old face has not, this is
             the start of a run of characters with box, i.e. it has
             a shadow on the left side.  The value of face_id of the
***************
*** 2353,2366 ****
        bufpos = IT_CHARPOS (*it);
        else
        bufpos = 0;
!       
        /* For strings from a buffer, i.e. overlay strings or strings
         from a `display' property, use the face at IT's current
         buffer position as the base face to merge with, so that
         overlay strings appear in the same face as surrounding
         text, unless they specify their own faces.  */
        base_face_id = underlying_face_id (it);
!       
        new_face_id = face_at_string_position (it->w,
                                             it->string,
                                             IT_STRING_CHARPOS (*it),
--- 2353,2366 ----
        bufpos = IT_CHARPOS (*it);
        else
        bufpos = 0;
! 
        /* For strings from a buffer, i.e. overlay strings or strings
         from a `display' property, use the face at IT's current
         buffer position as the base face to merge with, so that
         overlay strings appear in the same face as surrounding
         text, unless they specify their own faces.  */
        base_face_id = underlying_face_id (it);
! 
        new_face_id = face_at_string_position (it->w,
                                             it->string,
                                             IT_STRING_CHARPOS (*it),
***************
*** 2369,2375 ****
                                             it->region_end_charpos,
                                             &next_stop,
                                             base_face_id, 0);
!       
  #if 0 /* This shouldn't be neccessary.  Let's check it.  */
        /* If IT is used to display a mode line we would really like to
         use the mode line face instead of the frame's default face.  */
--- 2369,2375 ----
                                             it->region_end_charpos,
                                             &next_stop,
                                             base_face_id, 0);
! 
  #if 0 /* This shouldn't be neccessary.  Let's check it.  */
        /* If IT is used to display a mode line we would really like to
         use the mode line face instead of the frame's default face.  */
***************
*** 2377,2383 ****
          && new_face_id == DEFAULT_FACE_ID)
        new_face_id = CURRENT_MODE_LINE_FACE_ID (it->w);
  #endif
!       
        /* Is this a start of a run of characters with box?  Caveat:
         this can be called for a freshly allocated iterator; face_id
         is -1 is this case.  We know that the new face will not
--- 2377,2383 ----
          && new_face_id == DEFAULT_FACE_ID)
        new_face_id = CURRENT_MODE_LINE_FACE_ID (it->w);
  #endif
! 
        /* Is this a start of a run of characters with box?  Caveat:
         this can be called for a freshly allocated iterator; face_id
         is -1 is this case.  We know that the new face will not
***************
*** 2389,2395 ****
        {
          struct face *new_face = FACE_FROM_ID (it->f, new_face_id);
          struct face *old_face = FACE_FROM_ID (it->f, it->face_id);
!         
          /* If new face has a box but old face hasn't, this is the
             start of a run of characters with box, i.e. it has a
             shadow on the left side.  */
--- 2389,2395 ----
        {
          struct face *new_face = FACE_FROM_ID (it->f, new_face_id);
          struct face *old_face = FACE_FROM_ID (it->f, it->face_id);
! 
          /* If new face has a box but old face hasn't, this is the
             start of a run of characters with box, i.e. it has a
             shadow on the left side.  */
***************
*** 2398,2404 ****
          it->face_box_p = new_face->box != FACE_NO_BOX;
        }
      }
!   
    it->face_id = new_face_id;
    return HANDLED_NORMALLY;
  }
--- 2398,2404 ----
          it->face_box_p = new_face->box != FACE_NO_BOX;
        }
      }
! 
    it->face_id = new_face_id;
    return HANDLED_NORMALLY;
  }
***************
*** 2439,2449 ****
    struct text_pos pos;
  
    xassert (it->s == NULL);
!     
    if (STRINGP (it->string))
      {
        int bufpos, base_face_id;
!       
        /* No face change past the end of the string (for the case
         we are padding with spaces).  No face change before the
         string start.  */
--- 2439,2449 ----
    struct text_pos pos;
  
    xassert (it->s == NULL);
! 
    if (STRINGP (it->string))
      {
        int bufpos, base_face_id;
! 
        /* No face change past the end of the string (for the case
         we are padding with spaces).  No face change before the
         string start.  */
***************
*** 2487,2493 ****
          int rest = SBYTES (it->string) - BYTEPOS (pos);
          int c, len;
          struct face *face = FACE_FROM_ID (it->f, face_id);
!       
          c = string_char_and_length (p, rest, &len);
          face_id = FACE_FOR_CHAR (it->f, face, c);
        }
--- 2487,2493 ----
          int rest = SBYTES (it->string) - BYTEPOS (pos);
          int c, len;
          struct face *face = FACE_FROM_ID (it->f, face_id);
! 
          c = string_char_and_length (p, rest, &len);
          face_id = FACE_FOR_CHAR (it->f, face, c);
        }
***************
*** 2497,2506 ****
        if ((IT_CHARPOS (*it) >= ZV && !before_p)
          || (IT_CHARPOS (*it) <= BEGV && before_p))
        return it->face_id;
!       
        limit = IT_CHARPOS (*it) + TEXT_PROP_DISTANCE_LIMIT;
        pos = it->current.pos;
!       
        if (before_p)
        DEC_TEXT_POS (pos, it->multibyte_p);
        else
--- 2497,2506 ----
        if ((IT_CHARPOS (*it) >= ZV && !before_p)
          || (IT_CHARPOS (*it) <= BEGV && before_p))
        return it->face_id;
! 
        limit = IT_CHARPOS (*it) + TEXT_PROP_DISTANCE_LIMIT;
        pos = it->current.pos;
! 
        if (before_p)
        DEC_TEXT_POS (pos, it->multibyte_p);
        else
***************
*** 2512,2518 ****
          else
            INC_TEXT_POS (pos, it->multibyte_p);
        }
!       
        /* Determine face for CHARSET_ASCII, or unibyte.  */
        face_id = face_at_buffer_position (it->w,
                                         CHARPOS (pos),
--- 2512,2518 ----
          else
            INC_TEXT_POS (pos, it->multibyte_p);
        }
! 
        /* Determine face for CHARSET_ASCII, or unibyte.  */
        face_id = face_at_buffer_position (it->w,
                                         CHARPOS (pos),
***************
*** 2531,2537 ****
          face_id = FACE_FOR_CHAR (it->f, face, c);
        }
      }
!   
    return face_id;
  }
  
--- 2531,2537 ----
          face_id = FACE_FOR_CHAR (it->f, face, c);
        }
      }
! 
    return face_id;
  }
  
***************
*** 2565,2571 ****
          && IT_STRING_CHARPOS (*it) < it->end_charpos)
        {
          handled = HANDLED_RECOMPUTE_PROPS;
!         
          /* Get the position at which the next change of the
             invisible text property can be found in IT->string.
             Value will be nil if the property value is the same for
--- 2565,2571 ----
          && IT_STRING_CHARPOS (*it) < it->end_charpos)
        {
          handled = HANDLED_RECOMPUTE_PROPS;
! 
          /* Get the position at which the next change of the
             invisible text property can be found in IT->string.
             Value will be nil if the property value is the same for
***************
*** 2573,2579 ****
          XSETINT (limit, SCHARS (it->string));
          end_charpos = Fnext_single_property_change (charpos, Qinvisible,
                                                      it->string, limit);
!         
          /* Text at current position is invisible.  The next
             change in the property is at position end_charpos.
             Move IT's current position to that position.  */
--- 2573,2579 ----
          XSETINT (limit, SCHARS (it->string));
          end_charpos = Fnext_single_property_change (charpos, Qinvisible,
                                                      it->string, limit);
! 
          /* Text at current position is invisible.  The next
             change in the property is at position end_charpos.
             Move IT's current position to that position.  */
***************
*** 2625,2631 ****
          int display_ellipsis_p = invis_p == 2;
  
          handled = HANDLED_RECOMPUTE_PROPS;
!         
          /* Loop skipping over invisible text.  The loop is left at
             ZV or with IT on the first char being visible again.  */
          do
--- 2625,2631 ----
          int display_ellipsis_p = invis_p == 2;
  
          handled = HANDLED_RECOMPUTE_PROPS;
! 
          /* Loop skipping over invisible text.  The loop is left at
             ZV or with IT on the first char being visible again.  */
          do
***************
*** 2655,2661 ****
                  prop = Fget_char_property (pos, Qinvisible, it->window);
                  invis_p = TEXT_PROP_MEANS_INVISIBLE (prop);
                }
!             
              /* If we ended up on invisible text, proceed to
                 skip starting with next_stop.  */
              if (invis_p)
--- 2655,2661 ----
                  prop = Fget_char_property (pos, Qinvisible, it->window);
                  invis_p = TEXT_PROP_MEANS_INVISIBLE (prop);
                }
! 
              /* If we ended up on invisible text, proceed to
                 skip starting with next_stop.  */
              if (invis_p)
***************
*** 2666,2672 ****
          /* The position newpos is now either ZV or on visible text.  */
          IT_CHARPOS (*it) = newpos;
          IT_BYTEPOS (*it) = CHAR_TO_BYTE (newpos);
!         
          /* If there are before-strings at the start of invisible
             text, and the text is invisible because of a text
             property, arrange to show before-strings because 20.x did
--- 2666,2672 ----
          /* The position newpos is now either ZV or on visible text.  */
          IT_CHARPOS (*it) = newpos;
          IT_BYTEPOS (*it) = CHAR_TO_BYTE (newpos);
! 
          /* If there are before-strings at the start of invisible
             text, and the text is invisible because of a text
             property, arrange to show before-strings because 20.x did
***************
*** 2694,2718 ****
  setup_for_ellipsis (it)
       struct it *it;
  {
!   if (it->dp 
        && VECTORP (DISP_INVIS_VECTOR (it->dp)))
      {
        struct Lisp_Vector *v = XVECTOR (DISP_INVIS_VECTOR (it->dp));
        it->dpvec = v->contents;
        it->dpend = v->contents + v->size;
      }
!   else 
      {
        /* Default `...'.  */
        it->dpvec = default_invis_vector;
        it->dpend = default_invis_vector + 3;
      }
!   
    /* The ellipsis display does not replace the display of the
       character at the new position.  Indicate this by setting
       IT->dpvec_char_len to zero.  */
    it->dpvec_char_len = 0;
!   
    it->current.dpvec_index = 0;
    it->method = next_element_from_display_vector;
  }
--- 2694,2718 ----
  setup_for_ellipsis (it)
       struct it *it;
  {
!   if (it->dp
        && VECTORP (DISP_INVIS_VECTOR (it->dp)))
      {
        struct Lisp_Vector *v = XVECTOR (DISP_INVIS_VECTOR (it->dp));
        it->dpvec = v->contents;
        it->dpend = v->contents + v->size;
      }
!   else
      {
        /* Default `...'.  */
        it->dpvec = default_invis_vector;
        it->dpend = default_invis_vector + 3;
      }
! 
    /* The ellipsis display does not replace the display of the
       character at the new position.  Indicate this by setting
       IT->dpvec_char_len to zero.  */
    it->dpvec_char_len = 0;
! 
    it->current.dpvec_index = 0;
    it->method = next_element_from_display_vector;
  }
***************
*** 2879,2885 ****
        UNGCPRO;
        unbind_to (count, Qnil);
      }
!   
    if (NILP (form))
      return 0;
  
--- 2879,2885 ----
        UNGCPRO;
        unbind_to (count, Qnil);
      }
! 
    if (NILP (form))
      return 0;
  
***************
*** 2889,2895 ****
      {
        if (FRAME_TERMCAP_P (it->f) || FRAME_MSDOS_P (it->f))
        return 0;
!       
        /* `(height HEIGHT)'.  */
        it->font_height = XCAR (XCDR (prop));
        if (!NILP (it->font_height))
--- 2889,2895 ----
      {
        if (FRAME_TERMCAP_P (it->f) || FRAME_MSDOS_P (it->f))
        return 0;
! 
        /* `(height HEIGHT)'.  */
        it->font_height = XCAR (XCDR (prop));
        if (!NILP (it->font_height))
***************
*** 2923,2929 ****
            {
              /* Value is a multiple of the canonical char height.  */
              struct face *face;
!             
              face = FACE_FROM_ID (it->f, DEFAULT_FACE_ID);
              new_height = (XFLOATINT (it->font_height)
                            * XINT (face->lface[LFACE_HEIGHT_INDEX]));
--- 2923,2929 ----
            {
              /* Value is a multiple of the canonical char height.  */
              struct face *face;
! 
              face = FACE_FROM_ID (it->f, DEFAULT_FACE_ID);
              new_height = (XFLOATINT (it->font_height)
                            * XINT (face->lface[LFACE_HEIGHT_INDEX]));
***************
*** 2934,2948 ****
                 current specified height to get the new height.  */
              Lisp_Object value;
              int count = BINDING_STACK_SIZE ();
!             
              specbind (Qheight, face->lface[LFACE_HEIGHT_INDEX]);
              value = safe_eval (it->font_height);
              unbind_to (count, Qnil);
!             
              if (NUMBERP (value))
                new_height = XFLOATINT (value);
            }
!         
          if (new_height > 0)
            it->face_id = face_with_height (it->f, it->face_id, new_height);
        }
--- 2934,2948 ----
                 current specified height to get the new height.  */
              Lisp_Object value;
              int count = BINDING_STACK_SIZE ();
! 
              specbind (Qheight, face->lface[LFACE_HEIGHT_INDEX]);
              value = safe_eval (it->font_height);
              unbind_to (count, Qnil);
! 
              if (NUMBERP (value))
                new_height = XFLOATINT (value);
            }
! 
          if (new_height > 0)
            it->face_id = face_with_height (it->f, it->face_id, new_height);
        }
***************
*** 2954,2960 ****
        /* `(space_width WIDTH)'.  */
        if (FRAME_TERMCAP_P (it->f) || FRAME_MSDOS_P (it->f))
        return 0;
!       
        value = XCAR (XCDR (prop));
        if (NUMBERP (value) && XFLOATINT (value) > 0)
        it->space_width = value;
--- 2954,2960 ----
        /* `(space_width WIDTH)'.  */
        if (FRAME_TERMCAP_P (it->f) || FRAME_MSDOS_P (it->f))
        return 0;
! 
        value = XCAR (XCDR (prop));
        if (NUMBERP (value) && XFLOATINT (value) > 0)
        it->space_width = value;
***************
*** 2966,2972 ****
        /* `(raise FACTOR)'.  */
        if (FRAME_TERMCAP_P (it->f) || FRAME_MSDOS_P (it->f))
        return 0;
!       
  #ifdef HAVE_WINDOW_SYSTEM
        value = XCAR (XCDR (prop));
        if (NUMBERP (value))
--- 2966,2972 ----
        /* `(raise FACTOR)'.  */
        if (FRAME_TERMCAP_P (it->f) || FRAME_MSDOS_P (it->f))
        return 0;
! 
  #ifdef HAVE_WINDOW_SYSTEM
        value = XCAR (XCDR (prop));
        if (NUMBERP (value))
***************
*** 2999,3005 ****
        if (CONSP (prop) && CONSP (XCAR (prop)))
        {
          Lisp_Object tem;
!         
          value = XCDR (prop);
          if (CONSP (value))
            value = XCAR (value);
--- 2999,3005 ----
        if (CONSP (prop) && CONSP (XCAR (prop)))
        {
          Lisp_Object tem;
! 
          value = XCDR (prop);
          if (CONSP (value))
            value = XCAR (value);
***************
*** 3030,3036 ****
  #else /* not HAVE_WINDOW_SYSTEM */
        valid_p = STRINGP (value);
  #endif /* not HAVE_WINDOW_SYSTEM */
!       
        if ((EQ (location, Qleft_margin)
           || EQ (location, Qright_margin)
           || NILP (location))
--- 3030,3036 ----
  #else /* not HAVE_WINDOW_SYSTEM */
        valid_p = STRINGP (value);
  #endif /* not HAVE_WINDOW_SYSTEM */
! 
        if ((EQ (location, Qleft_margin)
           || EQ (location, Qright_margin)
           || NILP (location))
***************
*** 3038,3055 ****
          && !display_replaced_before_p)
        {
          replaces_text_display_p = 1;
!         
          /* Save current settings of IT so that we can restore them
             when we are finished with the glyph property value.  */
          push_it (it);
!         
          if (NILP (location))
            it->area = TEXT_AREA;
          else if (EQ (location, Qleft_margin))
            it->area = LEFT_MARGIN_AREA;
          else
            it->area = RIGHT_MARGIN_AREA;
!         
          if (STRINGP (value))
            {
              it->string = value;
--- 3038,3055 ----
          && !display_replaced_before_p)
        {
          replaces_text_display_p = 1;
! 
          /* Save current settings of IT so that we can restore them
             when we are finished with the glyph property value.  */
          push_it (it);
! 
          if (NILP (location))
            it->area = TEXT_AREA;
          else if (EQ (location, Qleft_margin))
            it->area = LEFT_MARGIN_AREA;
          else
            it->area = RIGHT_MARGIN_AREA;
! 
          if (STRINGP (value))
            {
              it->string = value;
***************
*** 3079,3085 ****
              it->position = start_pos;
              it->object = NILP (object) ? it->w->buffer : object;
              it->method = next_element_from_image;
!             
              /* Say that we haven't consumed the characters with
                 `display' property yet.  The call to pop_it in
                 set_iterator_to_next will clean this up.  */
--- 3079,3085 ----
              it->position = start_pos;
              it->object = NILP (object) ? it->w->buffer : object;
              it->method = next_element_from_image;
! 
              /* Say that we haven't consumed the characters with
                 `display' property yet.  The call to pop_it in
                 set_iterator_to_next will clean this up.  */
***************
*** 3130,3136 ****
          || EQ (XCAR (prop), Qright_margin))
        return 0;
      }
!   
    return CONSP (prop) && EQ (XCAR (prop), Qimage);
  }
  
--- 3130,3136 ----
          || EQ (XCAR (prop), Qright_margin))
        return 0;
      }
! 
    return CONSP (prop) && EQ (XCAR (prop), Qimage);
  }
  
***************
*** 3177,3183 ****
  {
    if (EQ (string, prop))
      return 1;
!   
    /* Skip over `when FORM'.  */
    if (CONSP (prop) && EQ (XCAR (prop), Qwhen))
      {
--- 3177,3183 ----
  {
    if (EQ (string, prop))
      return 1;
! 
    /* Skip over `when FORM'.  */
    if (CONSP (prop) && EQ (XCAR (prop), Qwhen))
      {
***************
*** 3199,3205 ****
        if (!CONSP (prop))
          return 0;
        }
!   
    return CONSP (prop) && EQ (XCAR (prop), string);
  }
  
--- 3199,3205 ----
        if (!CONSP (prop))
          return 0;
        }
! 
    return CONSP (prop) && EQ (XCAR (prop), string);
  }
  
***************
*** 3384,3390 ****
     overlay strings to display, IT->string and
     IT->current.overlay_string_index are set appropriately here.
     Otherwise IT->string is set to nil.  */
!    
  static void
  next_overlay_string (it)
       struct it *it;
--- 3384,3390 ----
     overlay strings to display, IT->string and
     IT->current.overlay_string_index are set appropriately here.
     Otherwise IT->string is set to nil.  */
! 
  static void
  next_overlay_string (it)
       struct it *it;
***************
*** 3396,3402 ****
         they were before overlay strings were processed, and
         continue to deliver from current_buffer.  */
        int display_ellipsis_p = it->stack[it->sp - 1].display_ellipsis_p;
!       
        pop_it (it);
        xassert (it->stop_charpos >= BEGV
               && it->stop_charpos <= it->end_charpos);
--- 3396,3402 ----
         they were before overlay strings were processed, and
         continue to deliver from current_buffer.  */
        int display_ellipsis_p = it->stack[it->sp - 1].display_ellipsis_p;
! 
        pop_it (it);
        xassert (it->stop_charpos >= BEGV
               && it->stop_charpos <= it->end_charpos);
***************
*** 3424,3430 ****
         where we must load IT->overlay_strings with more strings, do
         it.  */
        int i = it->current.overlay_string_index % OVERLAY_STRING_CHUNK_SIZE;
!   
        if (it->current.overlay_string_index && i == 0)
        load_overlay_strings (it, 0);
  
--- 3424,3430 ----
         where we must load IT->overlay_strings with more strings, do
         it.  */
        int i = it->current.overlay_string_index % OVERLAY_STRING_CHUNK_SIZE;
! 
        if (it->current.overlay_string_index && i == 0)
        load_overlay_strings (it, 0);
  
***************
*** 3436,3442 ****
        it->method = next_element_from_string;
        it->stop_charpos = 0;
      }
!   
    CHECK_IT (it);
  }
  
--- 3436,3442 ----
        it->method = next_element_from_string;
        it->stop_charpos = 0;
      }
! 
    CHECK_IT (it);
  }
  
***************
*** 3447,3453 ****
  
     1. All after-strings come in front of before-strings, except
     when they come from the same overlay.
!    
     2. Within after-strings, strings are sorted so that overlay strings
     from overlays with higher priorities come first.
  
--- 3447,3453 ----
  
     1. All after-strings come in front of before-strings, except
     when they come from the same overlay.
! 
     2. Within after-strings, strings are sorted so that overlay strings
     from overlays with higher priorities come first.
  
***************
*** 3456,3462 ****
  
     Value is analogous to strcmp.  */
  
!   
  static int
  compare_overlay_entries (e1, e2)
       void *e1, *e2;
--- 3456,3462 ----
  
     Value is analogous to strcmp.  */
  
! 
  static int
  compare_overlay_entries (e1, e2)
       void *e1, *e2;
***************
*** 3508,3514 ****
     front of before-string strings.  Within before and after-strings,
     strings are sorted by overlay priority.  See also function
     compare_overlay_entries.  */
!    
  static void
  load_overlay_strings (it, charpos)
       struct it *it;
--- 3508,3514 ----
     front of before-string strings.  Within before and after-strings,
     strings are sorted by overlay priority.  See also function
     compare_overlay_entries.  */
! 
  static void
  load_overlay_strings (it, charpos)
       struct it *it;
***************
*** 3561,3567 ****
        xassert (OVERLAYP (overlay));
        start = OVERLAY_POSITION (OVERLAY_START (overlay));
        end = OVERLAY_POSITION (OVERLAY_END (overlay));
!       
        if (end < charpos)
        break;
  
--- 3561,3567 ----
        xassert (OVERLAYP (overlay));
        start = OVERLAY_POSITION (OVERLAY_START (overlay));
        end = OVERLAY_POSITION (OVERLAY_END (overlay));
! 
        if (end < charpos)
        break;
  
***************
*** 3569,3575 ****
         position.  */
        if (end != charpos && start != charpos)
        continue;
!       
        /* Skip this overlay if it doesn't apply to IT->w.  */
        window = Foverlay_get (overlay, Qwindow);
        if (WINDOWP (window) && XWINDOW (window) != it->w)
--- 3569,3575 ----
         position.  */
        if (end != charpos && start != charpos)
        continue;
! 
        /* Skip this overlay if it doesn't apply to IT->w.  */
        window = Foverlay_get (overlay, Qwindow);
        if (WINDOWP (window) && XWINDOW (window) != it->w)
***************
*** 3586,3599 ****
          && (str = Foverlay_get (overlay, Qbefore_string), STRINGP (str))
          && SCHARS (str))
        RECORD_OVERLAY_STRING (overlay, str, 0);
!       
        /* If overlay has a non-empty after-string, record it.  */
        if ((end == charpos || (start == charpos && invis_p))
          && (str = Foverlay_get (overlay, Qafter_string), STRINGP (str))
          && SCHARS (str))
        RECORD_OVERLAY_STRING (overlay, str, 1);
      }
!       
    /* Process overlays after the overlay center.  */
    for (ov = current_buffer->overlays_after; CONSP (ov); ov = XCDR (ov))
      {
--- 3586,3599 ----
          && (str = Foverlay_get (overlay, Qbefore_string), STRINGP (str))
          && SCHARS (str))
        RECORD_OVERLAY_STRING (overlay, str, 0);
! 
        /* If overlay has a non-empty after-string, record it.  */
        if ((end == charpos || (start == charpos && invis_p))
          && (str = Foverlay_get (overlay, Qafter_string), STRINGP (str))
          && SCHARS (str))
        RECORD_OVERLAY_STRING (overlay, str, 1);
      }
! 
    /* Process overlays after the overlay center.  */
    for (ov = current_buffer->overlays_after; CONSP (ov); ov = XCDR (ov))
      {
***************
*** 3604,3610 ****
  
        if (start > charpos)
        break;
!       
        /* Skip this overlay if it doesn't start or end at IT's current
         position.  */
        if (end != charpos && start != charpos)
--- 3604,3610 ----
  
        if (start > charpos)
        break;
! 
        /* Skip this overlay if it doesn't start or end at IT's current
         position.  */
        if (end != charpos && start != charpos)
***************
*** 3614,3620 ****
        window = Foverlay_get (overlay, Qwindow);
        if (WINDOWP (window) && XWINDOW (window) != it->w)
        continue;
!       
        /* If the text ``under'' the overlay is invisible, it has a zero
         dimension, and both before- and after-strings apply.  */
        invisible = Foverlay_get (overlay, Qinvisible);
--- 3614,3620 ----
        window = Foverlay_get (overlay, Qwindow);
        if (WINDOWP (window) && XWINDOW (window) != it->w)
        continue;
! 
        /* If the text ``under'' the overlay is invisible, it has a zero
         dimension, and both before- and after-strings apply.  */
        invisible = Foverlay_get (overlay, Qinvisible);
***************
*** 3625,3631 ****
          && (str = Foverlay_get (overlay, Qbefore_string), STRINGP (str))
          && SCHARS (str))
        RECORD_OVERLAY_STRING (overlay, str, 0);
!                              
        /* If overlay has a non-empty after-string, record it.  */
        if ((end == charpos || (start == charpos && invis_p))
          && (str = Foverlay_get (overlay, Qafter_string), STRINGP (str))
--- 3625,3631 ----
          && (str = Foverlay_get (overlay, Qbefore_string), STRINGP (str))
          && SCHARS (str))
        RECORD_OVERLAY_STRING (overlay, str, 0);
! 
        /* If overlay has a non-empty after-string, record it.  */
        if ((end == charpos || (start == charpos && invis_p))
          && (str = Foverlay_get (overlay, Qafter_string), STRINGP (str))
***************
*** 3634,3640 ****
      }
  
  #undef RECORD_OVERLAY_STRING
!    
    /* Sort entries.  */
    if (n > 1)
      qsort (entries, n, sizeof *entries, compare_overlay_entries);
--- 3634,3640 ----
      }
  
  #undef RECORD_OVERLAY_STRING
! 
    /* Sort entries.  */
    if (n > 1)
      qsort (entries, n, sizeof *entries, compare_overlay_entries);
***************
*** 3683,3689 ****
         strings.  */
        compute_stop_pos (it);
        xassert (it->face_id >= 0);
!       
        /* Save IT's settings.  They are restored after all overlay
         strings have been processed.  */
        xassert (it->sp == 0);
--- 3683,3689 ----
         strings.  */
        compute_stop_pos (it);
        xassert (it->face_id >= 0);
! 
        /* Save IT's settings.  They are restored after all overlay
         strings have been processed.  */
        xassert (it->sp == 0);
***************
*** 3728,3734 ****
       struct it *it;
  {
    struct iterator_stack_entry *p;
!   
    xassert (it->sp < 2);
    p = it->stack + it->sp;
  
--- 3728,3734 ----
       struct it *it;
  {
    struct iterator_stack_entry *p;
! 
    xassert (it->sp < 2);
    p = it->stack + it->sp;
  
***************
*** 3761,3767 ****
       struct it *it;
  {
    struct iterator_stack_entry *p;
!   
    xassert (it->sp > 0);
    --it->sp;
    p = it->stack + it->sp;
--- 3761,3767 ----
       struct it *it;
  {
    struct iterator_stack_entry *p;
! 
    xassert (it->sp > 0);
    --it->sp;
    p = it->stack + it->sp;
***************
*** 3797,3808 ****
  
  
  /* Move IT to the next line start.
!    
     Value is non-zero if a newline was found.  Set *SKIPPED_P to 1 if
     we skipped over part of the text (as opposed to moving the iterator
     continuously over the text).  Otherwise, don't change the value
     of *SKIPPED_P.
!    
     Newlines may come from buffer text, overlay strings, or strings
     displayed via the `display' property.  That's the reason we can't
     simply use find_next_newline_no_quit.
--- 3797,3808 ----
  
  
  /* Move IT to the next line start.
! 
     Value is non-zero if a newline was found.  Set *SKIPPED_P to 1 if
     we skipped over part of the text (as opposed to moving the iterator
     continuously over the text).  Otherwise, don't change the value
     of *SKIPPED_P.
! 
     Newlines may come from buffer text, overlay strings, or strings
     displayed via the `display' property.  That's the reason we can't
     simply use find_next_newline_no_quit.
***************
*** 3918,3926 ****
         are invisible.  */
        if (it->selective > 0
          && indented_beyond_p (IT_CHARPOS (*it), IT_BYTEPOS (*it),
!                               it->selective))
        visible_p = 0;
!       else 
        {
          Lisp_Object prop;
  
--- 3918,3926 ----
         are invisible.  */
        if (it->selective > 0
          && indented_beyond_p (IT_CHARPOS (*it), IT_BYTEPOS (*it),
!                               (float) it->selective)) /* iftc */
        visible_p = 0;
!       else
        {
          Lisp_Object prop;
  
***************
*** 3978,3984 ****
    if (it->selective > 0)
      while (IT_CHARPOS (*it) < ZV
           && indented_beyond_p (IT_CHARPOS (*it), IT_BYTEPOS (*it),
!                                it->selective))
        {
        xassert (FETCH_BYTE (IT_BYTEPOS (*it) - 1) == '\n');
        newline_found_p = forward_to_next_line_start (it, &skipped_p);
--- 3978,3984 ----
    if (it->selective > 0)
      while (IT_CHARPOS (*it) < ZV
           && indented_beyond_p (IT_CHARPOS (*it), IT_BYTEPOS (*it),
!                                (float) it->selective)) /* iftc */
        {
        xassert (FETCH_BYTE (IT_BYTEPOS (*it) - 1) == '\n');
        newline_found_p = forward_to_next_line_start (it, &skipped_p);
***************
*** 4004,4010 ****
      }
    else if (skipped_p)
      reseat (it, it->current.pos, 0);
!   
    CHECK_IT (it);
  }
  
--- 4004,4010 ----
      }
    else if (skipped_p)
      reseat (it, it->current.pos, 0);
! 
    CHECK_IT (it);
  }
  
***************
*** 4077,4083 ****
  /* Set up IT for displaying a string, starting at CHARPOS in window W.
     If S is non-null, it is a C string to iterate over.  Otherwise,
     STRING gives a Lisp string to iterate over.
!    
     If PRECISION > 0, don't return more then PRECISION number of
     characters from the string.
  
--- 4077,4083 ----
  /* Set up IT for displaying a string, starting at CHARPOS in window W.
     If S is non-null, it is a C string to iterate over.  Otherwise,
     STRING gives a Lisp string to iterate over.
! 
     If PRECISION > 0, don't return more then PRECISION number of
     characters from the string.
  
***************
*** 4111,4122 ****
    it->current.overlay_string_index = -1;
    it->current.dpvec_index = -1;
    xassert (charpos >= 0);
!   
    /* If STRING is specified, use its multibyteness, otherwise use the
       setting of MULTIBYTE, if specified.  */
    if (multibyte >= 0)
      it->multibyte_p = multibyte > 0;
!   
    if (s == NULL)
      {
        xassert (STRINGP (string));
--- 4111,4122 ----
    it->current.overlay_string_index = -1;
    it->current.dpvec_index = -1;
    xassert (charpos >= 0);
! 
    /* If STRING is specified, use its multibyteness, otherwise use the
       setting of MULTIBYTE, if specified.  */
    if (multibyte >= 0)
      it->multibyte_p = multibyte > 0;
! 
    if (s == NULL)
      {
        xassert (STRINGP (string));
***************
*** 4144,4150 ****
          IT_CHARPOS (*it) = IT_BYTEPOS (*it) = charpos;
          it->end_charpos = it->string_nchars = strlen (s);
        }
!       
        it->method = next_element_from_c_string;
      }
  
--- 4144,4150 ----
          IT_CHARPOS (*it) = IT_BYTEPOS (*it) = charpos;
          it->end_charpos = it->string_nchars = strlen (s);
        }
! 
        it->method = next_element_from_c_string;
      }
  
***************
*** 4314,4324 ****
                      XSETINT (it->ctl_chars[i * 4], escape_glyph);
                      /* Insert three more glyphs into IT->ctl_chars for
                         the octal display of the character.  */
!                     g = FAST_MAKE_GLYPH (((str[i] >> 6) & 7) + '0', 0); 
                      XSETINT (it->ctl_chars[i * 4 + 1], g);
!                     g = FAST_MAKE_GLYPH (((str[i] >> 3) & 7) + '0', 0); 
                      XSETINT (it->ctl_chars[i * 4 + 2], g);
!                     g = FAST_MAKE_GLYPH ((str[i] & 7) + '0', 0); 
                      XSETINT (it->ctl_chars[i * 4 + 3], g);
                    }
  
--- 4314,4324 ----
                      XSETINT (it->ctl_chars[i * 4], escape_glyph);
                      /* Insert three more glyphs into IT->ctl_chars for
                         the octal display of the character.  */
!                     g = FAST_MAKE_GLYPH (((str[i] >> 6) & 7) + '0', 0);
                      XSETINT (it->ctl_chars[i * 4 + 1], g);
!                     g = FAST_MAKE_GLYPH (((str[i] >> 3) & 7) + '0', 0);
                      XSETINT (it->ctl_chars[i * 4 + 2], g);
!                     g = FAST_MAKE_GLYPH ((str[i] & 7) + '0', 0);
                      XSETINT (it->ctl_chars[i * 4 + 3], g);
                    }
  
***************
*** 4389,4395 ****
       with box.  Reset them at the start of this function because
       moving the iterator to a new position might set them.  */
    it->start_of_box_run_p = it->end_of_box_run_p = 0;
!   
    if (it->method == next_element_from_buffer)
      {
        /* The current display element of IT is a character from
--- 4389,4395 ----
       with box.  Reset them at the start of this function because
       moving the iterator to a new position might set them.  */
    it->start_of_box_run_p = it->end_of_box_run_p = 0;
! 
    if (it->method == next_element_from_buffer)
      {
        /* The current display element of IT is a character from
***************
*** 4439,4445 ****
        /* Restore face of the iterator to what they were before the
           display vector entry (these entries may contain faces).  */
        it->face_id = it->saved_face_id;
!       
        if (it->dpvec + it->current.dpvec_index == it->dpend)
        {
          if (it->s)
--- 4439,4445 ----
        /* Restore face of the iterator to what they were before the
           display vector entry (these entries may contain faces).  */
        it->face_id = it->saved_face_id;
! 
        if (it->dpvec + it->current.dpvec_index == it->dpend)
        {
          if (it->s)
***************
*** 4468,4474 ****
        xassert (it->s == NULL && STRINGP (it->string));
        IT_STRING_BYTEPOS (*it) += it->len;
        IT_STRING_CHARPOS (*it) += 1;
!       
      consider_string_end:
  
        if (it->current.overlay_string_index >= 0)
--- 4468,4474 ----
        xassert (it->s == NULL && STRINGP (it->string));
        IT_STRING_BYTEPOS (*it) += it->len;
        IT_STRING_CHARPOS (*it) += 1;
! 
      consider_string_end:
  
        if (it->current.overlay_string_index >= 0)
***************
*** 4536,4542 ****
    /* Remember the current face id in case glyphs specify faces.
       IT's face is restored in set_iterator_to_next.  */
    it->saved_face_id = it->face_id;
!   
    if (INTEGERP (*it->dpvec)
        && GLYPH_CHAR_VALID_P (XFASTINT (*it->dpvec)))
      {
--- 4536,4542 ----
    /* Remember the current face id in case glyphs specify faces.
       IT's face is restored in set_iterator_to_next.  */
    it->saved_face_id = it->face_id;
! 
    if (INTEGERP (*it->dpvec)
        && GLYPH_CHAR_VALID_P (XFASTINT (*it->dpvec)))
      {
***************
*** 4671,4682 ****
       struct it *it;
  {
    int success_p = 1;
!   
    xassert (it->s);
    it->what = IT_CHARACTER;
    BYTEPOS (it->position) = CHARPOS (it->position) = 0;
    it->object = Qnil;
!   
    /* IT's position can be greater IT->string_nchars in case a field
       width or precision has been specified when the iterator was
       initialized.  */
--- 4671,4682 ----
       struct it *it;
  {
    int success_p = 1;
! 
    xassert (it->s);
    it->what = IT_CHARACTER;
    BYTEPOS (it->position) = CHARPOS (it->position) = 0;
    it->object = Qnil;
! 
    /* IT's position can be greater IT->string_nchars in case a field
       width or precision has been specified when the iterator was
       initialized.  */
***************
*** 4703,4709 ****
      }
    else
      it->c = it->s[IT_BYTEPOS (*it)], it->len = 1;
!   
    return success_p;
  }
  
--- 4703,4709 ----
      }
    else
      it->c = it->s[IT_BYTEPOS (*it)], it->len = 1;
! 
    return success_p;
  }
  
***************
*** 4751,4757 ****
        reseat_at_next_visible_line_start (it, 1);
        it->face_before_selective_p = 1;
      }
!   
    return get_next_display_element (it);
  }
  
--- 4751,4757 ----
        reseat_at_next_visible_line_start (it, 1);
        it->face_before_selective_p = 1;
      }
! 
    return get_next_display_element (it);
  }
  
***************
*** 4759,4765 ****
  /* Deliver an image display element.  The iterator IT is already
     filled with image information (done in handle_display_prop).  Value
     is always 1.  */
!   
  
  static int
  next_element_from_image (it)
--- 4759,4765 ----
  /* Deliver an image display element.  The iterator IT is already
     filled with image information (done in handle_display_prop).  Value
     is always 1.  */
! 
  
  static int
  next_element_from_image (it)
***************
*** 4804,4810 ****
        if (IT_CHARPOS (*it) >= it->end_charpos)
        {
          int overlay_strings_follow_p;
!         
          /* End of the game, except when overlay strings follow that
             haven't been returned yet.  */
          if (it->overlay_strings_at_end_processed_p)
--- 4804,4810 ----
        if (IT_CHARPOS (*it) >= it->end_charpos)
        {
          int overlay_strings_follow_p;
! 
          /* End of the game, except when overlay strings follow that
             haven't been returned yet.  */
          if (it->overlay_strings_at_end_processed_p)
***************
*** 4871,4877 ****
                  && IT_CHARPOS (*it) + 1 < ZV
                  && indented_beyond_p (IT_CHARPOS (*it) + 1,
                                        IT_BYTEPOS (*it) + 1,
!                                       it->selective))
                {
                  success_p = next_element_from_ellipsis (it);
                  it->dpvec_char_len = -1;
--- 4871,4877 ----
                  && IT_CHARPOS (*it) + 1 < ZV
                  && indented_beyond_p (IT_CHARPOS (*it) + 1,
                                        IT_BYTEPOS (*it) + 1,
!                                       (float) it->selective)) /* iftc */
                {
                  success_p = next_element_from_ellipsis (it);
                  it->dpvec_char_len = -1;
***************
*** 4893,4899 ****
    return success_p;
  }
  
!      
  /* Run the redisplay end trigger hook for IT.  */
  
  static void
--- 4893,4899 ----
    return success_p;
  }
  
! 
  /* Run the redisplay end trigger hook for IT.  */
  
  static void
***************
*** 4916,4922 ****
       them again, even if they get an error.  */
    it->w->redisplay_end_trigger = Qnil;
    Frun_hook_with_args (3, args);
!   
    /* Notice if it changed the face of the character we are on.  */
    handle_face_prop (it);
  }
--- 4916,4922 ----
       them again, even if they get an error.  */
    it->w->redisplay_end_trigger = Qnil;
    Frun_hook_with_args (3, args);
! 
    /* Notice if it changed the face of the character we are on.  */
    handle_face_prop (it);
  }
***************
*** 4960,4973 ****
  
     MOVE_POS_MATCH_OR_ZV
       - when TO_POS or ZV was reached.
!       
     MOVE_X_REACHED
       -when TO_X was reached before TO_POS or ZV were reached.
!       
     MOVE_LINE_CONTINUED
       - when we reached the end of the display area and the line must
       be continued.
!                          
     MOVE_LINE_TRUNCATED
       - when we reached the end of the display area and the line is
       truncated.
--- 4960,4973 ----
  
     MOVE_POS_MATCH_OR_ZV
       - when TO_POS or ZV was reached.
! 
     MOVE_X_REACHED
       -when TO_X was reached before TO_POS or ZV were reached.
! 
     MOVE_LINE_CONTINUED
       - when we reached the end of the display area and the line must
       be continued.
! 
     MOVE_LINE_TRUNCATED
       - when we reached the end of the display area and the line is
       truncated.
***************
*** 4991,4997 ****
    while (1)
      {
        int x, i, ascent = 0, descent = 0;
!       
        /* Stop when ZV or TO_CHARPOS reached.  */
        if (!get_next_display_element (it)
          || ((op & MOVE_TO_POS) != 0
--- 4991,4997 ----
    while (1)
      {
        int x, i, ascent = 0, descent = 0;
! 
        /* Stop when ZV or TO_CHARPOS reached.  */
        if (!get_next_display_element (it)
          || ((op & MOVE_TO_POS) != 0
***************
*** 5001,5013 ****
          result = MOVE_POS_MATCH_OR_ZV;
          break;
        }
!         
        /* The call to produce_glyphs will get the metrics of the
         display element IT is loaded with.  We record in x the
         x-position before this display element in case it does not
         fit on the line.  */
        x = it->current_x;
!       
        /* Remember the line height so far in case the next element doesn't
         fit on the line.  */
        if (!it->truncate_lines_p)
--- 5001,5013 ----
          result = MOVE_POS_MATCH_OR_ZV;
          break;
        }
! 
        /* The call to produce_glyphs will get the metrics of the
         display element IT is loaded with.  We record in x the
         x-position before this display element in case it does not
         fit on the line.  */
        x = it->current_x;
! 
        /* Remember the line height so far in case the next element doesn't
         fit on the line.  */
        if (!it->truncate_lines_p)
***************
*** 5015,5021 ****
          ascent = it->max_ascent;
          descent = it->max_descent;
        }
!       
        PRODUCE_GLYPHS (it);
  
        if (it->area != TEXT_AREA)
--- 5015,5021 ----
          ascent = it->max_ascent;
          descent = it->max_descent;
        }
! 
        PRODUCE_GLYPHS (it);
  
        if (it->area != TEXT_AREA)
***************
*** 5048,5054 ****
             glyphs have the same width.  */
          int single_glyph_width = it->pixel_width / it->nglyphs;
          int new_x;
!         
          for (i = 0; i < it->nglyphs; ++i, x = new_x)
            {
              new_x = x + single_glyph_width;
--- 5048,5054 ----
             glyphs have the same width.  */
          int single_glyph_width = it->pixel_width / it->nglyphs;
          int new_x;
! 
          for (i = 0; i < it->nglyphs; ++i, x = new_x)
            {
              new_x = x + single_glyph_width;
***************
*** 5086,5092 ****
                      it->max_ascent = ascent;
                      it->max_descent = descent;
                    }
!                 
                  TRACE_MOVE ((stderr, "move_it_in: continued at %d\n",
                               IT_CHARPOS (*it)));
                  result = MOVE_LINE_CONTINUED;
--- 5086,5092 ----
                      it->max_ascent = ascent;
                      it->max_descent = descent;
                    }
! 
                  TRACE_MOVE ((stderr, "move_it_in: continued at %d\n",
                               IT_CHARPOS (*it)));
                  result = MOVE_LINE_CONTINUED;
***************
*** 5100,5106 ****
                }
              else
                {
!                 /* Glyph is completely off the left margin of the display 
                     area.  Nothing to do.  */
                }
            }
--- 5100,5106 ----
                }
              else
                {
!                 /* Glyph is completely off the left margin of the display
                     area.  Nothing to do.  */
                }
            }
***************
*** 5118,5135 ****
          result = MOVE_X_REACHED;
          break;
        }
!   
        /* Is this a line end?  If yes, we're done.  */
        if (ITERATOR_AT_END_OF_LINE_P (it))
        {
          result = MOVE_NEWLINE_OR_CR;
          break;
        }
!       
        /* The current display element has been consumed.  Advance
         to the next.  */
        set_iterator_to_next (it, 1);
!       
        /* Stop if lines are truncated and IT's current x-position is
         past the right edge of the window now.  */
        if (it->truncate_lines_p
--- 5118,5135 ----
          result = MOVE_X_REACHED;
          break;
        }
! 
        /* Is this a line end?  If yes, we're done.  */
        if (ITERATOR_AT_END_OF_LINE_P (it))
        {
          result = MOVE_NEWLINE_OR_CR;
          break;
        }
! 
        /* The current display element has been consumed.  Advance
         to the next.  */
        set_iterator_to_next (it, 1);
! 
        /* Stop if lines are truncated and IT's current x-position is
         past the right edge of the window now.  */
        if (it->truncate_lines_p
***************
*** 5153,5159 ****
     OP is a bit-mask that specifies where to stop, and in particular,
     which of those four position arguments makes a difference.  See the
     description of enum move_operation_enum.
!    
     If TO_CHARPOS is in invisible text, e.g. a truncated part of a
     screen line, this function will set IT to the next position >
     TO_CHARPOS.  */
--- 5153,5159 ----
     OP is a bit-mask that specifies where to stop, and in particular,
     which of those four position arguments makes a difference.  See the
     description of enum move_operation_enum.
! 
     If TO_CHARPOS is in invisible text, e.g. a truncated part of a
     screen line, this function will set IT to the next position >
     TO_CHARPOS.  */
***************
*** 5193,5199 ****
                  reached = 2;
                  break;
                }
!             
              skip = move_it_in_display_line_to (it, to_charpos, to_x, op);
  
              if (skip == MOVE_POS_MATCH_OR_ZV || it->vpos == to_vpos)
--- 5193,5199 ----
                  reached = 2;
                  break;
                }
! 
              skip = move_it_in_display_line_to (it, to_charpos, to_x, op);
  
              if (skip == MOVE_POS_MATCH_OR_ZV || it->vpos == to_vpos)
***************
*** 5217,5223 ****
        else if (op & MOVE_TO_Y)
        {
          struct it it_backup;
!         
          /* TO_Y specified means stop at TO_X in the line containing
             TO_Y---or at TO_CHARPOS if this is reached first.  The
             problem is that we can't really tell whether the line
--- 5217,5223 ----
        else if (op & MOVE_TO_Y)
        {
          struct it it_backup;
! 
          /* TO_Y specified means stop at TO_X in the line containing
             TO_Y---or at TO_CHARPOS if this is reached first.  The
             problem is that we can't really tell whether the line
***************
*** 5242,5248 ****
              reached = 5;
              break;
            }
!         
          /* If TO_X was reached, we would like to know whether TO_Y
             is in the line.  This can only be said if we know the
             total line height which requires us to scan the rest of
--- 5242,5248 ----
              reached = 5;
              break;
            }
! 
          /* If TO_X was reached, we would like to know whether TO_Y
             is in the line.  This can only be said if we know the
             total line height which requires us to scan the rest of
***************
*** 5259,5265 ****
          /* Now, decide whether TO_Y is in this line.  */
          line_height = it->max_ascent + it->max_descent;
          TRACE_MOVE ((stderr, "move_it: line_height = %d\n", line_height));
!         
          if (to_y >= it->current_y
              && to_y < it->current_y + line_height)
            {
--- 5259,5265 ----
          /* Now, decide whether TO_Y is in this line.  */
          line_height = it->max_ascent + it->max_descent;
          TRACE_MOVE ((stderr, "move_it: line_height = %d\n", line_height));
! 
          if (to_y >= it->current_y
              && to_y < it->current_y + line_height)
            {
***************
*** 5322,5328 ****
        last_max_ascent = it->max_ascent;
        it->max_ascent = it->max_descent = 0;
      }
!   
   out:
  
    TRACE_MOVE ((stderr, "move_it_to: reached %d\n", reached));
--- 5322,5328 ----
        last_max_ascent = it->max_ascent;
        it->max_ascent = it->max_descent = 0;
      }
! 
   out:
  
    TRACE_MOVE ((stderr, "move_it_to: reached %d\n", reached));
***************
*** 5345,5351 ****
    int nlines, h;
    struct it it2, it3;
    int start_pos = IT_CHARPOS (*it);
!   
    xassert (dy >= 0);
  
    /* Estimate how many newlines we must move back.  */
--- 5345,5351 ----
    int nlines, h;
    struct it it2, it3;
    int start_pos = IT_CHARPOS (*it);
! 
    xassert (dy >= 0);
  
    /* Estimate how many newlines we must move back.  */
***************
*** 5374,5380 ****
              MOVE_TO_POS | MOVE_TO_VPOS);
    xassert (IT_CHARPOS (*it) >= BEGV);
    it3 = it2;
!   
    move_it_to (&it2, start_pos, -1, -1, -1, MOVE_TO_POS);
    xassert (IT_CHARPOS (*it) >= BEGV);
    h = it2.current_y - it->current_y;
--- 5374,5380 ----
              MOVE_TO_POS | MOVE_TO_VPOS);
    xassert (IT_CHARPOS (*it) >= BEGV);
    it3 = it2;
! 
    move_it_to (&it2, start_pos, -1, -1, -1, MOVE_TO_POS);
    xassert (IT_CHARPOS (*it) >= BEGV);
    h = it2.current_y - it->current_y;
***************
*** 5383,5389 ****
    /* Correct IT's y and vpos position.  */
    it->vpos -= nlines;
    it->current_y -= h;
!   
    if (dy == 0)
      {
        /* DY == 0 means move to the start of the screen line.  The
--- 5383,5389 ----
    /* Correct IT's y and vpos position.  */
    it->vpos -= nlines;
    it->current_y -= h;
! 
    if (dy == 0)
      {
        /* DY == 0 means move to the start of the screen line.  The
***************
*** 5420,5432 ****
               && IT_CHARPOS (*it) < ZV)
        {
          /* Should move forward by at least one line, maybe more.
!            
             Note: Calling move_it_by_lines can be expensive on
             terminal frames, where compute_motion is used (via
             vmotion) to do the job, when there are very long lines
             and truncate-lines is nil.  That's the reason for
             treating terminal frames specially here.  */
!         
          if (!FRAME_WINDOW_P (it->f))
            move_it_vertically (it, target_y - (it->current_y + line_height));
          else
--- 5420,5432 ----
               && IT_CHARPOS (*it) < ZV)
        {
          /* Should move forward by at least one line, maybe more.
! 
             Note: Calling move_it_by_lines can be expensive on
             terminal frames, where compute_motion is used (via
             vmotion) to do the job, when there are very long lines
             and truncate-lines is nil.  That's the reason for
             treating terminal frames specially here.  */
! 
          if (!FRAME_WINDOW_P (it->f))
            move_it_vertically (it, target_y - (it->current_y + line_height));
          else
***************
*** 5448,5454 ****
     move backwards.  DY = 0 means move to start of screen line.  At the
     end, IT will be on the start of a screen line.  */
  
! void 
  move_it_vertically (it, dy)
      struct it *it;
      int dy;
--- 5448,5454 ----
     move backwards.  DY = 0 means move to start of screen line.  At the
     end, IT will be on the start of a screen line.  */
  
! void
  move_it_vertically (it, dy)
      struct it *it;
      int dy;
***************
*** 5478,5484 ****
       struct it *it;
  {
    enum move_it_result rc;
!   
    rc = move_it_in_display_line_to (it, Z, 0, MOVE_TO_POS);
    if (rc == MOVE_NEWLINE_OR_CR)
      set_iterator_to_next (it, 0);
--- 5478,5484 ----
       struct it *it;
  {
    enum move_it_result rc;
! 
    rc = move_it_in_display_line_to (it, Z, 0, MOVE_TO_POS);
    if (rc == MOVE_NEWLINE_OR_CR)
      set_iterator_to_next (it, 0);
***************
*** 5498,5504 ****
  {
    Lisp_Object prop, limit;
    int invisible_found_p;
!   
    xassert (it != NULL && start_charpos <= end_charpos);
  
    /* Is text at START invisible?  */
--- 5498,5504 ----
  {
    Lisp_Object prop, limit;
    int invisible_found_p;
! 
    xassert (it != NULL && start_charpos <= end_charpos);
  
    /* Is text at START invisible?  */
***************
*** 5535,5545 ****
       int dvpos, need_y_p;
  {
    struct position pos;
!   
    if (!FRAME_WINDOW_P (it->f))
      {
        struct text_pos textpos;
!       
        /* We can use vmotion on frames without proportional fonts.  */
        pos = *vmotion (IT_CHARPOS (*it), dvpos, it->w);
        SET_TEXT_POS (textpos, pos.bufpos, pos.bytepos);
--- 5535,5545 ----
       int dvpos, need_y_p;
  {
    struct position pos;
! 
    if (!FRAME_WINDOW_P (it->f))
      {
        struct text_pos textpos;
! 
        /* We can use vmotion on frames without proportional fonts.  */
        pos = *vmotion (IT_CHARPOS (*it), dvpos, it->w);
        SET_TEXT_POS (textpos, pos.bufpos, pos.bytepos);
***************
*** 5559,5569 ****
      {
        struct it it2;
        int start_charpos, i;
!       
        /* Start at the beginning of the screen line containing IT's
         position.  */
        move_it_vertically_backward (it, 0);
!       
        /* Go back -DVPOS visible lines and reseat the iterator there.  */
        start_charpos = IT_CHARPOS (*it);
        for (i = -dvpos; i && IT_CHARPOS (*it) > BEGV; --i)
--- 5559,5569 ----
      {
        struct it it2;
        int start_charpos, i;
! 
        /* Start at the beginning of the screen line containing IT's
         position.  */
        move_it_vertically_backward (it, 0);
! 
        /* Go back -DVPOS visible lines and reseat the iterator there.  */
        start_charpos = IT_CHARPOS (*it);
        for (i = -dvpos; i && IT_CHARPOS (*it) > BEGV; --i)
***************
*** 5618,5624 ****
  
    fmt = msg = Qnil;
    GCPRO4 (fmt, msg, arg1, arg2);
!   
    args[0] = fmt = build_string (format);
    args[1] = arg1;
    args[2] = arg2;
--- 5618,5624 ----
  
    fmt = msg = Qnil;
    GCPRO4 (fmt, msg, arg1, arg2);
! 
    args[0] = fmt = build_string (format);
    args[1] = arg1;
    args[2] = arg2;
***************
*** 5627,5633 ****
    len = SBYTES (msg) + 1;
    buffer = (char *) alloca (len);
    bcopy (SDATA (msg), buffer, len);
!   
    message_dolog (buffer, len - 1, 1, 0);
    UNGCPRO;
  }
--- 5627,5633 ----
    len = SBYTES (msg) + 1;
    buffer = (char *) alloca (len);
    bcopy (SDATA (msg), buffer, len);
! 
    message_dolog (buffer, len - 1, 1, 0);
    UNGCPRO;
  }
***************
*** 5695,5701 ****
        {
          int i, c, char_bytes;
          unsigned char work[1];
!         
          /* Convert a multibyte string to single-byte
             for the *Message* buffer.  */
          for (i = 0; i < nbytes; i += nbytes)
--- 5695,5701 ----
        {
          int i, c, char_bytes;
          unsigned char work[1];
! 
          /* Convert a multibyte string to single-byte
             for the *Message* buffer.  */
          for (i = 0; i < nbytes; i += nbytes)
***************
*** 5898,5904 ****
    /* A null message buffer means that the frame hasn't really been
       initialized yet.  Error messages get reported properly by
       cmd_error, so this must be just an informative message; toss it.  */
!   else if (INTERACTIVE 
           && sf->glyphs_initialized_p
           && FRAME_MESSAGE_BUF (sf))
      {
--- 5898,5904 ----
    /* A null message buffer means that the frame hasn't really been
       initialized yet.  Error messages get reported properly by
       cmd_error, so this must be just an informative message; toss it.  */
!   else if (INTERACTIVE
           && sf->glyphs_initialized_p
           && FRAME_MESSAGE_BUF (sf))
      {
***************
*** 5947,5953 ****
    struct gcpro gcpro1;
  
    GCPRO1 (m);
!   
    /* First flush out any partial line written with print.  */
    message_log_maybe_newline ();
    if (STRINGP (m))
--- 5947,5953 ----
    struct gcpro gcpro1;
  
    GCPRO1 (m);
! 
    /* First flush out any partial line written with print.  */
    message_log_maybe_newline ();
    if (STRINGP (m))
***************
*** 5982,5988 ****
    /* A null message buffer means that the frame hasn't really been
       initialized yet.  Error messages get reported properly by
       cmd_error, so this must be just an informative message; toss it.  */
!   else if (INTERACTIVE 
           && sf->glyphs_initialized_p
           && FRAME_MESSAGE_BUF (sf))
      {
--- 5982,5988 ----
    /* A null message buffer means that the frame hasn't really been
       initialized yet.  Error messages get reported properly by
       cmd_error, so this must be just an informative message; toss it.  */
!   else if (INTERACTIVE
           && sf->glyphs_initialized_p
           && FRAME_MESSAGE_BUF (sf))
      {
***************
*** 6091,6097 ****
          args[1] = message = string;
          GCPRO2 (args[0], message);
          gcpro1.nvars = 2;
!         
          message = Fformat (2, args);
  
          if (log)
--- 6091,6097 ----
          args[1] = message = string;
          GCPRO2 (args[0], message);
          gcpro1.nvars = 2;
! 
          message = Fformat (2, args);
  
          if (log)
***************
*** 6206,6212 ****
      {
        Lisp_Object string;
        string = Fcurrent_message ();
!       message3 (string, SBYTES (string), 
                !NILP (current_buffer->enable_multibyte_characters));
      }
  }
--- 6206,6212 ----
      {
        Lisp_Object string;
        string = Fcurrent_message ();
!       message3 (string, SBYTES (string),
                !NILP (current_buffer->enable_multibyte_characters));
      }
  }
***************
*** 6273,6279 ****
    ensure_echo_area_buffers ();
  
    clear_buffer_p = 0;
!   
    if (which == 0)
      this_one = 0, the_other = 1;
    else if (which > 0)
--- 6273,6279 ----
    ensure_echo_area_buffers ();
  
    clear_buffer_p = 0;
! 
    if (which == 0)
      this_one = 0, the_other = 1;
    else if (which > 0)
***************
*** 6282,6288 ****
      {
        this_one = 0, the_other = 1;
        clear_buffer_p = 1;
!       
        /* We need a fresh one in case the current echo buffer equals
         the one containing the last displayed echo area message.  */
        if (!NILP (echo_area_buffer[this_one])
--- 6282,6288 ----
      {
        this_one = 0, the_other = 1;
        clear_buffer_p = 1;
! 
        /* We need a fresh one in case the current echo buffer equals
         the one containing the last displayed echo area message.  */
        if (!NILP (echo_area_buffer[this_one])
***************
*** 6360,6373 ****
       Vwith_echo_area_save_vector.  */
    vector = Vwith_echo_area_save_vector;
    Vwith_echo_area_save_vector = Qnil;
!   
    if (NILP (vector))
      vector = Fmake_vector (make_number (7), Qnil);
!   
    XSETBUFFER (AREF (vector, i), current_buffer); ++i;
    AREF (vector, i) = Vdeactivate_mark, ++i;
    AREF (vector, i) = make_number (windows_or_buffers_changed), ++i;
!   
    if (w)
      {
        XSETWINDOW (AREF (vector, i), w); ++i;
--- 6360,6373 ----
       Vwith_echo_area_save_vector.  */
    vector = Vwith_echo_area_save_vector;
    Vwith_echo_area_save_vector = Qnil;
! 
    if (NILP (vector))
      vector = Fmake_vector (make_number (7), Qnil);
! 
    XSETBUFFER (AREF (vector, i), current_buffer); ++i;
    AREF (vector, i) = Vdeactivate_mark, ++i;
    AREF (vector, i) = make_number (windows_or_buffers_changed), ++i;
! 
    if (w)
      {
        XSETWINDOW (AREF (vector, i), w); ++i;
***************
*** 6402,6413 ****
      {
        struct window *w;
        Lisp_Object buffer, charpos, bytepos;
!       
        w = XWINDOW (AREF (vector, 3));
        buffer = AREF (vector, 4);
        charpos = AREF (vector, 5);
        bytepos = AREF (vector, 6);
!       
        w->buffer = buffer;
        set_marker_both (w->pointm, buffer,
                       XFASTINT (charpos), XFASTINT (bytepos));
--- 6402,6413 ----
      {
        struct window *w;
        Lisp_Object buffer, charpos, bytepos;
! 
        w = XWINDOW (AREF (vector, 3));
        buffer = AREF (vector, 4);
        charpos = AREF (vector, 5);
        bytepos = AREF (vector, 6);
! 
        w->buffer = buffer;
        set_marker_both (w->pointm, buffer,
                       XFASTINT (charpos), XFASTINT (bytepos));
***************
*** 6432,6445 ****
        /* A message has been output since the last time we printed.
         Choose a fresh echo area buffer.  */
        if (EQ (echo_area_buffer[1], echo_buffer[0]))
!       echo_area_buffer[0] = echo_buffer[1]; 
        else
        echo_area_buffer[0] = echo_buffer[0];
  
        /* Switch to that buffer and clear it.  */
        set_buffer_internal (XBUFFER (echo_area_buffer[0]));
        current_buffer->truncate_lines = Qnil;
!       
        if (Z > BEG)
        {
          int count = BINDING_STACK_SIZE ();
--- 6432,6445 ----
        /* A message has been output since the last time we printed.
         Choose a fresh echo area buffer.  */
        if (EQ (echo_area_buffer[1], echo_buffer[0]))
!       echo_area_buffer[0] = echo_buffer[1];
        else
        echo_area_buffer[0] = echo_buffer[0];
  
        /* Switch to that buffer and clear it.  */
        set_buffer_internal (XBUFFER (echo_area_buffer[0]));
        current_buffer->truncate_lines = Qnil;
! 
        if (Z > BEG)
        {
          int count = BINDING_STACK_SIZE ();
***************
*** 6471,6481 ****
        if (NILP (echo_area_buffer[0]))
        {
          if (EQ (echo_area_buffer[1], echo_buffer[0]))
!           echo_area_buffer[0] = echo_buffer[1]; 
          else
            echo_area_buffer[0] = echo_buffer[0];
        }
!       
        if (current_buffer != XBUFFER (echo_area_buffer[0]))
        {
          /* Someone switched buffers between print requests.  */
--- 6471,6481 ----
        if (NILP (echo_area_buffer[0]))
        {
          if (EQ (echo_area_buffer[1], echo_buffer[0]))
!           echo_area_buffer[0] = echo_buffer[1];
          else
            echo_area_buffer[0] = echo_buffer[0];
        }
! 
        if (current_buffer != XBUFFER (echo_area_buffer[0]))
        {
          /* Someone switched buffers between print requests.  */
***************
*** 6510,6516 ****
       with_echo_area_buffer will sets it to an empty buffer.  */
    i = display_last_displayed_message_p ? 1 : 0;
    no_message_p = NILP (echo_area_buffer[i]);
!   
    window_height_changed_p
      = with_echo_area_buffer (w, display_last_displayed_message_p,
                             display_echo_area_1,
--- 6510,6516 ----
       with_echo_area_buffer will sets it to an empty buffer.  */
    i = display_last_displayed_message_p ? 1 : 0;
    no_message_p = NILP (echo_area_buffer[i]);
! 
    window_height_changed_p
      = with_echo_area_buffer (w, display_last_displayed_message_p,
                             display_echo_area_1,
***************
*** 6573,6579 ****
        resize_exactly = Qt;
        else
        resize_exactly = Qnil;
!       
        resized_p = with_echo_area_buffer (w, 0, resize_mini_window_1,
                                         (EMACS_INT) w, resize_exactly, 0, 0);
        if (resized_p)
--- 6573,6579 ----
        resize_exactly = Qt;
        else
        resize_exactly = Qnil;
! 
        resized_p = with_echo_area_buffer (w, 0, resize_mini_window_1,
                                         (EMACS_INT) w, resize_exactly, 0, 0);
        if (resized_p)
***************
*** 6625,6636 ****
       functions with safe_call which binds inhibit-redisplay to t.  */
    if (!NILP (Vinhibit_redisplay))
      return 0;
!   
    /* Nil means don't try to resize.  */
    if (NILP (Vresize_mini_windows)
        || (FRAME_X_P (f) && f->output_data.x == NULL))
      return 0;
!   
    if (!FRAME_MINIBUF_ONLY_P (f))
      {
        struct it it;
--- 6625,6636 ----
       functions with safe_call which binds inhibit-redisplay to t.  */
    if (!NILP (Vinhibit_redisplay))
      return 0;
! 
    /* Nil means don't try to resize.  */
    if (NILP (Vresize_mini_windows)
        || (FRAME_X_P (f) && f->output_data.x == NULL))
      return 0;
! 
    if (!FRAME_MINIBUF_ONLY_P (f))
      {
        struct it it;
***************
*** 6656,6666 ****
        max_height = XINT (Vmax_mini_window_height);
        else
        max_height = total_height / 4;
!       
        /* Correct that max. height if it's bogus.  */
        max_height = max (1, max_height);
        max_height = min (total_height, max_height);
!       
        /* Find out the height of the text in the window.  */
        if (it.truncate_lines_p)
        height = 1;
--- 6656,6666 ----
        max_height = XINT (Vmax_mini_window_height);
        else
        max_height = total_height / 4;
! 
        /* Correct that max. height if it's bogus.  */
        max_height = max (1, max_height);
        max_height = min (total_height, max_height);
! 
        /* Find out the height of the text in the window.  */
        if (it.truncate_lines_p)
        height = 1;
***************
*** 6675,6681 ****
          height -= it.extra_line_spacing;
          height = (height + unit - 1) / unit;
        }
!       
        /* Compute a suitable window start.  */
        if (height > max_height)
        {
--- 6675,6681 ----
          height -= it.extra_line_spacing;
          height = (height + unit - 1) / unit;
        }
! 
        /* Compute a suitable window start.  */
        if (height > max_height)
        {
***************
*** 6708,6714 ****
              window_height_changed_p = XFASTINT (w->height) != old_height;
            }
        }
!       else 
        {
          /* Always resize to exact size needed.  */
          if (height > XFASTINT (w->height))
--- 6708,6714 ----
              window_height_changed_p = XFASTINT (w->height) != old_height;
            }
        }
!       else
        {
          /* Always resize to exact size needed.  */
          if (height > XFASTINT (w->height))
***************
*** 6729,6735 ****
                  freeze_window_starts (f, 1);
                  grow_mini_window (w, height - XFASTINT (w->height));
                }
!             
              window_height_changed_p = XFASTINT (w->height) != old_height;
            }
        }
--- 6729,6735 ----
                  freeze_window_starts (f, 1);
                  grow_mini_window (w, height - XFASTINT (w->height));
                }
! 
              window_height_changed_p = XFASTINT (w->height) != old_height;
            }
        }
***************
*** 6759,6765 ****
        if (NILP (msg))
        echo_area_buffer[0] = Qnil;
      }
!   
    return msg;
  }
  
--- 6759,6765 ----
        if (NILP (msg))
        echo_area_buffer[0] = Qnil;
      }
! 
    return msg;
  }
  
***************
*** 6771,6777 ****
       EMACS_INT a3, a4;
  {
    Lisp_Object *msg = (Lisp_Object *) a1;
!   
    if (Z > BEG)
      *msg = make_buffer_string (BEG, Z, 1);
    else
--- 6771,6777 ----
       EMACS_INT a3, a4;
  {
    Lisp_Object *msg = (Lisp_Object *) a1;
! 
    if (Z > BEG)
      *msg = make_buffer_string (BEG, Z, 1);
    else
***************
*** 6812,6818 ****
  restore_message ()
  {
    Lisp_Object msg;
!   
    xassert (CONSP (Vmessage_stack));
    msg = XCAR (Vmessage_stack);
    if (STRINGP (msg))
--- 6812,6818 ----
  restore_message ()
  {
    Lisp_Object msg;
! 
    xassert (CONSP (Vmessage_stack));
    msg = XCAR (Vmessage_stack);
    if (STRINGP (msg))
***************
*** 6903,6909 ****
    message_enable_multibyte
      = ((s && multibyte_p)
         || (STRINGP (string) && STRING_MULTIBYTE (string)));
!   
    with_echo_area_buffer (0, -1, set_message_1,
                         (EMACS_INT) s, string, nbytes, multibyte_p);
    message_buf_print = 0;
--- 6903,6909 ----
    message_enable_multibyte
      = ((s && multibyte_p)
         || (STRINGP (string) && STRING_MULTIBYTE (string)));
! 
    with_echo_area_buffer (0, -1, set_message_1,
                         (EMACS_INT) s, string, nbytes, multibyte_p);
    message_buf_print = 0;
***************
*** 6924,6950 ****
  {
    char *s = (char *) a1;
    Lisp_Object string = a2;
!   
    xassert (BEG == Z);
!   
    /* Change multibyteness of the echo buffer appropriately.  */
    if (message_enable_multibyte
        != !NILP (current_buffer->enable_multibyte_characters))
      Fset_buffer_multibyte (message_enable_multibyte ? Qt : Qnil);
  
    current_buffer->truncate_lines = message_truncate_lines ? Qt : Qnil;
!   
    /* Insert new message at BEG.  */
    TEMP_SET_PT_BOTH (BEG, BEG_BYTE);
  
    if (STRINGP (string))
      {
        int nchars;
!       
        if (nbytes == 0)
        nbytes = SBYTES (string);
        nchars = string_byte_to_char (string, nbytes);
!       
        /* This function takes care of single/multibyte conversion.  We
           just have to ensure that the echo area buffer has the right
           setting of enable_multibyte_characters.  */
--- 6924,6950 ----
  {
    char *s = (char *) a1;
    Lisp_Object string = a2;
! 
    xassert (BEG == Z);
! 
    /* Change multibyteness of the echo buffer appropriately.  */
    if (message_enable_multibyte
        != !NILP (current_buffer->enable_multibyte_characters))
      Fset_buffer_multibyte (message_enable_multibyte ? Qt : Qnil);
  
    current_buffer->truncate_lines = message_truncate_lines ? Qt : Qnil;
! 
    /* Insert new message at BEG.  */
    TEMP_SET_PT_BOTH (BEG, BEG_BYTE);
  
    if (STRINGP (string))
      {
        int nchars;
! 
        if (nbytes == 0)
        nbytes = SBYTES (string);
        nchars = string_byte_to_char (string, nbytes);
! 
        /* This function takes care of single/multibyte conversion.  We
           just have to ensure that the echo area buffer has the right
           setting of enable_multibyte_characters.  */
***************
*** 6954,6966 ****
      {
        if (nbytes == 0)
        nbytes = strlen (s);
!       
        if (multibyte_p && NILP (current_buffer->enable_multibyte_characters))
        {
          /* Convert from multi-byte to single-byte.  */
          int i, c, n;
          unsigned char work[1];
!         
          /* Convert a multibyte string to single-byte.  */
          for (i = 0; i < nbytes; i += n)
            {
--- 6954,6966 ----
      {
        if (nbytes == 0)
        nbytes = strlen (s);
! 
        if (multibyte_p && NILP (current_buffer->enable_multibyte_characters))
        {
          /* Convert from multi-byte to single-byte.  */
          int i, c, n;
          unsigned char work[1];
! 
          /* Convert a multibyte string to single-byte.  */
          for (i = 0; i < nbytes; i += n)
            {
***************
*** 6978,6984 ****
          int i, c, n;
          unsigned char *msg = (unsigned char *) s;
          unsigned char str[MAX_MULTIBYTE_LENGTH];
!       
          /* Convert a single-byte string to multibyte.  */
          for (i = 0; i < nbytes; i++)
            {
--- 6978,6984 ----
          int i, c, n;
          unsigned char *msg = (unsigned char *) s;
          unsigned char str[MAX_MULTIBYTE_LENGTH];
! 
          /* Convert a single-byte string to multibyte.  */
          for (i = 0; i < nbytes; i++)
            {
***************
*** 7008,7017 ****
        echo_area_buffer[0] = Qnil;
        message_cleared_p = 1;
      }
!   
    if (last_displayed_p)
      echo_area_buffer[1] = Qnil;
!   
    message_buf_print = 0;
  }
  
--- 7008,7017 ----
        echo_area_buffer[0] = Qnil;
        message_cleared_p = 1;
      }
! 
    if (last_displayed_p)
      echo_area_buffer[1] = Qnil;
! 
    message_buf_print = 0;
  }
  
***************
*** 7031,7041 ****
      {
        Lisp_Object tail, frame;
        int changed_count = 0;
!       
        FOR_EACH_FRAME (tail, frame)
        {
          struct frame *f = XFRAME (frame);
!         
          if (FRAME_VISIBLE_P (f) && FRAME_GARBAGED_P (f))
            {
              if (f->resized_p)
--- 7031,7041 ----
      {
        Lisp_Object tail, frame;
        int changed_count = 0;
! 
        FOR_EACH_FRAME (tail, frame)
        {
          struct frame *f = XFRAME (frame);
! 
          if (FRAME_VISIBLE_P (f) && FRAME_GARBAGED_P (f))
            {
              if (f->resized_p)
***************
*** 7082,7088 ****
    /* When Emacs starts, selected_frame may be a visible terminal
       frame, even if we run under a window system.  If we let this
       through, a message would be displayed on the terminal.  */
!   if (EQ (selected_frame, Vterminal_frame) 
        && !NILP (Vwindow_system))
      return 0;
  #endif /* HAVE_WINDOW_SYSTEM */
--- 7082,7088 ----
    /* When Emacs starts, selected_frame may be a visible terminal
       frame, even if we run under a window system.  If we let this
       through, a message would be displayed on the terminal.  */
!   if (EQ (selected_frame, Vterminal_frame)
        && !NILP (Vwindow_system))
      return 0;
  #endif /* HAVE_WINDOW_SYSTEM */
***************
*** 7113,7119 ****
             garbaged.  This looks odd, so we prevent it here.  */
          if (!display_completed)
            n = redisplay_mode_lines (FRAME_ROOT_WINDOW (f), 0);
!           
          if (window_height_changed_p
              /* Don't do this if Emacs is shutting down.  Redisplay
                 needs to run hooks.  */
--- 7113,7119 ----
             garbaged.  This looks odd, so we prevent it here.  */
          if (!display_completed)
            n = redisplay_mode_lines (FRAME_ROOT_WINDOW (f), 0);
! 
          if (window_height_changed_p
              /* Don't do this if Emacs is shutting down.  Redisplay
                 needs to run hooks.  */
***************
*** 7151,7157 ****
  
    /* Last displayed message is now the current message.  */
    echo_area_buffer[1] = echo_area_buffer[0];
!       
    /* Prevent redisplay optimization in redisplay_internal by resetting
       this_line_start_pos.  This is done because the mini-buffer now
       displays the message instead of its buffer text.  */
--- 7151,7157 ----
  
    /* Last displayed message is now the current message.  */
    echo_area_buffer[1] = echo_area_buffer[0];
! 
    /* Prevent redisplay optimization in redisplay_internal by resetting
       this_line_start_pos.  This is done because the mini-buffer now
       displays the message instead of its buffer text.  */
***************
*** 7263,7269 ****
          Lisp_Object other_frame = XCAR (tail);
          struct frame *tf = XFRAME (other_frame);
  
!         if (tf != f 
              && FRAME_KBOARD (tf) == FRAME_KBOARD (f)
              && !FRAME_MINIBUF_ONLY_P (tf)
              && !EQ (other_frame, tip_frame)
--- 7263,7269 ----
          Lisp_Object other_frame = XCAR (tail);
          struct frame *tf = XFRAME (other_frame);
  
!         if (tf != f
              && FRAME_KBOARD (tf) == FRAME_KBOARD (f)
              && !FRAME_MINIBUF_ONLY_P (tf)
              && !EQ (other_frame, tip_frame)
***************
*** 7293,7299 ****
         already wasted too much time by walking through the list with
         display_mode_element, then we might need to optimize at a
         higher level than this.)  */
!       if (! STRINGP (f->name) 
          || SBYTES (f->name) != len
          || bcmp (frame_title_buf, SDATA (f->name), len) != 0)
        x_implicitly_set_name (f, make_string (frame_title_buf, len), Qnil);
--- 7293,7299 ----
         already wasted too much time by walking through the list with
         display_mode_element, then we might need to optimize at a
         higher level than this.)  */
!       if (! STRINGP (f->name)
          || SBYTES (f->name) != len
          || bcmp (frame_title_buf, SDATA (f->name), len) != 0)
        x_implicitly_set_name (f, make_string (frame_title_buf, len), Qnil);
***************
*** 7352,7358 ****
  
    /* Update the menu bar item lists, if appropriate.  This has to be
       done before any actual redisplay or generation of display lines.  */
!   all_windows = (update_mode_lines 
                 || buffer_shared > 1
                 || windows_or_buffers_changed);
    if (all_windows)
--- 7352,7358 ----
  
    /* Update the menu bar item lists, if appropriate.  This has to be
       done before any actual redisplay or generation of display lines.  */
!   all_windows = (update_mode_lines
                 || buffer_shared > 1
                 || windows_or_buffers_changed);
    if (all_windows)
***************
*** 7369,7386 ****
          /* Ignore tooltip frame.  */
          if (EQ (frame, tooltip_frame))
            continue;
!         
          /* If a window on this frame changed size, report that to
             the user and clear the size-change flag.  */
          if (FRAME_WINDOW_SIZES_CHANGED (f))
            {
              Lisp_Object functions;
!             
              /* Clear flag first in case we get an error below.  */
              FRAME_WINDOW_SIZES_CHANGED (f) = 0;
              functions = Vwindow_size_change_functions;
              GCPRO2 (tail, functions);
!             
              while (CONSP (functions))
                {
                  call1 (XCAR (functions), frame);
--- 7369,7386 ----
          /* Ignore tooltip frame.  */
          if (EQ (frame, tooltip_frame))
            continue;
! 
          /* If a window on this frame changed size, report that to
             the user and clear the size-change flag.  */
          if (FRAME_WINDOW_SIZES_CHANGED (f))
            {
              Lisp_Object functions;
! 
              /* Clear flag first in case we get an error below.  */
              FRAME_WINDOW_SIZES_CHANGED (f) = 0;
              functions = Vwindow_size_change_functions;
              GCPRO2 (tail, functions);
! 
              while (CONSP (functions))
                {
                  call1 (XCAR (functions), frame);
***************
*** 7388,7394 ****
                }
              UNGCPRO;
            }
!         
          GCPRO1 (tail);
          update_menu_bar (f, 0);
  #ifdef HAVE_WINDOW_SYSTEM
--- 7388,7394 ----
                }
              UNGCPRO;
            }
! 
          GCPRO1 (tail);
          update_menu_bar (f, 0);
  #ifdef HAVE_WINDOW_SYSTEM
***************
*** 7438,7449 ****
  
    window = FRAME_SELECTED_WINDOW (f);
    w = XWINDOW (window);
!   
  #if 0 /* The if statement below this if statement used to include the
           condition !NILP (w->update_mode_line), rather than using
           update_mode_lines directly, and this if statement may have
           been added to make that condition work.  Now the if
!          statement below matches its comment, this isn't needed.  */  
    if (update_mode_lines)
      w->update_mode_line = Qt;
  #endif
--- 7438,7449 ----
  
    window = FRAME_SELECTED_WINDOW (f);
    w = XWINDOW (window);
! 
  #if 0 /* The if statement below this if statement used to include the
           condition !NILP (w->update_mode_line), rather than using
           update_mode_lines directly, and this if statement may have
           been added to make that condition work.  Now the if
!          statement below matches its comment, this isn't needed.  */
    if (update_mode_lines)
      w->update_mode_line = Qt;
  #endif
***************
*** 7451,7457 ****
    if (FRAME_WINDOW_P (f)
        ?
  #if defined (USE_X_TOOLKIT) || defined (HAVE_NTGUI) || defined (MAC_OS)
!       FRAME_EXTERNAL_MENU_BAR (f) 
  #else
        FRAME_MENU_BAR_LINES (f) > 0
  #endif
--- 7451,7457 ----
    if (FRAME_WINDOW_P (f)
        ?
  #if defined (USE_X_TOOLKIT) || defined (HAVE_NTGUI) || defined (MAC_OS)
!       FRAME_EXTERNAL_MENU_BAR (f)
  #else
        FRAME_MENU_BAR_LINES (f) > 0
  #endif
***************
*** 7491,7505 ****
  
          /* Run the Lucid hook.  */
          safe_run_hooks (Qactivate_menubar_hook);
!         
          /* If it has changed current-menubar from previous value,
             really recompute the menu-bar from the value.  */
          if (! NILP (Vlucid_menu_bar_dirty_flag))
            call0 (Qrecompute_lucid_menubar);
!         
          safe_run_hooks (Qmenu_bar_update_hook);
          FRAME_MENU_BAR_ITEMS (f) = menu_bar_items (FRAME_MENU_BAR_ITEMS (f));
!         
          /* Redisplay the menu bar in case we changed it.  */
  #if defined (USE_X_TOOLKIT) || defined (HAVE_NTGUI) || defined (MAC_OS)
          if (FRAME_WINDOW_P (f)
--- 7491,7505 ----
  
          /* Run the Lucid hook.  */
          safe_run_hooks (Qactivate_menubar_hook);
! 
          /* If it has changed current-menubar from previous value,
             really recompute the menu-bar from the value.  */
          if (! NILP (Vlucid_menu_bar_dirty_flag))
            call0 (Qrecompute_lucid_menubar);
! 
          safe_run_hooks (Qmenu_bar_update_hook);
          FRAME_MENU_BAR_ITEMS (f) = menu_bar_items (FRAME_MENU_BAR_ITEMS (f));
! 
          /* Redisplay the menu bar in case we changed it.  */
  #if defined (USE_X_TOOLKIT) || defined (HAVE_NTGUI) || defined (MAC_OS)
          if (FRAME_WINDOW_P (f)
***************
*** 7552,7558 ****
  
        window = FRAME_SELECTED_WINDOW (f);
        w = XWINDOW (window);
!   
        /* If the user has switched buffers or windows, we need to
         recompute to reflect the new bindings.  But we'll
         recompute when update_mode_lines is set too; that means
--- 7552,7558 ----
  
        window = FRAME_SELECTED_WINDOW (f);
        w = XWINDOW (window);
! 
        /* If the user has switched buffers or windows, we need to
         recompute to reflect the new bindings.  But we'll
         recompute when update_mode_lines is set too; that means
***************
*** 7591,7597 ****
          /* Build desired tool-bar items from keymaps.  */
          f->tool_bar_items
            = tool_bar_items (f->tool_bar_items, &f->n_tool_bar_items);
!         
          /* Redisplay the tool-bar in case we changed it.  */
          w->update_mode_line = Qt;
  
--- 7591,7597 ----
          /* Build desired tool-bar items from keymaps.  */
          f->tool_bar_items
            = tool_bar_items (f->tool_bar_items, &f->n_tool_bar_items);
! 
          /* Redisplay the tool-bar in case we changed it.  */
          w->update_mode_line = Qt;
  
***************
*** 7619,7625 ****
  
    /* Prepare F->desired_tool_bar_string.  If we can reuse it, do so.
       Otherwise, make a new string.  */
!   
    /* The size of the string we might be able to reuse.  */
    size = (STRINGP (f->desired_tool_bar_string)
          ? SCHARS (f->desired_tool_bar_string)
--- 7619,7625 ----
  
    /* Prepare F->desired_tool_bar_string.  If we can reuse it, do so.
       Otherwise, make a new string.  */
! 
    /* The size of the string we might be able to reuse.  */
    size = (STRINGP (f->desired_tool_bar_string)
          ? SCHARS (f->desired_tool_bar_string)
***************
*** 7627,7633 ****
  
    /* We need one space in the string for each image.  */
    size_needed = f->n_tool_bar_items;
!   
    /* Reuse f->desired_tool_bar_string, if possible.  */
    if (size < size_needed || NILP (f->desired_tool_bar_string))
      f->desired_tool_bar_string = Fmake_string (make_number (size_needed),
--- 7627,7633 ----
  
    /* We need one space in the string for each image.  */
    size_needed = f->n_tool_bar_items;
! 
    /* Reuse f->desired_tool_bar_string, if possible.  */
    if (size < size_needed || NILP (f->desired_tool_bar_string))
      f->desired_tool_bar_string = Fmake_string (make_number (size_needed),
***************
*** 7664,7670 ****
            idx = (selected_p
                   ? TOOL_BAR_IMAGE_DISABLED_SELECTED
                   : TOOL_BAR_IMAGE_DISABLED_DESELECTED);
!         
          xassert (ASIZE (image) >= idx);
          image = AREF (image, idx);
        }
--- 7664,7670 ----
            idx = (selected_p
                   ? TOOL_BAR_IMAGE_DISABLED_SELECTED
                   : TOOL_BAR_IMAGE_DISABLED_DESELECTED);
! 
          xassert (ASIZE (image) >= idx);
          image = AREF (image, idx);
        }
***************
*** 7695,7706 ****
          if (INTEGERP (XCAR (Vtool_bar_button_margin))
              && XINT (XCAR (Vtool_bar_button_margin)) > 0)
            hmargin += XFASTINT (XCAR (Vtool_bar_button_margin));
!         
          if (INTEGERP (XCDR (Vtool_bar_button_margin))
              && XINT (XCDR (Vtool_bar_button_margin)) > 0)
            vmargin += XFASTINT (XCDR (Vtool_bar_button_margin));
        }
!       
        if (auto_raise_tool_bar_buttons_p)
        {
          /* Add a `:relief' property to the image spec if the item is
--- 7695,7706 ----
          if (INTEGERP (XCAR (Vtool_bar_button_margin))
              && XINT (XCAR (Vtool_bar_button_margin)) > 0)
            hmargin += XFASTINT (XCAR (Vtool_bar_button_margin));
! 
          if (INTEGERP (XCDR (Vtool_bar_button_margin))
              && XINT (XCDR (Vtool_bar_button_margin)) > 0)
            vmargin += XFASTINT (XCDR (Vtool_bar_button_margin));
        }
! 
        if (auto_raise_tool_bar_buttons_p)
        {
          /* Add a `:relief' property to the image spec if the item is
***************
*** 7735,7747 ****
                                Fcons (make_number (hmargin),
                                       make_number (vmargin)));
        }
!         
        /* If button is not enabled, and we don't have special images
         for the disabled state, make the image appear disabled by
         applying an appropriate algorithm to it.  */
        if (!enabled_p && idx < 0)
        plist = Fplist_put (plist, QCconversion, Qdisabled);
!       
        /* Put a `display' text property on the string for the image to
         display.  Put a `menu-item' property on the string that gives
         the start of this item's properties in the tool-bar items
--- 7735,7747 ----
                                Fcons (make_number (hmargin),
                                       make_number (vmargin)));
        }
! 
        /* If button is not enabled, and we don't have special images
         for the disabled state, make the image appear disabled by
         applying an appropriate algorithm to it.  */
        if (!enabled_p && idx < 0)
        plist = Fplist_put (plist, QCconversion, Qdisabled);
! 
        /* Put a `display' text property on the string for the image to
         display.  Put a `menu-item' property on the string that gives
         the start of this item's properties in the tool-bar items
***************
*** 7775,7788 ****
    struct glyph_row *row = it->glyph_row;
    int max_x = it->last_visible_x;
    struct glyph *last;
!   
    prepare_desired_row (row);
    row->y = it->current_y;
  
    /* Note that this isn't made use of if the face hasn't a box,
       so there's no need to check the face here.  */
    it->start_of_box_run_p = 1;
!   
    while (it->current_x < max_x)
      {
        int x_before, x, n_glyphs_before, i, nglyphs;
--- 7775,7788 ----
    struct glyph_row *row = it->glyph_row;
    int max_x = it->last_visible_x;
    struct glyph *last;
! 
    prepare_desired_row (row);
    row->y = it->current_y;
  
    /* Note that this isn't made use of if the face hasn't a box,
       so there's no need to check the face here.  */
    it->start_of_box_run_p = 1;
! 
    while (it->current_x < max_x)
      {
        int x_before, x, n_glyphs_before, i, nglyphs;
***************
*** 7802,7808 ****
        while (i < nglyphs)
        {
          struct glyph *glyph = row->glyphs[TEXT_AREA] + n_glyphs_before + i;
!         
          if (x + glyph->pixel_width > max_x)
            {
              /* Glyph doesn't fit on line.  */
--- 7802,7808 ----
        while (i < nglyphs)
        {
          struct glyph *glyph = row->glyphs[TEXT_AREA] + n_glyphs_before + i;
! 
          if (x + glyph->pixel_width > max_x)
            {
              /* Glyph doesn't fit on line.  */
***************
*** 7832,7845 ****
    if (last == row->glyphs[TEXT_AREA])
      last->left_box_line_p = 1;
    compute_line_metrics (it);
!   
    /* If line is empty, make it occupy the rest of the tool-bar.  */
    if (!row->displays_text_p)
      {
        row->height = row->phys_height = it->last_visible_y - row->y;
        row->ascent = row->phys_ascent = 0;
      }
!   
    row->full_width_p = 1;
    row->continued_p = 0;
    row->truncated_on_left_p = 0;
--- 7832,7845 ----
    if (last == row->glyphs[TEXT_AREA])
      last->left_box_line_p = 1;
    compute_line_metrics (it);
! 
    /* If line is empty, make it occupy the rest of the tool-bar.  */
    if (!row->displays_text_p)
      {
        row->height = row->phys_height = it->last_visible_y - row->y;
        row->ascent = row->phys_ascent = 0;
      }
! 
    row->full_width_p = 1;
    row->continued_p = 0;
    row->truncated_on_left_p = 0;
***************
*** 7861,7867 ****
  {
    struct window *w = XWINDOW (f->tool_bar_window);
    struct it it;
!   
    /* Initialize an iterator for iteration over
       F->desired_tool_bar_string in the tool-bar window of frame F.  */
    init_iterator (&it, w, -1, -1, w->desired_matrix->rows, TOOL_BAR_FACE_ID);
--- 7861,7867 ----
  {
    struct window *w = XWINDOW (f->tool_bar_window);
    struct it it;
! 
    /* Initialize an iterator for iteration over
       F->desired_tool_bar_string in the tool-bar window of frame F.  */
    init_iterator (&it, w, -1, -1, w->desired_matrix->rows, TOOL_BAR_FACE_ID);
***************
*** 7895,7901 ****
    else
      CHECK_FRAME (frame);
    f = XFRAME (frame);
!   
    if (WINDOWP (f->tool_bar_window)
        || (w = XWINDOW (f->tool_bar_window),
          XFASTINT (w->height) > 0))
--- 7895,7901 ----
    else
      CHECK_FRAME (frame);
    f = XFRAME (frame);
! 
    if (WINDOWP (f->tool_bar_window)
        || (w = XWINDOW (f->tool_bar_window),
          XFASTINT (w->height) > 0))
***************
*** 7923,7929 ****
    struct it it;
    struct glyph_row *row;
    int change_height_p = 0;
!   
    /* If frame hasn't a tool-bar window or if it is zero-height, don't
       do anything.  This means you must start with tool-bar-lines
       non-zero to get the auto-sizing effect.  Or in other words, you
--- 7923,7929 ----
    struct it it;
    struct glyph_row *row;
    int change_height_p = 0;
! 
    /* If frame hasn't a tool-bar window or if it is zero-height, don't
       do anything.  This means you must start with tool-bar-lines
       non-zero to get the auto-sizing effect.  Or in other words, you
***************
*** 7960,7966 ****
         height.  */
        if (IT_STRING_CHARPOS (it) < it.end_charpos)
        change_height_p = 1;
!       
        /* If there are blank lines at the end, except for a partially
         visible blank line at the end that is smaller than
         CANON_Y_UNIT, change the tool-bar's height.  */
--- 7960,7966 ----
         height.  */
        if (IT_STRING_CHARPOS (it) < it.end_charpos)
        change_height_p = 1;
! 
        /* If there are blank lines at the end, except for a partially
         visible blank line at the end that is smaller than
         CANON_Y_UNIT, change the tool-bar's height.  */
***************
*** 7984,7990 ****
          extern Lisp_Object Qtool_bar_lines;
          Lisp_Object frame;
          int old_height = XFASTINT (w->height);
!         
          XSETFRAME (frame, f);
          clear_glyph_matrix (w->desired_matrix);
          Fmodify_frame_parameters (frame,
--- 7984,7990 ----
          extern Lisp_Object Qtool_bar_lines;
          Lisp_Object frame;
          int old_height = XFASTINT (w->height);
! 
          XSETFRAME (frame, f);
          clear_glyph_matrix (w->desired_matrix);
          Fmodify_frame_parameters (frame,
***************
*** 8020,8026 ****
       error.  */
    charpos = min (SCHARS (f->current_tool_bar_string), glyph->charpos);
    charpos = max (0, charpos);
!   
    /* Get the text property `menu-item' at pos. The value of that
       property is the start index of this item's properties in
       F->tool_bar_items.  */
--- 8020,8026 ----
       error.  */
    charpos = min (SCHARS (f->current_tool_bar_string), glyph->charpos);
    charpos = max (0, charpos);
! 
    /* Get the text property `menu-item' at pos. The value of that
       property is the start index of this item's properties in
       F->tool_bar_items.  */
***************
*** 8036,8042 ****
  
    return success_p;
  }
!   
  #endif /* HAVE_WINDOW_SYSTEM */
  
  
--- 8036,8042 ----
  
    return success_p;
  }
! 
  #endif /* HAVE_WINDOW_SYSTEM */
  
  
***************
*** 8200,8206 ****
       Lisp_Object window;
  {
    int hscrolled_p;
!   
    if (automatic_hscrolling_p)
      {
        hscrolled_p = hscroll_window_tree (window);
--- 8200,8206 ----
       Lisp_Object window;
  {
    int hscrolled_p;
! 
    if (automatic_hscrolling_p)
      {
        hscrolled_p = hscroll_window_tree (window);
***************
*** 8265,8271 ****
        method[len] = '|';
        --remaining, ++len;
      }
!   
    strncpy (method + len, buffer, remaining);
  
    if (trace_redisplay_p)
--- 8265,8271 ----
        method[len] = '|';
        --remaining, ++len;
      }
! 
    strncpy (method + len, buffer, remaining);
  
    if (trace_redisplay_p)
***************
*** 8309,8315 ****
       int start, end;
  {
    int unchanged_p = 1;
!   
    /* If text or overlays have changed, see where.  */
    if (XFASTINT (w->last_modified) < MODIFF
        || XFASTINT (w->last_overlay_modified) < OVERLAY_MODIFF)
--- 8309,8315 ----
       int start, end;
  {
    int unchanged_p = 1;
! 
    /* If text or overlays have changed, see where.  */
    if (XFASTINT (w->last_modified) < MODIFF
        || XFASTINT (w->last_overlay_modified) < OVERLAY_MODIFF)
***************
*** 8323,8329 ****
          && (BEG_UNCHANGED < start - 1
              || END_UNCHANGED < end))
        unchanged_p = 0;
!       
        /* If selective display, can't optimize if changes start at the
         beginning of the line.  */
        if (unchanged_p
--- 8323,8329 ----
          && (BEG_UNCHANGED < start - 1
              || END_UNCHANGED < end))
        unchanged_p = 0;
! 
        /* If selective display, can't optimize if changes start at the
         beginning of the line.  */
        if (unchanged_p
***************
*** 8389,8395 ****
        if (prev_pt == pt)
        /* Point didn't move.  */
        return 0;
!     
        if (prev_pt > BUF_BEGV (buf) && prev_pt < BUF_ZV (buf)
          && find_composition (prev_pt, -1, &start, &end, &prop, buffer)
          && COMPOSITION_VALID_P (start, end, prop)
--- 8389,8395 ----
        if (prev_pt == pt)
        /* Point didn't move.  */
        return 0;
! 
        if (prev_pt > BUF_BEGV (buf) && prev_pt < BUF_ZV (buf)
          && find_composition (prev_pt, -1, &start, &end, &prop, buffer)
          && COMPOSITION_VALID_P (start, end, prop)
***************
*** 8471,8477 ****
    /* Non-zero means redisplay has to consider all windows on all
       frames.  Zero means, only selected_window is considered.  */
    int consider_all_windows_p;
!   
    TRACE ((stderr, "redisplay_internal %d\n", redisplaying_p));
  
    /* No redisplay if running in batch mode or frame is not yet fully
--- 8471,8477 ----
    /* Non-zero means redisplay has to consider all windows on all
       frames.  Zero means, only selected_window is considered.  */
    int consider_all_windows_p;
! 
    TRACE ((stderr, "redisplay_internal %d\n", redisplaying_p));
  
    /* No redisplay if running in batch mode or frame is not yet fully
***************
*** 8506,8512 ****
    count = BINDING_STACK_SIZE ();
    record_unwind_protect (unwind_redisplay, make_number (redisplaying_p));
    ++redisplaying_p;
!   
   retry:
    pause = 0;
    reconsider_clip_changes (w, current_buffer);
--- 8506,8512 ----
    count = BINDING_STACK_SIZE ();
    record_unwind_protect (unwind_redisplay, make_number (redisplaying_p));
    ++redisplaying_p;
! 
   retry:
    pause = 0;
    reconsider_clip_changes (w, current_buffer);
***************
*** 8550,8556 ****
      FOR_EACH_FRAME (tail, frame)
        {
        struct frame *f = XFRAME (frame);
!       
        FRAME_SAMPLE_VISIBILITY (f);
        if (FRAME_VISIBLE_P (f))
          ++number_of_visible_frames;
--- 8550,8556 ----
      FOR_EACH_FRAME (tail, frame)
        {
        struct frame *f = XFRAME (frame);
! 
        FRAME_SAMPLE_VISIBILITY (f);
        if (FRAME_VISIBLE_P (f))
          ++number_of_visible_frames;
***************
*** 8586,8593 ****
        && !(PT == XFASTINT (w->last_point)
           && XFASTINT (w->last_modified) >= MODIFF
           && XFASTINT (w->last_overlay_modified) >= OVERLAY_MODIFF)
!       && XFASTINT (w->column_number_displayed) != current_column ())
!     w->update_mode_line = Qt; 
  
    FRAME_SCROLL_BOTTOM_VPOS (XFRAME (w->frame)) = -1;
  
--- 8586,8594 ----
        && !(PT == XFASTINT (w->last_point)
           && XFASTINT (w->last_modified) >= MODIFF
           && XFASTINT (w->last_overlay_modified) >= OVERLAY_MODIFF)
!       && (XFASTINT (w->column_number_displayed)
!           != (int) current_column ()))  /* iftc */
!     w->update_mode_line = Qt;
  
    FRAME_SCROLL_BOTTOM_VPOS (XFRAME (w->frame)) = -1;
  
***************
*** 8625,8631 ****
         the echo area.  */
        if (!display_last_displayed_message_p)
        message_cleared_p = 0;
!       
        if (fonts_changed_p)
        goto retry;
        else if (window_height_changed_p)
--- 8626,8632 ----
         the echo area.  */
        if (!display_last_displayed_message_p)
        message_cleared_p = 0;
! 
        if (fonts_changed_p)
        goto retry;
        else if (window_height_changed_p)
***************
*** 8633,8639 ****
          consider_all_windows_p = 1;
          ++update_mode_lines;
          ++windows_or_buffers_changed;
!         
          /* If window configuration was changed, frames may have been
             marked garbaged.  Clear them or we will experience
             surprises wrt scrolling.  */
--- 8634,8640 ----
          consider_all_windows_p = 1;
          ++update_mode_lines;
          ++windows_or_buffers_changed;
! 
          /* If window configuration was changed, frames may have been
             marked garbaged.  Clear them or we will experience
             surprises wrt scrolling.  */
***************
*** 8653,8666 ****
        consider_all_windows_p = 1;
        ++windows_or_buffers_changed;
        ++update_mode_lines;
!       
        /* If window configuration was changed, frames may have been
         marked garbaged.  Clear them or we will experience
         surprises wrt scrolling.  */
        if (frame_garbaged)
        clear_garbaged_frames ();
      }
!   
  
    /* If showing the region, and mark has changed, we must redisplay
       the whole window.  The assignment to this_line_start_pos prevents
--- 8654,8667 ----
        consider_all_windows_p = 1;
        ++windows_or_buffers_changed;
        ++update_mode_lines;
! 
        /* If window configuration was changed, frames may have been
         marked garbaged.  Clear them or we will experience
         surprises wrt scrolling.  */
        if (frame_garbaged)
        clear_garbaged_frames ();
      }
! 
  
    /* If showing the region, and mark has changed, we must redisplay
       the whole window.  The assignment to this_line_start_pos prevents
***************
*** 8742,8748 ****
  
          /* If line contains point, is not continued,
               and ends at same distance from eob as before, we win */
!         if (w->cursor.vpos >= 0 
                /* Line is not continued, otherwise this_line_start_pos
                   would have been set to 0 in display_line.  */
              && CHARPOS (this_line_start_pos)
--- 8743,8749 ----
  
          /* If line contains point, is not continued,
               and ends at same distance from eob as before, we win */
!         if (w->cursor.vpos >= 0
                /* Line is not continued, otherwise this_line_start_pos
                   would have been set to 0 in display_line.  */
              && CHARPOS (this_line_start_pos)
***************
*** 8759,8765 ****
                  struct glyph_row *row
                    = MATRIX_ROW (w->current_matrix, this_line_vpos + 1);
                  int delta, delta_bytes;
!   
                  if (Z - CHARPOS (tlendpos) == ZV)
                    {
                      /* This line ends at end of (accessible part of)
--- 8760,8766 ----
                  struct glyph_row *row
                    = MATRIX_ROW (w->current_matrix, this_line_vpos + 1);
                  int delta, delta_bytes;
! 
                  if (Z - CHARPOS (tlendpos) == ZV)
                    {
                      /* This line ends at end of (accessible part of)
***************
*** 8783,8789 ****
                                     - BYTEPOS (tlendpos)
                                     - MATRIX_ROW_START_BYTEPOS (row));
                    }
!   
                  increment_matrix_positions (w->current_matrix,
                                              this_line_vpos + 1,
                                              w->current_matrix->nrows,
--- 8784,8790 ----
                                     - BYTEPOS (tlendpos)
                                     - MATRIX_ROW_START_BYTEPOS (row));
                    }
! 
                  increment_matrix_positions (w->current_matrix,
                                              this_line_vpos + 1,
                                              w->current_matrix->nrows,
***************
*** 8802,8808 ****
                       && this_line_vpos > 0)
                XSETINT (w->window_end_vpos, this_line_vpos - 1);
              w->window_end_valid = Qnil;
!             
              /* Update hint: No need to try to scroll in update_window.  */
              w->desired_matrix->no_scrolling_p = 1;
  
--- 8803,8809 ----
                       && this_line_vpos > 0)
                XSETINT (w->window_end_vpos, this_line_vpos - 1);
              w->window_end_valid = Qnil;
! 
              /* Update hint: No need to try to scroll in update_window.  */
              w->desired_matrix->no_scrolling_p = 1;
  
***************
*** 8826,8832 ****
            {
              do_pending_window_change (1);
  
!             /* We used to always goto end_of_redisplay here, but this 
                 isn't enough if we have a blinking cursor.  */
              if (w->cursor_off_p == w->last_cursor_off_p)
                goto end_of_redisplay;
--- 8827,8833 ----
            {
              do_pending_window_change (1);
  
!             /* We used to always goto end_of_redisplay here, but this
                 isn't enough if we have a blinking cursor.  */
              if (w->cursor_off_p == w->last_cursor_off_p)
                goto end_of_redisplay;
***************
*** 8854,8860 ****
          it.current_x = this_line_start_x;
          it.current_y = this_line_y;
          it.vpos = this_line_vpos;
!         
          /* The call to move_it_to stops in front of PT, but
             moves over before-strings.  */
          move_it_to (&it, PT, -1, -1, -1, MOVE_TO_POS);
--- 8855,8861 ----
          it.current_x = this_line_start_x;
          it.current_y = this_line_y;
          it.vpos = this_line_vpos;
! 
          /* The call to move_it_to stops in front of PT, but
             moves over before-strings.  */
          move_it_to (&it, PT, -1, -1, -1, MOVE_TO_POS);
***************
*** 8885,8891 ****
    consider_all_windows_p |= buffer_shared > 1;
    ++clear_face_cache_count;
  
!   
    /* Build desired matrices, and update the display.  If
       consider_all_windows_p is non-zero, do it for all windows on all
       frames.  Otherwise do it for selected_window, only.  */
--- 8886,8892 ----
    consider_all_windows_p |= buffer_shared > 1;
    ++clear_face_cache_count;
  
! 
    /* Build desired matrices, and update the display.  If
       consider_all_windows_p is non-zero, do it for all windows on all
       frames.  Otherwise do it for selected_window, only.  */
***************
*** 8911,8917 ****
        FOR_EACH_FRAME (tail, frame)
        {
          struct frame *f = XFRAME (frame);
!         
          if (FRAME_WINDOW_P (f) || f == sf)
            {
  #ifdef HAVE_WINDOW_SYSTEM
--- 8912,8918 ----
        FOR_EACH_FRAME (tail, frame)
        {
          struct frame *f = XFRAME (frame);
! 
          if (FRAME_WINDOW_P (f) || f == sf)
            {
  #ifdef HAVE_WINDOW_SYSTEM
***************
*** 8936,8942 ****
              /* If fonts changed, display again.  */
              if (fonts_changed_p)
                goto retry;
!             
              if (FRAME_VISIBLE_P (f) && !FRAME_OBSCURED_P (f))
                {
                  /* See if we have to hscroll.  */
--- 8937,8943 ----
              /* If fonts changed, display again.  */
              if (fonts_changed_p)
                goto retry;
! 
              if (FRAME_VISIBLE_P (f) && !FRAME_OBSCURED_P (f))
                {
                  /* See if we have to hscroll.  */
***************
*** 8964,8970 ****
                      bcopy (updated, p, nbytes);
                      size *= 2;
                    }
!                 
                  updated[n++] = f;
                }
            }
--- 8965,8971 ----
                      bcopy (updated, p, nbytes);
                      size *= 2;
                    }
! 
                  updated[n++] = f;
                }
            }
***************
*** 8992,9001 ****
        internal_condition_case_1 (redisplay_window_1, selected_window,
                                 list_of_error,
                                 redisplay_window_error);
!   
        /* Compare desired and current matrices, perform output.  */
      update:
!   
        /* If fonts changed, display again.  */
        if (fonts_changed_p)
        goto retry;
--- 8993,9002 ----
        internal_condition_case_1 (redisplay_window_1, selected_window,
                                 list_of_error,
                                 redisplay_window_error);
! 
        /* Compare desired and current matrices, perform output.  */
      update:
! 
        /* If fonts changed, display again.  */
        if (fonts_changed_p)
        goto retry;
***************
*** 9011,9017 ****
        {
          if (hscroll_windows (selected_window))
            goto retry;
!         
          XWINDOW (selected_window)->must_be_updated_p = 1;
          pause = update_frame (sf, 0, 0);
        }
--- 9012,9018 ----
        {
          if (hscroll_windows (selected_window))
            goto retry;
! 
          XWINDOW (selected_window)->must_be_updated_p = 1;
          pause = update_frame (sf, 0, 0);
        }
***************
*** 9023,9029 ****
         it here.  */
        mini_window = FRAME_MINIBUF_WINDOW (sf);
        mini_frame = XFRAME (WINDOW_FRAME (XWINDOW (mini_window)));
!       
        if (mini_frame != sf && FRAME_WINDOW_P (mini_frame))
        {
          XWINDOW (mini_window)->must_be_updated_p = 1;
--- 9024,9030 ----
         it here.  */
        mini_window = FRAME_MINIBUF_WINDOW (sf);
        mini_frame = XFRAME (WINDOW_FRAME (XWINDOW (mini_window)));
! 
        if (mini_frame != sf && FRAME_WINDOW_P (mini_frame))
        {
          XWINDOW (mini_window)->must_be_updated_p = 1;
***************
*** 9048,9054 ****
          last_arrow_position = Qt;
          last_arrow_string = Qt;
        }
!       
        /* If we pause after scrolling, some rows in the current
         matrices of some windows are not valid.  */
        if (!WINDOW_FULL_WIDTH_P (w)
--- 9049,9055 ----
          last_arrow_position = Qt;
          last_arrow_string = Qt;
        }
! 
        /* If we pause after scrolling, some rows in the current
         matrices of some windows are not valid.  */
        if (!WINDOW_FULL_WIDTH_P (w)
***************
*** 9062,9071 ****
          /* This has already been done above if
             consider_all_windows_p is set.  */
          mark_window_display_accurate_1 (w, 1);
!         
          last_arrow_position = COERCE_MARKER (Voverlay_arrow_position);
          last_arrow_string = Voverlay_arrow_string;
!         
          if (frame_up_to_date_hook != 0)
            frame_up_to_date_hook (sf);
        }
--- 9063,9072 ----
          /* This has already been done above if
             consider_all_windows_p is set.  */
          mark_window_display_accurate_1 (w, 1);
! 
          last_arrow_position = COERCE_MARKER (Voverlay_arrow_position);
          last_arrow_string = Voverlay_arrow_string;
! 
          if (frame_up_to_date_hook != 0)
            frame_up_to_date_hook (sf);
        }
***************
*** 9182,9188 ****
    if (BUFFERP (w->buffer))
      {
        struct buffer *b = XBUFFER (w->buffer);
!         
        w->last_modified
        = make_number (accurate_p ? BUF_MODIFF (b) : 0);
        w->last_overlay_modified
--- 9183,9189 ----
    if (BUFFERP (w->buffer))
      {
        struct buffer *b = XBUFFER (w->buffer);
! 
        w->last_modified
        = make_number (accurate_p ? BUF_MODIFF (b) : 0);
        w->last_overlay_modified
***************
*** 9199,9212 ****
          BUF_OVERLAY_UNCHANGED_MODIFIED (b) = BUF_OVERLAY_MODIFF (b);
          BUF_BEG_UNCHANGED (b) = BUF_GPT (b) - BUF_BEG (b);
          BUF_END_UNCHANGED (b) = BUF_Z (b) - BUF_GPT (b);
!         
          w->current_matrix->buffer = b;
          w->current_matrix->begv = BUF_BEGV (b);
          w->current_matrix->zv = BUF_ZV (b);
!         
          w->last_cursor = w->cursor;
          w->last_cursor_off_p = w->cursor_off_p;
!         
          if (w == XWINDOW (selected_window))
            w->last_point = make_number (BUF_PT (b));
          else
--- 9200,9213 ----
          BUF_OVERLAY_UNCHANGED_MODIFIED (b) = BUF_OVERLAY_MODIFF (b);
          BUF_BEG_UNCHANGED (b) = BUF_GPT (b) - BUF_BEG (b);
          BUF_END_UNCHANGED (b) = BUF_Z (b) - BUF_GPT (b);
! 
          w->current_matrix->buffer = b;
          w->current_matrix->begv = BUF_BEGV (b);
          w->current_matrix->zv = BUF_ZV (b);
! 
          w->last_cursor = w->cursor;
          w->last_cursor_off_p = w->cursor_off_p;
! 
          if (w == XWINDOW (selected_window))
            w->last_point = make_number (BUF_PT (b));
          else
***************
*** 9238,9244 ****
       int accurate_p;
  {
    struct window *w;
!   
    for (; !NILP (window); window = w->next)
      {
        w = XWINDOW (window);
--- 9239,9245 ----
       int accurate_p;
  {
    struct window *w;
! 
    for (; !NILP (window); window = w->next)
      {
        w = XWINDOW (window);
***************
*** 9281,9293 ****
  
    if (SINGLE_BYTE_CHAR_P (c))
      return (dp->contents[c]);
!   
    SPLIT_CHAR (c, code[0], code[1], code[2]);
    if (code[1] < 32)
      code[1] = -1;
    else if (code[2] < 32)
      code[2] = -1;
!   
    /* Here, the possible range of code[0] (== charset ID) is
       128..max_charset.  Since the top level char table contains data
       for multibyte characters after 256th element, we must increment
--- 9282,9294 ----
  
    if (SINGLE_BYTE_CHAR_P (c))
      return (dp->contents[c]);
! 
    SPLIT_CHAR (c, code[0], code[1], code[2]);
    if (code[1] < 32)
      code[1] = -1;
    else if (code[2] < 32)
      code[2] = -1;
! 
    /* Here, the possible range of code[0] (== charset ID) is
       128..max_charset.  Since the top level char table contains data
       for multibyte characters after 256th element, we must increment
***************
*** 9301,9307 ****
        if (!SUB_CHAR_TABLE_P (val))
        return (NILP (val) ? dp->defalt : val);
      }
!   
    /* Here, val is a sub char table.  We return the default value of
       it.  */
    return (dp->defalt);
--- 9302,9308 ----
        if (!SUB_CHAR_TABLE_P (val))
        return (NILP (val) ? dp->defalt : val);
      }
! 
    /* Here, val is a sub char table.  We return the default value of
       it.  */
    return (dp->defalt);
***************
*** 9322,9328 ****
    while (!NILP (window))
      {
        struct window *w = XWINDOW (window);
!       
        if (!NILP (w->hchild))
        redisplay_windows (w->hchild);
        else if (!NILP (w->vchild))
--- 9323,9329 ----
    while (!NILP (window))
      {
        struct window *w = XWINDOW (window);
! 
        if (!NILP (w->hchild))
        redisplay_windows (w->hchild);
        else if (!NILP (w->vchild))
***************
*** 9332,9338 ****
          displayed_buffer = XBUFFER (w->buffer);
          /* Use list_of_error, not Qerror, so that
             we catch only errors and don't run the debugger.  */
!         internal_condition_case_1 (redisplay_window_0, window, 
                                     list_of_error,
                                     redisplay_window_error);
        }
--- 9333,9339 ----
          displayed_buffer = XBUFFER (w->buffer);
          /* Use list_of_error, not Qerror, so that
             we catch only errors and don't run the debugger.  */
!         internal_condition_case_1 (redisplay_window_0, window,
                                     list_of_error,
                                     redisplay_window_error);
        }
***************
*** 9415,9431 ****
          && row->x == 0)
        {
          this_line_buffer = XBUFFER (w->buffer);
!         
          CHARPOS (this_line_start_pos)
            = MATRIX_ROW_START_CHARPOS (row) + delta;
          BYTEPOS (this_line_start_pos)
            = MATRIX_ROW_START_BYTEPOS (row) + delta_bytes;
!         
          CHARPOS (this_line_end_pos)
            = Z - (MATRIX_ROW_END_CHARPOS (row) + delta);
          BYTEPOS (this_line_end_pos)
            = Z_BYTE - (MATRIX_ROW_END_BYTEPOS (row) + delta_bytes);
!         
          this_line_y = w->cursor.y;
          this_line_pixel_height = row->height;
          this_line_vpos = w->cursor.vpos;
--- 9416,9432 ----
          && row->x == 0)
        {
          this_line_buffer = XBUFFER (w->buffer);
! 
          CHARPOS (this_line_start_pos)
            = MATRIX_ROW_START_CHARPOS (row) + delta;
          BYTEPOS (this_line_start_pos)
            = MATRIX_ROW_START_BYTEPOS (row) + delta_bytes;
! 
          CHARPOS (this_line_end_pos)
            = Z - (MATRIX_ROW_END_CHARPOS (row) + delta);
          BYTEPOS (this_line_end_pos)
            = Z_BYTE - (MATRIX_ROW_END_BYTEPOS (row) + delta_bytes);
! 
          this_line_y = w->cursor.y;
          this_line_pixel_height = row->height;
          this_line_vpos = w->cursor.vpos;
***************
*** 9455,9461 ****
  
    if (!NILP (Vwindow_scroll_functions))
      {
!       run_hook_with_args_2 (Qwindow_scroll_functions, window, 
                            make_number (CHARPOS (startp)));
        SET_TEXT_POS_FROM_MARKER (startp, w->start);
        /* In case the hook functions switch buffers.  */
--- 9456,9462 ----
  
    if (!NILP (Vwindow_scroll_functions))
      {
!       run_hook_with_args_2 (Qwindow_scroll_functions, window,
                            make_number (CHARPOS (startp)));
        SET_TEXT_POS_FROM_MARKER (startp, w->start);
        /* In case the hook functions switch buffers.  */
***************
*** 9479,9490 ****
    struct glyph_matrix *matrix;
    struct glyph_row *row;
    int window_height;
!   
    /* It's not always possible to find the cursor, e.g, when a window
       is full of overlay strings.  Don't do anything in that case.  */
    if (w->cursor.vpos < 0)
      return 1;
!   
    matrix = w->desired_matrix;
    row = MATRIX_ROW (matrix, w->cursor.vpos);
  
--- 9480,9491 ----
    struct glyph_matrix *matrix;
    struct glyph_row *row;
    int window_height;
! 
    /* It's not always possible to find the cursor, e.g, when a window
       is full of overlay strings.  Don't do anything in that case.  */
    if (w->cursor.vpos < 0)
      return 1;
! 
    matrix = w->desired_matrix;
    row = MATRIX_ROW (matrix, w->cursor.vpos);
  
***************
*** 9513,9519 ****
        w->cursor.y += dy;
        shift_glyph_matrix (w, matrix, 0, matrix->nrows, dy);
      }
!   
    /* When we change the cursor y-position of the selected window,
       change this_line_y as well so that the display optimization for
       the cursor line of the selected window in redisplay_internal uses
--- 9514,9520 ----
        w->cursor.y += dy;
        shift_glyph_matrix (w, matrix, 0, matrix->nrows, dy);
      }
! 
    /* When we change the cursor y-position of the selected window,
       change this_line_y as well so that the display optimization for
       the cursor line of the selected window in redisplay_internal uses
***************
*** 9542,9550 ****
     Value is
  
     1  if scrolling succeeded
!     
     0  if scrolling didn't find point.
!    
     -1 if new fonts have been loaded so that we must interrupt
     redisplay, adjust glyph matrices, and try again.  */
  
--- 9543,9551 ----
     Value is
  
     1  if scrolling succeeded
! 
     0  if scrolling didn't find point.
! 
     -1 if new fonts have been loaded so that we must interrupt
     redisplay, adjust glyph matrices, and try again.  */
  
***************
*** 9583,9589 ****
  #endif
  
    SET_TEXT_POS_FROM_MARKER (startp, w->start);
!   
    /* Compute scroll margin height in pixels.  We scroll when point is
       within this distance from the top or bottom of the window.  */
    if (scroll_margin > 0)
--- 9584,9590 ----
  #endif
  
    SET_TEXT_POS_FROM_MARKER (startp, w->start);
! 
    /* Compute scroll margin height in pixels.  We scroll when point is
       within this distance from the top or bottom of the window.  */
    if (scroll_margin > 0)
***************
*** 9625,9631 ****
    if (PT >= CHARPOS (scroll_margin_pos))
      {
        int y0;
!       
        /* Point is in the scroll margin at the bottom of the window, or
         below.  Compute a new window start that makes point visible.  */
  
--- 9626,9632 ----
    if (PT >= CHARPOS (scroll_margin_pos))
      {
        int y0;
! 
        /* Point is in the scroll margin at the bottom of the window, or
         below.  Compute a new window start that makes point visible.  */
  
***************
*** 9640,9649 ****
         down so that the line the cursor is in is visible, which
         means we have to add in the height of the cursor line.  */
        dy = line_bottom_y (&it) - y0;
!       
        if (dy > scroll_max)
        return SCROLLING_FAILED;
!       
        /* Move the window start down.  If scrolling conservatively,
         move it just enough down to make point visible.  If
         scroll_step is set, move it down by scroll_step.  */
--- 9641,9650 ----
         down so that the line the cursor is in is visible, which
         means we have to add in the height of the cursor line.  */
        dy = line_bottom_y (&it) - y0;
! 
        if (dy > scroll_max)
        return SCROLLING_FAILED;
! 
        /* Move the window start down.  If scrolling conservatively,
         move it just enough down to make point visible.  If
         scroll_step is set, move it down by scroll_step.  */
***************
*** 9687,9693 ****
          /* Point is in the scroll margin at the top of the window or
             above what is displayed in the window.  */
          int y0;
!         
          /* Compute the vertical distance from PT to the scroll
             margin position.  Give up if distance is greater than
             scroll_max.  */
--- 9688,9694 ----
          /* Point is in the scroll margin at the top of the window or
             above what is displayed in the window.  */
          int y0;
! 
          /* Compute the vertical distance from PT to the scroll
             margin position.  Give up if distance is greater than
             scroll_max.  */
***************
*** 9700,9709 ****
          dy = it.current_y - y0;
          if (dy > scroll_max)
            return SCROLLING_FAILED;
!         
          /* Compute new window start.  */
          start_display (&it, w, startp);
!         
          if (scroll_conservatively)
            amount_to_scroll =
              max (dy, CANON_Y_UNIT (f) * max (scroll_step, temp_scroll_step));
--- 9701,9710 ----
          dy = it.current_y - y0;
          if (dy > scroll_max)
            return SCROLLING_FAILED;
! 
          /* Compute new window start.  */
          start_display (&it, w, startp);
! 
          if (scroll_conservatively)
            amount_to_scroll =
              max (dy, CANON_Y_UNIT (f) * max (scroll_step, temp_scroll_step));
***************
*** 9720,9726 ****
  
          if (amount_to_scroll <= 0)
            return SCROLLING_FAILED;
!         
          move_it_vertically (&it, - amount_to_scroll);
          startp = it.current.pos;
        }
--- 9721,9727 ----
  
          if (amount_to_scroll <= 0)
            return SCROLLING_FAILED;
! 
          move_it_vertically (&it, - amount_to_scroll);
          startp = it.current.pos;
        }
***************
*** 9741,9751 ****
    else
      {
        /* Maybe forget recorded base line for line number display.  */
!       if (!just_this_one_p 
          || current_buffer->clip_changed
          || BEG_UNCHANGED < CHARPOS (startp))
        w->base_line_number = Qnil;
!       
        /* If cursor ends up on a partially visible line, shift display
         lines up or down.  If that fails because we need larger
         matrices, give up.  */
--- 9742,9752 ----
    else
      {
        /* Maybe forget recorded base line for line number display.  */
!       if (!just_this_one_p
          || current_buffer->clip_changed
          || BEG_UNCHANGED < CHARPOS (startp))
        w->base_line_number = Qnil;
! 
        /* If cursor ends up on a partially visible line, shift display
         lines up or down.  If that fails because we need larger
         matrices, give up.  */
***************
*** 9777,9783 ****
    SET_TEXT_POS_FROM_MARKER (start_pos, w->start);
  
    /* If window start is on a continuation line...  Window start may be
!      < BEGV in case there's invisible text at the start of the 
       buffer (M-x rmail, for example).  */
    if (CHARPOS (start_pos) > BEGV
        && FETCH_BYTE (BYTEPOS (start_pos) - 1) != '\n')
--- 9778,9784 ----
    SET_TEXT_POS_FROM_MARKER (start_pos, w->start);
  
    /* If window start is on a continuation line...  Window start may be
!      < BEGV in case there's invisible text at the start of the
       buffer (M-x rmail, for example).  */
    if (CHARPOS (start_pos) > BEGV
        && FETCH_BYTE (BYTEPOS (start_pos) - 1) != '\n')
***************
*** 9790,9796 ****
        SET_TEXT_POS (start_pos, BEGV, BEGV_BYTE);
        else if (CHARPOS (start_pos) > ZV)
        SET_TEXT_POS (start_pos, ZV, ZV_BYTE);
!       
        /* Find the start of the continued line.  This should be fast
         because scan_buffer is fast (newline cache).  */
        row = w->desired_matrix->rows + (WINDOW_WANTS_HEADER_LINE_P (w) ? 1 : 
0);
--- 9791,9797 ----
        SET_TEXT_POS (start_pos, BEGV, BEGV_BYTE);
        else if (CHARPOS (start_pos) > ZV)
        SET_TEXT_POS (start_pos, ZV, ZV_BYTE);
! 
        /* Find the start of the continued line.  This should be fast
         because scan_buffer is fast (newline cache).  */
        row = w->desired_matrix->rows + (WINDOW_WANTS_HEADER_LINE_P (w) ? 1 : 
0);
***************
*** 9804,9810 ****
          < XFASTINT (w->height) * XFASTINT (w->width))
        {
          int min_distance, distance;
!         
          /* Move forward by display lines to find the new window
             start.  If window width was enlarged, the new start can
             be expected to be > the old start.  If window width was
--- 9805,9811 ----
          < XFASTINT (w->height) * XFASTINT (w->width))
        {
          int min_distance, distance;
! 
          /* Move forward by display lines to find the new window
             start.  If window width was enlarged, the new start can
             be expected to be > the old start.  If window width was
***************
*** 9820,9832 ****
              pos = it.current.pos;
              move_it_by_lines (&it, 1, 0);
            }
!         
          /* Set the window start there.  */
          SET_MARKER_FROM_TEXT_POS (w->start, pos);
          window_start_changed_p = 1;
        }
      }
!   
    return window_start_changed_p;
  }
  
--- 9821,9833 ----
              pos = it.current.pos;
              move_it_by_lines (&it, 1, 0);
            }
! 
          /* Set the window start there.  */
          SET_MARKER_FROM_TEXT_POS (w->start, pos);
          window_start_changed_p = 1;
        }
      }
! 
    return window_start_changed_p;
  }
  
***************
*** 9835,9841 ****
     with window start STARTP.  Value is
  
     CURSOR_MOVEMENT_SUCCESS if successful
!    
     CURSOR_MOVEMENT_CANNOT_BE_USED if this method cannot be used
  
     CURSOR_MOVEMENT_MUST_SCROLL if we know we have to scroll the
--- 9836,9842 ----
     with window start STARTP.  Value is
  
     CURSOR_MOVEMENT_SUCCESS if successful
! 
     CURSOR_MOVEMENT_CANNOT_BE_USED if this method cannot be used
  
     CURSOR_MOVEMENT_MUST_SCROLL if we know we have to scroll the
***************
*** 9846,9852 ****
     which case we have to abort this redisplay, and adjust matrices
     first.  */
  
! enum 
  {
    CURSOR_MOVEMENT_SUCCESS,
    CURSOR_MOVEMENT_CANNOT_BE_USED,
--- 9847,9853 ----
     which case we have to abort this redisplay, and adjust matrices
     first.  */
  
! enum
  {
    CURSOR_MOVEMENT_SUCCESS,
    CURSOR_MOVEMENT_CANNOT_BE_USED,
***************
*** 9863,9869 ****
    struct window *w = XWINDOW (window);
    struct frame *f = XFRAME (w->frame);
    int rc = CURSOR_MOVEMENT_CANNOT_BE_USED;
!   
  #if GLYPH_DEBUG
    if (inhibit_try_cursor_movement)
      return rc;
--- 9864,9870 ----
    struct window *w = XWINDOW (window);
    struct frame *f = XFRAME (w->frame);
    int rc = CURSOR_MOVEMENT_CANNOT_BE_USED;
! 
  #if GLYPH_DEBUG
    if (inhibit_try_cursor_movement)
      return rc;
***************
*** 9882,9888 ****
        && !update_mode_lines
        && !windows_or_buffers_changed
        && !cursor_type_changed
!       /* Can't use this case if highlighting a region.  When a 
           region exists, cursor movement has to do more than just
           set the cursor.  */
        && !(!NILP (Vtransient_mark_mode)
--- 9883,9889 ----
        && !update_mode_lines
        && !windows_or_buffers_changed
        && !cursor_type_changed
!       /* Can't use this case if highlighting a region.  When a
           region exists, cursor movement has to do more than just
           set the cursor.  */
        && !(!NILP (Vtransient_mark_mode)
***************
*** 9940,9946 ****
        {
          int scroll_p = 0;
          int last_y = window_text_bottom_y (w) - this_scroll_margin;
!         
          if (PT > XFASTINT (w->last_point))
            {
              /* Point has moved forward.  */
--- 9941,9947 ----
        {
          int scroll_p = 0;
          int last_y = window_text_bottom_y (w) - this_scroll_margin;
! 
          if (PT > XFASTINT (w->last_point))
            {
              /* Point has moved forward.  */
***************
*** 10008,10014 ****
                     && MATRIX_ROW_END_CHARPOS (row) == PT
                     && !cursor_row_p (w, row))
                ++row;
!         
              /* If within the scroll margin, scroll.  */
              if (row->y < this_scroll_margin
                  && CHARPOS (startp) != BEGV)
--- 10009,10015 ----
                     && MATRIX_ROW_END_CHARPOS (row) == PT
                     && !cursor_row_p (w, row))
                ++row;
! 
              /* If within the scroll margin, scroll.  */
              if (row->y < this_scroll_margin
                  && CHARPOS (startp) != BEGV)
***************
*** 10094,10101 ****
    specbind (Qinhibit_point_motion_hooks, Qt);
  
    reconsider_clip_changes (w, buffer);
!     
!   /* Has the mode line to be updated?  */ 
    update_mode_line = (!NILP (w->update_mode_line)
                      || update_mode_lines
                      || buffer->clip_changed);
--- 10095,10102 ----
    specbind (Qinhibit_point_motion_hooks, Qt);
  
    reconsider_clip_changes (w, buffer);
! 
!   /* Has the mode line to be updated?  */
    update_mode_line = (!NILP (w->update_mode_line)
                      || update_mode_lines
                      || buffer->clip_changed);
***************
*** 10152,10158 ****
         window start in case the window's width changed.  */
        if (XMARKER (w->start)->buffer == current_buffer)
        compute_window_start_on_continuation_line (w);
!       
        w->window_end_valid = Qnil;
      }
  
--- 10153,10159 ----
         window start in case the window's width changed.  */
        if (XMARKER (w->start)->buffer == current_buffer)
        compute_window_start_on_continuation_line (w);
! 
        w->window_end_valid = Qnil;
      }
  
***************
*** 10170,10177 ****
        && !(PT == XFASTINT (w->last_point)
           && XFASTINT (w->last_modified) >= MODIFF
           && XFASTINT (w->last_overlay_modified) >= OVERLAY_MODIFF)
!       && XFASTINT (w->column_number_displayed) != current_column ())
!     update_mode_line = 1; 
  
    /* Count number of windows showing the selected buffer.  An indirect
       buffer counts as its base buffer.  */
--- 10171,10179 ----
        && !(PT == XFASTINT (w->last_point)
           && XFASTINT (w->last_modified) >= MODIFF
           && XFASTINT (w->last_overlay_modified) >= OVERLAY_MODIFF)
!       && (XFASTINT (w->column_number_displayed)
!           != (int) current_column ()))  /* iftc */
!     update_mode_line = 1;
  
    /* Count number of windows showing the selected buffer.  An indirect
       buffer counts as its base buffer.  */
***************
*** 10206,10212 ****
          new_pt_byte = ZV_BYTE;
          set_marker_both (w->pointm, Qnil, ZV, ZV_BYTE);
        }
!       
        /* We don't use SET_PT so that the point-motion hooks don't run.  */
        TEMP_SET_PT_BOTH (new_pt, new_pt_byte);
      }
--- 10208,10214 ----
          new_pt_byte = ZV_BYTE;
          set_marker_both (w->pointm, Qnil, ZV, ZV_BYTE);
        }
! 
        /* We don't use SET_PT so that the point-motion hooks don't run.  */
        TEMP_SET_PT_BOTH (new_pt, new_pt_byte);
      }
***************
*** 10278,10292 ****
          w->update_mode_line = Qt;
          startp = run_window_scroll_functions (window, startp);
        }
!       
        w->last_modified = make_number (0);
        w->last_overlay_modified = make_number (0);
        if (CHARPOS (startp) < BEGV)
        SET_TEXT_POS (startp, BEGV, BEGV_BYTE);
        else if (CHARPOS (startp) > ZV)
        SET_TEXT_POS (startp, ZV, ZV_BYTE);
!       
!       /* Redisplay, then check if cursor has been set during the 
         redisplay.  Give up if new fonts were loaded.  */
        if (!try_window (window, startp))
        {
--- 10280,10294 ----
          w->update_mode_line = Qt;
          startp = run_window_scroll_functions (window, startp);
        }
! 
        w->last_modified = make_number (0);
        w->last_overlay_modified = make_number (0);
        if (CHARPOS (startp) < BEGV)
        SET_TEXT_POS (startp, BEGV, BEGV_BYTE);
        else if (CHARPOS (startp) > ZV)
        SET_TEXT_POS (startp, ZV, ZV_BYTE);
! 
!       /* Redisplay, then check if cursor has been set during the
         redisplay.  Give up if new fonts were loaded.  */
        if (!try_window (window, startp))
        {
***************
*** 10317,10323 ****
            SET_TEXT_POS (lpoint, PT, PT_BYTE);
  
          set_cursor_from_row (w, row, w->desired_matrix, 0, 0, 0, 0);
!         
          /* If we are highlighting the region, then we just changed
             the region, so redisplay to show it.  */
          if (!NILP (Vtransient_mark_mode)
--- 10319,10325 ----
            SET_TEXT_POS (lpoint, PT, PT_BYTE);
  
          set_cursor_from_row (w, row, w->desired_matrix, 0, 0, 0, 0);
! 
          /* If we are highlighting the region, then we just changed
             the region, so redisplay to show it.  */
          if (!NILP (Vtransient_mark_mode)
***************
*** 10347,10359 ****
        {
        case CURSOR_MOVEMENT_SUCCESS:
          goto done;
!         
        case CURSOR_MOVEMENT_NEED_LARGER_MATRICES:
          goto need_larger_matrices;
!         
        case CURSOR_MOVEMENT_MUST_SCROLL:
          goto try_to_scroll;
!         
        default:
          abort ();
        }
--- 10349,10361 ----
        {
        case CURSOR_MOVEMENT_SUCCESS:
          goto done;
! 
        case CURSOR_MOVEMENT_NEED_LARGER_MATRICES:
          goto need_larger_matrices;
! 
        case CURSOR_MOVEMENT_MUST_SCROLL:
          goto try_to_scroll;
! 
        default:
          abort ();
        }
***************
*** 10369,10375 ****
  #endif
        goto recenter;
      }
!   
    /* Try scrolling with try_window_id.  Value is > 0 if update has
       been done, it is -1 if we know that the same window start will
       not work.  It is 0 if unsuccessful for some other reason.  */
--- 10371,10377 ----
  #endif
        goto recenter;
      }
! 
    /* Try scrolling with try_window_id.  Value is > 0 if update has
       been done, it is -1 if we know that the same window start will
       not work.  It is 0 if unsuccessful for some other reason.  */
***************
*** 10399,10405 ****
  #if GLYPH_DEBUG
        debug_method_add (w, "same window start");
  #endif
!       
        /* Try to redisplay starting at same place as before.
           If point has not moved off frame, accept the results.  */
        if (!current_matrix_up_to_date_p
--- 10401,10407 ----
  #if GLYPH_DEBUG
        debug_method_add (w, "same window start");
  #endif
! 
        /* Try to redisplay starting at same place as before.
           If point has not moved off frame, accept the results.  */
        if (!current_matrix_up_to_date_p
***************
*** 10416,10430 ****
  
        if (fonts_changed_p)
        goto need_larger_matrices;
!       
        if (w->cursor.vpos >= 0)
        {
!         if (!just_this_one_p 
              || current_buffer->clip_changed
              || BEG_UNCHANGED < CHARPOS (startp))
            /* Forget any recorded base line for line number display.  */
            w->base_line_number = Qnil;
!         
          if (!make_cursor_line_fully_visible (w))
            goto need_larger_matrices;
          goto done;
--- 10418,10432 ----
  
        if (fonts_changed_p)
        goto need_larger_matrices;
! 
        if (w->cursor.vpos >= 0)
        {
!         if (!just_this_one_p
              || current_buffer->clip_changed
              || BEG_UNCHANGED < CHARPOS (startp))
            /* Forget any recorded base line for line number display.  */
            w->base_line_number = Qnil;
! 
          if (!make_cursor_line_fully_visible (w))
            goto need_larger_matrices;
          goto done;
***************
*** 10452,10458 ****
         || NUMBERP (current_buffer->scroll_up_aggressively)
         || NUMBERP (current_buffer->scroll_down_aggressively))
        && !current_buffer->clip_changed
!       && CHARPOS (startp) >= BEGV 
        && CHARPOS (startp) <= ZV)
      {
        /* The function returns -1 if new fonts were loaded, 1 if
--- 10454,10460 ----
         || NUMBERP (current_buffer->scroll_up_aggressively)
         || NUMBERP (current_buffer->scroll_down_aggressively))
        && !current_buffer->clip_changed
!       && CHARPOS (startp) >= BEGV
        && CHARPOS (startp) <= ZV)
      {
        /* The function returns -1 if new fonts were loaded, 1 if
***************
*** 10465,10477 ****
        {
        case SCROLLING_SUCCESS:
          goto done;
!         
        case SCROLLING_NEED_LARGER_MATRICES:
          goto need_larger_matrices;
!         
        case SCROLLING_FAILED:
          break;
!         
        default:
          abort ();
        }
--- 10467,10479 ----
        {
        case SCROLLING_SUCCESS:
          goto done;
! 
        case SCROLLING_NEED_LARGER_MATRICES:
          goto need_larger_matrices;
! 
        case SCROLLING_FAILED:
          break;
! 
        default:
          abort ();
        }
***************
*** 10512,10518 ****
      }
  
    it.current_x = it.hpos = 0;
!   
    /* Set startp here explicitly in case that helps avoid an infinite loop
       in case the window-scroll-functions functions get errors.  */
    set_marker_both (w->start, Qnil, IT_CHARPOS (it), IT_BYTEPOS (it));
--- 10514,10520 ----
      }
  
    it.current_x = it.hpos = 0;
! 
    /* Set startp here explicitly in case that helps avoid an infinite loop
       in case the window-scroll-functions functions get errors.  */
    set_marker_both (w->start, Qnil, IT_CHARPOS (it), IT_BYTEPOS (it));
***************
*** 10575,10581 ****
        ++row;
        set_cursor_from_row (w, row, w->current_matrix, 0, 0, 0, 0);
      }
!   
    if (!make_cursor_line_fully_visible (w))
      goto need_larger_matrices;
  
--- 10577,10583 ----
        ++row;
        set_cursor_from_row (w, row, w->current_matrix, 0, 0, 0, 0);
      }
! 
    if (!make_cursor_line_fully_visible (w))
      goto need_larger_matrices;
  
***************
*** 10589,10605 ****
    /* Display the mode line, if we must.  */
    if ((update_mode_line
         /* If window not full width, must redo its mode line
!         if (a) the window to its side is being redone and 
          (b) we do a frame-based redisplay.  This is a consequence
          of how inverted lines are drawn in frame-based redisplay.  */
!        || (!just_this_one_p 
           && !FRAME_WINDOW_P (f)
           && !WINDOW_FULL_WIDTH_P (w))
         /* Line number to display.  */
         || INTEGERP (w->base_line_pos)
         /* Column number is displayed and different from the one displayed.  */
         || (!NILP (w->column_number_displayed)
!          && XFASTINT (w->column_number_displayed) != current_column ()))
         /* This means that the window has a mode line.  */
         && (WINDOW_WANTS_MODELINE_P (w)
           || WINDOW_WANTS_HEADER_LINE_P (w)))
--- 10591,10608 ----
    /* Display the mode line, if we must.  */
    if ((update_mode_line
         /* If window not full width, must redo its mode line
!         if (a) the window to its side is being redone and
          (b) we do a frame-based redisplay.  This is a consequence
          of how inverted lines are drawn in frame-based redisplay.  */
!        || (!just_this_one_p
           && !FRAME_WINDOW_P (f)
           && !WINDOW_FULL_WIDTH_P (w))
         /* Line number to display.  */
         || INTEGERP (w->base_line_pos)
         /* Column number is displayed and different from the one displayed.  */
         || (!NILP (w->column_number_displayed)
!          && (XFASTINT (w->column_number_displayed)
!                != (int) current_column ()))) /* iftc */
         /* This means that the window has a mode line.  */
         && (WINDOW_WANTS_MODELINE_P (w)
           || WINDOW_WANTS_HEADER_LINE_P (w)))
***************
*** 10615,10621 ****
          MATRIX_MODE_LINE_ROW (w->current_matrix)->height
            = DESIRED_MODE_LINE_HEIGHT (w);
        }
!       
        /* If top line height has changed, arrange for a thorough
         immediate redisplay using the correct mode line height.  */
        if (WINDOW_WANTS_HEADER_LINE_P (w)
--- 10618,10624 ----
          MATRIX_MODE_LINE_ROW (w->current_matrix)->height
            = DESIRED_MODE_LINE_HEIGHT (w);
        }
! 
        /* If top line height has changed, arrange for a thorough
         immediate redisplay using the correct mode line height.  */
        if (WINDOW_WANTS_HEADER_LINE_P (w)
***************
*** 10638,10644 ****
      }
  
   finish_menu_bars:
!   
    /* When we reach a frame's selected window, redo the frame's menu bar.  */
    if (update_mode_line
        && EQ (FRAME_SELECTED_WINDOW (f), window))
--- 10641,10647 ----
      }
  
   finish_menu_bars:
! 
    /* When we reach a frame's selected window, redo the frame's menu bar.  */
    if (update_mode_line
        && EQ (FRAME_SELECTED_WINDOW (f), window))
***************
*** 10692,10700 ****
             moment, we'll pretend it is.  */
          end = (Z - XFASTINT (w->window_end_pos)) - BEGV;
  
!         if (end < start) 
            end = start;
!         if (whole < (end - start)) 
            whole = end - start;
        }
        else
--- 10695,10703 ----
             moment, we'll pretend it is.  */
          end = (Z - XFASTINT (w->window_end_pos)) - BEGV;
  
!         if (end < start)
            end = start;
!         if (whole < (end - start))
            whole = end - start;
        }
        else
***************
*** 10775,10781 ****
        w->window_end_bytepos = 0;
        w->window_end_pos = w->window_end_vpos = make_number (0);
      }
!   
    /* But that is not valid info until redisplay finishes.  */
    w->window_end_valid = Qnil;
    return 1;
--- 10778,10784 ----
        w->window_end_bytepos = 0;
        w->window_end_pos = w->window_end_vpos = make_number (0);
      }
! 
    /* But that is not valid info until redisplay finishes.  */
    w->window_end_valid = Qnil;
    return 1;
***************
*** 10846,10856 ****
  
    /* Clear the desired matrix for the display below.  */
    clear_glyph_matrix (w->desired_matrix);
!   
    if (CHARPOS (new_start) <= CHARPOS (start))
      {
        int first_row_y;
!       
        /* Don't use this method if the display starts with an ellipsis
         displayed for invisible text.  It's not easy to handle that case
         below, and it's certainly not worth the effort since this is
--- 10849,10859 ----
  
    /* Clear the desired matrix for the display below.  */
    clear_glyph_matrix (w->desired_matrix);
! 
    if (CHARPOS (new_start) <= CHARPOS (start))
      {
        int first_row_y;
! 
        /* Don't use this method if the display starts with an ellipsis
         displayed for invisible text.  It's not easy to handle that case
         below, and it's certainly not worth the effort since this is
***************
*** 10859,10865 ****
        return 0;
  
        IF_DEBUG (debug_method_add (w, "twu1"));
!       
        /* Display up to a row that can be reused.  The variable
         last_text_row is set to the last row displayed that displays
         text.  Note that it.vpos == 0 if or if not there is a
--- 10862,10868 ----
        return 0;
  
        IF_DEBUG (debug_method_add (w, "twu1"));
! 
        /* Display up to a row that can be reused.  The variable
         last_text_row is set to the last row displayed that displays
         text.  Note that it.vpos == 0 if or if not there is a
***************
*** 10868,10874 ****
        first_row_y = it.current_y;
        w->cursor.vpos = -1;
        last_text_row = last_reused_text_row = NULL;
!       
        while (it.current_y < it.last_visible_y
             && IT_CHARPOS (it) < CHARPOS (start)
             && !fonts_changed_p)
--- 10871,10877 ----
        first_row_y = it.current_y;
        w->cursor.vpos = -1;
        last_text_row = last_reused_text_row = NULL;
! 
        while (it.current_y < it.last_visible_y
             && IT_CHARPOS (it) < CHARPOS (start)
             && !fonts_changed_p)
***************
*** 10882,10893 ****
        {
          /* IT.vpos always starts from 0; it counts text lines.  */
          nrows_scrolled = it.vpos;
!         
          /* Find PT if not already found in the lines displayed.  */
          if (w->cursor.vpos < 0)
            {
              int dy = it.current_y - first_row_y;
!             
              row = MATRIX_FIRST_TEXT_ROW (w->current_matrix);
              row = row_containing_pos (w, PT, row, NULL, dy);
              if (row)
--- 10885,10896 ----
        {
          /* IT.vpos always starts from 0; it counts text lines.  */
          nrows_scrolled = it.vpos;
! 
          /* Find PT if not already found in the lines displayed.  */
          if (w->cursor.vpos < 0)
            {
              int dy = it.current_y - first_row_y;
! 
              row = MATRIX_FIRST_TEXT_ROW (w->current_matrix);
              row = row_containing_pos (w, PT, row, NULL, dy);
              if (row)
***************
*** 10926,10932 ****
                         start_vpos,
                         MATRIX_ROW_VPOS (bottom_row, w->current_matrix),
                         nrows_scrolled);
!         
          /* Disable lines that must be updated.  */
          for (i = 0; i < it.vpos; ++i)
            (start_row + i)->enabled_p = 0;
--- 10929,10935 ----
                         start_vpos,
                         MATRIX_ROW_VPOS (bottom_row, w->current_matrix),
                         nrows_scrolled);
! 
          /* Disable lines that must be updated.  */
          for (i = 0; i < it.vpos; ++i)
            (start_row + i)->enabled_p = 0;
***************
*** 10945,10951 ****
                row->visible_height -= min_y - row->y;
              if (row->y + row->height > max_y)
                row->visible_height -= row->y + row->height - max_y;
!             
              it.current_y += row->height;
  
              if (MATRIX_ROW_DISPLAYS_TEXT_P (row))
--- 10948,10954 ----
                row->visible_height -= min_y - row->y;
              if (row->y + row->height > max_y)
                row->visible_height -= row->y + row->height - max_y;
! 
              it.current_y += row->height;
  
              if (MATRIX_ROW_DISPLAYS_TEXT_P (row))
***************
*** 10953,10959 ****
              if (MATRIX_ROW_BOTTOM_Y (row) >= it.last_visible_y)
                break;
            }
!         
          /* Disable lines in the current matrix which are now
             below the window.  */
          for (++row; row < bottom_row; ++row)
--- 10956,10962 ----
              if (MATRIX_ROW_BOTTOM_Y (row) >= it.last_visible_y)
                break;
            }
! 
          /* Disable lines in the current matrix which are now
             below the window.  */
          for (++row; row < bottom_row; ++row)
***************
*** 10993,10999 ****
  
        /* Update hint: don't try scrolling again in update_window.  */
        w->desired_matrix->no_scrolling_p = 1;
!       
  #if GLYPH_DEBUG
        debug_method_add (w, "try_window_reusing_current_matrix 1");
  #endif
--- 10996,11002 ----
  
        /* Update hint: don't try scrolling again in update_window.  */
        w->desired_matrix->no_scrolling_p = 1;
! 
  #if GLYPH_DEBUG
        debug_method_add (w, "try_window_reusing_current_matrix 1");
  #endif
***************
*** 11080,11086 ****
        run.desired_y = WINDOW_DISPLAY_HEADER_LINE_HEIGHT (w);
        run.height = it.last_visible_y - run.current_y;
        dy = run.current_y - run.desired_y;
!       
        if (run.height)
        {
          struct frame *f = XFRAME (WINDOW_FRAME (w));
--- 11083,11089 ----
        run.desired_y = WINDOW_DISPLAY_HEADER_LINE_HEIGHT (w);
        run.height = it.last_visible_y - run.current_y;
        dy = run.current_y - run.desired_y;
! 
        if (run.height)
        {
          struct frame *f = XFRAME (WINDOW_FRAME (w));
***************
*** 11134,11140 ****
          w->window_end_vpos
            = make_number (XFASTINT (w->window_end_vpos) - nrows_scrolled);
        }
!       
        w->window_end_valid = Qnil;
        w->desired_matrix->no_scrolling_p = 1;
  
--- 11137,11143 ----
          w->window_end_vpos
            = make_number (XFASTINT (w->window_end_vpos) - nrows_scrolled);
        }
! 
        w->window_end_valid = Qnil;
        w->desired_matrix->no_scrolling_p = 1;
  
***************
*** 11143,11149 ****
  #endif
        return 1;
      }
!   
    return 0;
  }
  
--- 11146,11152 ----
  #endif
        return 1;
      }
! 
    return 0;
  }
  
***************
*** 11187,11193 ****
        break;
        ++row;
      }
!   
    return row_found;
  }
  
--- 11190,11196 ----
        break;
        ++row;
      }
! 
    return row_found;
  }
  
***************
*** 11232,11238 ****
        /* Stop if last visible row.  */
       if (MATRIX_ROW_BOTTOM_Y (row) >= yb)
        break;
!       
        ++row;
      }
  
--- 11235,11241 ----
        /* Stop if last visible row.  */
       if (MATRIX_ROW_BOTTOM_Y (row) >= yb)
        break;
! 
        ++row;
      }
  
***************
*** 11241,11257 ****
  
  
  /* Find the first glyph row in the current matrix of W that is not
!    affected by changes at the end of current_buffer since the 
     time W's current matrix was built.
  
     Return in *DELTA the number of chars by which buffer positions in
     unchanged text at the end of current_buffer must be adjusted.
!    
     Return in *DELTA_BYTES the corresponding number of bytes.
  
     Value is null if no such row exists, i.e. all rows are affected by
     changes.  */
!    
  static struct glyph_row *
  find_first_unchanged_at_end_row (w, delta, delta_bytes)
       struct window *w;
--- 11244,11260 ----
  
  
  /* Find the first glyph row in the current matrix of W that is not
!    affected by changes at the end of current_buffer since the
     time W's current matrix was built.
  
     Return in *DELTA the number of chars by which buffer positions in
     unchanged text at the end of current_buffer must be adjusted.
! 
     Return in *DELTA_BYTES the corresponding number of bytes.
  
     Value is null if no such row exists, i.e. all rows are affected by
     changes.  */
! 
  static struct glyph_row *
  find_first_unchanged_at_end_row (w, delta, delta_bytes)
       struct window *w;
***************
*** 11266,11272 ****
       is not up to date.  */
    if (NILP (w->window_end_valid))
      abort ();
!   
    /* A value of window_end_pos >= END_UNCHANGED means that the window
       end is in the range of changed text.  If so, there is no
       unchanged row at the end of W's current matrix.  */
--- 11269,11275 ----
       is not up to date.  */
    if (NILP (w->window_end_valid))
      abort ();
! 
    /* A value of window_end_pos >= END_UNCHANGED means that the window
       end is in the range of changed text.  If so, there is no
       unchanged row at the end of W's current matrix.  */
***************
*** 11275,11282 ****
  
    /* Set row to the last row in W's current matrix displaying text.  */
    row = MATRIX_ROW (w->current_matrix, XFASTINT (w->window_end_vpos));
!   
!   /* If matrix is entirely empty, no unchanged row exists.  */ 
    if (MATRIX_ROW_DISPLAYS_TEXT_P (row))
      {
        /* The value of row is the last glyph row in the matrix having a
--- 11278,11285 ----
  
    /* Set row to the last row in W's current matrix displaying text.  */
    row = MATRIX_ROW (w->current_matrix, XFASTINT (w->window_end_vpos));
! 
!   /* If matrix is entirely empty, no unchanged row exists.  */
    if (MATRIX_ROW_DISPLAYS_TEXT_P (row))
      {
        /* The value of row is the last glyph row in the matrix having a
***************
*** 11301,11314 ****
         position.  */
        last_unchanged_pos = Z - END_UNCHANGED + BEG;
        last_unchanged_pos_old = last_unchanged_pos - *delta;
!       
        /* Search backward from ROW for a row displaying a line that
         starts at a minimum position >= last_unchanged_pos_old.  */
        for (; row > first_text_row; --row)
        {
          if (!row->enabled_p || !MATRIX_ROW_DISPLAYS_TEXT_P (row))
            abort ();
!         
          if (MATRIX_ROW_START_CHARPOS (row) >= last_unchanged_pos_old)
            row_found = row;
        }
--- 11304,11317 ----
         position.  */
        last_unchanged_pos = Z - END_UNCHANGED + BEG;
        last_unchanged_pos_old = last_unchanged_pos - *delta;
! 
        /* Search backward from ROW for a row displaying a line that
         starts at a minimum position >= last_unchanged_pos_old.  */
        for (; row > first_text_row; --row)
        {
          if (!row->enabled_p || !MATRIX_ROW_DISPLAYS_TEXT_P (row))
            abort ();
! 
          if (MATRIX_ROW_START_CHARPOS (row) >= last_unchanged_pos_old)
            row_found = row;
        }
***************
*** 11316,11322 ****
  
    if (row_found && !MATRIX_ROW_DISPLAYS_TEXT_P (row_found))
      abort ();
!   
    return row_found;
  }
  
--- 11319,11325 ----
  
    if (row_found && !MATRIX_ROW_DISPLAYS_TEXT_P (row_found))
      abort ();
! 
    return row_found;
  }
  
***************
*** 11361,11367 ****
         been disabled in try_window_id.  */
        if (!window_row->enabled_p)
        frame_row->enabled_p = 0;
!       
        ++window_row, ++frame_row;
      }
  }
--- 11364,11370 ----
         been disabled in try_window_id.  */
        if (!window_row->enabled_p)
        frame_row->enabled_p = 0;
! 
        ++window_row, ++frame_row;
      }
  }
***************
*** 11385,11396 ****
    /* If we happen to start on a header-line, skip that.  */
    if (row->mode_line_p)
      ++row;
!   
    if ((end && row >= end) || !row->enabled_p)
      return NULL;
!   
    last_y = window_text_bottom_y (w) - dy;
!       
    while ((end == NULL || row < end)
         && MATRIX_ROW_BOTTOM_Y (row) < last_y
         && (MATRIX_ROW_END_CHARPOS (row) < charpos
--- 11388,11399 ----
    /* If we happen to start on a header-line, skip that.  */
    if (row->mode_line_p)
      ++row;
! 
    if ((end && row >= end) || !row->enabled_p)
      return NULL;
! 
    last_y = window_text_bottom_y (w) - dy;
! 
    while ((end == NULL || row < end)
         && MATRIX_ROW_BOTTOM_Y (row) < last_y
         && (MATRIX_ROW_END_CHARPOS (row) < charpos
***************
*** 11402,11408 ****
                 && !row->ends_at_zv_p
                 && !MATRIX_ROW_ENDS_IN_MIDDLE_OF_CHAR_P (row))))
      ++row;
!       
    /* Give up if CHARPOS not found.  */
    if ((end && row >= end)
        || charpos < MATRIX_ROW_START_CHARPOS (row)
--- 11405,11411 ----
                 && !row->ends_at_zv_p
                 && !MATRIX_ROW_ENDS_IN_MIDDLE_OF_CHAR_P (row))))
      ++row;
! 
    /* Give up if CHARPOS not found.  */
    if ((end && row >= end)
        || charpos < MATRIX_ROW_START_CHARPOS (row)
***************
*** 11484,11501 ****
  #else
  #define GIVE_UP(X) return 0
  #endif
!   
    SET_TEXT_POS_FROM_MARKER (start, w->start);
  
    /* Don't use this for mini-windows because these can show
       messages and mini-buffers, and we don't handle that here.  */
    if (MINI_WINDOW_P (w))
      GIVE_UP (1);
!   
    /* This flag is used to prevent redisplay optimizations.  */
    if (windows_or_buffers_changed || cursor_type_changed)
      GIVE_UP (2);
!   
    /* Verify that narrowing has not changed.  This flag is also set to prevent
       redisplay optimizations.  It would be nice to further
       reduce the number of cases where this prevents try_window_id.  */
--- 11487,11504 ----
  #else
  #define GIVE_UP(X) return 0
  #endif
! 
    SET_TEXT_POS_FROM_MARKER (start, w->start);
  
    /* Don't use this for mini-windows because these can show
       messages and mini-buffers, and we don't handle that here.  */
    if (MINI_WINDOW_P (w))
      GIVE_UP (1);
! 
    /* This flag is used to prevent redisplay optimizations.  */
    if (windows_or_buffers_changed || cursor_type_changed)
      GIVE_UP (2);
! 
    /* Verify that narrowing has not changed.  This flag is also set to prevent
       redisplay optimizations.  It would be nice to further
       reduce the number of cases where this prevents try_window_id.  */
***************
*** 11515,11529 ****
    /* Another way to prevent redisplay optimizations.  */
    if (XFASTINT (w->last_modified) == 0)
      GIVE_UP (6);
!   
    /* Verify that window is not hscrolled.  */
    if (XFASTINT (w->hscroll) != 0)
      GIVE_UP (7);
!   
    /* Verify that display wasn't paused.  */
    if (NILP (w->window_end_valid))
      GIVE_UP (8);
!   
    /* Can't use this if highlighting a region because a cursor movement
       will do more than just set the cursor.  */
    if (!NILP (Vtransient_mark_mode)
--- 11518,11532 ----
    /* Another way to prevent redisplay optimizations.  */
    if (XFASTINT (w->last_modified) == 0)
      GIVE_UP (6);
! 
    /* Verify that window is not hscrolled.  */
    if (XFASTINT (w->hscroll) != 0)
      GIVE_UP (7);
! 
    /* Verify that display wasn't paused.  */
    if (NILP (w->window_end_valid))
      GIVE_UP (8);
! 
    /* Can't use this if highlighting a region because a cursor movement
       will do more than just set the cursor.  */
    if (!NILP (Vtransient_mark_mode)
***************
*** 11533,11549 ****
    /* Likewise if highlighting trailing whitespace.  */
    if (!NILP (Vshow_trailing_whitespace))
      GIVE_UP (11);
!   
    /* Likewise if showing a region.  */
    if (!NILP (w->region_showing))
      GIVE_UP (10);
!   
    /* Can use this if overlay arrow position and or string have changed.  */
    if (!EQ (last_arrow_position, COERCE_MARKER (Voverlay_arrow_position))
        || !EQ (last_arrow_string, Voverlay_arrow_string))
      GIVE_UP (12);
  
!   
    /* Make sure beg_unchanged and end_unchanged are up to date.  Do it
       only if buffer has really changed.  The reason is that the gap is
       initially at Z for freshly visited files.  The code below would
--- 11536,11552 ----
    /* Likewise if highlighting trailing whitespace.  */
    if (!NILP (Vshow_trailing_whitespace))
      GIVE_UP (11);
! 
    /* Likewise if showing a region.  */
    if (!NILP (w->region_showing))
      GIVE_UP (10);
! 
    /* Can use this if overlay arrow position and or string have changed.  */
    if (!EQ (last_arrow_position, COERCE_MARKER (Voverlay_arrow_position))
        || !EQ (last_arrow_string, Voverlay_arrow_string))
      GIVE_UP (12);
  
! 
    /* Make sure beg_unchanged and end_unchanged are up to date.  Do it
       only if buffer has really changed.  The reason is that the gap is
       initially at Z for freshly visited files.  The code below would
***************
*** 11583,11589 ****
        Z_BYTE_old = MATRIX_ROW_END_BYTEPOS (row) + w->window_end_bytepos;
        delta = Z - Z_old;
        delta_bytes = Z_BYTE - Z_BYTE_old;
!         
        /* Give up if PT is not in the window.  Note that it already has
         been checked at the start of try_window_id that PT is not in
         front of the window start.  */
--- 11586,11592 ----
        Z_BYTE_old = MATRIX_ROW_END_BYTEPOS (row) + w->window_end_bytepos;
        delta = Z - Z_old;
        delta_bytes = Z_BYTE - Z_BYTE_old;
! 
        /* Give up if PT is not in the window.  Note that it already has
         been checked at the start of try_window_id that PT is not in
         front of the window start.  */
***************
*** 11607,11613 ****
                                          MATRIX_ROW_VPOS (r1, current_matrix),
                                          delta, delta_bytes);
            }
!       
          /* Set the cursor.  */
          row = row_containing_pos (w, PT, r0, NULL, 0);
          set_cursor_from_row (w, row, current_matrix, 0, 0, 0, 0);
--- 11610,11616 ----
                                          MATRIX_ROW_VPOS (r1, current_matrix),
                                          delta, delta_bytes);
            }
! 
          /* Set the cursor.  */
          row = row_containing_pos (w, PT, r0, NULL, 0);
          set_cursor_from_row (w, row, current_matrix, 0, 0, 0, 0);
***************
*** 11654,11660 ****
      }
  
    /* Give up if window start is in the changed area.
!      
       The condition used to read
  
       (BEG_UNCHANGED + END_UNCHANGED != Z - BEG && ...)
--- 11657,11663 ----
      }
  
    /* Give up if window start is in the changed area.
! 
       The condition used to read
  
       (BEG_UNCHANGED + END_UNCHANGED != Z - BEG && ...)
***************
*** 11663,11669 ****
    if (CHARPOS (start) >= first_changed_charpos
        && CHARPOS (start) <= last_changed_charpos)
      GIVE_UP (15);
!   
    /* Check that window start agrees with the start of the first glyph
       row in its current matrix.  Check this after we know the window
       start is not in changed text, otherwise positions would not be
--- 11666,11672 ----
    if (CHARPOS (start) >= first_changed_charpos
        && CHARPOS (start) <= last_changed_charpos)
      GIVE_UP (15);
! 
    /* Check that window start agrees with the start of the first glyph
       row in its current matrix.  Check this after we know the window
       start is not in changed text, otherwise positions would not be
***************
*** 11702,11708 ****
        if (init_to_row_end (&it, w, last_unchanged_at_beg_row) == 0)
        GIVE_UP (18);
        start_pos = it.current.pos;
!       
        /* Start displaying new lines in the desired matrix at the same
         vpos we would use in the current matrix, i.e. below
         last_unchanged_at_beg_row.  */
--- 11705,11711 ----
        if (init_to_row_end (&it, w, last_unchanged_at_beg_row) == 0)
        GIVE_UP (18);
        start_pos = it.current.pos;
! 
        /* Start displaying new lines in the desired matrix at the same
         vpos we would use in the current matrix, i.e. below
         last_unchanged_at_beg_row.  */
***************
*** 11731,11737 ****
      = find_first_unchanged_at_end_row (w, &delta, &delta_bytes);
    IF_DEBUG (debug_delta = delta);
    IF_DEBUG (debug_delta_bytes = delta_bytes);
!   
    /* Set stop_pos to the buffer position up to which we will have to
       display new lines.  If first_unchanged_at_end_row != NULL, this
       is the buffer position of the start of the line displayed in that
--- 11734,11740 ----
      = find_first_unchanged_at_end_row (w, &delta, &delta_bytes);
    IF_DEBUG (debug_delta = delta);
    IF_DEBUG (debug_delta_bytes = delta_bytes);
! 
    /* Set stop_pos to the buffer position up to which we will have to
       display new lines.  If first_unchanged_at_end_row != NULL, this
       is the buffer position of the start of the line displayed in that
***************
*** 11742,11748 ****
      {
        xassert (last_unchanged_at_beg_row == NULL
               || first_unchanged_at_end_row >= last_unchanged_at_beg_row);
!       
        /* If this is a continuation line, move forward to the next one
         that isn't.  Changes in lines above affect this line.
         Caution: this may move first_unchanged_at_end_row to a row
--- 11745,11751 ----
      {
        xassert (last_unchanged_at_beg_row == NULL
               || first_unchanged_at_end_row >= last_unchanged_at_beg_row);
! 
        /* If this is a continuation line, move forward to the next one
         that isn't.  Changes in lines above affect this line.
         Caution: this may move first_unchanged_at_end_row to a row
***************
*** 11771,11792 ****
  
  
  #if GLYPH_DEBUG
!   
    /* Either there is no unchanged row at the end, or the one we have
       now displays text.  This is a necessary condition for the window
       end pos calculation at the end of this function.  */
    xassert (first_unchanged_at_end_row == NULL
           || MATRIX_ROW_DISPLAYS_TEXT_P (first_unchanged_at_end_row));
!   
    debug_last_unchanged_at_beg_vpos
      = (last_unchanged_at_beg_row
         ? MATRIX_ROW_VPOS (last_unchanged_at_beg_row, current_matrix)
         : -1);
    debug_first_unchanged_at_end_vpos = first_unchanged_at_end_vpos;
!   
  #endif /* GLYPH_DEBUG != 0 */
  
!   
    /* Display new lines.  Set last_text_row to the last new line
       displayed which has text on it, i.e. might end up as being the
       line where the window_end_vpos is.  */
--- 11774,11795 ----
  
  
  #if GLYPH_DEBUG
! 
    /* Either there is no unchanged row at the end, or the one we have
       now displays text.  This is a necessary condition for the window
       end pos calculation at the end of this function.  */
    xassert (first_unchanged_at_end_row == NULL
           || MATRIX_ROW_DISPLAYS_TEXT_P (first_unchanged_at_end_row));
! 
    debug_last_unchanged_at_beg_vpos
      = (last_unchanged_at_beg_row
         ? MATRIX_ROW_VPOS (last_unchanged_at_beg_row, current_matrix)
         : -1);
    debug_first_unchanged_at_end_vpos = first_unchanged_at_end_vpos;
! 
  #endif /* GLYPH_DEBUG != 0 */
  
! 
    /* Display new lines.  Set last_text_row to the last new line
       displayed which has text on it, i.e. might end up as being the
       line where the window_end_vpos is.  */
***************
*** 11868,11884 ****
          return -1;
        }
      }
!   
    /* Don't let the cursor end in the scroll margins.  */
    {
      int this_scroll_margin, cursor_height;
!     
      this_scroll_margin = max (0, scroll_margin);
      this_scroll_margin = min (this_scroll_margin,
                              XFASTINT (w->height) / 4);
      this_scroll_margin *= CANON_Y_UNIT (it.f);
      cursor_height = MATRIX_ROW (w->desired_matrix, w->cursor.vpos)->height;
!     
      if ((w->cursor.y < this_scroll_margin
         && CHARPOS (start) > BEGV)
        /* Don't take scroll margin into account at the bottom because
--- 11871,11887 ----
          return -1;
        }
      }
! 
    /* Don't let the cursor end in the scroll margins.  */
    {
      int this_scroll_margin, cursor_height;
! 
      this_scroll_margin = max (0, scroll_margin);
      this_scroll_margin = min (this_scroll_margin,
                              XFASTINT (w->height) / 4);
      this_scroll_margin *= CANON_Y_UNIT (it.f);
      cursor_height = MATRIX_ROW (w->desired_matrix, w->cursor.vpos)->height;
! 
      if ((w->cursor.y < this_scroll_margin
         && CHARPOS (start) > BEGV)
        /* Don't take scroll margin into account at the bottom because
***************
*** 11897,11903 ****
    if (dy && run.height)
      {
        update_begin (f);
!         
        if (FRAME_WINDOW_P (f))
        {
          rif->update_window_begin_hook (w);
--- 11900,11906 ----
    if (dy && run.height)
      {
        update_begin (f);
! 
        if (FRAME_WINDOW_P (f))
        {
          rif->update_window_begin_hook (w);
***************
*** 11915,11921 ****
          int end = (XFASTINT (w->top)
                     + (WINDOW_WANTS_HEADER_LINE_P (w) ? 1 : 0)
                     + window_internal_height (w));
!         
          /* Perform the operation on the screen.  */
          if (dvpos > 0)
            {
--- 11918,11924 ----
          int end = (XFASTINT (w->top)
                     + (WINDOW_WANTS_HEADER_LINE_P (w) ? 1 : 0)
                     + window_internal_height (w));
! 
          /* Perform the operation on the screen.  */
          if (dvpos > 0)
            {
***************
*** 11949,11958 ****
              if (!scroll_region_ok)
                ins_del_lines (end + dvpos, -dvpos);
            }
!         
          set_terminal_window (0);
        }
!       
        update_end (f);
      }
  
--- 11952,11961 ----
              if (!scroll_region_ok)
                ins_del_lines (end + dvpos, -dvpos);
            }
! 
          set_terminal_window (0);
        }
! 
        update_end (f);
      }
  
***************
*** 12033,12039 ****
         get the right continuation_lines_width and current_x.  */
        it.continuation_lines_width = last_row->continuation_lines_width;
        it.hpos = it.current_x = 0;
!       
        /* Display the rest of the lines at the window end.  */
        it.glyph_row = MATRIX_ROW (desired_matrix, it.vpos);
        while (it.current_y < it.last_visible_y
--- 12036,12042 ----
         get the right continuation_lines_width and current_x.  */
        it.continuation_lines_width = last_row->continuation_lines_width;
        it.hpos = it.current_x = 0;
! 
        /* Display the rest of the lines at the window end.  */
        it.glyph_row = MATRIX_ROW (desired_matrix, it.vpos);
        while (it.current_y < it.last_visible_y
***************
*** 12062,12068 ****
        row = find_last_row_displaying_text (w->current_matrix, &it,
                                           first_unchanged_at_end_row);
        xassert (row && MATRIX_ROW_DISPLAYS_TEXT_P (row));
!       
        w->window_end_pos = make_number (Z - MATRIX_ROW_END_CHARPOS (row));
        w->window_end_bytepos = Z_BYTE - MATRIX_ROW_END_BYTEPOS (row);
        w->window_end_vpos
--- 12065,12071 ----
        row = find_last_row_displaying_text (w->current_matrix, &it,
                                           first_unchanged_at_end_row);
        xassert (row && MATRIX_ROW_DISPLAYS_TEXT_P (row));
! 
        w->window_end_pos = make_number (Z - MATRIX_ROW_END_CHARPOS (row));
        w->window_end_bytepos = Z_BYTE - MATRIX_ROW_END_BYTEPOS (row);
        w->window_end_vpos
***************
*** 12263,12269 ****
      {
        fprintf (stderr, "Row Start   End Used oEI><O\\CTZFesm     X    Y    W  
  H    V    A    P\n");
        fprintf (stderr, 
"=======================================================================\n");
!   
        fprintf (stderr, "%3d %5d %5d %4d %1.1d%1.1d%1.1d%1.1d%1.1d\
  %1.1d%1.1d%1.1d%1.1d%1.1d%1.1d%1.1d%1.1d  %4d %4d %4d %4d %4d %4d %4d\n",
               vpos,
--- 12266,12272 ----
      {
        fprintf (stderr, "Row Start   End Used oEI><O\\CTZFesm     X    Y    W  
  H    V    A    P\n");
        fprintf (stderr, 
"=======================================================================\n");
! 
        fprintf (stderr, "%3d %5d %5d %4d %1.1d%1.1d%1.1d%1.1d%1.1d\
  %1.1d%1.1d%1.1d%1.1d%1.1d%1.1d%1.1d%1.1d  %4d %4d %4d %4d %4d %4d %4d\n",
               vpos,
***************
*** 12299,12305 ****
        fprintf (stderr, "%9d %5d\n", row->start.dpvec_index,
               row->end.dpvec_index);
      }
!   
    if (glyphs > 1)
      {
        int area;
--- 12302,12308 ----
        fprintf (stderr, "%9d %5d\n", row->start.dpvec_index,
               row->end.dpvec_index);
      }
! 
    if (glyphs > 1)
      {
        int area;
***************
*** 12308,12321 ****
        {
          struct glyph *glyph = row->glyphs[area];
          struct glyph *glyph_end = glyph + row->used[area];
!       
          /* Glyph for a line end in text.  */
          if (area == TEXT_AREA && glyph == glyph_end && glyph->charpos > 0)
            ++glyph_end;
!       
          if (glyph < glyph_end)
            fprintf (stderr, "  Glyph    Type Pos   O W    Code C Face LR\n");
!       
          for (; glyph < glyph_end; ++glyph)
            dump_glyph (row, glyph, area);
        }
--- 12311,12324 ----
        {
          struct glyph *glyph = row->glyphs[area];
          struct glyph *glyph_end = glyph + row->used[area];
! 
          /* Glyph for a line end in text.  */
          if (area == TEXT_AREA && glyph == glyph_end && glyph->charpos > 0)
            ++glyph_end;
! 
          if (glyph < glyph_end)
            fprintf (stderr, "  Glyph    Type Pos   O W    Code C Face LR\n");
! 
          for (; glyph < glyph_end; ++glyph)
            dump_glyph (row, glyph, area);
        }
***************
*** 12339,12345 ****
              else
                s[i] = '.';
            }
!       
          s[i] = '\0';
          fprintf (stderr, "%3d: (%d) '%s'\n", vpos, row->enabled_p, s);
        }
--- 12342,12348 ----
              else
                s[i] = '.';
            }
! 
          s[i] = '\0';
          fprintf (stderr, "%3d: (%d) '%s'\n", vpos, row->enabled_p, s);
        }
***************
*** 12390,12396 ****
  {
    struct glyph_matrix *matrix;
    int vpos;
!   
    CHECK_NUMBER (row);
    matrix = XWINDOW (selected_window)->current_matrix;
    vpos = XINT (row);
--- 12393,12399 ----
  {
    struct glyph_matrix *matrix;
    int vpos;
! 
    CHECK_NUMBER (row);
    matrix = XWINDOW (selected_window)->current_matrix;
    vpos = XINT (row);
***************
*** 12413,12419 ****
    struct frame *sf = SELECTED_FRAME ();
    struct glyph_matrix *m = XWINDOW (sf->tool_bar_window)->current_matrix;
    int vpos;
!   
    CHECK_NUMBER (row);
    vpos = XINT (row);
    if (vpos >= 0 && vpos < m->nrows)
--- 12416,12422 ----
    struct frame *sf = SELECTED_FRAME ();
    struct glyph_matrix *m = XWINDOW (sf->tool_bar_window)->current_matrix;
    int vpos;
! 
    CHECK_NUMBER (row);
    vpos = XINT (row);
    if (vpos >= 0 && vpos < m->nrows)
***************
*** 12436,12442 ****
        arg = Fprefix_numeric_value (arg);
        trace_redisplay_p = XINT (arg) > 0;
      }
!   
    return Qnil;
  }
  
--- 12439,12445 ----
        arg = Fprefix_numeric_value (arg);
        trace_redisplay_p = XINT (arg) > 0;
      }
! 
    return Qnil;
  }
  
***************
*** 12451,12457 ****
    fprintf (stderr, "%s", SDATA (s));
    return Qnil;
  }
!       
  #endif /* GLYPH_DEBUG */
  
  
--- 12454,12460 ----
    fprintf (stderr, "%s", SDATA (s));
    return Qnil;
  }
! 
  #endif /* GLYPH_DEBUG */
  
  
***************
*** 12488,12501 ****
    while (p < arrow_end)
      {
        Lisp_Object face, ilisp;
!       
        /* Get the next character.  */
        if (multibyte_p)
        it.c = string_char_and_length (p, arrow_len, &it.len);
        else
        it.c = *p, it.len = 1;
        p += it.len;
!       
        /* Get its face.  */
        ilisp = make_number (p - arrow_string);
        face = Fget_text_property (ilisp, Qface, Voverlay_arrow_string);
--- 12491,12504 ----
    while (p < arrow_end)
      {
        Lisp_Object face, ilisp;
! 
        /* Get the next character.  */
        if (multibyte_p)
        it.c = string_char_and_length (p, arrow_len, &it.len);
        else
        it.c = *p, it.len = 1;
        p += it.len;
! 
        /* Get its face.  */
        ilisp = make_number (p - arrow_string);
        face = Fget_text_property (ilisp, Qface, Voverlay_arrow_string);
***************
*** 12514,12520 ****
          break;
        }
      }
!   
    set_buffer_temp (old);
    return it.glyph_row;
  }
--- 12517,12523 ----
          break;
        }
      }
! 
    set_buffer_temp (old);
    return it.glyph_row;
  }
***************
*** 12544,12550 ****
    CHARPOS (truncate_it.position) = BYTEPOS (truncate_it.position) = -1;
    truncate_it.object = make_number (0);
    produce_special_glyphs (&truncate_it, IT_TRUNCATION);
!   
    /* Overwrite glyphs from IT with truncation glyphs.  */
    from = truncate_it.glyph_row->glyphs[TEXT_AREA];
    end = from + truncate_it.glyph_row->used[TEXT_AREA];
--- 12547,12553 ----
    CHARPOS (truncate_it.position) = BYTEPOS (truncate_it.position) = -1;
    truncate_it.object = make_number (0);
    produce_special_glyphs (&truncate_it, IT_TRUNCATION);
! 
    /* Overwrite glyphs from IT with truncation glyphs.  */
    from = truncate_it.glyph_row->glyphs[TEXT_AREA];
    end = from + truncate_it.glyph_row->used[TEXT_AREA];
***************
*** 12607,12613 ****
          row->phys_ascent = it->max_phys_ascent;
          row->phys_height = it->max_phys_ascent + it->max_phys_descent;
        }
!       
        /* Compute the width of this line.  */
        row->pixel_width = row->x;
        for (i = 0; i < row->used[TEXT_AREA]; ++i)
--- 12610,12616 ----
          row->phys_ascent = it->max_phys_ascent;
          row->phys_height = it->max_phys_ascent + it->max_phys_descent;
        }
! 
        /* Compute the width of this line.  */
        row->pixel_width = row->x;
        for (i = 0; i < row->used[TEXT_AREA]; ++i)
***************
*** 12631,12637 ****
  
        /* Compute how much of the line is visible.  */
        row->visible_height = row->height;
!       
        min_y = WINDOW_DISPLAY_HEADER_LINE_HEIGHT (it->w);
        max_y = WINDOW_DISPLAY_HEIGHT_NO_MODE_LINE (it->w);
  
--- 12634,12640 ----
  
        /* Compute how much of the line is visible.  */
        row->visible_height = row->height;
! 
        min_y = WINDOW_DISPLAY_HEADER_LINE_HEIGHT (it->w);
        max_y = WINDOW_DISPLAY_HEIGHT_NO_MODE_LINE (it->w);
  
***************
*** 12705,12711 ****
  
          saved_object = it->object;
          saved_pos = it->position;
!         
          it->what = IT_CHARACTER;
          bzero (&it->position, sizeof it->position);
          it->object = make_number (0);
--- 12708,12714 ----
  
          saved_object = it->object;
          saved_pos = it->position;
! 
          it->what = IT_CHARACTER;
          bzero (&it->position, sizeof it->position);
          it->object = make_number (0);
***************
*** 12720,12726 ****
          it->face_id = FACE_FOR_CHAR (it->f, face, 0);
  
          PRODUCE_GLYPHS (it);
!         
          it->current_x = saved_x;
          it->object = saved_object;
          it->position = saved_pos;
--- 12723,12729 ----
          it->face_id = FACE_FOR_CHAR (it->f, face, 0);
  
          PRODUCE_GLYPHS (it);
! 
          it->current_x = saved_x;
          it->object = saved_object;
          it->position = saved_pos;
***************
*** 12740,12746 ****
     to the end of the display line.  Called from display_line.
     If the glyph row is empty, add a space glyph to it so that we
     know the face to draw.  Set the glyph row flag fill_line_p.  */
!    
  static void
  extend_face_to_end_of_line (it)
       struct it *it;
--- 12743,12749 ----
     to the end of the display line.  Called from display_line.
     If the glyph row is empty, add a space glyph to it so that we
     know the face to draw.  Set the glyph row flag fill_line_p.  */
! 
  static void
  extend_face_to_end_of_line (it)
       struct it *it;
***************
*** 12751,12757 ****
    /* If line is already filled, do nothing.  */
    if (it->current_x >= it->last_visible_x)
      return;
!   
    /* Face extension extends the background and box of IT->face_id
       to the end of the line.  If the background equals the background
       of the frame, we don't have to do anything.  */
--- 12754,12760 ----
    /* If line is already filled, do nothing.  */
    if (it->current_x >= it->last_visible_x)
      return;
! 
    /* Face extension extends the background and box of IT->face_id
       to the end of the line.  If the background equals the background
       of the frame, we don't have to do anything.  */
***************
*** 12759,12765 ****
      face = FACE_FROM_ID (it->f, it->saved_face_id);
    else
      face = FACE_FROM_ID (f, it->face_id);
!   
    if (FRAME_WINDOW_P (f)
        && face->box == FACE_NO_BOX
        && face->background == FRAME_BACKGROUND_PIXEL (f)
--- 12762,12768 ----
      face = FACE_FROM_ID (it->f, it->saved_face_id);
    else
      face = FACE_FROM_ID (f, it->face_id);
! 
    if (FRAME_WINDOW_P (f)
        && face->box == FACE_NO_BOX
        && face->background == FRAME_BACKGROUND_PIXEL (f)
***************
*** 12801,12819 ****
  
        saved_object = it->object;
        saved_pos = it->position;
!   
        it->what = IT_CHARACTER;
        bzero (&it->position, sizeof it->position);
        it->object = make_number (0);
        it->c = ' ';
        it->len = 1;
        it->face_id = face->id;
!       
        PRODUCE_GLYPHS (it);
!       
        while (it->current_x <= it->last_visible_x)
        PRODUCE_GLYPHS (it);
!       
        /* Don't count these blanks really.  It would let us insert a left
         truncation glyph below and make us set the cursor on them, maybe.  */
        it->current_x = saved_x;
--- 12804,12822 ----
  
        saved_object = it->object;
        saved_pos = it->position;
! 
        it->what = IT_CHARACTER;
        bzero (&it->position, sizeof it->position);
        it->object = make_number (0);
        it->c = ' ';
        it->len = 1;
        it->face_id = face->id;
! 
        PRODUCE_GLYPHS (it);
! 
        while (it->current_x <= it->last_visible_x)
        PRODUCE_GLYPHS (it);
! 
        /* Don't count these blanks really.  It would let us insert a left
         truncation glyph below and make us set the cursor on them, maybe.  */
        it->current_x = saved_x;
***************
*** 12857,12863 ****
       struct glyph_row *row;
  {
    int used = row->used[TEXT_AREA];
!   
    if (used)
      {
        struct glyph *start = row->glyphs[TEXT_AREA];
--- 12860,12866 ----
       struct glyph_row *row;
  {
    int used = row->used[TEXT_AREA];
! 
    if (used)
      {
        struct glyph *start = row->glyphs[TEXT_AREA];
***************
*** 12883,12889 ****
          && trailing_whitespace_p (glyph->charpos))
        {
          int face_id = lookup_named_face (f, Qtrailing_whitespace, 0);
!         
          while (glyph >= start
                 && BUFFERP (glyph->object)
                 && (glyph->type == STRETCH_GLYPH
--- 12886,12892 ----
          && trailing_whitespace_p (glyph->charpos))
        {
          int face_id = lookup_named_face (f, Qtrailing_whitespace, 0);
! 
          while (glyph >= start
                 && BUFFERP (glyph->object)
                 && (glyph->type == STRETCH_GLYPH
***************
*** 12904,12910 ****
       struct glyph_row *row;
  {
    int cursor_row_p = 1;
!   
    if (PT == MATRIX_ROW_END_CHARPOS (row))
      {
        /* If the row ends with a newline from a string, we don't want
--- 12907,12913 ----
       struct glyph_row *row;
  {
    int cursor_row_p = 1;
! 
    if (PT == MATRIX_ROW_END_CHARPOS (row))
      {
        /* If the row ends with a newline from a string, we don't want
***************
*** 12931,12937 ****
     for an overview of struct it.  Value is non-zero if
     IT->glyph_row displays text, as opposed to a line displaying ZV
     only.  */
!    
  static int
  display_line (it)
       struct it *it;
--- 12934,12940 ----
     for an overview of struct it.  Value is non-zero if
     IT->glyph_row displays text, as opposed to a line displaying ZV
     only.  */
! 
  static int
  display_line (it)
       struct it *it;
***************
*** 13006,13012 ****
                      || (minibuf_level && EQ (it->window, minibuf_window))))
                row->indicate_empty_line_p = 1;
            }
!         
          it->continuation_lines_width = 0;
          row->ends_at_zv_p = 1;
          break;
--- 13009,13015 ----
                      || (minibuf_level && EQ (it->window, minibuf_window))))
                row->indicate_empty_line_p = 1;
            }
! 
          it->continuation_lines_width = 0;
          row->ends_at_zv_p = 1;
          break;
***************
*** 13026,13032 ****
          phys_ascent = it->max_phys_ascent;
          phys_descent = it->max_phys_descent;
        }
!       
        PRODUCE_GLYPHS (it);
  
        /* If this display element was in marginal areas, continue with
--- 13029,13035 ----
          phys_ascent = it->max_phys_ascent;
          phys_descent = it->max_phys_descent;
        }
! 
        PRODUCE_GLYPHS (it);
  
        /* If this display element was in marginal areas, continue with
***************
*** 13073,13079 ****
        {
          int new_x;
          struct glyph *glyph;
!         
          for (i = 0; i < nglyphs; ++i, x = new_x)
            {
              glyph = row->glyphs[TEXT_AREA] + n_glyphs_before + i;
--- 13076,13082 ----
        {
          int new_x;
          struct glyph *glyph;
! 
          for (i = 0; i < nglyphs; ++i, x = new_x)
            {
              glyph = row->glyphs[TEXT_AREA] + n_glyphs_before + i;
***************
*** 13088,13094 ****
                          && FRAME_WINDOW_P (it->f))))
                {
                  /* End of a continued line.  */
!                 
                  if (it->hpos == 0
                      || (new_x == it->last_visible_x
                          && FRAME_WINDOW_P (it->f)))
--- 13091,13097 ----
                          && FRAME_WINDOW_P (it->f))))
                {
                  /* End of a continued line.  */
! 
                  if (it->hpos == 0
                      || (new_x == it->last_visible_x
                          && FRAME_WINDOW_P (it->f)))
***************
*** 13111,13127 ****
                         This means the whole character doesn't fit
                         on the line.  */
                      row->used[TEXT_AREA] = n_glyphs_before;
!                 
                      /* Fill the rest of the row with continuation
                         glyphs like in 20.x.  */
                      while (row->glyphs[TEXT_AREA] + row->used[TEXT_AREA]
                             < row->glyphs[1 + TEXT_AREA])
                        produce_special_glyphs (it, IT_CONTINUATION);
!                     
                      row->continued_p = 1;
                      it->current_x = x_before;
                      it->continuation_lines_width += x_before;
!                     
                      /* Restore the height to what it was before the
                         element not fitting on the line.  */
                      it->max_ascent = ascent;
--- 13114,13130 ----
                         This means the whole character doesn't fit
                         on the line.  */
                      row->used[TEXT_AREA] = n_glyphs_before;
! 
                      /* Fill the rest of the row with continuation
                         glyphs like in 20.x.  */
                      while (row->glyphs[TEXT_AREA] + row->used[TEXT_AREA]
                             < row->glyphs[1 + TEXT_AREA])
                        produce_special_glyphs (it, IT_CONTINUATION);
! 
                      row->continued_p = 1;
                      it->current_x = x_before;
                      it->continuation_lines_width += x_before;
! 
                      /* Restore the height to what it was before the
                         element not fitting on the line.  */
                      it->max_ascent = ascent;
***************
*** 13148,13167 ****
                         the right edge of the window.  Restore
                         positions to values before the element.  */
                      row->used[TEXT_AREA] = n_glyphs_before + i;
!                 
                      /* Display continuation glyphs.  */
                      if (!FRAME_WINDOW_P (it->f))
                        produce_special_glyphs (it, IT_CONTINUATION);
                      row->continued_p = 1;
  
                      it->continuation_lines_width += x;
!                     
                      if (nglyphs > 1 && i > 0)
                        {
                          row->ends_in_middle_of_char_p = 1;
                          it->starts_in_middle_of_char_p = 1;
                        }
!                     
                      /* Restore the height to what it was before the
                         element not fitting on the line.  */
                      it->max_ascent = ascent;
--- 13151,13170 ----
                         the right edge of the window.  Restore
                         positions to values before the element.  */
                      row->used[TEXT_AREA] = n_glyphs_before + i;
! 
                      /* Display continuation glyphs.  */
                      if (!FRAME_WINDOW_P (it->f))
                        produce_special_glyphs (it, IT_CONTINUATION);
                      row->continued_p = 1;
  
                      it->continuation_lines_width += x;
! 
                      if (nglyphs > 1 && i > 0)
                        {
                          row->ends_in_middle_of_char_p = 1;
                          it->starts_in_middle_of_char_p = 1;
                        }
! 
                      /* Restore the height to what it was before the
                         element not fitting on the line.  */
                      it->max_ascent = ascent;
***************
*** 13176,13182 ****
                {
                  /* Increment number of glyphs actually displayed.  */
                  ++it->hpos;
!                 
                  if (x < it->first_visible_x)
                    /* Glyph is partially visible, i.e. row starts at
                       negative X position.  */
--- 13179,13185 ----
                {
                  /* Increment number of glyphs actually displayed.  */
                  ++it->hpos;
! 
                  if (x < it->first_visible_x)
                    /* Glyph is partially visible, i.e. row starts at
                       negative X position.  */
***************
*** 13191,13203 ****
                  abort ();
                }
            }
!         
          row->ascent = max (row->ascent, it->max_ascent);
          row->height = max (row->height, it->max_ascent + it->max_descent);
          row->phys_ascent = max (row->phys_ascent, it->max_phys_ascent);
          row->phys_height = max (row->phys_height,
                                  it->max_phys_ascent + it->max_phys_descent);
!         
          /* End of this display line if row is continued.  */
          if (row->continued_p)
            break;
--- 13194,13206 ----
                  abort ();
                }
            }
! 
          row->ascent = max (row->ascent, it->max_ascent);
          row->height = max (row->height, it->max_ascent + it->max_descent);
          row->phys_ascent = max (row->phys_ascent, it->max_phys_ascent);
          row->phys_height = max (row->phys_height,
                                  it->max_phys_ascent + it->max_phys_descent);
! 
          /* End of this display line if row is continued.  */
          if (row->continued_p)
            break;
***************
*** 13215,13235 ****
          /* Add a space at the end of the line that is used to
             display the cursor there.  */
          append_space (it, 0);
!         
          /* Extend the face to the end of the line.  */
          extend_face_to_end_of_line (it);
  
          /* Make sure we have the position.  */
          if (used_before == 0)
            row->glyphs[TEXT_AREA]->charpos = CHARPOS (it->position);
!         
          /* Consume the line end.  This skips over invisible lines.  */
          set_iterator_to_next (it, 1);
          it->continuation_lines_width = 0;
          break;
        }
  
!       /* Proceed with next display element.  Note that this skips 
         over lines invisible because of selective display.  */
        set_iterator_to_next (it, 1);
  
--- 13218,13238 ----
          /* Add a space at the end of the line that is used to
             display the cursor there.  */
          append_space (it, 0);
! 
          /* Extend the face to the end of the line.  */
          extend_face_to_end_of_line (it);
  
          /* Make sure we have the position.  */
          if (used_before == 0)
            row->glyphs[TEXT_AREA]->charpos = CHARPOS (it->position);
! 
          /* Consume the line end.  This skips over invisible lines.  */
          set_iterator_to_next (it, 1);
          it->continuation_lines_width = 0;
          break;
        }
  
!       /* Proceed with next display element.  Note that this skips
         over lines invisible because of selective display.  */
        set_iterator_to_next (it, 1);
  
***************
*** 13244,13250 ****
          if (!FRAME_WINDOW_P (it->f))
            {
              int i, n;
!             
              for (i = row->used[TEXT_AREA] - 1; i > 0; --i)
                if (!CHAR_GLYPH_PADDING_P (row->glyphs[TEXT_AREA][i]))
                  break;
--- 13247,13253 ----
          if (!FRAME_WINDOW_P (it->f))
            {
              int i, n;
! 
              for (i = row->used[TEXT_AREA] - 1; i > 0; --i)
                if (!CHAR_GLYPH_PADDING_P (row->glyphs[TEXT_AREA][i]))
                  break;
***************
*** 13255,13261 ****
                  produce_special_glyphs (it, IT_TRUNCATION);
                }
            }
!         
          row->truncated_on_right_p = 1;
          it->continuation_lines_width = 0;
          reseat_at_next_visible_line_start (it, 0);
--- 13258,13264 ----
                  produce_special_glyphs (it, IT_TRUNCATION);
                }
            }
! 
          row->truncated_on_right_p = 1;
          it->continuation_lines_width = 0;
          reseat_at_next_visible_line_start (it, 0);
***************
*** 13312,13318 ****
              row->used[TEXT_AREA] = p2 - row->glyphs[TEXT_AREA];
            }
        }
!       
        overlay_arrow_seen = 1;
        row->overlay_arrow_p = 1;
      }
--- 13315,13321 ----
              row->used[TEXT_AREA] = p2 - row->glyphs[TEXT_AREA];
            }
        }
! 
        overlay_arrow_seen = 1;
        row->overlay_arrow_p = 1;
      }
***************
*** 13355,13361 ****
  
     The menu bar of X frames that don't have X toolkit support is
     displayed in a special window W->frame->menu_bar_window.
!    
     The menu bar of terminal frames is treated specially as far as
     glyph matrices are concerned.  Menu bar lines are not part of
     windows, so the update is done directly on the frame matrix rows
--- 13358,13364 ----
  
     The menu bar of X frames that don't have X toolkit support is
     displayed in a special window W->frame->menu_bar_window.
! 
     The menu bar of terminal frames is treated specially as far as
     glyph matrices are concerned.  Menu bar lines are not part of
     windows, so the update is done directly on the frame matrix rows
***************
*** 13471,13481 ****
       int force;
  {
    int nwindows = 0;
!   
    while (!NILP (window))
      {
        struct window *w = XWINDOW (window);
!       
        if (WINDOWP (w->hchild))
        nwindows += redisplay_mode_lines (w->hchild, force);
        else if (WINDOWP (w->vchild))
--- 13474,13484 ----
       int force;
  {
    int nwindows = 0;
! 
    while (!NILP (window))
      {
        struct window *w = XWINDOW (window);
! 
        if (WINDOWP (w->hchild))
        nwindows += redisplay_mode_lines (w->hchild, force);
        else if (WINDOWP (w->vchild))
***************
*** 13490,13502 ****
          /* Set the window's buffer for the mode line display.  */
          SET_TEXT_POS (lpoint, PT, PT_BYTE);
          set_buffer_internal_1 (XBUFFER (w->buffer));
!         
          /* Point refers normally to the selected window.  For any
             other window, set up appropriate value.  */
          if (!EQ (window, selected_window))
            {
              struct text_pos pt;
!             
              SET_TEXT_POS_FROM_MARKER (pt, w->pointm);
              if (CHARPOS (pt) < BEGV)
                TEMP_SET_PT_BOTH (BEGV, BEGV_BYTE);
--- 13493,13505 ----
          /* Set the window's buffer for the mode line display.  */
          SET_TEXT_POS (lpoint, PT, PT_BYTE);
          set_buffer_internal_1 (XBUFFER (w->buffer));
! 
          /* Point refers normally to the selected window.  For any
             other window, set up appropriate value.  */
          if (!EQ (window, selected_window))
            {
              struct text_pos pt;
! 
              SET_TEXT_POS_FROM_MARKER (pt, w->pointm);
              if (CHARPOS (pt) < BEGV)
                TEMP_SET_PT_BOTH (BEGV, BEGV_BYTE);
***************
*** 13540,13546 ****
    selected_frame = w->frame;
    old_selected_window = selected_window;
    XSETWINDOW (selected_window, w);
!   
    /* These will be set while the mode line specs are processed.  */
    line_number_displayed = 0;
    w->column_number_displayed = Qnil;
--- 13543,13549 ----
    selected_frame = w->frame;
    old_selected_window = selected_window;
    XSETWINDOW (selected_window, w);
! 
    /* These will be set while the mode line specs are processed.  */
    line_number_displayed = 0;
    w->column_number_displayed = Qnil;
***************
*** 13554,13560 ****
                         current_buffer->mode_line_format);
        ++n;
      }
!   
    if (WINDOW_WANTS_HEADER_LINE_P (w))
      {
        display_mode_line (w, HEADER_LINE_FACE_ID,
--- 13557,13563 ----
                         current_buffer->mode_line_format);
        ++n;
      }
! 
    if (WINDOW_WANTS_HEADER_LINE_P (w))
      {
        display_mode_line (w, HEADER_LINE_FACE_ID,
***************
*** 13598,13604 ****
  
    /* Fill up with spaces.  */
    display_string (" ", Qnil, Qnil, 0, 0, &it, 10000, -1, -1, 0);
!   
    compute_line_metrics (&it);
    it.glyph_row->full_width_p = 1;
    it.glyph_row->mode_line_p = 1;
--- 13601,13607 ----
  
    /* Fill up with spaces.  */
    display_string (" ", Qnil, Qnil, 0, 0, &it, 10000, -1, -1, 0);
! 
    compute_line_metrics (&it);
    it.glyph_row->full_width_p = 1;
    it.glyph_row->mode_line_p = 1;
***************
*** 13640,13646 ****
  
     PROPS is a property list to add to any string we encounter.
  
!    If RISKY is nonzero, remove (disregard) any properties in any string 
     we encounter, and ignore :eval and :propertize.  */
  
  static int
--- 13643,13649 ----
  
     PROPS is a property list to add to any string we encounter.
  
!    If RISKY is nonzero, remove (disregard) any properties in any string
     we encounter, and ignore :eval and :propertize.  */
  
  static int
***************
*** 13745,13751 ****
            /* Advance to end of string or next format specifier.  */
            while ((c = *this++) != '\0' && c != '%')
              ;
!           
            if (this - 1 != last)
              {
                /* Output to end of string or up to '%'.  Field width
--- 13748,13754 ----
            /* Advance to end of string or next format specifier.  */
            while ((c = *this++) != '\0' && c != '%')
              ;
! 
            if (this - 1 != last)
              {
                /* Output to end of string or up to '%'.  Field width
***************
*** 13756,13762 ****
                prec = chars_in_text (last, this - last);
                if (precision > 0 && prec > precision - n)
                  prec = precision - n;
!               
                if (frame_title_ptr)
                  n += store_frame_title (last, 0, prec);
                else
--- 13759,13765 ----
                prec = chars_in_text (last, this - last);
                if (precision > 0 && prec > precision - n)
                  prec = precision - n;
! 
                if (frame_title_ptr)
                  n += store_frame_title (last, 0, prec);
                else
***************
*** 13771,13777 ****
            else /* c == '%' */
              {
                unsigned char *percent_position = this;
!               
                /* Get the specified minimum width.  Zero means
                   don't pad.  */
                field = 0;
--- 13774,13780 ----
            else /* c == '%' */
              {
                unsigned char *percent_position = this;
! 
                /* Get the specified minimum width.  Zero means
                   don't pad.  */
                field = 0;
***************
*** 13784,13790 ****
  
                /* Note that either PRECISION <= 0 or N < PRECISION.  */
                prec = precision - n;
!               
                if (c == 'M')
                  n += display_mode_element (it, depth, field, prec,
                                             Vglobal_mode_string, props,
--- 13787,13793 ----
  
                /* Note that either PRECISION <= 0 or N < PRECISION.  */
                prec = precision - n;
! 
                if (c == 'M')
                  n += display_mode_element (it, depth, field, prec,
                                             Vglobal_mode_string, props,
***************
*** 13794,13800 ****
                    int multibyte;
                    int bytepos, charpos;
                    unsigned char *spec;
!                       
                    bytepos = percent_position - lisp_string;
                    charpos = (STRING_MULTIBYTE (elt)
                               ? string_byte_to_char (elt, bytepos)
--- 13797,13803 ----
                    int multibyte;
                    int bytepos, charpos;
                    unsigned char *spec;
! 
                    bytepos = percent_position - lisp_string;
                    charpos = (STRING_MULTIBYTE (elt)
                               ? string_byte_to_char (elt, bytepos)
***************
*** 13808,13814 ****
                    else
                      {
                        int nglyphs_before, nwritten;
!                       
                        nglyphs_before = it->glyph_row->used[TEXT_AREA];
                        nwritten = display_string (spec, Qnil, elt,
                                                   charpos, 0, it,
--- 13811,13817 ----
                    else
                      {
                        int nglyphs_before, nwritten;
! 
                        nglyphs_before = it->glyph_row->used[TEXT_AREA];
                        nwritten = display_string (spec, Qnil, elt,
                                                   charpos, 0, it,
***************
*** 13830,13836 ****
                                glyph[i].object = elt;
                                glyph[i].charpos = charpos;
                              }
!                           
                            n += nwritten;
                          }
                      }
--- 13833,13839 ----
                                glyph[i].object = elt;
                                glyph[i].charpos = charpos;
                              }
! 
                            n += nwritten;
                          }
                      }
***************
*** 14008,14014 ****
        n += display_string ("", Qnil, Qnil, 0, 0, it, field_width - n,
                             0, 0, 0);
      }
!   
    return n;
  }
  
--- 14011,14017 ----
        n += display_string ("", Qnil, Qnil, 0, 0, it, field_width - n,
                             0, 0, 0);
      }
! 
    return n;
  }
  
***************
*** 14023,14029 ****
       register int d;
  {
    register char *p = buf;
!   
    if (d <= 0)
      *p++ = '0';
    else
--- 14026,14032 ----
       register int d;
  {
    register char *p = buf;
! 
    if (d <= 0)
      *p++ = '0';
    else
***************
*** 14034,14040 ****
          d /= 10;
        }
      }
!   
    for (width -= (int) (p - buf); width > 0; --width)
      *p++ = ' ';
    *p-- = '\0';
--- 14037,14043 ----
          d /= 10;
        }
      }
! 
    for (width -= (int) (p - buf); width > 0; --width)
      *p++ = ' ';
    *p-- = '\0';
***************
*** 14100,14106 ****
                          ? eol_mnemonic_dos : eol_mnemonic_mac));
        }
      }
!   
    if (eol_flag)
      {
        /* Mention the EOL conversion if it is not the usual one.  */
--- 14103,14109 ----
                          ? eol_mnemonic_dos : eol_mnemonic_mac));
        }
      }
! 
    if (eol_flag)
      {
        /* Mention the EOL conversion if it is not the usual one.  */
***************
*** 14176,14182 ****
      case '%':
        return "%";
  
!     case '[': 
        {
        int i;
        char *p;
--- 14179,14185 ----
      case '%':
        return "%";
  
!     case '[':
        {
        int i;
        char *p;
***************
*** 14190,14196 ****
        return decode_mode_spec_buf;
        }
  
!     case ']': 
        {
        int i;
        char *p;
--- 14193,14199 ----
        return decode_mode_spec_buf;
        }
  
!     case ']':
        {
        int i;
        char *p;
***************
*** 14221,14233 ****
          return lots_of_dashes;
        }
  
!     case 'b': 
        obj = b->name;
        break;
  
      case 'c':
        {
!       int col = current_column ();
        w->column_number_displayed = make_number (col);
        pint2str (decode_mode_spec_buf, field_width, col);
        return decode_mode_spec_buf;
--- 14224,14236 ----
          return lots_of_dashes;
        }
  
!     case 'b':
        obj = b->name;
        break;
  
      case 'c':
        {
!       int col = (int) current_column (); /* iftc */
        w->column_number_displayed = make_number (col);
        pint2str (decode_mode_spec_buf, field_width, col);
        return decode_mode_spec_buf;
***************
*** 14241,14247 ****
        return (char *) SDATA (f->name);
        return "Emacs";
  
!     case 'f': 
        obj = b->filename;
        break;
  
--- 14244,14250 ----
        return (char *) SDATA (f->name);
        return "Emacs";
  
!     case 'f':
        obj = b->filename;
        break;
  
***************
*** 14253,14259 ****
        int nlines, junk;
        int height = XFASTINT (w->height);
  
!       /* If we decided that this buffer isn't suitable for line numbers, 
           don't forget that too fast.  */
        if (EQ (w->base_line_pos, w->buffer))
          goto no_value;
--- 14256,14262 ----
        int nlines, junk;
        int height = XFASTINT (w->height);
  
!       /* If we decided that this buffer isn't suitable for line numbers,
           don't forget that too fast.  */
        if (EQ (w->base_line_pos, w->buffer))
          goto no_value;
***************
*** 14319,14325 ****
                                          limit_byte,
                                          - (height * 2 + 30),
                                          &position);
!           /* If we couldn't find the lines we wanted within 
               line_number_display_limit_width chars per line,
               give up on line numbers for this window.  */
            if (position == limit_byte && limit == startpos - distance)
--- 14322,14328 ----
                                          limit_byte,
                                          - (height * 2 + 30),
                                          &position);
!           /* If we couldn't find the lines we wanted within
               line_number_display_limit_width chars per line,
               give up on line numbers for this window.  */
            if (position == limit_byte && limit == startpos - distance)
***************
*** 14357,14363 ****
        }
        break;
  
!     case 'm': 
        obj = b->mode_name;
        break;
  
--- 14360,14366 ----
        }
        break;
  
!     case 'm':
        obj = b->mode_name;
        break;
  
***************
*** 14617,14623 ****
     If STRING has fewer characters than FIELD_WIDTH, pad to the right
     with spaces.  If STRING has more characters, more than FIELD_WIDTH
     glyphs will be produced.  FIELD_WIDTH <= 0 means don't pad.
!    
     PRECISION is the maximum number of characters to output from
     STRING.  PRECISION < 0  means don't truncate the string.
  
--- 14620,14626 ----
     If STRING has fewer characters than FIELD_WIDTH, pad to the right
     with spaces.  If STRING has more characters, more than FIELD_WIDTH
     glyphs will be produced.  FIELD_WIDTH <= 0 means don't pad.
! 
     PRECISION is the maximum number of characters to output from
     STRING.  PRECISION < 0  means don't truncate the string.
  
***************
*** 14663,14669 ****
      {
        int endptr;
        struct face *face;
!       
        it->face_id
        = face_at_string_position (it->w, face_string, face_string_pos,
                                   0, it->region_beg_charpos,
--- 14666,14672 ----
      {
        int endptr;
        struct face *face;
! 
        it->face_id
        = face_at_string_position (it->w, face_string, face_string_pos,
                                   0, it->region_beg_charpos,
***************
*** 14712,14718 ****
        while (i < nglyphs)
        {
          struct glyph *glyph = row->glyphs[TEXT_AREA] + n_glyphs_before + i;
!         
          if (!it->truncate_lines_p
              && x + glyph->pixel_width > max_x)
            {
--- 14715,14721 ----
        while (i < nglyphs)
        {
          struct glyph *glyph = row->glyphs[TEXT_AREA] + n_glyphs_before + i;
! 
          if (!it->truncate_lines_p
              && x + glyph->pixel_width > max_x)
            {
***************
*** 14807,14813 ****
      }
  
    it->face_id = saved_face_id;
!   
    /* Value is number of columns displayed.  */
    return it->hpos - hpos_at_start;
  }
--- 14810,14816 ----
      }
  
    it->face_id = saved_face_id;
! 
    /* Value is number of columns displayed.  */
    return it->hpos - hpos_at_start;
  }
***************
*** 14828,14834 ****
       Lisp_Object list;
  {
    register Lisp_Object tail, proptail;
!   
    for (tail = list; CONSP (tail); tail = XCDR (tail))
      {
        register Lisp_Object tem;
--- 14831,14837 ----
       Lisp_Object list;
  {
    register Lisp_Object tail, proptail;
! 
    for (tail = list; CONSP (tail); tail = XCDR (tail))
      {
        register Lisp_Object tem;
***************
*** 14838,14844 ****
        if (CONSP (tem) && EQ (propval, XCAR (tem)))
        return NILP (XCDR (tem)) ? 1 : 2;
      }
!   
    if (CONSP (propval))
      {
        for (proptail = propval; CONSP (proptail); proptail = XCDR (proptail))
--- 14841,14847 ----
        if (CONSP (tem) && EQ (propval, XCAR (tem)))
        return NILP (XCDR (tem)) ? 1 : 2;
      }
! 
    if (CONSP (propval))
      {
        for (proptail = propval; CONSP (proptail); proptail = XCDR (proptail))
***************
*** 14856,14862 ****
            }
        }
      }
!   
    return 0;
  }
  
--- 14859,14865 ----
            }
        }
      }
! 
    return 0;
  }
  
***************
*** 14873,14879 ****
  
    Vmessage_stack = Qnil;
    staticpro (&Vmessage_stack);
!   
    Qinhibit_redisplay = intern ("inhibit-redisplay");
    staticpro (&Qinhibit_redisplay);
  
--- 14876,14882 ----
  
    Vmessage_stack = Qnil;
    staticpro (&Vmessage_stack);
! 
    Qinhibit_redisplay = intern ("inhibit-redisplay");
    staticpro (&Qinhibit_redisplay);
  
***************
*** 14910,14916 ****
  
    staticpro (&Qredisplay_end_trigger_functions);
    Qredisplay_end_trigger_functions = intern 
("redisplay-end-trigger-functions");
!   
    staticpro (&Qinhibit_point_motion_hooks);
    Qinhibit_point_motion_hooks = intern ("inhibit-point-motion-hooks");
  
--- 14913,14919 ----
  
    staticpro (&Qredisplay_end_trigger_functions);
    Qredisplay_end_trigger_functions = intern 
("redisplay-end-trigger-functions");
! 
    staticpro (&Qinhibit_point_motion_hooks);
    Qinhibit_point_motion_hooks = intern ("inhibit-point-motion-hooks");
  
***************
*** 14982,14988 ****
    last_arrow_string = Qnil;
    staticpro (&last_arrow_position);
    staticpro (&last_arrow_string);
!   
    echo_buffer[0] = echo_buffer[1] = Qnil;
    staticpro (&echo_buffer[0]);
    staticpro (&echo_buffer[1]);
--- 14985,14991 ----
    last_arrow_string = Qnil;
    staticpro (&last_arrow_position);
    staticpro (&last_arrow_string);
! 
    echo_buffer[0] = echo_buffer[1] = Qnil;
    staticpro (&echo_buffer[0]);
    staticpro (&echo_buffer[1]);
***************
*** 14996,15002 ****
  
    mode_line_proptrans_alist = Qnil;
    staticpro (&mode_line_proptrans_alist);
!   
    DEFVAR_LISP ("show-trailing-whitespace", &Vshow_trailing_whitespace,
      doc: /* Non-nil means highlight trailing whitespace.
  The face used for trailing whitespace is `trailing-whitespace'.  */);
--- 14999,15005 ----
  
    mode_line_proptrans_alist = Qnil;
    staticpro (&mode_line_proptrans_alist);
! 
    DEFVAR_LISP ("show-trailing-whitespace", &Vshow_trailing_whitespace,
      doc: /* Non-nil means highlight trailing whitespace.
  The face used for trailing whitespace is `trailing-whitespace'.  */);
***************
*** 15123,15136 ****
  and its new display-start position.  Note that the value of `window-end'
  is not valid when these functions are called.  */);
    Vwindow_scroll_functions = Qnil;
!   
    DEFVAR_BOOL ("auto-resize-tool-bars", &auto_resize_tool_bars_p,
      doc: /* *Non-nil means automatically resize tool-bars.
  This increases a tool-bar's height if not all tool-bar items are visible.
  It decreases a tool-bar's height when it would display blank lines
  otherwise.  */);
    auto_resize_tool_bars_p = 1;
!   
    DEFVAR_BOOL ("auto-raise-tool-bar-buttons", &auto_raise_tool_bar_buttons_p,
      doc: /* *Non-nil means raise tool-bar buttons when the mouse moves over 
them.  */);
    auto_raise_tool_bar_buttons_p = 1;
--- 15126,15139 ----
  and its new display-start position.  Note that the value of `window-end'
  is not valid when these functions are called.  */);
    Vwindow_scroll_functions = Qnil;
! 
    DEFVAR_BOOL ("auto-resize-tool-bars", &auto_resize_tool_bars_p,
      doc: /* *Non-nil means automatically resize tool-bars.
  This increases a tool-bar's height if not all tool-bar items are visible.
  It decreases a tool-bar's height when it would display blank lines
  otherwise.  */);
    auto_resize_tool_bars_p = 1;
! 
    DEFVAR_BOOL ("auto-raise-tool-bar-buttons", &auto_raise_tool_bar_buttons_p,
      doc: /* *Non-nil means raise tool-bar buttons when the mouse moves over 
them.  */);
    auto_raise_tool_bar_buttons_p = 1;
***************
*** 15184,15190 ****
      doc: /* *Non-nil means display a hollow cursor in non-selected windows.
  nil means don't display a cursor there.  */);
    cursor_in_non_selected_windows = 1;
!   
    DEFVAR_BOOL ("auto-hscroll-mode", &automatic_hscrolling_p,
      doc: /* *Non-nil means scroll the display automatically to make point 
visible.  */);
    automatic_hscrolling_p = 1;
--- 15187,15193 ----
      doc: /* *Non-nil means display a hollow cursor in non-selected windows.
  nil means don't display a cursor there.  */);
    cursor_in_non_selected_windows = 1;
! 
    DEFVAR_BOOL ("auto-hscroll-mode", &automatic_hscrolling_p,
      doc: /* *Non-nil means scroll the display automatically to make point 
visible.  */);
    automatic_hscrolling_p = 1;
***************
*** 15211,15222 ****
  Note that the lower bound for automatic hscrolling specified by `scroll-left'
  and `scroll-right' overrides this variable's effect.  */);
    Vhscroll_step = make_number (0);
!   
    DEFVAR_LISP ("image-types", &Vimage_types,
      doc: /* List of supported image types.
  Each element of the list is a symbol for a supported image type.  */);
    Vimage_types = Qnil;
!   
    DEFVAR_BOOL ("message-truncate-lines", &message_truncate_lines,
      doc: /* If non-nil, messages are truncated instead of resizing the echo 
area.
  Bind this around calls to `message' to let it take effect.  */);
--- 15214,15225 ----
  Note that the lower bound for automatic hscrolling specified by `scroll-left'
  and `scroll-right' overrides this variable's effect.  */);
    Vhscroll_step = make_number (0);
! 
    DEFVAR_LISP ("image-types", &Vimage_types,
      doc: /* List of supported image types.
  Each element of the list is a symbol for a supported image type.  */);
    Vimage_types = Qnil;
! 
    DEFVAR_BOOL ("message-truncate-lines", &message_truncate_lines,
      doc: /* If non-nil, messages are truncated instead of resizing the echo 
area.
  Bind this around calls to `message' to let it take effect.  */);
***************
*** 15226,15232 ****
      doc: /* Normal hook run for clicks on menu bar, before displaying a 
submenu.
  Can be used to update submenus whose contents should vary.  */);
    Vmenu_bar_update_hook = Qnil;
!   
    DEFVAR_BOOL ("inhibit-menubar-update", &inhibit_menubar_update,
      doc: /* Non-nil means don't update menu bars.  Internal use only.  */);
    inhibit_menubar_update = 0;
--- 15229,15235 ----
      doc: /* Normal hook run for clicks on menu bar, before displaying a 
submenu.
  Can be used to update submenus whose contents should vary.  */);
    Vmenu_bar_update_hook = Qnil;
! 
    DEFVAR_BOOL ("inhibit-menubar-update", &inhibit_menubar_update,
      doc: /* Non-nil means don't update menu bars.  Internal use only.  */);
    inhibit_menubar_update = 0;
***************
*** 15285,15291 ****
        scratch_glyph_row.glyphs[TEXT_AREA + 1]
        = scratch_glyphs + MAX_SCRATCH_GLYPHS;
  
!       /* The default ellipsis glyphs `...'.  */ 
        for (i = 0; i < 3; ++i)
        default_invis_vector[i] = make_number ('.');
      }
--- 15288,15294 ----
        scratch_glyph_row.glyphs[TEXT_AREA + 1]
        = scratch_glyphs + MAX_SCRATCH_GLYPHS;
  
!       /* The default ellipsis glyphs `...'.  */
        for (i = 0; i < 3; ++i)
        default_invis_vector[i] = make_number ('.');
      }
***************
*** 15299,15305 ****
      frame_title_ptr = NULL;
    }
  #endif /* HAVE_WINDOW_SYSTEM */
!   
    help_echo_showing_p = 0;
  }
  
--- 15302,15308 ----
      frame_title_ptr = NULL;
    }
  #endif /* HAVE_WINDOW_SYSTEM */
! 
    help_echo_showing_p = 0;
  }
  



reply via email to

[Prev in Thread] Current Thread [Next in Thread]