X-Git-Url: https://code.delx.au/gnu-emacs/blobdiff_plain/f3fbd1553534bb85c75baf891c0ca9aaa4c3fa6f..2afd5e90eb946a0e70547e56a4c705d7d0d4cb7f:/src/composite.c diff --git a/src/composite.c b/src/composite.c index ff6d1a5ba3..7bd50a2339 100644 --- a/src/composite.c +++ b/src/composite.c @@ -92,32 +92,32 @@ Boston, MA 02111-1307, USA. */ The former is a hash table in which keys are COMPONENTS-VECs and values are the corresponding COMPOSITION-IDs. This hash table is - weak, but as each key (COMPONENTS-VEC) is also kept as a value of + weak, but as each key (COMPONENTS-VEC) is also kept as a value of the `composition' property, it won't be collected as garbage until all - text that have the same COMPONENTS-VEC are deleted. + bits of text that have the same COMPONENTS-VEC are deleted. The latter is a table of pointers to `struct composition' indexed - by COMPOSITION-ID. This structure keep the other information (see + by COMPOSITION-ID. This structure keeps the other information (see composite.h). In general, a text property holds information about individual characters. But, a `composition' property holds information about - a sequence of characters (in this sense, it is like `intangible' + a sequence of characters (in this sense, it is like the `intangible' property). That means that we should not share the property value - in adjacent compositions we can't distinguish them if they have the + in adjacent compositions -- we can't distinguish them if they have the same property. So, after any changes, we call `update_compositions' and change a property of one of adjacent compositions to a copy of it. This function also runs a proper composition modification function to make a composition that gets invalid by the change valid again. - As a value of `composition' property holds information about a + As the value of the `composition' property holds information about a specific range of text, the value gets invalid if we change the - text in the range. We treat `composition' property always + text in the range. We treat the `composition' property as always rear-nonsticky (currently by setting default-text-properties to (rear-nonsticky (composition))) and we never make properties of adjacent compositions identical. Thus, any such changes make the - range just shorter. So, we can check the validity of `composition' + range just shorter. So, we can check the validity of the `composition' property by comparing LENGTH information with the actual length of the composition. @@ -158,12 +158,6 @@ Lisp_Object composition_temp; #define CHAR_WIDTH(c) \ (SINGLE_BYTE_CHAR_P (c) ? 1 : CHARSET_WIDTH (CHAR_CHARSET (c))) -/* The following macros for hash table are copied from fns.c. */ -/* Value is the key part of entry IDX in hash table H. */ -#define HASH_KEY(H, IDX) AREF ((H)->key_and_value, 2 * (IDX)) -/* Value is the value part of entry IDX in hash table H. */ -#define HASH_VALUE(H, IDX) AREF ((H)->key_and_value, 2 * (IDX) + 1) - /* Return COMPOSITION-ID of a composition at buffer position CHARPOS/BYTEPOS and length NCHARS. The `composition' property of the sequence is PROP. STRING, if non-nil, is a string that @@ -468,7 +462,7 @@ run_composition_function (from, to, prop) && find_composition (to, -1, &start, &end, &prop, Qnil) && !COMPOSITION_VALID_P (start, end, prop)) to = end; - if (!NILP (func)) + if (!NILP (Ffboundp (func))) call2 (func, make_number (from), make_number (to)); else if (!NILP (Ffboundp (Vcompose_chars_after_function))) call3 (Vcompose_chars_after_function, @@ -484,7 +478,7 @@ run_composition_function (from, to, prop) void update_compositions (from, to, check_mask) - int from, to; + int from, to, check_mask; { Lisp_Object prop; int start, end; @@ -611,18 +605,18 @@ compose_chars_in_text (start, end, string) /* Set to nonzero if we don't have to compose ASCII characters. */ int skip_ascii; int i, len, stop, c; - unsigned char *ptr, *pend; + const unsigned char *ptr, *pend; if (! CHAR_TABLE_P (Vcomposition_function_table)) return; if (STRINGP (string)) { - count = specpdl_ptr - specpdl; + count = SPECPDL_INDEX (); GCPRO1 (string); stop = end; - ptr = XSTRING (string)->data + string_char_to_byte (string, start); - pend = ptr + STRING_BYTES (XSTRING (string)); + ptr = SDATA (string) + string_char_to_byte (string, start); + pend = ptr + SBYTES (string); } else { @@ -656,7 +650,7 @@ compose_chars_in_text (start, end, string) break; stop = end; if (STRINGP (string)) - ptr = XSTRING (string)->data + string_char_to_byte (string, start); + ptr = SDATA (string) + string_char_to_byte (string, start); else ptr = CHAR_POS_ADDR (start); } @@ -686,7 +680,7 @@ compose_chars_in_text (start, end, string) { start += XINT (val); if (STRINGP (string)) - ptr = XSTRING (string)->data + string_char_to_byte (string, start); + ptr = SDATA (string) + string_char_to_byte (string, start); else ptr = CHAR_POS_ADDR (start); } @@ -717,12 +711,12 @@ compose_chars_in_text (start, end, string) DEFUN ("compose-region-internal", Fcompose_region_internal, Scompose_region_internal, 2, 4, 0, - "Internal use only.\n\ -\n\ -Compose text in the region between START and END.\n\ -Optional 3rd and 4th arguments are COMPONENTS and MODIFICATION-FUNC\n\ -for the composition. See `compose-region' for more detial.") - (start, end, components, mod_func) + doc: /* Internal use only. + +Compose text in the region between START and END. +Optional 3rd and 4th arguments are COMPONENTS and MODIFICATION-FUNC +for the composition. See `compose-region' for more detail. */) + (start, end, components, mod_func) Lisp_Object start, end, components, mod_func; { validate_region (&start, &end); @@ -730,7 +724,7 @@ for the composition. See `compose-region' for more detial.") && !INTEGERP (components) && !CONSP (components) && !STRINGP (components)) - CHECK_VECTOR (components, 2); + CHECK_VECTOR (components); compose_text (XINT (start), XINT (end), components, mod_func, Qnil); return Qnil; @@ -738,21 +732,21 @@ for the composition. See `compose-region' for more detial.") DEFUN ("compose-string-internal", Fcompose_string_internal, Scompose_string_internal, 3, 5, 0, - "Internal use only.\n\ -\n\ -Compose text between indices START and END of STRING.\n\ -Optional 4th and 5th arguments are COMPONENTS and MODIFICATION-FUNC\n\ -for the composition. See `compose-string' for more detial.") - (string, start, end, components, mod_func) + doc: /* Internal use only. + +Compose text between indices START and END of STRING. +Optional 4th and 5th arguments are COMPONENTS and MODIFICATION-FUNC +for the composition. See `compose-string' for more detail. */) + (string, start, end, components, mod_func) Lisp_Object string, start, end, components, mod_func; { - CHECK_STRING (string, 0); - CHECK_NUMBER (start, 1); - CHECK_NUMBER (end, 2); + CHECK_STRING (string); + CHECK_NUMBER (start); + CHECK_NUMBER (end); if (XINT (start) < 0 || XINT (start) > XINT (end) - || XINT (end) > XSTRING (string)->size) + || XINT (end) > SCHARS (string)) args_out_of_range (start, end); compose_text (XINT (start), XINT (end), components, mod_func, string); @@ -761,22 +755,22 @@ for the composition. See `compose-string' for more detial.") DEFUN ("find-composition-internal", Ffind_composition_internal, Sfind_composition_internal, 4, 4, 0, - "Internal use only.\n\ -\n\ -Return information about composition at or nearest to position POS.\n\ -See `find-composition' for more detail.") - (pos, limit, string, detail_p) + doc: /* Internal use only. + +Return information about composition at or nearest to position POS. +See `find-composition' for more detail. */) + (pos, limit, string, detail_p) Lisp_Object pos, limit, string, detail_p; { Lisp_Object prop, tail; int start, end; int id; - CHECK_NUMBER_COERCE_MARKER (pos, 0); + CHECK_NUMBER_COERCE_MARKER (pos); start = XINT (pos); if (!NILP (limit)) { - CHECK_NUMBER_COERCE_MARKER (limit, 1); + CHECK_NUMBER_COERCE_MARKER (limit); end = XINT (limit); } else @@ -784,8 +778,8 @@ See `find-composition' for more detail.") if (!NILP (string)) { - CHECK_STRING (string, 2); - if (XINT (pos) < 0 || XINT (pos) > XSTRING (string)->size) + CHECK_STRING (string); + if (XINT (pos) < 0 || XINT (pos) > SCHARS (string)) args_out_of_range (string, pos); } else @@ -849,7 +843,7 @@ syms_of_composite () args[0] = QCtest; args[1] = Qequal; args[2] = QCweakness; - args[3] = Qnil; + args[3] = Qt; args[4] = QCsize; args[5] = make_number (311); composition_hash_table = Fmake_hash_table (6, args); @@ -861,17 +855,17 @@ syms_of_composite () = Fcons (Fcons (Qcomposition, Qt), Vtext_property_default_nonsticky); DEFVAR_LISP ("compose-chars-after-function", &Vcompose_chars_after_function, - "Function to adjust composition of buffer text.\n\ -\n\ -The function is called with three arguments FROM, TO, and OBJECT.\n\ -FROM and TO specify the range of text of which composition should be\n\ -adjusted. OBJECT, if non-nil, is a string that contains the text.\n\ -\n\ -This function is called after a text with `composition' property is\n\ -inserted or deleted to keep `composition' property of buffer text\n\ -valid.\n\ -\n\ -The default value is the function `compose-chars-after'."); + doc: /* Function to adjust composition of buffer text. + +The function is called with three arguments FROM, TO, and OBJECT. +FROM and TO specify the range of text of which composition should be +adjusted. OBJECT, if non-nil, is a string that contains the text. + +This function is called after a text with `composition' property is +inserted or deleted to keep `composition' property of buffer text +valid. + +The default value is the function `compose-chars-after'. */); Vcompose_chars_after_function = intern ("compose-chars-after"); Qcomposition_function_table = intern ("composition-function-table"); @@ -885,16 +879,16 @@ The default value is the function `compose-chars-after'."); Fput (Qcomposition_function_table, Qchar_table_extra_slots, make_number (0)); DEFVAR_LISP ("composition-function-table", &Vcomposition_function_table, - "Char table of patterns and functions to make a composition.\n\ -\n\ -Each element is nil or an alist of PATTERNs vs FUNCs, where PATTERNs\n\ -are regular expressions and FUNCs are functions. FUNC is responsible\n\ -for composing text matching the corresponding PATTERN. FUNC is called\n\ -with three arguments FROM, TO, and PATTERN. See the function\n\ -`compose-chars-after' for more detail.\n\ -\n\ -This table is looked up by the first character of a composition when\n\ -the composition gets invalid after a change in a buffer."); + doc: /* Char table of patterns and functions to make a composition. + +Each element is nil or an alist of PATTERNs vs FUNCs, where PATTERNs +are regular expressions and FUNCs are functions. FUNC is responsible +for composing text matching the corresponding PATTERN. FUNC is called +with three arguments FROM, TO, and PATTERN. See the function +`compose-chars-after' for more detail. + +This table is looked up by the first character of a composition when +the composition gets invalid after a change in a buffer. */); Vcomposition_function_table = Fmake_char_table (Qcomposition_function_table, Qnil);