From e53d2f0069d07b6823b0698cf441fe6f3843b7bc Mon Sep 17 00:00:00 2001 From: Kenichi Handa Date: Tue, 30 Sep 2003 11:07:55 +0000 Subject: [PATCH] (handle_auto_composed_prop): Check if the last characters of auto-composed region is newly composed with the following characters. (handle_composition_prop): Fix checking of point being inside composition. --- src/xdisp.c | 56 +++++++++++++++++++++++++++++++++++++++++++++-------- 1 file changed, 48 insertions(+), 8 deletions(-) diff --git a/src/xdisp.c b/src/xdisp.c index 04e74f1e7e1..12dca91d0ac 100644 --- a/src/xdisp.c +++ b/src/xdisp.c @@ -3774,17 +3774,48 @@ handle_auto_composed_prop (it) { enum prop_handled handled = HANDLED_NORMALLY; - if (! NILP (Vauto_composition_function)) + if (FUNCTIONP (Vauto_composition_function)) { Lisp_Object val; - int pos; + EMACS_INT pos, this_pos; if (STRINGP (it->string)) pos = IT_STRING_CHARPOS (*it); else pos = IT_CHARPOS (*it); + this_pos = pos; val =Fget_char_property (make_number (pos), Qauto_composed, it->string); + if (! NILP (val)) + { + Lisp_Object next; + + next = (Fnext_single_property_change + (make_number (pos), Qauto_composed, it->string, Qnil)); + if (INTEGERP (next)) + { + /* The current point is auto-composed, but there exist + characers not yet composed beyond the auto-compused + region. There's a possiblity that the last + characters in the region may be newly composed. */ + int charpos = XINT (next) - 1, bytepos, c; + + if (STRINGP (it->string)) + { + bytepos = string_char_to_byte (it->string, charpos); + c = SDATA (it->string)[bytepos]; + } + else + { + bytepos = CHAR_TO_BYTE (charpos); + c = FETCH_BYTE (bytepos); + } + if (c != '\n') + /* If the last character is not newline, it may be + composed with the following characters. */ + val = Qnil, pos = charpos + 1; + } + } if (NILP (val)) { int count = SPECPDL_INDEX (); @@ -3798,7 +3829,7 @@ handle_auto_composed_prop (it) unbind_to (count, Qnil); val = Fget_char_property (args[1], Qauto_composed, it->string); - if (! NILP (val)) + if (! NILP (val) && this_pos == pos) handled = HANDLED_RECOMPUTE_PROPS; } } @@ -3814,7 +3845,7 @@ handle_composition_prop (it) struct it *it; { Lisp_Object prop, string; - EMACS_INT pos, pos_byte, end; + EMACS_INT pos, pos_byte, start, end; enum prop_handled handled = HANDLED_NORMALLY; if (STRINGP (it->string)) @@ -3833,11 +3864,20 @@ handle_composition_prop (it) /* If there's a valid composition and point is not inside of the composition (in the case that the composition is from the current buffer), draw a glyph composed from the composition components. */ - if (find_composition (pos, -1, &pos, &end, &prop, string) - && COMPOSITION_VALID_P (pos, end, prop) - && (STRINGP (it->string) || (PT <= pos || PT >= end))) + if (find_composition (pos, -1, &start, &end, &prop, string) + && COMPOSITION_VALID_P (start, end, prop) + && (STRINGP (it->string) || (PT <= start || PT >= end))) { - int id = get_composition_id (pos, pos_byte, end - pos, prop, string); + int id; + + if (start != pos) + { + if (STRINGP (it->string)) + pos_byte = string_char_to_byte (it->string, start); + else + pos_byte = CHAR_TO_BYTE (start); + } + id = get_composition_id (start, pos_byte, end - start, prop, string); if (id >= 0) { -- 2.39.2