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

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

Re: Display problems with 'before-string in overlay


From: Chong Yidong
Subject: Re: Display problems with 'before-string in overlay
Date: Sat, 14 Apr 2007 19:26:47 -0400
User-agent: Gnus/5.11 (Gnus v5.11) Emacs/22.0.97 (gnu/linux)

address@hidden (Kim F. Storm) writes:

> (progn
>   (switch-to-buffer (get-buffer-create "*test*"))
>   (erase-buffer)
>   (insert ".\n<\n.\n>\n")
>   (goto-char (point-min))
>   (let ((ov (make-overlay 4 7)))
>       (overlay-put ov 'display "Ax\nyB"))
>   (goto-char (point-max)))
>
> With my change, moving the cursor places it on the 'A'.
> Without my change, moving the cursor places it on the 'y'.
> So my change may be incorrect - but it _does_ solve a real problem.

I think the following approach may work.

It reverts your cursor_row_p change, and deals with overlays
containing display properties by modifying adjust_point_for_property
so that one is never at the start of such an overlay (the behavior for
display text properties is left unchanged).  It doesn't deal with the
other issue I raised (i.e., the apparently false assumption in the way
set_cursor_from_row uses string_buffer_position).  However, dealing
with the opens up another can of worms, and the current patch seems
sufficient to provide good behavior for all cases I've tried.

Of course, redisplay can lead to some pretty subtle bugs.  It's still
debatable whether we want to make such a change at this stage.

*** emacs/src/xdisp.c.~1.1146.~ 2007-04-14 16:57:50.000000000 -0400
--- emacs/src/xdisp.c   2007-04-14 19:03:17.000000000 -0400
***************
*** 15854,15865 ****
    if (PT == MATRIX_ROW_END_CHARPOS (row))
      {
        /* If the row ends with a newline from a string, we don't want
!        the cursor there, but we still want it at the start of the
!        string if the string starts in this row.
         If the row is continued it doesn't end in a newline.  */
        if (CHARPOS (row->end.string_pos) >= 0)
!       cursor_row_p = (row->continued_p
!                       || PT >= MATRIX_ROW_START_CHARPOS (row));
        else if (MATRIX_ROW_ENDS_IN_MIDDLE_OF_CHAR_P (row))
        {
          /* If the row ends in middle of a real character,
--- 15854,15863 ----
    if (PT == MATRIX_ROW_END_CHARPOS (row))
      {
        /* If the row ends with a newline from a string, we don't want
!        the cursor there.
         If the row is continued it doesn't end in a newline.  */
        if (CHARPOS (row->end.string_pos) >= 0)
!       cursor_row_p = row->continued_p;
        else if (MATRIX_ROW_ENDS_IN_MIDDLE_OF_CHAR_P (row))
        {
          /* If the row ends in middle of a real character,
*** emacs/src/keyboard.c.~1.899.~       2007-04-14 16:26:52.000000000 -0400
--- emacs/src/keyboard.c        2007-04-14 19:22:33.000000000 -0400
***************
*** 2006,2027 ****
        }
        check_composition = 0;
        if (check_display
!         && PT > BEGV && PT < ZV
          && !NILP (val = get_char_property_and_overlay
                              (make_number (PT), Qdisplay, Qnil, &overlay))
!         && display_prop_intangible_p (val)
!         && (!OVERLAYP (overlay)
!             ? get_property_and_range (PT, Qdisplay, &val, &beg, &end, Qnil)
!             : (beg = OVERLAY_POSITION (OVERLAY_START (overlay)),
!                end = OVERLAY_POSITION (OVERLAY_END (overlay))))
!         && (beg < PT /* && end > PT   <- It's always the case.  */
!             || (beg <= PT && STRINGP (val) && SCHARS (val) == 0)))
!       {
!         xassert (end > PT);
!         SET_PT (PT < last_pt
!                 ? (STRINGP (val) && SCHARS (val) == 0 ? beg - 1 : beg)
!                 : end);
!         check_composition = check_invisible = 1;
        }
        check_display = 0;
        if (check_invisible && PT > BEGV && PT < ZV)
--- 2006,2041 ----
        }
        check_composition = 0;
        if (check_display
!         && PT >= BEGV && PT < ZV
          && !NILP (val = get_char_property_and_overlay
                              (make_number (PT), Qdisplay, Qnil, &overlay))
!         && display_prop_intangible_p (val))
!       {
!         if (OVERLAYP (overlay))
!           {
!             beg = OVERLAY_POSITION (OVERLAY_START (overlay));
!             end = OVERLAY_POSITION (OVERLAY_END (overlay));
!             if (beg <= PT)
!               {
!                 SET_PT (PT < last_pt
!                         ? (beg > BEGV) ? beg - 1 : end
!                         : end);
!                 check_composition = check_invisible = 1;
!               }
!           }
!         else if (PT > BEGV)
!           {
!             get_property_and_range (PT, Qdisplay, &val, &beg, &end, Qnil);
!             xassert (end > PT);
!             if ((beg < PT)
!                 || (beg == PT && STRINGP (val) && SCHARS (val) == 0))
!               {
!                 SET_PT (PT < last_pt
!                         ? (STRINGP (val) && SCHARS (val) == 0 ? beg - 1 : beg)
!                         : end);
!                 check_composition = check_invisible = 1;
!               }
!           }
        }
        check_display = 0;
        if (check_invisible && PT > BEGV && PT < ZV)





reply via email to

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