aboutsummaryrefslogtreecommitdiffstats
path: root/src/composite.c
diff options
context:
space:
mode:
authorKenichi Handa2009-12-25 02:43:36 +0000
committerKenichi Handa2009-12-25 02:43:36 +0000
commite614ea00ff346e8373fa5e7a61de6e0318f17e7e (patch)
tree4bcd262f749012e402731b3cccc0c27439f95e68 /src/composite.c
parent4abd35cb643b6c18207955a9615e8993eed74b88 (diff)
downloademacs-e614ea00ff346e8373fa5e7a61de6e0318f17e7e.tar.gz
emacs-e614ea00ff346e8373fa5e7a61de6e0318f17e7e.zip
(composition_reseat_it): Don't make a composition
spanning over point. (CHAR_COMPOSABLE_P): Treat U+200C (ZWNJ) and U+200D (ZWJ) as composable characters. (composition_adjust_point): New arg NEW_PT. Callers changed.
Diffstat (limited to 'src/composite.c')
-rw-r--r--src/composite.c52
1 files changed, 30 insertions, 22 deletions
diff --git a/src/composite.c b/src/composite.c
index 33dd4ba1abd..a24abd0fe8f 100644
--- a/src/composite.c
+++ b/src/composite.c
@@ -1104,6 +1104,9 @@ composition_reseat_it (cmp_it, charpos, bytepos, endpos, w, face, string)
1104 struct face *face; 1104 struct face *face;
1105 Lisp_Object string; 1105 Lisp_Object string;
1106{ 1106{
1107 if (charpos < PT && PT < endpos)
1108 endpos = PT;
1109
1107 if (cmp_it->ch == -2) 1110 if (cmp_it->ch == -2)
1108 { 1111 {
1109 composition_compute_stop_pos (cmp_it, charpos, bytepos, endpos, string); 1112 composition_compute_stop_pos (cmp_it, charpos, bytepos, endpos, string);
@@ -1269,11 +1272,12 @@ static Lisp_Object _work_val;
1269static int _work_char; 1272static int _work_char;
1270 1273
1271/* 1 iff the character C is composable. */ 1274/* 1 iff the character C is composable. */
1272#define CHAR_COMPOSABLE_P(C) \ 1275#define CHAR_COMPOSABLE_P(C) \
1273 (_work_val = CHAR_TABLE_REF (Vunicode_category_table, (C)), \ 1276 ((C) == 0x200C || (C) == 0x200D \
1274 (SYMBOLP (_work_val) \ 1277 || (_work_val = CHAR_TABLE_REF (Vunicode_category_table, (C)), \
1275 && (_work_char = SDATA (SYMBOL_NAME (_work_val))[0]) != 'C' \ 1278 (SYMBOLP (_work_val) \
1276 && _work_char != 'Z')) 1279 && (_work_char = SDATA (SYMBOL_NAME (_work_val))[0]) != 'C' \
1280 && _work_char != 'Z')))
1277 1281
1278/* This is like find_composition, but find an automatic composition 1282/* This is like find_composition, but find an automatic composition
1279 instead. If found, set *GSTRING to the glyph-string representing 1283 instead. If found, set *GSTRING to the glyph-string representing
@@ -1449,49 +1453,53 @@ find_automatic_composition (pos, limit, start, end, gstring, string)
1449 return 0; 1453 return 0;
1450} 1454}
1451 1455
1456/* Return the adjusted point provided that point is moved from LAST_PT
1457 to NEW_PT. */
1458
1452int 1459int
1453composition_adjust_point (last_pt) 1460composition_adjust_point (last_pt, new_pt)
1454 EMACS_INT last_pt; 1461 EMACS_INT last_pt, new_pt;
1455{ 1462{
1456 EMACS_INT charpos, bytepos, startpos, beg, end, pos; 1463 EMACS_INT charpos, bytepos, startpos, beg, end, pos;
1457 Lisp_Object val; 1464 Lisp_Object val;
1458 int i; 1465 int i;
1459 1466
1460 if (PT == BEGV || PT == ZV) 1467 if (new_pt == BEGV || new_pt == ZV)
1461 return PT; 1468 return new_pt;
1462 1469
1463 /* At first check the static composition. */ 1470 /* At first check the static composition. */
1464 if (get_property_and_range (PT, Qcomposition, &val, &beg, &end, Qnil) 1471 if (get_property_and_range (new_pt, Qcomposition, &val, &beg, &end, Qnil)
1465 && COMPOSITION_VALID_P (beg, end, val)) 1472 && COMPOSITION_VALID_P (beg, end, val))
1466 { 1473 {
1467 if (beg < PT /* && end > PT <- It's always the case. */ 1474 if (beg < new_pt /* && end > new_pt <- It's always the case. */
1468 && (last_pt <= beg || last_pt >= end)) 1475 && (last_pt <= beg || last_pt >= end))
1469 return (PT < last_pt ? beg : end); 1476 return (new_pt < last_pt ? beg : end);
1470 return PT; 1477 return new_pt;
1471 } 1478 }
1472 1479
1473 if (NILP (current_buffer->enable_multibyte_characters) 1480 if (NILP (current_buffer->enable_multibyte_characters)
1474 || ! FUNCTIONP (Vauto_composition_function)) 1481 || ! FUNCTIONP (Vauto_composition_function))
1475 return PT; 1482 return new_pt;
1476 1483
1477 /* Next check the automatic composition. */ 1484 /* Next check the automatic composition. */
1478 if (! find_automatic_composition (PT, (EMACS_INT) -1, &beg, &end, &val, Qnil) 1485 if (! find_automatic_composition (new_pt, (EMACS_INT) -1, &beg, &end, &val,
1479 || beg == PT) 1486 Qnil)
1480 return PT; 1487 || beg == new_pt)
1488 return new_pt;
1481 for (i = 0; i < LGSTRING_GLYPH_LEN (val); i++) 1489 for (i = 0; i < LGSTRING_GLYPH_LEN (val); i++)
1482 { 1490 {
1483 Lisp_Object glyph = LGSTRING_GLYPH (val, i); 1491 Lisp_Object glyph = LGSTRING_GLYPH (val, i);
1484 1492
1485 if (NILP (glyph)) 1493 if (NILP (glyph))
1486 break; 1494 break;
1487 if (beg + LGLYPH_FROM (glyph) == PT) 1495 if (beg + LGLYPH_FROM (glyph) == new_pt)
1488 return PT; 1496 return new_pt;
1489 if (beg + LGLYPH_TO (glyph) >= PT) 1497 if (beg + LGLYPH_TO (glyph) >= new_pt)
1490 return (PT < last_pt 1498 return (new_pt < last_pt
1491 ? beg + LGLYPH_FROM (glyph) 1499 ? beg + LGLYPH_FROM (glyph)
1492 : beg + LGLYPH_TO (glyph) + 1); 1500 : beg + LGLYPH_TO (glyph) + 1);
1493 } 1501 }
1494 return PT; 1502 return new_pt;
1495} 1503}
1496 1504
1497DEFUN ("composition-get-gstring", Fcomposition_get_gstring, 1505DEFUN ("composition-get-gstring", Fcomposition_get_gstring,