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: Lennart Borgman (gmail)
Subject: Re: Display problems with 'before-string in overlay
Date: Fri, 13 Apr 2007 00:38:31 +0200
User-agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.0.10) Gecko/20070221 Thunderbird/1.5.0.10 Mnenhy/0.7.5.666

Chong Yidong wrote:
address@hidden (Kim F. Storm) writes:

IIRC, the original problem I tried to solve is shown by this test-case:

(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.

OK, now I see the problem.

I believe the underlying fault is not in cursor_row_p, but in
set_cursor_from_row, on xdisp.c:11948:

  pos = string_buffer_position (w, string, string_before_pos);
  /* If STRING is from overlay, LAST_POS == 0.  We skip such glyphs
     because we always put cursor after overlay strings.  */
  while (pos == 0 && glyph < stop)
    {
      string = glyph->object;

The assumption made in the comment is not correct:
string_buffer_position returns non-zero values for overlay strings
with the `display' property.  In xdisp.c:4446:

  prop = Fget_char_property (pos, Qdisplay, Qnil);
  if (!NILP (prop) && display_prop_string_p (prop, string))
    found = 1;

This suggests that the way to fix this is to change
string_buffer_position to do what that says.

I tested with !display_prop_string_p at the two places in string_buffer_position where it occurs. That does the correct thing in my case, but not in Kim's example AFAICS.

In Kim's example the cursor stops after the 'display part when moving char by char from left or right. It stays on that position for an extra left or right arrow.

Checking if the string is from 'display at the correct position in set_cursor_from_row could perhaps cure the problem. There is a test now for Qdisplay, but it looks like this test might be disabled by the while loop right above it which skips all overlays.


However, it is dangerous
to change string_buffer_position right now, because it's called from
several places in xdisp.c.  Changing its behavior runs a serious risk
of introducing subtle bugs.


Maybe. They are either in set_cursor_from_row or note_mouse_highlight.




reply via email to

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