X-Git-Url: https://code.delx.au/gnu-emacs/blobdiff_plain/dd33cc5605a2dc5418868246afcf453d727615e2..59b7fa6569f8b865b6ef688a8531d745f1cc67d4:/src/composite.c diff --git a/src/composite.c b/src/composite.c index 9ff5f855be..2ef8533ea6 100644 --- a/src/composite.c +++ b/src/composite.c @@ -1,6 +1,7 @@ /* Composite sequence support. Copyright (C) 1999 Electrotechnical Laboratory, JAPAN. Licensed to the Free Software Foundation. + Copyright (C) 2001 Free Software Foundation, Inc. This file is part of GNU Emacs. @@ -248,8 +249,8 @@ get_composition_id (charpos, bytepos, nchars, prop, string) modify the cons cell of PROP because it is not shared. */ key = HASH_KEY (hash_table, hash_index); id = HASH_VALUE (hash_table, hash_index); - XCAR (prop) = id; - XCDR (prop) = Fcons (make_number (nchars), Fcons (key, XCDR (prop))); + XSETCAR (prop, id); + XSETCDR (prop, Fcons (make_number (nchars), Fcons (key, XCDR (prop)))); return XINT (id); } @@ -296,8 +297,8 @@ get_composition_id (charpos, bytepos, nchars, prop, string) /* Change PROP from Form-A above to Form-B. We can directly modify the cons cell of PROP because it is not shared. */ XSETFASTINT (id, n_compositions); - XCAR (prop) = id; - XCDR (prop) = Fcons (make_number (nchars), Fcons (key, XCDR (prop))); + XSETCAR (prop, id); + XSETCDR (prop, Fcons (make_number (nchars), Fcons (key, XCDR (prop)))); /* Register the composition in composition_hash_table. */ hash_index = hash_put (hash_table, key, id, hash_code); @@ -488,6 +489,9 @@ update_compositions (from, to, check_mask) Lisp_Object prop; int start, end; + if (inhibit_modification_hooks) + return; + /* If FROM and TO are not in a valid range, do nothing. */ if (! (BEGV <= from && from <= to && to <= ZV)) return; @@ -565,7 +569,7 @@ make_composition_value_copy (list) { if (EQ (XCAR (plist), Qcomposition) && (val = XCAR (XCDR (plist)), CONSP (val))) - XCAR (XCDR (plist)) = Fcons (XCAR (val), XCDR (val)); + XSETCAR (XCDR (plist), Fcons (XCAR (val), XCDR (val))); plist = XCDR (XCDR (plist)); } } @@ -601,7 +605,7 @@ compose_chars_in_text (start, end, string) int start, end; Lisp_Object string; { - int count; + int count = 0; struct gcpro gcpro1; Lisp_Object tail, elt, val, to; /* Set to nonzero if we don't have to compose ASCII characters. */ @@ -713,12 +717,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 detial. */) + (start, end, components, mod_func) Lisp_Object start, end, components, mod_func; { validate_region (&start, &end); @@ -726,7 +730,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; @@ -734,17 +738,17 @@ 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 detial. */) + (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) @@ -757,28 +761,38 @@ 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 end = -1; + if (!NILP (string)) - CHECK_STRING (string, 2); + { + CHECK_STRING (string); + if (XINT (pos) < 0 || XINT (pos) > XSTRING (string)->size) + args_out_of_range (string, pos); + } + else + { + if (XINT (pos) < BEGV || XINT (pos) > ZV) + args_out_of_range (Fcurrent_buffer (), pos); + } if (!find_composition (start, end, &start, &end, &prop, string)) return Qnil; @@ -847,17 +861,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"); @@ -871,16 +885,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);