emacs-pretest-bug
[Top][All Lists]
Advanced

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

Re: line-spacing and (recenter -1)


From: Kim F. Storm
Subject: Re: line-spacing and (recenter -1)
Date: 17 Jun 2004 00:36:44 +0200
User-agent: Gnus/5.09 (Gnus v5.9.0) Emacs/21.3.50

SAITO Takuya <address@hidden> writes:

> (recenter -1) does not show point at the bottom of the window
> if line-spacing is set to positive integer.
> 
> Start emacs -Q, and evaluate below:
> 
> (progn
>   (setq line-spacing 1)
>   (dotimes (i (window-height))
>     (insert "\n" (int-to-string i)))
>   (recenter -1))
> 
> Then, point is displayed at the center of the window.
> But point should be displayed at the bottom of the window like Emacs-21.3.


Well, in 21.3, emacs automatically turns on window-vscroll to make the
last line visible, whereas CVS emacs doesn't do this, and consequently
fails to move the cursor line to the bottom of the screen (it happens to
be only partially visible, so CVS emacs will scroll by lines in this case).

This is caused by the following change:

2002-07-07  Richard M. Stallman  <address@hidden>

        * xdisp.c (make_cursor_line_fully_visible): Don't try short scrolls.
        Instead just return 0 when there is something to be done.
        (try_scrolling): If make_cursor_line_fully_visible returns 0,
        retry scrolling as if cursor were off the bottom.
        (try_cursor_movement): If make_cursor_line_fully_visible returns 0,
        return CURSOR_MOVEMENT_MUST_SCROLL.
        (redisplay_window): If make_cursor_line_fully_visible returns 0,
        go to try_to_scroll.



I don't know what error that change was supposed to fix, but it obviously
broke other things...   

Since I don't know that, I don't know how to fix this problem without
introducing other problems.  Maybe RMS will know how to fix this.


Here is the relevant function; notice the #if 0 section:


/* Make sure the line containing the cursor is fully visible.
   A value of 1 means there is nothing to be done.
   (Either the line is fully visible, or it cannot be made so,
   or we cannot tell.)

   If FORCE_P is non-zero, return 0 even if partial visible cursor row
   is higher than window.

   A value of 0 means the caller should do scrolling
   as if point had gone off the screen.  */

static int
make_cursor_line_fully_visible (w, force_p)
     struct window *w;
     int force_p;
{
  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);

  /* If the cursor row is not partially visible, there's nothing to do.  */
  if (!MATRIX_ROW_PARTIALLY_VISIBLE_P (row))
    return 1;

  /* If the row the cursor is in is taller than the window's height,
     it's not clear what to do, so do nothing.  */
  window_height = window_box_height (w);
  if (row->height >= window_height)
    {
      if (!force_p || w->vscroll)
        return 1;
    }
  return 0;

#if 0
  /* This code used to try to scroll the window just enough to make
     the line visible.  It returned 0 to say that the caller should
     allocate larger glyph matrices.  */

  if (MATRIX_ROW_PARTIALLY_VISIBLE_AT_TOP_P (w, row))
    {
      int dy = row->height - row->visible_height;
      w->vscroll = 0;
      w->cursor.y += dy;
      shift_glyph_matrix (w, matrix, 0, matrix->nrows, dy);
    }
  else /* MATRIX_ROW_PARTIALLY_VISIBLE_AT_BOTTOM_P (w, row)) */
    {
      int dy = - (row->height - row->visible_height);
      w->vscroll = dy;
      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
     the correct y-position.  */
  if (w == XWINDOW (selected_window))
    this_line_y = w->cursor.y;

  /* If vscrolling requires a larger glyph matrix, arrange for a fresh
     redisplay with larger matrices.  */
  if (matrix->nrows < required_matrix_height (w))
    {
      fonts_changed_p = 1;
      return 0;
    }

  return 1;
#endif /* 0 */
}


It is called from this code around line 11870 in xdisp.c:

      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, 1))
            {
              clear_glyph_matrix (w->desired_matrix);
              last_line_misfit = 1;
            }
            /* Drop through and scroll.  */
          else
            goto done;
        }

-- 
Kim F. Storm  http://www.cua.dk





reply via email to

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