+2011-09-28 Eli Zaretskii <eliz@gnu.org>
+
+ * xdisp.c (compute_display_string_end): If there's no display
+ string at CHARPOS, return -1.
+
+ * bidi.c (bidi_fetch_char): When compute_display_string_end
+ returns a negative value, treat the character as a normal
+ character not covered by a display string. (Bug#9624)
+
2011-09-28 Juanma Barranquero <lekktu@gmail.com>
* lread.c (Fread_from_string): Fix typo in docstring.
ch = 0xFFFC;
}
disp_end_pos = compute_display_string_end (*disp_pos, string);
+ if (disp_end_pos < 0)
+ {
+ /* Somebody removed the display string from the buffer
+ behind our back. Recover by processing this buffer
+ position as if no display property were present there to
+ begin with. */
+ *disp_prop = 0;
+ goto normal_char;
+ }
*nchars = disp_end_pos - *disp_pos;
if (*nchars <= 0)
abort ();
}
else
{
+ normal_char:
if (string->s)
{
int len;
}
/* Return the character position of the end of the display string that
- started at CHARPOS. A display string is either an overlay with
- `display' property whose value is a string or a `display' text
- property whose value is a string. */
+ started at CHARPOS. If there's no display string at CHARPOS,
+ return -1. A display string is either an overlay with `display'
+ property whose value is a string or a `display' text property whose
+ value is a string. */
EMACS_INT
compute_display_string_end (EMACS_INT charpos, struct bidi_string_data *string)
{
if (charpos >= eob || (string->s && !STRINGP (object)))
return eob;
+ /* It could happen that the display property or overlay was removed
+ since we found it in compute_display_string_pos above. One way
+ this can happen is if JIT font-lock was called (through
+ handle_fontified_prop), and jit-lock-functions remove text
+ properties or overlays from the portion of buffer that includes
+ CHARPOS. Muse mode is known to do that, for example. In this
+ case, we return -1 to the caller, to signal that no display
+ string is actually present at CHARPOS. See bidi_fetch_char for
+ how this is handled.
+
+ An alternative would be to never look for display properties past
+ it->stop_charpos. But neither compute_display_string_pos nor
+ bidi_fetch_char that calls it know or care where the next
+ stop_charpos is. */
if (NILP (Fget_char_property (pos, Qdisplay, object)))
- abort ();
+ return -1;
/* Look forward for the first character where the `display' property
changes. */