annotate src/category.c @ 28203:c10ee0e6982b

(RE_STRING_CHAR): New macro. (GET_CHAR_AFER_2): Remove. (RE_TRANSLATE, RE_TRANSLATE_P): New macros moved from regex.h. (enum re_opcode_t): Remove on_failure_jump_exclusive. (print_partial_compiled_pattern, re_compile_fastmap) (re_match_2_internal): Remove on_failure_jump_exclusive. (regex_compile): Turn optimizable P+ loops into PP*, so that the optimization only need to work for * (ie. can use of_keep_string_jump). Remove the special case for .*\n since it is now covered by the general optimization. (re_search_2): Don't bother with `room'. (skip_one_char): New function. (skip_noops): Simplify since `memory' is not needed any more. (mutually_exclusive_p): Restructure slightly to use `switch' and add handling for "all" remaining cases. (re_match_2_internal): Change on_failure_jump_smart to use on_failure_keep_string_jump (and redirect the end-of-loop jump) rather than on_failure_jump_exclusive.
author Stefan Monnier <monnier@iro.umontreal.ca>
date Sun, 19 Mar 2000 23:22:06 +0000
parents dfead1ef574c
children 16ed41346de7
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1 /* GNU Emacs routines to deal with category tables.
18341
33e78cc7f058 Change copyright notices.
Richard M. Stallman <rms@gnu.org>
parents: 17787
diff changeset
2 Copyright (C) 1995, 1997 Electrotechnical Laboratory, JAPAN.
33e78cc7f058 Change copyright notices.
Richard M. Stallman <rms@gnu.org>
parents: 17787
diff changeset
3 Licensed to the Free Software Foundation.
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5 This file is part of GNU Emacs.
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
6
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
7 GNU Emacs is free software; you can redistribute it and/or modify
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
8 it under the terms of the GNU General Public License as published by
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
9 the Free Software Foundation; either version 2, or (at your option)
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
10 any later version.
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
11
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
12 GNU Emacs is distributed in the hope that it will be useful,
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
15 GNU General Public License for more details.
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
16
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
17 You should have received a copy of the GNU General Public License
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
18 along with GNU Emacs; see the file COPYING. If not, write to
17071
70194012fb3a Fix FSF address in comment.
Karl Heuer <kwzh@gnu.org>
parents: 17052
diff changeset
19 the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
70194012fb3a Fix FSF address in comment.
Karl Heuer <kwzh@gnu.org>
parents: 17052
diff changeset
20 Boston, MA 02111-1307, USA. */
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
21
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
22
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
23 /* Here we handle three objects: category, category set, and category
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
24 table. Read comments in the file category.h to understand them. */
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
25
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
26 #include <config.h>
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
27 #include <ctype.h>
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
28 #include "lisp.h"
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
29 #include "buffer.h"
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
30 #include "charset.h"
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
31 #include "category.h"
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
32
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
33 /* The version number of the latest category table. Each category
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
34 table has a unique version number. It is assigned a new number
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
35 also when it is modified. When a regular expression is compiled
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
36 into the struct re_pattern_buffer, the version number of the
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
37 category table (of the current buffer) at that moment is also
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
38 embedded in the structure.
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
39
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
40 For the moment, we are not using this feature. */
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
41 static int category_table_version;
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
42
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
43 Lisp_Object Qcategory_table, Qcategoryp, Qcategorysetp, Qcategory_table_p;
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
44
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
45 /* Variables to determine word boundary. */
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
46 Lisp_Object Vword_combining_categories, Vword_separating_categories;
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
47
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
48 /* Temporary internal variable used in macro CHAR_HAS_CATEGORY. */
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
49 Lisp_Object _temp_category_set;
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
50
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
51
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
52 /* Category set staff. */
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
53
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
54 DEFUN ("make-category-set", Fmake_category_set, Smake_category_set, 1, 1, 0,
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
55 "Return a newly created category-set which contains CATEGORIES.\n\
20825
1b98a0ab1bee (Fmodify_category_entry): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents: 20612
diff changeset
56 CATEGORIES is a string of category mnemonics.\n\
1b98a0ab1bee (Fmodify_category_entry): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents: 20612
diff changeset
57 The value is a bool-vector which has t at the indices corresponding to\n\
1b98a0ab1bee (Fmodify_category_entry): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents: 20612
diff changeset
58 those categories.")
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
59 (categories)
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
60 Lisp_Object categories;
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
61 {
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
62 Lisp_Object val;
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
63 int len;
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
64
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
65 CHECK_STRING (categories, 0);
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
66 val = MAKE_CATEGORY_SET;
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
67
20612
5a0922f8c841 (Fmake_category_set): Don't allow multibyte string.
Richard M. Stallman <rms@gnu.org>
parents: 20189
diff changeset
68 if (STRING_MULTIBYTE (categories))
5a0922f8c841 (Fmake_category_set): Don't allow multibyte string.
Richard M. Stallman <rms@gnu.org>
parents: 20189
diff changeset
69 error ("Multibyte string in make-category-set");
5a0922f8c841 (Fmake_category_set): Don't allow multibyte string.
Richard M. Stallman <rms@gnu.org>
parents: 20189
diff changeset
70
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
71 len = XSTRING (categories)->size;
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
72 while (--len >= 0)
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
73 {
17369
566b26e1930e (Fmake_category_set): Use XSETFASTINT.
Karl Heuer <kwzh@gnu.org>
parents: 17324
diff changeset
74 Lisp_Object category;
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
75
17369
566b26e1930e (Fmake_category_set): Use XSETFASTINT.
Karl Heuer <kwzh@gnu.org>
parents: 17324
diff changeset
76 XSETFASTINT (category, XSTRING (categories)->data[len]);
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
77 CHECK_CATEGORY (category, 0);
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
78 SET_CATEGORY_SET (val, category, Qt);
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
79 }
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
80 return val;
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
81 }
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
82
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
83
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
84 /* Category staff. */
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
85
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
86 Lisp_Object check_category_table ();
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
87
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
88 DEFUN ("define-category", Fdefine_category, Sdefine_category, 2, 3, 0,
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
89 "Define CHAR as a category which is described by DOCSTRING.\n\
20825
1b98a0ab1bee (Fmodify_category_entry): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents: 20612
diff changeset
90 CHAR should be an ASCII printing character in the range ` ' to `~'.\n\
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
91 DOCSTRING is a documentation string of the category.\n\
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
92 The category is defined only in category table TABLE, which defaults to\n\
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
93 the current buffer's category table.")
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
94 (category, docstring, table)
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
95 Lisp_Object category, docstring, table;
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
96 {
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
97 CHECK_CATEGORY (category, 0);
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
98 CHECK_STRING (docstring, 1);
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
99 table = check_category_table (table);
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
100
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
101 if (!NILP (CATEGORY_DOCSTRING (table, XFASTINT (category))))
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
102 error ("Category `%c' is already defined", XFASTINT (category));
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
103 CATEGORY_DOCSTRING (table, XFASTINT (category)) = docstring;
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
104
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
105 return Qnil;
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
106 }
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
107
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
108 DEFUN ("category-docstring", Fcategory_docstring, Scategory_docstring, 1, 2, 0,
20825
1b98a0ab1bee (Fmodify_category_entry): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents: 20612
diff changeset
109 "Return the documentation string of CATEGORY, as defined in CATEGORY-TABLE.")
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
110 (category, table)
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
111 Lisp_Object category, table;
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
112 {
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
113 Lisp_Object doc;
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
114
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
115 CHECK_CATEGORY (category, 0);
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
116 table = check_category_table (table);
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
117
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
118 return CATEGORY_DOCSTRING (table, XFASTINT (category));
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
119 }
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
120
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
121 DEFUN ("get-unused-category", Fget_unused_category, Sget_unused_category,
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
122 0, 1, 0,
20825
1b98a0ab1bee (Fmodify_category_entry): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents: 20612
diff changeset
123 "Return a category which is not yet defined in CATEGORY-TABLE.\n\
1b98a0ab1bee (Fmodify_category_entry): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents: 20612
diff changeset
124 If no category remains available, return nil.\n\
1b98a0ab1bee (Fmodify_category_entry): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents: 20612
diff changeset
125 The optional argument CATEGORY-TABLE specifies which category table\n\
1b98a0ab1bee (Fmodify_category_entry): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents: 20612
diff changeset
126 to modify; it defaults to the current buffer's category table.")
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
127 (table)
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
128 Lisp_Object table;
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
129 {
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
130 int i;
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
131 Lisp_Object docstring_vector;
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
132
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
133 table = check_category_table (table);
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
134
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
135 for (i = ' '; i <= '~'; i++)
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
136 if (NILP (CATEGORY_DOCSTRING (table, i)))
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
137 return make_number (i);
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
138
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
139 return Qnil;
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
140 }
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
141
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
142
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
143 /* Category-table staff. */
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
144
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
145 DEFUN ("category-table-p", Fcategory_table_p, Scategory_table_p, 1, 1, 0,
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
146 "Return t if ARG is a category table.")
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
147 (arg)
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
148 Lisp_Object arg;
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
149 {
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
150 if (CHAR_TABLE_P (arg)
17324
ed53084a1655 (category-table-p): Check only type and purpose.
Kenichi Handa <handa@m17n.org>
parents: 17187
diff changeset
151 && EQ (XCHAR_TABLE (arg)->purpose, Qcategory_table))
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
152 return Qt;
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
153 return Qnil;
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
154 }
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
155
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
156 /* If TABLE is nil, return the current category table. If TABLE is
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
157 not nil, check the validity of TABLE as a category table. If
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
158 valid, return TABLE itself, but if not valid, signal an error of
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
159 wrong-type-argument. */
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
160
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
161 Lisp_Object
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
162 check_category_table (table)
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
163 Lisp_Object table;
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
164 {
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
165 register Lisp_Object tem;
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
166 if (NILP (table))
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
167 return current_buffer->category_table;
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
168 while (tem = Fcategory_table_p (table), NILP (tem))
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
169 table = wrong_type_argument (Qcategory_table_p, table);
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
170 return table;
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
171 }
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
172
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
173 DEFUN ("category-table", Fcategory_table, Scategory_table, 0, 0, 0,
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
174 "Return the current category table.\n\
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
175 This is the one specified by the current buffer.")
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
176 ()
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
177 {
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
178 return current_buffer->category_table;
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
179 }
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
180
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
181 DEFUN ("standard-category-table", Fstandard_category_table,
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
182 Sstandard_category_table, 0, 0, 0,
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
183 "Return the standard category table.\n\
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
184 This is the one used for new buffers.")
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
185 ()
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
186 {
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
187 return Vstandard_category_table;
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
188 }
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
189
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
190 /* Return a copy of category table TABLE. We can't simply use the
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
191 function copy-sequence because no contents should be shared between
17324
ed53084a1655 (category-table-p): Check only type and purpose.
Kenichi Handa <handa@m17n.org>
parents: 17187
diff changeset
192 the original and the copy. This function is called recursively by
20189
16f5b56c2f68 (copy_category_table): Copy also the first extra slot
Kenichi Handa <handa@m17n.org>
parents: 19659
diff changeset
193 binding TABLE to a sub char table. */
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
194
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
195 Lisp_Object
17324
ed53084a1655 (category-table-p): Check only type and purpose.
Kenichi Handa <handa@m17n.org>
parents: 17187
diff changeset
196 copy_category_table (table)
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
197 Lisp_Object table;
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
198 {
17324
ed53084a1655 (category-table-p): Check only type and purpose.
Kenichi Handa <handa@m17n.org>
parents: 17187
diff changeset
199 Lisp_Object tmp;
ed53084a1655 (category-table-p): Check only type and purpose.
Kenichi Handa <handa@m17n.org>
parents: 17187
diff changeset
200 int i, to;
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
201
17324
ed53084a1655 (category-table-p): Check only type and purpose.
Kenichi Handa <handa@m17n.org>
parents: 17187
diff changeset
202 if (!NILP (XCHAR_TABLE (table)->top))
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
203 {
17324
ed53084a1655 (category-table-p): Check only type and purpose.
Kenichi Handa <handa@m17n.org>
parents: 17187
diff changeset
204 /* TABLE is a top level char table.
ed53084a1655 (category-table-p): Check only type and purpose.
Kenichi Handa <handa@m17n.org>
parents: 17187
diff changeset
205 At first, make a copy of tree structure of the table. */
ed53084a1655 (category-table-p): Check only type and purpose.
Kenichi Handa <handa@m17n.org>
parents: 17187
diff changeset
206 table = Fcopy_sequence (table);
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
207
17324
ed53084a1655 (category-table-p): Check only type and purpose.
Kenichi Handa <handa@m17n.org>
parents: 17187
diff changeset
208 /* Then, copy elements for single byte characters one by one. */
ed53084a1655 (category-table-p): Check only type and purpose.
Kenichi Handa <handa@m17n.org>
parents: 17187
diff changeset
209 for (i = 0; i < CHAR_TABLE_SINGLE_BYTE_SLOTS; i++)
ed53084a1655 (category-table-p): Check only type and purpose.
Kenichi Handa <handa@m17n.org>
parents: 17187
diff changeset
210 if (!NILP (tmp = XCHAR_TABLE (table)->contents[i]))
ed53084a1655 (category-table-p): Check only type and purpose.
Kenichi Handa <handa@m17n.org>
parents: 17187
diff changeset
211 XCHAR_TABLE (table)->contents[i] = Fcopy_sequence (tmp);
ed53084a1655 (category-table-p): Check only type and purpose.
Kenichi Handa <handa@m17n.org>
parents: 17187
diff changeset
212 to = CHAR_TABLE_ORDINARY_SLOTS;
20189
16f5b56c2f68 (copy_category_table): Copy also the first extra slot
Kenichi Handa <handa@m17n.org>
parents: 19659
diff changeset
213
16f5b56c2f68 (copy_category_table): Copy also the first extra slot
Kenichi Handa <handa@m17n.org>
parents: 19659
diff changeset
214 /* Also copy the first (and sole) extra slot. It is a vector
16f5b56c2f68 (copy_category_table): Copy also the first extra slot
Kenichi Handa <handa@m17n.org>
parents: 19659
diff changeset
215 containing docstring of each category. */
16f5b56c2f68 (copy_category_table): Copy also the first extra slot
Kenichi Handa <handa@m17n.org>
parents: 19659
diff changeset
216 Fset_char_table_extra_slot
16f5b56c2f68 (copy_category_table): Copy also the first extra slot
Kenichi Handa <handa@m17n.org>
parents: 19659
diff changeset
217 (table, make_number (0),
16f5b56c2f68 (copy_category_table): Copy also the first extra slot
Kenichi Handa <handa@m17n.org>
parents: 19659
diff changeset
218 Fcopy_sequence (Fchar_table_extra_slot (table, make_number (0))));
17324
ed53084a1655 (category-table-p): Check only type and purpose.
Kenichi Handa <handa@m17n.org>
parents: 17187
diff changeset
219 }
ed53084a1655 (category-table-p): Check only type and purpose.
Kenichi Handa <handa@m17n.org>
parents: 17187
diff changeset
220 else
ed53084a1655 (category-table-p): Check only type and purpose.
Kenichi Handa <handa@m17n.org>
parents: 17187
diff changeset
221 {
ed53084a1655 (category-table-p): Check only type and purpose.
Kenichi Handa <handa@m17n.org>
parents: 17187
diff changeset
222 i = 32;
ed53084a1655 (category-table-p): Check only type and purpose.
Kenichi Handa <handa@m17n.org>
parents: 17187
diff changeset
223 to = SUB_CHAR_TABLE_ORDINARY_SLOTS;
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
224 }
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
225
17324
ed53084a1655 (category-table-p): Check only type and purpose.
Kenichi Handa <handa@m17n.org>
parents: 17187
diff changeset
226 /* If the table has non-nil default value, copy it. */
ed53084a1655 (category-table-p): Check only type and purpose.
Kenichi Handa <handa@m17n.org>
parents: 17187
diff changeset
227 if (!NILP (tmp = XCHAR_TABLE (table)->defalt))
ed53084a1655 (category-table-p): Check only type and purpose.
Kenichi Handa <handa@m17n.org>
parents: 17187
diff changeset
228 XCHAR_TABLE (table)->defalt = Fcopy_sequence (tmp);
ed53084a1655 (category-table-p): Check only type and purpose.
Kenichi Handa <handa@m17n.org>
parents: 17187
diff changeset
229
ed53084a1655 (category-table-p): Check only type and purpose.
Kenichi Handa <handa@m17n.org>
parents: 17187
diff changeset
230 /* At last, copy the remaining elements while paying attention to a
ed53084a1655 (category-table-p): Check only type and purpose.
Kenichi Handa <handa@m17n.org>
parents: 17187
diff changeset
231 sub char table. */
ed53084a1655 (category-table-p): Check only type and purpose.
Kenichi Handa <handa@m17n.org>
parents: 17187
diff changeset
232 for (; i < to; i++)
ed53084a1655 (category-table-p): Check only type and purpose.
Kenichi Handa <handa@m17n.org>
parents: 17187
diff changeset
233 if (!NILP (tmp = XCHAR_TABLE (table)->contents[i]))
ed53084a1655 (category-table-p): Check only type and purpose.
Kenichi Handa <handa@m17n.org>
parents: 17187
diff changeset
234 XCHAR_TABLE (table)->contents[i]
ed53084a1655 (category-table-p): Check only type and purpose.
Kenichi Handa <handa@m17n.org>
parents: 17187
diff changeset
235 = (SUB_CHAR_TABLE_P (tmp)
ed53084a1655 (category-table-p): Check only type and purpose.
Kenichi Handa <handa@m17n.org>
parents: 17187
diff changeset
236 ? copy_category_table (tmp) : Fcopy_sequence (tmp));
ed53084a1655 (category-table-p): Check only type and purpose.
Kenichi Handa <handa@m17n.org>
parents: 17187
diff changeset
237
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
238 return table;
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
239 }
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
240
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
241 DEFUN ("copy-category-table", Fcopy_category_table, Scopy_category_table,
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
242 0, 1, 0,
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
243 "Construct a new category table and return it.\n\
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
244 It is a copy of the TABLE, which defaults to the standard category table.")
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
245 (table)
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
246 Lisp_Object table;
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
247 {
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
248 if (!NILP (table))
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
249 check_category_table (table);
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
250 else
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
251 table = Vstandard_category_table;
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
252
20189
16f5b56c2f68 (copy_category_table): Copy also the first extra slot
Kenichi Handa <handa@m17n.org>
parents: 19659
diff changeset
253 return copy_category_table (table);
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
254 }
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
255
26841
dfead1ef574c (word_boundary_p): Delete codes for a composite
Kenichi Handa <handa@m17n.org>
parents: 25835
diff changeset
256 DEFUN ("make-category-table", Fmake_category_table, Smake_category_table,
dfead1ef574c (word_boundary_p): Delete codes for a composite
Kenichi Handa <handa@m17n.org>
parents: 25835
diff changeset
257 0, 0, 0,
dfead1ef574c (word_boundary_p): Delete codes for a composite
Kenichi Handa <handa@m17n.org>
parents: 25835
diff changeset
258 "Construct a new and empty category table and return it.")
dfead1ef574c (word_boundary_p): Delete codes for a composite
Kenichi Handa <handa@m17n.org>
parents: 25835
diff changeset
259 ()
dfead1ef574c (word_boundary_p): Delete codes for a composite
Kenichi Handa <handa@m17n.org>
parents: 25835
diff changeset
260 {
dfead1ef574c (word_boundary_p): Delete codes for a composite
Kenichi Handa <handa@m17n.org>
parents: 25835
diff changeset
261 Lisp_Object val;
dfead1ef574c (word_boundary_p): Delete codes for a composite
Kenichi Handa <handa@m17n.org>
parents: 25835
diff changeset
262
dfead1ef574c (word_boundary_p): Delete codes for a composite
Kenichi Handa <handa@m17n.org>
parents: 25835
diff changeset
263 val = Fmake_char_table (Qcategory_table, Qnil);
dfead1ef574c (word_boundary_p): Delete codes for a composite
Kenichi Handa <handa@m17n.org>
parents: 25835
diff changeset
264 XCHAR_TABLE (val)->defalt = MAKE_CATEGORY_SET;
dfead1ef574c (word_boundary_p): Delete codes for a composite
Kenichi Handa <handa@m17n.org>
parents: 25835
diff changeset
265 Fset_char_table_extra_slot (val, make_number (0),
dfead1ef574c (word_boundary_p): Delete codes for a composite
Kenichi Handa <handa@m17n.org>
parents: 25835
diff changeset
266 Fmake_vector (make_number (95), Qnil));
dfead1ef574c (word_boundary_p): Delete codes for a composite
Kenichi Handa <handa@m17n.org>
parents: 25835
diff changeset
267 return val;
dfead1ef574c (word_boundary_p): Delete codes for a composite
Kenichi Handa <handa@m17n.org>
parents: 25835
diff changeset
268 }
dfead1ef574c (word_boundary_p): Delete codes for a composite
Kenichi Handa <handa@m17n.org>
parents: 25835
diff changeset
269
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
270 DEFUN ("set-category-table", Fset_category_table, Sset_category_table, 1, 1, 0,
20825
1b98a0ab1bee (Fmodify_category_entry): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents: 20612
diff changeset
271 "Specify TABLE as the category table for the current buffer.")
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
272 (table)
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
273 Lisp_Object table;
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
274 {
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
275 table = check_category_table (table);
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
276 current_buffer->category_table = table;
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
277 /* Indicate that this buffer now has a specified category table. */
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
278 current_buffer->local_var_flags
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
279 |= XFASTINT (buffer_local_flags.category_table);
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
280 return table;
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
281 }
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
282
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
283
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
284 DEFUN ("char-category-set", Fchar_category_set, Schar_category_set, 1, 1, 0,
20825
1b98a0ab1bee (Fmodify_category_entry): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents: 20612
diff changeset
285 "Return the category set of CHAR.")
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
286 (ch)
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
287 Lisp_Object ch;
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
288 {
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
289 Lisp_Object val;
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
290 int charset;
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
291 unsigned char c1, c2;
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
292
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
293 CHECK_NUMBER (ch, 0);
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
294 return CATEGORY_SET (XFASTINT (ch));
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
295 }
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
296
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
297 DEFUN ("category-set-mnemonics", Fcategory_set_mnemonics,
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
298 Scategory_set_mnemonics, 1, 1, 0,
20825
1b98a0ab1bee (Fmodify_category_entry): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents: 20612
diff changeset
299 "Return a string containing mnemonics of the categories in CATEGORY-SET.\n\
1b98a0ab1bee (Fmodify_category_entry): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents: 20612
diff changeset
300 CATEGORY-SET is a bool-vector, and the categories \"in\" it are those\n\
1b98a0ab1bee (Fmodify_category_entry): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents: 20612
diff changeset
301 that are indexes where t occurs the bool-vector.\n\
1b98a0ab1bee (Fmodify_category_entry): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents: 20612
diff changeset
302 The return value is a string containing those same categories.")
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
303 (category_set)
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
304 Lisp_Object category_set;
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
305 {
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
306 int i, j;
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
307 char str[96];
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
308
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
309 CHECK_CATEGORY_SET (category_set, 0);
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
310
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
311 j = 0;
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
312 for (i = 32; i < 127; i++)
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
313 if (CATEGORY_MEMBER (i, category_set))
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
314 str[j++] = i;
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
315 str[j] = '\0';
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
316
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
317 return build_string (str);
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
318 }
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
319
17324
ed53084a1655 (category-table-p): Check only type and purpose.
Kenichi Handa <handa@m17n.org>
parents: 17187
diff changeset
320 /* Modify all category sets stored under sub char-table TABLE so that
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
321 they contain (SET_VALUE is t) or don't contain (SET_VALUE is nil)
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
322 CATEGORY. */
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
323
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
324 void
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
325 modify_lower_category_set (table, category, set_value)
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
326 Lisp_Object table, category, set_value;
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
327 {
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
328 Lisp_Object val;
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
329 int i;
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
330
25835
265202db376b (modify_lower_category_set): Set default value of
Kenichi Handa <handa@m17n.org>
parents: 25662
diff changeset
331 val = XCHAR_TABLE (table)->defalt;
265202db376b (modify_lower_category_set): Set default value of
Kenichi Handa <handa@m17n.org>
parents: 25662
diff changeset
332 if (!CATEGORY_SET_P (val))
265202db376b (modify_lower_category_set): Set default value of
Kenichi Handa <handa@m17n.org>
parents: 25662
diff changeset
333 val = MAKE_CATEGORY_SET;
265202db376b (modify_lower_category_set): Set default value of
Kenichi Handa <handa@m17n.org>
parents: 25662
diff changeset
334 SET_CATEGORY_SET (val, category, set_value);
265202db376b (modify_lower_category_set): Set default value of
Kenichi Handa <handa@m17n.org>
parents: 25662
diff changeset
335 XCHAR_TABLE (table)->defalt = val;
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
336
17324
ed53084a1655 (category-table-p): Check only type and purpose.
Kenichi Handa <handa@m17n.org>
parents: 17187
diff changeset
337 for (i = 32; i < SUB_CHAR_TABLE_ORDINARY_SLOTS; i++)
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
338 {
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
339 val = XCHAR_TABLE (table)->contents[i];
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
340
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
341 if (CATEGORY_SET_P (val))
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
342 SET_CATEGORY_SET (val, category, set_value);
17324
ed53084a1655 (category-table-p): Check only type and purpose.
Kenichi Handa <handa@m17n.org>
parents: 17187
diff changeset
343 else if (SUB_CHAR_TABLE_P (val))
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
344 modify_lower_category_set (val, category, set_value);
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
345 }
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
346 }
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
347
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
348 void
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
349 set_category_set (category_set, category, val)
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
350 Lisp_Object category_set, category, val;
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
351 {
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
352 do {
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
353 int idx = XINT (category) / 8;
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
354 unsigned char bits = 1 << (XINT (category) % 8);
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
355
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
356 if (NILP (val))
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
357 XCATEGORY_SET (category_set)->data[idx] &= ~bits;
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
358 else
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
359 XCATEGORY_SET (category_set)->data[idx] |= bits;
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
360 } while (0);
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
361 }
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
362
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
363 DEFUN ("modify-category-entry", Fmodify_category_entry,
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
364 Smodify_category_entry, 2, 4, 0,
20825
1b98a0ab1bee (Fmodify_category_entry): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents: 20612
diff changeset
365 "Modify the category set of CHARACTER by adding CATEGORY to it.\n\
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
366 The category is changed only for table TABLE, which defaults to\n\
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
367 the current buffer's category table.\n\
20825
1b98a0ab1bee (Fmodify_category_entry): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents: 20612
diff changeset
368 If optional fourth argument RESET is non-nil,\n\
1b98a0ab1bee (Fmodify_category_entry): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents: 20612
diff changeset
369 then delete CATEGORY from the category set instead of adding it.")
1b98a0ab1bee (Fmodify_category_entry): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents: 20612
diff changeset
370 (character, category, table, reset)
1b98a0ab1bee (Fmodify_category_entry): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents: 20612
diff changeset
371 Lisp_Object character, category, table, reset;
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
372 {
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
373 int c, charset, c1, c2;
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
374 Lisp_Object set_value; /* Actual value to be set in category sets. */
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
375 Lisp_Object val, category_set;
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
376
20825
1b98a0ab1bee (Fmodify_category_entry): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents: 20612
diff changeset
377 CHECK_NUMBER (character, 0);
1b98a0ab1bee (Fmodify_category_entry): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents: 20612
diff changeset
378 c = XINT (character);
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
379 CHECK_CATEGORY (category, 1);
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
380 table = check_category_table (table);
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
381
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
382 if (NILP (CATEGORY_DOCSTRING (table, XFASTINT (category))))
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
383 error ("Undefined category: %c", XFASTINT (category));
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
384
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
385 set_value = NILP (reset) ? Qt : Qnil;
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
386
17324
ed53084a1655 (category-table-p): Check only type and purpose.
Kenichi Handa <handa@m17n.org>
parents: 17187
diff changeset
387 if (c < CHAR_TABLE_SINGLE_BYTE_SLOTS)
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
388 {
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
389 val = XCHAR_TABLE (table)->contents[c];
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
390 if (!CATEGORY_SET_P (val))
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
391 XCHAR_TABLE (table)->contents[c] = (val = MAKE_CATEGORY_SET);
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
392 SET_CATEGORY_SET (val, category, set_value);
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
393 return Qnil;
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
394 }
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
395
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
396 SPLIT_NON_ASCII_CHAR (c, charset, c1, c2);
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
397
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
398 /* The top level table. */
17187
9ab0c08a3359 Adjusted for the change of CHAR_TABLE_ORDINARY_SLOTS.
Kenichi Handa <handa@m17n.org>
parents: 17071
diff changeset
399 val = XCHAR_TABLE (table)->contents[charset + 128];
17324
ed53084a1655 (category-table-p): Check only type and purpose.
Kenichi Handa <handa@m17n.org>
parents: 17187
diff changeset
400 if (CATEGORY_SET_P (val))
ed53084a1655 (category-table-p): Check only type and purpose.
Kenichi Handa <handa@m17n.org>
parents: 17187
diff changeset
401 category_set = val;
ed53084a1655 (category-table-p): Check only type and purpose.
Kenichi Handa <handa@m17n.org>
parents: 17187
diff changeset
402 else if (!SUB_CHAR_TABLE_P (val))
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
403 {
17324
ed53084a1655 (category-table-p): Check only type and purpose.
Kenichi Handa <handa@m17n.org>
parents: 17187
diff changeset
404 category_set = val = MAKE_CATEGORY_SET;
17187
9ab0c08a3359 Adjusted for the change of CHAR_TABLE_ORDINARY_SLOTS.
Kenichi Handa <handa@m17n.org>
parents: 17071
diff changeset
405 XCHAR_TABLE (table)->contents[charset + 128] = category_set;
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
406 }
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
407
17324
ed53084a1655 (category-table-p): Check only type and purpose.
Kenichi Handa <handa@m17n.org>
parents: 17187
diff changeset
408 if (c1 <= 0)
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
409 {
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
410 /* Only a charset is specified. */
17324
ed53084a1655 (category-table-p): Check only type and purpose.
Kenichi Handa <handa@m17n.org>
parents: 17187
diff changeset
411 if (SUB_CHAR_TABLE_P (val))
ed53084a1655 (category-table-p): Check only type and purpose.
Kenichi Handa <handa@m17n.org>
parents: 17187
diff changeset
412 /* All characters in CHARSET should be the same as for having
ed53084a1655 (category-table-p): Check only type and purpose.
Kenichi Handa <handa@m17n.org>
parents: 17187
diff changeset
413 CATEGORY or not. */
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
414 modify_lower_category_set (val, category, set_value);
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
415 else
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
416 SET_CATEGORY_SET (category_set, category, set_value);
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
417 return Qnil;
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
418 }
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
419
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
420 /* The second level table. */
17324
ed53084a1655 (category-table-p): Check only type and purpose.
Kenichi Handa <handa@m17n.org>
parents: 17187
diff changeset
421 if (!SUB_CHAR_TABLE_P (val))
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
422 {
17324
ed53084a1655 (category-table-p): Check only type and purpose.
Kenichi Handa <handa@m17n.org>
parents: 17187
diff changeset
423 val = make_sub_char_table (Qnil);
17187
9ab0c08a3359 Adjusted for the change of CHAR_TABLE_ORDINARY_SLOTS.
Kenichi Handa <handa@m17n.org>
parents: 17071
diff changeset
424 XCHAR_TABLE (table)->contents[charset + 128] = val;
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
425 /* We must set default category set of CHARSET in `defalt' slot. */
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
426 XCHAR_TABLE (val)->defalt = category_set;
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
427 }
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
428 table = val;
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
429
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
430 val = XCHAR_TABLE (table)->contents[c1];
17324
ed53084a1655 (category-table-p): Check only type and purpose.
Kenichi Handa <handa@m17n.org>
parents: 17187
diff changeset
431 if (CATEGORY_SET_P (val))
ed53084a1655 (category-table-p): Check only type and purpose.
Kenichi Handa <handa@m17n.org>
parents: 17187
diff changeset
432 category_set = val;
ed53084a1655 (category-table-p): Check only type and purpose.
Kenichi Handa <handa@m17n.org>
parents: 17187
diff changeset
433 else if (!SUB_CHAR_TABLE_P (val))
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
434 {
17324
ed53084a1655 (category-table-p): Check only type and purpose.
Kenichi Handa <handa@m17n.org>
parents: 17187
diff changeset
435 category_set = val = Fcopy_sequence (XCHAR_TABLE (table)->defalt);
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
436 XCHAR_TABLE (table)->contents[c1] = category_set;
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
437 }
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
438
17324
ed53084a1655 (category-table-p): Check only type and purpose.
Kenichi Handa <handa@m17n.org>
parents: 17187
diff changeset
439 if (c2 <= 0)
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
440 {
17324
ed53084a1655 (category-table-p): Check only type and purpose.
Kenichi Handa <handa@m17n.org>
parents: 17187
diff changeset
441 if (SUB_CHAR_TABLE_P (val))
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
442 /* All characters in C1 group of CHARSET should be the same as
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
443 for CATEGORY. */
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
444 modify_lower_category_set (val, category, set_value);
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
445 else
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
446 SET_CATEGORY_SET (category_set, category, set_value);
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
447 return Qnil;
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
448 }
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
449
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
450 /* The third (bottom) level table. */
17324
ed53084a1655 (category-table-p): Check only type and purpose.
Kenichi Handa <handa@m17n.org>
parents: 17187
diff changeset
451 if (!SUB_CHAR_TABLE_P (val))
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
452 {
17459
22fc94ab9e79 (Fmodify_category_entry): Delete second arg in call to make_sub_char_table.
Karl Heuer <kwzh@gnu.org>
parents: 17369
diff changeset
453 val = make_sub_char_table (Qnil);
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
454 XCHAR_TABLE (table)->contents[c1] = val;
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
455 /* We must set default category set of CHARSET and C1 in
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
456 `defalt' slot. */
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
457 XCHAR_TABLE (val)->defalt = category_set;
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
458 }
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
459 table = val;
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
460
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
461 val = XCHAR_TABLE (table)->contents[c2];
17324
ed53084a1655 (category-table-p): Check only type and purpose.
Kenichi Handa <handa@m17n.org>
parents: 17187
diff changeset
462 if (CATEGORY_SET_P (val))
ed53084a1655 (category-table-p): Check only type and purpose.
Kenichi Handa <handa@m17n.org>
parents: 17187
diff changeset
463 category_set = val;
ed53084a1655 (category-table-p): Check only type and purpose.
Kenichi Handa <handa@m17n.org>
parents: 17187
diff changeset
464 else if (!SUB_CHAR_TABLE_P (val))
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
465 {
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
466 category_set = Fcopy_sequence (XCHAR_TABLE (table)->defalt);
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
467 XCHAR_TABLE (table)->contents[c2] = category_set;
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
468 }
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
469 else
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
470 /* This should never happen. */
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
471 error ("Invalid category table");
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
472
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
473 SET_CATEGORY_SET (category_set, category, set_value);
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
474
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
475 return Qnil;
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
476 }
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
477
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
478 /* Dump category table to buffer in human-readable format */
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
479
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
480 static void
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
481 describe_category (value)
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
482 Lisp_Object value;
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
483 {
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
484 Lisp_Object mnemonics;
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
485
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
486 Findent_to (make_number (16), make_number (1));
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
487
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
488 if (NILP (value))
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
489 {
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
490 insert_string ("default\n");
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
491 return;
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
492 }
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
493
19659
315acc2627fe (describe_category): Handle a sub-chartable.
Richard M. Stallman <rms@gnu.org>
parents: 18613
diff changeset
494 if (CHAR_TABLE_P (value))
315acc2627fe (describe_category): Handle a sub-chartable.
Richard M. Stallman <rms@gnu.org>
parents: 18613
diff changeset
495 {
315acc2627fe (describe_category): Handle a sub-chartable.
Richard M. Stallman <rms@gnu.org>
parents: 18613
diff changeset
496 insert_string ("deeper char-table ...\n");
315acc2627fe (describe_category): Handle a sub-chartable.
Richard M. Stallman <rms@gnu.org>
parents: 18613
diff changeset
497 return;
315acc2627fe (describe_category): Handle a sub-chartable.
Richard M. Stallman <rms@gnu.org>
parents: 18613
diff changeset
498 }
315acc2627fe (describe_category): Handle a sub-chartable.
Richard M. Stallman <rms@gnu.org>
parents: 18613
diff changeset
499
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
500 if (!CATEGORY_SET_P (value))
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
501 {
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
502 insert_string ("invalid\n");
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
503 return;
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
504 }
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
505
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
506 mnemonics = Fcategory_set_mnemonics (value);
20612
5a0922f8c841 (Fmake_category_set): Don't allow multibyte string.
Richard M. Stallman <rms@gnu.org>
parents: 20189
diff changeset
507 insert_from_string (mnemonics, 0, 0, XSTRING (mnemonics)->size,
21244
50929073a0ba Use STRING_BYTES and SET_STRING_BYTES.
Richard M. Stallman <rms@gnu.org>
parents: 20825
diff changeset
508 STRING_BYTES (XSTRING (mnemonics)), 0);
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
509 insert_string ("\n");
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
510 return;
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
511 }
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
512
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
513 static Lisp_Object
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
514 describe_category_1 (vector)
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
515 Lisp_Object vector;
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
516 {
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
517 struct buffer *old = current_buffer;
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
518 set_buffer_internal (XBUFFER (Vstandard_output));
17787
eacf563a6d0d (describe_category_1): Pass new args to describe_vector.
Richard M. Stallman <rms@gnu.org>
parents: 17459
diff changeset
519 describe_vector (vector, Qnil, describe_category, 0, Qnil, Qnil,
eacf563a6d0d (describe_category_1): Pass new args to describe_vector.
Richard M. Stallman <rms@gnu.org>
parents: 17459
diff changeset
520 (int *)0, 0);
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
521 {
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
522 int i;
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
523 Lisp_Object docs = XCHAR_TABLE (vector)->extras[0];
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
524 Lisp_Object elt;
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
525
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
526 if (!VECTORP (docs) || XVECTOR (docs)->size != 95)
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
527 {
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
528 insert_string ("Invalid first extra slot in this char table\n");
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
529 return Qnil;
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
530 }
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
531
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
532 insert_string ("Meanings of mnemonice characters are:\n");
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
533 for (i = 0; i < 95; i++)
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
534 {
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
535 elt = XVECTOR (docs)->contents[i];
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
536 if (NILP (elt))
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
537 continue;
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
538
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
539 insert_char (i + 32);
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
540 insert (": ", 2);
20612
5a0922f8c841 (Fmake_category_set): Don't allow multibyte string.
Richard M. Stallman <rms@gnu.org>
parents: 20189
diff changeset
541 insert_from_string (elt, 0, 0, XSTRING (elt)->size,
21244
50929073a0ba Use STRING_BYTES and SET_STRING_BYTES.
Richard M. Stallman <rms@gnu.org>
parents: 20825
diff changeset
542 STRING_BYTES (XSTRING (elt)), 0);
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
543 insert ("\n", 1);
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
544 }
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
545 }
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
546
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
547 while (! NILP (XCHAR_TABLE (vector)->parent))
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
548 {
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
549 vector = XCHAR_TABLE (vector)->parent;
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
550 insert_string ("\nThe parent category table is:");
17787
eacf563a6d0d (describe_category_1): Pass new args to describe_vector.
Richard M. Stallman <rms@gnu.org>
parents: 17459
diff changeset
551 describe_vector (vector, Qnil, describe_category, 0, Qnil, Qnil,
eacf563a6d0d (describe_category_1): Pass new args to describe_vector.
Richard M. Stallman <rms@gnu.org>
parents: 17459
diff changeset
552 (int *) 0, 0);
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
553 }
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
554
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
555 call0 (intern ("help-mode"));
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
556 set_buffer_internal (old);
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
557 return Qnil;
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
558 }
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
559
20825
1b98a0ab1bee (Fmodify_category_entry): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents: 20612
diff changeset
560 DEFUN ("describe-categories", Fdescribe_categories, Sdescribe_categories, 0, 0, "",
1b98a0ab1bee (Fmodify_category_entry): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents: 20612
diff changeset
561 "Describe the category specifications in the current category table.\n\
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
562 The descriptions are inserted in a buffer, which is then displayed.")
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
563 ()
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
564 {
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
565 internal_with_output_to_temp_buffer
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
566 ("*Help*", describe_category_1, current_buffer->category_table);
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
567
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
568 return Qnil;
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
569 }
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
570
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
571 /* Return 1 if there is a word boundary between two word-constituent
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
572 characters C1 and C2 if they appear in this order, else return 0.
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
573 Use the macro WORD_BOUNDARY_P instead of calling this function
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
574 directly. */
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
575
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
576 int
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
577 word_boundary_p (c1, c2)
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
578 int c1, c2;
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
579 {
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
580 Lisp_Object category_set1, category_set2;
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
581 Lisp_Object tail;
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
582 int default_result;
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
583
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
584 if (CHAR_CHARSET (c1) == CHAR_CHARSET (c2))
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
585 {
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
586 tail = Vword_separating_categories;
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
587 default_result = 0;
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
588 }
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
589 else
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
590 {
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
591 tail = Vword_combining_categories;
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
592 default_result = 1;
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
593 }
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
594
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
595 category_set1 = CATEGORY_SET (c1);
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
596 if (NILP (category_set1))
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
597 return default_result;
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
598 category_set2 = CATEGORY_SET (c2);
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
599 if (NILP (category_set2))
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
600 return default_result;
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
601
25662
0a7261c1d487 Use XCAR, XCDR, and XFLOAT_DATA instead of explicit member access.
Ken Raeburn <raeburn@raeburn.org>
parents: 23755
diff changeset
602 for (; CONSP (tail); tail = XCDR (tail))
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
603 {
25662
0a7261c1d487 Use XCAR, XCDR, and XFLOAT_DATA instead of explicit member access.
Ken Raeburn <raeburn@raeburn.org>
parents: 23755
diff changeset
604 Lisp_Object elt = XCAR (tail);
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
605
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
606 if (CONSP (elt)
25662
0a7261c1d487 Use XCAR, XCDR, and XFLOAT_DATA instead of explicit member access.
Ken Raeburn <raeburn@raeburn.org>
parents: 23755
diff changeset
607 && CATEGORYP (XCAR (elt))
0a7261c1d487 Use XCAR, XCDR, and XFLOAT_DATA instead of explicit member access.
Ken Raeburn <raeburn@raeburn.org>
parents: 23755
diff changeset
608 && CATEGORYP (XCDR (elt))
0a7261c1d487 Use XCAR, XCDR, and XFLOAT_DATA instead of explicit member access.
Ken Raeburn <raeburn@raeburn.org>
parents: 23755
diff changeset
609 && CATEGORY_MEMBER (XFASTINT (XCAR (elt)), category_set1)
0a7261c1d487 Use XCAR, XCDR, and XFLOAT_DATA instead of explicit member access.
Ken Raeburn <raeburn@raeburn.org>
parents: 23755
diff changeset
610 && CATEGORY_MEMBER (XFASTINT (XCDR (elt)), category_set2))
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
611 return !default_result;
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
612 }
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
613 return default_result;
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
614 }
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
615
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
616
21514
fa9ff387d260 Fix -Wimplicit warnings.
Andreas Schwab <schwab@suse.de>
parents: 21244
diff changeset
617 void
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
618 init_category_once ()
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
619 {
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
620 /* This has to be done here, before we call Fmake_char_table. */
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
621 Qcategory_table = intern ("category-table");
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
622 staticpro (&Qcategory_table);
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
623
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
624 /* Intern this now in case it isn't already done.
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
625 Setting this variable twice is harmless.
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
626 But don't staticpro it here--that is done in alloc.c. */
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
627 Qchar_table_extra_slots = intern ("char-table-extra-slots");
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
628
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
629 /* Now we are ready to set up this property, so we can
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
630 create category tables. */
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
631 Fput (Qcategory_table, Qchar_table_extra_slots, make_number (2));
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
632
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
633 Vstandard_category_table = Fmake_char_table (Qcategory_table, Qnil);
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
634 /* Set a category set which contains nothing to the default. */
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
635 XCHAR_TABLE (Vstandard_category_table)->defalt = MAKE_CATEGORY_SET;
20189
16f5b56c2f68 (copy_category_table): Copy also the first extra slot
Kenichi Handa <handa@m17n.org>
parents: 19659
diff changeset
636 Fset_char_table_extra_slot (Vstandard_category_table, make_number (0),
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
637 Fmake_vector (make_number (95), Qnil));
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
638 }
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
639
21514
fa9ff387d260 Fix -Wimplicit warnings.
Andreas Schwab <schwab@suse.de>
parents: 21244
diff changeset
640 void
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
641 syms_of_category ()
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
642 {
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
643 Qcategoryp = intern ("categoryp");
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
644 staticpro (&Qcategoryp);
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
645 Qcategorysetp = intern ("categorysetp");
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
646 staticpro (&Qcategorysetp);
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
647 Qcategory_table_p = intern ("category-table-p");
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
648 staticpro (&Qcategory_table_p);
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
649
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
650 DEFVAR_LISP ("word-combining-categories", &Vword_combining_categories,
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
651 "List of pair (cons) of categories to determine word boundary.\n\
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
652 \n\
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
653 Emacs treats a sequence of word constituent characters as a single\n\
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
654 word (i.e. finds no word boundary between them) iff they belongs to\n\
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
655 the same charset. But, exceptions are allowed in the following cases.\n\
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
656 \n\
23543
6f3b920860e5 (syms_of_category): Doc-string modified.
Kenichi Handa <handa@m17n.org>
parents: 21514
diff changeset
657 \(1) The case that characters are in different charsets is controlled\n\
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
658 by the variable `word-combining-categories'.\n\
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
659 \n\
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
660 Emacs finds no word boundary between characters of different charsets\n\
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
661 if they have categories matching some element of this list.\n\
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
662 \n\
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
663 More precisely, if an element of this list is a cons of category CAT1\n\
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
664 and CAT2, and a multibyte character C1 which has CAT1 is followed by\n\
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
665 C2 which has CAT2, there's no word boundary between C1 and C2.\n\
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
666 \n\
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
667 For instance, to tell that ASCII characters and Latin-1 characters can\n\
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
668 form a single word, the element `(?l . ?l)' should be in this list\n\
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
669 because both characters have the category `l' (Latin characters).\n\
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
670 \n\
23543
6f3b920860e5 (syms_of_category): Doc-string modified.
Kenichi Handa <handa@m17n.org>
parents: 21514
diff changeset
671 \(2) The case that character are in the same charset is controlled by\n\
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
672 the variable `word-separating-categories'.\n\
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
673 \n\
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
674 Emacs find a word boundary between characters of the same charset\n\
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
675 if they have categories matching some element of this list.\n\
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
676 \n\
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
677 More precisely, if an element of this list is a cons of category CAT1\n\
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
678 and CAT2, and a multibyte character C1 which has CAT1 is followed by\n\
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
679 C2 which has CAT2, there's a word boundary between C1 and C2.\n\
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
680 \n\
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
681 For instance, to tell that there's a word boundary between Japanese\n\
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
682 Hiragana and Japanese Kanji (both are in the same charset), the\n\
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
683 element `(?H . ?C) should be in this list.");
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
684
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
685 Vword_combining_categories = Qnil;
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
686
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
687 DEFVAR_LISP ("word-separating-categories", &Vword_separating_categories,
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
688 "List of pair (cons) of categories to determine word boundary.\n\
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
689 See the documentation of the variable `word-combining-categories'.");
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
690
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
691 Vword_separating_categories = Qnil;
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
692
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
693 defsubr (&Smake_category_set);
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
694 defsubr (&Sdefine_category);
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
695 defsubr (&Scategory_docstring);
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
696 defsubr (&Sget_unused_category);
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
697 defsubr (&Scategory_table_p);
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
698 defsubr (&Scategory_table);
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
699 defsubr (&Sstandard_category_table);
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
700 defsubr (&Scopy_category_table);
26841
dfead1ef574c (word_boundary_p): Delete codes for a composite
Kenichi Handa <handa@m17n.org>
parents: 25835
diff changeset
701 defsubr (&Smake_category_table);
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
702 defsubr (&Sset_category_table);
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
703 defsubr (&Schar_category_set);
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
704 defsubr (&Scategory_set_mnemonics);
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
705 defsubr (&Smodify_category_entry);
20825
1b98a0ab1bee (Fmodify_category_entry): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents: 20612
diff changeset
706 defsubr (&Sdescribe_categories);
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
707
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
708 category_table_version = 0;
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
709 }