Mercurial > emacs
annotate src/category.c @ 80189:7eb8c249adfa
* xterm.c (x_set_offset): Don't change the gravity if
CHANGE_GRAVITY is -1.
author | Chong Yidong <cyd@stupidchicken.com> |
---|---|
date | Sun, 24 Feb 2008 01:04:34 +0000 |
parents | fc2bcd2a8aad |
children | 606f2d163a64 |
rev | line source |
---|---|
17052 | 1 /* GNU Emacs routines to deal with category tables. |
79759 | 2 Copyright (C) 1998, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008 |
75227
e90d04cd455a
Update copyright for years from Emacs 21 to present (mainly adding
Glenn Morris <rgm@gnu.org>
parents:
74605
diff
changeset
|
3 Free Software Foundation, Inc. |
74605
6ee41fdd69ff
Update AIST copyright years.
Kenichi Handa <handa@m17n.org>
parents:
73927
diff
changeset
|
4 Copyright (C) 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, |
79759 | 5 2005, 2006, 2007, 2008 |
67658 | 6 National Institute of Advanced Industrial Science and Technology (AIST) |
7 Registration Number H14PRO021 | |
17052 | 8 |
9 This file is part of GNU Emacs. | |
10 | |
11 GNU Emacs is free software; you can redistribute it and/or modify | |
12 it under the terms of the GNU General Public License as published by | |
78313
2b9404c2f01f
Remove license from trivial file.
Glenn Morris <rgm@gnu.org>
parents:
75227
diff
changeset
|
13 the Free Software Foundation; either version 3, or (at your option) |
17052 | 14 any later version. |
15 | |
16 GNU Emacs is distributed in the hope that it will be useful, | |
17 but WITHOUT ANY WARRANTY; without even the implied warranty of | |
18 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
19 GNU General Public License for more details. | |
20 | |
21 You should have received a copy of the GNU General Public License | |
22 along with GNU Emacs; see the file COPYING. If not, write to | |
64084 | 23 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, |
24 Boston, MA 02110-1301, USA. */ | |
17052 | 25 |
26 | |
27 /* Here we handle three objects: category, category set, and category | |
28 table. Read comments in the file category.h to understand them. */ | |
29 | |
30 #include <config.h> | |
31 #include <ctype.h> | |
32 #include "lisp.h" | |
33 #include "buffer.h" | |
34 #include "charset.h" | |
35 #include "category.h" | |
39748
42b7a798ff79
Include keymap.h.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
34984
diff
changeset
|
36 #include "keymap.h" |
17052 | 37 |
38 /* The version number of the latest category table. Each category | |
39 table has a unique version number. It is assigned a new number | |
40 also when it is modified. When a regular expression is compiled | |
41 into the struct re_pattern_buffer, the version number of the | |
42 category table (of the current buffer) at that moment is also | |
43 embedded in the structure. | |
44 | |
45 For the moment, we are not using this feature. */ | |
46 static int category_table_version; | |
47 | |
48 Lisp_Object Qcategory_table, Qcategoryp, Qcategorysetp, Qcategory_table_p; | |
49 | |
50 /* Variables to determine word boundary. */ | |
51 Lisp_Object Vword_combining_categories, Vword_separating_categories; | |
52 | |
53 /* Temporary internal variable used in macro CHAR_HAS_CATEGORY. */ | |
54 Lisp_Object _temp_category_set; | |
55 | |
56 | |
57 /* Category set staff. */ | |
58 | |
59 DEFUN ("make-category-set", Fmake_category_set, Smake_category_set, 1, 1, 0, | |
40103
6b389fb978bc
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Janík <Pavel@Janik.cz>
parents:
39748
diff
changeset
|
60 doc: /* Return a newly created category-set which contains CATEGORIES. |
6b389fb978bc
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Janík <Pavel@Janik.cz>
parents:
39748
diff
changeset
|
61 CATEGORIES is a string of category mnemonics. |
6b389fb978bc
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Janík <Pavel@Janik.cz>
parents:
39748
diff
changeset
|
62 The value is a bool-vector which has t at the indices corresponding to |
6b389fb978bc
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Janík <Pavel@Janik.cz>
parents:
39748
diff
changeset
|
63 those categories. */) |
6b389fb978bc
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Janík <Pavel@Janik.cz>
parents:
39748
diff
changeset
|
64 (categories) |
17052 | 65 Lisp_Object categories; |
66 { | |
67 Lisp_Object val; | |
68 int len; | |
69 | |
40656
cdfd4d09b79a
Update usage of CHECK_ macros (remove unused second argument).
Pavel Janík <Pavel@Janik.cz>
parents:
40103
diff
changeset
|
70 CHECK_STRING (categories); |
17052 | 71 val = MAKE_CATEGORY_SET; |
72 | |
20612
5a0922f8c841
(Fmake_category_set): Don't allow multibyte string.
Richard M. Stallman <rms@gnu.org>
parents:
20189
diff
changeset
|
73 if (STRING_MULTIBYTE (categories)) |
63694
8f10ba0f0a86
(Fmake_category_set): Follow error conventions.
Juanma Barranquero <lekktu@gmail.com>
parents:
54091
diff
changeset
|
74 error ("Multibyte string in `make-category-set'"); |
20612
5a0922f8c841
(Fmake_category_set): Don't allow multibyte string.
Richard M. Stallman <rms@gnu.org>
parents:
20189
diff
changeset
|
75 |
46370
40db0673e6f0
Most uses of XSTRING combined with STRING_BYTES or indirection changed to
Ken Raeburn <raeburn@raeburn.org>
parents:
41643
diff
changeset
|
76 len = SCHARS (categories); |
17052 | 77 while (--len >= 0) |
78 { | |
17369
566b26e1930e
(Fmake_category_set): Use XSETFASTINT.
Karl Heuer <kwzh@gnu.org>
parents:
17324
diff
changeset
|
79 Lisp_Object category; |
17052 | 80 |
46370
40db0673e6f0
Most uses of XSTRING combined with STRING_BYTES or indirection changed to
Ken Raeburn <raeburn@raeburn.org>
parents:
41643
diff
changeset
|
81 XSETFASTINT (category, SREF (categories, len)); |
40656
cdfd4d09b79a
Update usage of CHECK_ macros (remove unused second argument).
Pavel Janík <Pavel@Janik.cz>
parents:
40103
diff
changeset
|
82 CHECK_CATEGORY (category); |
17052 | 83 SET_CATEGORY_SET (val, category, Qt); |
84 } | |
85 return val; | |
86 } | |
87 | |
88 | |
89 /* Category staff. */ | |
90 | |
91 Lisp_Object check_category_table (); | |
92 | |
93 DEFUN ("define-category", Fdefine_category, Sdefine_category, 2, 3, 0, | |
54091
15dabc5988ff
(Fdefine_category, Fcategory_docstring)
Luc Teirlinck <teirllm@auburn.edu>
parents:
52401
diff
changeset
|
94 doc: /* Define CATEGORY as a category which is described by DOCSTRING. |
15dabc5988ff
(Fdefine_category, Fcategory_docstring)
Luc Teirlinck <teirllm@auburn.edu>
parents:
52401
diff
changeset
|
95 CATEGORY should be an ASCII printing character in the range ` ' to `~'. |
15dabc5988ff
(Fdefine_category, Fcategory_docstring)
Luc Teirlinck <teirllm@auburn.edu>
parents:
52401
diff
changeset
|
96 DOCSTRING is the documentation string of the category. |
40103
6b389fb978bc
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Janík <Pavel@Janik.cz>
parents:
39748
diff
changeset
|
97 The category is defined only in category table TABLE, which defaults to |
54091
15dabc5988ff
(Fdefine_category, Fcategory_docstring)
Luc Teirlinck <teirllm@auburn.edu>
parents:
52401
diff
changeset
|
98 the current buffer's category table. */) |
40103
6b389fb978bc
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Janík <Pavel@Janik.cz>
parents:
39748
diff
changeset
|
99 (category, docstring, table) |
17052 | 100 Lisp_Object category, docstring, table; |
101 { | |
40656
cdfd4d09b79a
Update usage of CHECK_ macros (remove unused second argument).
Pavel Janík <Pavel@Janik.cz>
parents:
40103
diff
changeset
|
102 CHECK_CATEGORY (category); |
cdfd4d09b79a
Update usage of CHECK_ macros (remove unused second argument).
Pavel Janík <Pavel@Janik.cz>
parents:
40103
diff
changeset
|
103 CHECK_STRING (docstring); |
17052 | 104 table = check_category_table (table); |
105 | |
106 if (!NILP (CATEGORY_DOCSTRING (table, XFASTINT (category)))) | |
107 error ("Category `%c' is already defined", XFASTINT (category)); | |
108 CATEGORY_DOCSTRING (table, XFASTINT (category)) = docstring; | |
109 | |
110 return Qnil; | |
111 } | |
112 | |
113 DEFUN ("category-docstring", Fcategory_docstring, Scategory_docstring, 1, 2, 0, | |
54091
15dabc5988ff
(Fdefine_category, Fcategory_docstring)
Luc Teirlinck <teirllm@auburn.edu>
parents:
52401
diff
changeset
|
114 doc: /* Return the documentation string of CATEGORY, as defined in TABLE. |
15dabc5988ff
(Fdefine_category, Fcategory_docstring)
Luc Teirlinck <teirllm@auburn.edu>
parents:
52401
diff
changeset
|
115 TABLE should be a category table and defaults to the current buffer's |
15dabc5988ff
(Fdefine_category, Fcategory_docstring)
Luc Teirlinck <teirllm@auburn.edu>
parents:
52401
diff
changeset
|
116 category table. */) |
40103
6b389fb978bc
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Janík <Pavel@Janik.cz>
parents:
39748
diff
changeset
|
117 (category, table) |
17052 | 118 Lisp_Object category, table; |
119 { | |
40656
cdfd4d09b79a
Update usage of CHECK_ macros (remove unused second argument).
Pavel Janík <Pavel@Janik.cz>
parents:
40103
diff
changeset
|
120 CHECK_CATEGORY (category); |
17052 | 121 table = check_category_table (table); |
122 | |
123 return CATEGORY_DOCSTRING (table, XFASTINT (category)); | |
124 } | |
125 | |
126 DEFUN ("get-unused-category", Fget_unused_category, Sget_unused_category, | |
127 0, 1, 0, | |
54091
15dabc5988ff
(Fdefine_category, Fcategory_docstring)
Luc Teirlinck <teirllm@auburn.edu>
parents:
52401
diff
changeset
|
128 doc: /* Return a category which is not yet defined in TABLE. |
41038
a882905d8a96
(Fget_unused_category): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents:
40656
diff
changeset
|
129 If no category remains available, return nil. |
54091
15dabc5988ff
(Fdefine_category, Fcategory_docstring)
Luc Teirlinck <teirllm@auburn.edu>
parents:
52401
diff
changeset
|
130 The optional argument TABLE specifies which category table to modify; |
41038
a882905d8a96
(Fget_unused_category): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents:
40656
diff
changeset
|
131 it defaults to the current buffer's category table. */) |
40103
6b389fb978bc
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Janík <Pavel@Janik.cz>
parents:
39748
diff
changeset
|
132 (table) |
17052 | 133 Lisp_Object table; |
134 { | |
135 int i; | |
136 | |
137 table = check_category_table (table); | |
138 | |
139 for (i = ' '; i <= '~'; i++) | |
140 if (NILP (CATEGORY_DOCSTRING (table, i))) | |
141 return make_number (i); | |
142 | |
143 return Qnil; | |
144 } | |
145 | |
146 | |
147 /* Category-table staff. */ | |
148 | |
149 DEFUN ("category-table-p", Fcategory_table_p, Scategory_table_p, 1, 1, 0, | |
40103
6b389fb978bc
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Janík <Pavel@Janik.cz>
parents:
39748
diff
changeset
|
150 doc: /* Return t if ARG is a category table. */) |
6b389fb978bc
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Janík <Pavel@Janik.cz>
parents:
39748
diff
changeset
|
151 (arg) |
17052 | 152 Lisp_Object arg; |
153 { | |
154 if (CHAR_TABLE_P (arg) | |
17324
ed53084a1655
(category-table-p): Check only type and purpose.
Kenichi Handa <handa@m17n.org>
parents:
17187
diff
changeset
|
155 && EQ (XCHAR_TABLE (arg)->purpose, Qcategory_table)) |
17052 | 156 return Qt; |
157 return Qnil; | |
158 } | |
159 | |
160 /* If TABLE is nil, return the current category table. If TABLE is | |
161 not nil, check the validity of TABLE as a category table. If | |
162 valid, return TABLE itself, but if not valid, signal an error of | |
163 wrong-type-argument. */ | |
164 | |
165 Lisp_Object | |
166 check_category_table (table) | |
167 Lisp_Object table; | |
168 { | |
169 if (NILP (table)) | |
170 return current_buffer->category_table; | |
71829
8adcaaf366b4
(check_category_table): Use CHECK_TYPE.
Kim F. Storm <storm@cua.dk>
parents:
68651
diff
changeset
|
171 CHECK_TYPE (!NILP (Fcategory_table_p (table)), Qcategory_table_p, table); |
17052 | 172 return table; |
49600
23a1cea22d13
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
46370
diff
changeset
|
173 } |
17052 | 174 |
175 DEFUN ("category-table", Fcategory_table, Scategory_table, 0, 0, 0, | |
40103
6b389fb978bc
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Janík <Pavel@Janik.cz>
parents:
39748
diff
changeset
|
176 doc: /* Return the current category table. |
6b389fb978bc
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Janík <Pavel@Janik.cz>
parents:
39748
diff
changeset
|
177 This is the one specified by the current buffer. */) |
6b389fb978bc
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Janík <Pavel@Janik.cz>
parents:
39748
diff
changeset
|
178 () |
17052 | 179 { |
180 return current_buffer->category_table; | |
181 } | |
182 | |
183 DEFUN ("standard-category-table", Fstandard_category_table, | |
184 Sstandard_category_table, 0, 0, 0, | |
40103
6b389fb978bc
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Janík <Pavel@Janik.cz>
parents:
39748
diff
changeset
|
185 doc: /* Return the standard category table. |
6b389fb978bc
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Janík <Pavel@Janik.cz>
parents:
39748
diff
changeset
|
186 This is the one used for new buffers. */) |
6b389fb978bc
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Janík <Pavel@Janik.cz>
parents:
39748
diff
changeset
|
187 () |
17052 | 188 { |
189 return Vstandard_category_table; | |
190 } | |
191 | |
192 /* Return a copy of category table TABLE. We can't simply use the | |
193 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
|
194 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
|
195 binding TABLE to a sub char table. */ |
17052 | 196 |
197 Lisp_Object | |
17324
ed53084a1655
(category-table-p): Check only type and purpose.
Kenichi Handa <handa@m17n.org>
parents:
17187
diff
changeset
|
198 copy_category_table (table) |
17052 | 199 Lisp_Object table; |
200 { | |
17324
ed53084a1655
(category-table-p): Check only type and purpose.
Kenichi Handa <handa@m17n.org>
parents:
17187
diff
changeset
|
201 Lisp_Object tmp; |
ed53084a1655
(category-table-p): Check only type and purpose.
Kenichi Handa <handa@m17n.org>
parents:
17187
diff
changeset
|
202 int i, to; |
17052 | 203 |
17324
ed53084a1655
(category-table-p): Check only type and purpose.
Kenichi Handa <handa@m17n.org>
parents:
17187
diff
changeset
|
204 if (!NILP (XCHAR_TABLE (table)->top)) |
17052 | 205 { |
17324
ed53084a1655
(category-table-p): Check only type and purpose.
Kenichi Handa <handa@m17n.org>
parents:
17187
diff
changeset
|
206 /* 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
|
207 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
|
208 table = Fcopy_sequence (table); |
17052 | 209 |
17324
ed53084a1655
(category-table-p): Check only type and purpose.
Kenichi Handa <handa@m17n.org>
parents:
17187
diff
changeset
|
210 /* 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
|
211 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
|
212 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
|
213 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
|
214 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
|
215 |
16f5b56c2f68
(copy_category_table): Copy also the first extra slot
Kenichi Handa <handa@m17n.org>
parents:
19659
diff
changeset
|
216 /* 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
|
217 containing docstring of each category. */ |
16f5b56c2f68
(copy_category_table): Copy also the first extra slot
Kenichi Handa <handa@m17n.org>
parents:
19659
diff
changeset
|
218 Fset_char_table_extra_slot |
16f5b56c2f68
(copy_category_table): Copy also the first extra slot
Kenichi Handa <handa@m17n.org>
parents:
19659
diff
changeset
|
219 (table, make_number (0), |
16f5b56c2f68
(copy_category_table): Copy also the first extra slot
Kenichi Handa <handa@m17n.org>
parents:
19659
diff
changeset
|
220 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
|
221 } |
ed53084a1655
(category-table-p): Check only type and purpose.
Kenichi Handa <handa@m17n.org>
parents:
17187
diff
changeset
|
222 else |
ed53084a1655
(category-table-p): Check only type and purpose.
Kenichi Handa <handa@m17n.org>
parents:
17187
diff
changeset
|
223 { |
ed53084a1655
(category-table-p): Check only type and purpose.
Kenichi Handa <handa@m17n.org>
parents:
17187
diff
changeset
|
224 i = 32; |
ed53084a1655
(category-table-p): Check only type and purpose.
Kenichi Handa <handa@m17n.org>
parents:
17187
diff
changeset
|
225 to = SUB_CHAR_TABLE_ORDINARY_SLOTS; |
17052 | 226 } |
227 | |
17324
ed53084a1655
(category-table-p): Check only type and purpose.
Kenichi Handa <handa@m17n.org>
parents:
17187
diff
changeset
|
228 /* 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
|
229 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
|
230 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
|
231 |
ed53084a1655
(category-table-p): Check only type and purpose.
Kenichi Handa <handa@m17n.org>
parents:
17187
diff
changeset
|
232 /* 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
|
233 sub char table. */ |
ed53084a1655
(category-table-p): Check only type and purpose.
Kenichi Handa <handa@m17n.org>
parents:
17187
diff
changeset
|
234 for (; i < to; i++) |
ed53084a1655
(category-table-p): Check only type and purpose.
Kenichi Handa <handa@m17n.org>
parents:
17187
diff
changeset
|
235 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
|
236 XCHAR_TABLE (table)->contents[i] |
ed53084a1655
(category-table-p): Check only type and purpose.
Kenichi Handa <handa@m17n.org>
parents:
17187
diff
changeset
|
237 = (SUB_CHAR_TABLE_P (tmp) |
ed53084a1655
(category-table-p): Check only type and purpose.
Kenichi Handa <handa@m17n.org>
parents:
17187
diff
changeset
|
238 ? 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
|
239 |
17052 | 240 return table; |
241 } | |
242 | |
243 DEFUN ("copy-category-table", Fcopy_category_table, Scopy_category_table, | |
244 0, 1, 0, | |
40103
6b389fb978bc
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Janík <Pavel@Janik.cz>
parents:
39748
diff
changeset
|
245 doc: /* Construct a new category table and return it. |
6b389fb978bc
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Janík <Pavel@Janik.cz>
parents:
39748
diff
changeset
|
246 It is a copy of the TABLE, which defaults to the standard category table. */) |
6b389fb978bc
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Janík <Pavel@Janik.cz>
parents:
39748
diff
changeset
|
247 (table) |
17052 | 248 Lisp_Object table; |
249 { | |
250 if (!NILP (table)) | |
251 check_category_table (table); | |
252 else | |
253 table = Vstandard_category_table; | |
254 | |
20189
16f5b56c2f68
(copy_category_table): Copy also the first extra slot
Kenichi Handa <handa@m17n.org>
parents:
19659
diff
changeset
|
255 return copy_category_table (table); |
17052 | 256 } |
257 | |
26841
dfead1ef574c
(word_boundary_p): Delete codes for a composite
Kenichi Handa <handa@m17n.org>
parents:
25835
diff
changeset
|
258 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
|
259 0, 0, 0, |
40103
6b389fb978bc
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Janík <Pavel@Janik.cz>
parents:
39748
diff
changeset
|
260 doc: /* Construct a new and empty category table and return it. */) |
6b389fb978bc
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Janík <Pavel@Janik.cz>
parents:
39748
diff
changeset
|
261 () |
26841
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 Lisp_Object val; |
dfead1ef574c
(word_boundary_p): Delete codes for a composite
Kenichi Handa <handa@m17n.org>
parents:
25835
diff
changeset
|
264 |
dfead1ef574c
(word_boundary_p): Delete codes for a composite
Kenichi Handa <handa@m17n.org>
parents:
25835
diff
changeset
|
265 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
|
266 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
|
267 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
|
268 Fmake_vector (make_number (95), Qnil)); |
dfead1ef574c
(word_boundary_p): Delete codes for a composite
Kenichi Handa <handa@m17n.org>
parents:
25835
diff
changeset
|
269 return val; |
dfead1ef574c
(word_boundary_p): Delete codes for a composite
Kenichi Handa <handa@m17n.org>
parents:
25835
diff
changeset
|
270 } |
dfead1ef574c
(word_boundary_p): Delete codes for a composite
Kenichi Handa <handa@m17n.org>
parents:
25835
diff
changeset
|
271 |
17052 | 272 DEFUN ("set-category-table", Fset_category_table, Sset_category_table, 1, 1, 0, |
54091
15dabc5988ff
(Fdefine_category, Fcategory_docstring)
Luc Teirlinck <teirllm@auburn.edu>
parents:
52401
diff
changeset
|
273 doc: /* Specify TABLE as the category table for the current buffer. |
15dabc5988ff
(Fdefine_category, Fcategory_docstring)
Luc Teirlinck <teirllm@auburn.edu>
parents:
52401
diff
changeset
|
274 Return TABLE. */) |
40103
6b389fb978bc
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Janík <Pavel@Janik.cz>
parents:
39748
diff
changeset
|
275 (table) |
17052 | 276 Lisp_Object table; |
277 { | |
28315
16ed41346de7
(Fset_category_table): Use new macros for per-buffer
Gerd Moellmann <gerd@gnu.org>
parents:
26841
diff
changeset
|
278 int idx; |
17052 | 279 table = check_category_table (table); |
280 current_buffer->category_table = table; | |
281 /* Indicate that this buffer now has a specified category table. */ | |
28351 | 282 idx = PER_BUFFER_VAR_IDX (category_table); |
283 SET_PER_BUFFER_VALUE_P (current_buffer, idx, 1); | |
17052 | 284 return table; |
285 } | |
286 | |
287 | |
288 DEFUN ("char-category-set", Fchar_category_set, Schar_category_set, 1, 1, 0, | |
73927
e74524ea3f55
(Fchar_category_set): Improve arg/docstring consistency.
Juanma Barranquero <lekktu@gmail.com>
parents:
71829
diff
changeset
|
289 doc: /* Return the category set of CHAR. |
e74524ea3f55
(Fchar_category_set): Improve arg/docstring consistency.
Juanma Barranquero <lekktu@gmail.com>
parents:
71829
diff
changeset
|
290 usage: (char-category-set CHAR) */) |
40103
6b389fb978bc
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Janík <Pavel@Janik.cz>
parents:
39748
diff
changeset
|
291 (ch) |
17052 | 292 Lisp_Object ch; |
293 { | |
40656
cdfd4d09b79a
Update usage of CHECK_ macros (remove unused second argument).
Pavel Janík <Pavel@Janik.cz>
parents:
40103
diff
changeset
|
294 CHECK_NUMBER (ch); |
17052 | 295 return CATEGORY_SET (XFASTINT (ch)); |
296 } | |
297 | |
298 DEFUN ("category-set-mnemonics", Fcategory_set_mnemonics, | |
299 Scategory_set_mnemonics, 1, 1, 0, | |
40103
6b389fb978bc
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Janík <Pavel@Janik.cz>
parents:
39748
diff
changeset
|
300 doc: /* Return a string containing mnemonics of the categories in CATEGORY-SET. |
6b389fb978bc
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Janík <Pavel@Janik.cz>
parents:
39748
diff
changeset
|
301 CATEGORY-SET is a bool-vector, and the categories \"in\" it are those |
54091
15dabc5988ff
(Fdefine_category, Fcategory_docstring)
Luc Teirlinck <teirllm@auburn.edu>
parents:
52401
diff
changeset
|
302 that are indexes where t occurs in the bool-vector. |
40103
6b389fb978bc
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Janík <Pavel@Janik.cz>
parents:
39748
diff
changeset
|
303 The return value is a string containing those same categories. */) |
6b389fb978bc
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Janík <Pavel@Janik.cz>
parents:
39748
diff
changeset
|
304 (category_set) |
17052 | 305 Lisp_Object category_set; |
306 { | |
307 int i, j; | |
308 char str[96]; | |
309 | |
40656
cdfd4d09b79a
Update usage of CHECK_ macros (remove unused second argument).
Pavel Janík <Pavel@Janik.cz>
parents:
40103
diff
changeset
|
310 CHECK_CATEGORY_SET (category_set); |
17052 | 311 |
312 j = 0; | |
313 for (i = 32; i < 127; i++) | |
314 if (CATEGORY_MEMBER (i, category_set)) | |
315 str[j++] = i; | |
316 str[j] = '\0'; | |
317 | |
318 return build_string (str); | |
319 } | |
320 | |
17324
ed53084a1655
(category-table-p): Check only type and purpose.
Kenichi Handa <handa@m17n.org>
parents:
17187
diff
changeset
|
321 /* Modify all category sets stored under sub char-table TABLE so that |
17052 | 322 they contain (SET_VALUE is t) or don't contain (SET_VALUE is nil) |
323 CATEGORY. */ | |
324 | |
325 void | |
326 modify_lower_category_set (table, category, set_value) | |
327 Lisp_Object table, category, set_value; | |
328 { | |
329 Lisp_Object val; | |
330 int i; | |
331 | |
25835
265202db376b
(modify_lower_category_set): Set default value of
Kenichi Handa <handa@m17n.org>
parents:
25662
diff
changeset
|
332 val = XCHAR_TABLE (table)->defalt; |
265202db376b
(modify_lower_category_set): Set default value of
Kenichi Handa <handa@m17n.org>
parents:
25662
diff
changeset
|
333 if (!CATEGORY_SET_P (val)) |
265202db376b
(modify_lower_category_set): Set default value of
Kenichi Handa <handa@m17n.org>
parents:
25662
diff
changeset
|
334 val = MAKE_CATEGORY_SET; |
265202db376b
(modify_lower_category_set): Set default value of
Kenichi Handa <handa@m17n.org>
parents:
25662
diff
changeset
|
335 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
|
336 XCHAR_TABLE (table)->defalt = val; |
17052 | 337 |
17324
ed53084a1655
(category-table-p): Check only type and purpose.
Kenichi Handa <handa@m17n.org>
parents:
17187
diff
changeset
|
338 for (i = 32; i < SUB_CHAR_TABLE_ORDINARY_SLOTS; i++) |
17052 | 339 { |
340 val = XCHAR_TABLE (table)->contents[i]; | |
341 | |
342 if (CATEGORY_SET_P (val)) | |
343 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
|
344 else if (SUB_CHAR_TABLE_P (val)) |
17052 | 345 modify_lower_category_set (val, category, set_value); |
346 } | |
347 } | |
348 | |
349 void | |
350 set_category_set (category_set, category, val) | |
351 Lisp_Object category_set, category, val; | |
352 { | |
353 do { | |
354 int idx = XINT (category) / 8; | |
355 unsigned char bits = 1 << (XINT (category) % 8); | |
356 | |
357 if (NILP (val)) | |
358 XCATEGORY_SET (category_set)->data[idx] &= ~bits; | |
359 else | |
360 XCATEGORY_SET (category_set)->data[idx] |= bits; | |
361 } while (0); | |
362 } | |
363 | |
364 DEFUN ("modify-category-entry", Fmodify_category_entry, | |
365 Smodify_category_entry, 2, 4, 0, | |
40103
6b389fb978bc
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Janík <Pavel@Janik.cz>
parents:
39748
diff
changeset
|
366 doc: /* Modify the category set of CHARACTER by adding CATEGORY to it. |
6b389fb978bc
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Janík <Pavel@Janik.cz>
parents:
39748
diff
changeset
|
367 The category is changed only for table TABLE, which defaults to |
6b389fb978bc
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Janík <Pavel@Janik.cz>
parents:
39748
diff
changeset
|
368 the current buffer's category table. |
6b389fb978bc
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Janík <Pavel@Janik.cz>
parents:
39748
diff
changeset
|
369 If optional fourth argument RESET is non-nil, |
6b389fb978bc
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Janík <Pavel@Janik.cz>
parents:
39748
diff
changeset
|
370 then delete CATEGORY from the category set instead of adding it. */) |
6b389fb978bc
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Janík <Pavel@Janik.cz>
parents:
39748
diff
changeset
|
371 (character, category, table, reset) |
20825
1b98a0ab1bee
(Fmodify_category_entry): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents:
20612
diff
changeset
|
372 Lisp_Object character, category, table, reset; |
17052 | 373 { |
374 int c, charset, c1, c2; | |
375 Lisp_Object set_value; /* Actual value to be set in category sets. */ | |
376 Lisp_Object val, category_set; | |
377 | |
40656
cdfd4d09b79a
Update usage of CHECK_ macros (remove unused second argument).
Pavel Janík <Pavel@Janik.cz>
parents:
40103
diff
changeset
|
378 CHECK_NUMBER (character); |
20825
1b98a0ab1bee
(Fmodify_category_entry): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents:
20612
diff
changeset
|
379 c = XINT (character); |
40656
cdfd4d09b79a
Update usage of CHECK_ macros (remove unused second argument).
Pavel Janík <Pavel@Janik.cz>
parents:
40103
diff
changeset
|
380 CHECK_CATEGORY (category); |
17052 | 381 table = check_category_table (table); |
382 | |
383 if (NILP (CATEGORY_DOCSTRING (table, XFASTINT (category)))) | |
384 error ("Undefined category: %c", XFASTINT (category)); | |
49600
23a1cea22d13
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
46370
diff
changeset
|
385 |
17052 | 386 set_value = NILP (reset) ? Qt : Qnil; |
387 | |
17324
ed53084a1655
(category-table-p): Check only type and purpose.
Kenichi Handa <handa@m17n.org>
parents:
17187
diff
changeset
|
388 if (c < CHAR_TABLE_SINGLE_BYTE_SLOTS) |
17052 | 389 { |
390 val = XCHAR_TABLE (table)->contents[c]; | |
391 if (!CATEGORY_SET_P (val)) | |
392 XCHAR_TABLE (table)->contents[c] = (val = MAKE_CATEGORY_SET); | |
393 SET_CATEGORY_SET (val, category, set_value); | |
394 return Qnil; | |
395 } | |
396 | |
29001
5cd01794225d
(Fmodify_category_entry): Use SPLIT_CHAR, not
Kenichi Handa <handa@m17n.org>
parents:
28351
diff
changeset
|
397 SPLIT_CHAR (c, charset, c1, c2); |
17052 | 398 |
399 /* The top level table. */ | |
17187
9ab0c08a3359
Adjusted for the change of CHAR_TABLE_ORDINARY_SLOTS.
Kenichi Handa <handa@m17n.org>
parents:
17071
diff
changeset
|
400 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
|
401 if (CATEGORY_SET_P (val)) |
ed53084a1655
(category-table-p): Check only type and purpose.
Kenichi Handa <handa@m17n.org>
parents:
17187
diff
changeset
|
402 category_set = val; |
ed53084a1655
(category-table-p): Check only type and purpose.
Kenichi Handa <handa@m17n.org>
parents:
17187
diff
changeset
|
403 else if (!SUB_CHAR_TABLE_P (val)) |
17052 | 404 { |
17324
ed53084a1655
(category-table-p): Check only type and purpose.
Kenichi Handa <handa@m17n.org>
parents:
17187
diff
changeset
|
405 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
|
406 XCHAR_TABLE (table)->contents[charset + 128] = category_set; |
17052 | 407 } |
408 | |
17324
ed53084a1655
(category-table-p): Check only type and purpose.
Kenichi Handa <handa@m17n.org>
parents:
17187
diff
changeset
|
409 if (c1 <= 0) |
17052 | 410 { |
411 /* Only a charset is specified. */ | |
17324
ed53084a1655
(category-table-p): Check only type and purpose.
Kenichi Handa <handa@m17n.org>
parents:
17187
diff
changeset
|
412 if (SUB_CHAR_TABLE_P (val)) |
ed53084a1655
(category-table-p): Check only type and purpose.
Kenichi Handa <handa@m17n.org>
parents:
17187
diff
changeset
|
413 /* 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
|
414 CATEGORY or not. */ |
17052 | 415 modify_lower_category_set (val, category, set_value); |
416 else | |
417 SET_CATEGORY_SET (category_set, category, set_value); | |
418 return Qnil; | |
419 } | |
420 | |
421 /* The second level table. */ | |
17324
ed53084a1655
(category-table-p): Check only type and purpose.
Kenichi Handa <handa@m17n.org>
parents:
17187
diff
changeset
|
422 if (!SUB_CHAR_TABLE_P (val)) |
17052 | 423 { |
17324
ed53084a1655
(category-table-p): Check only type and purpose.
Kenichi Handa <handa@m17n.org>
parents:
17187
diff
changeset
|
424 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
|
425 XCHAR_TABLE (table)->contents[charset + 128] = val; |
17052 | 426 /* We must set default category set of CHARSET in `defalt' slot. */ |
427 XCHAR_TABLE (val)->defalt = category_set; | |
428 } | |
429 table = val; | |
430 | |
431 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
|
432 if (CATEGORY_SET_P (val)) |
ed53084a1655
(category-table-p): Check only type and purpose.
Kenichi Handa <handa@m17n.org>
parents:
17187
diff
changeset
|
433 category_set = val; |
ed53084a1655
(category-table-p): Check only type and purpose.
Kenichi Handa <handa@m17n.org>
parents:
17187
diff
changeset
|
434 else if (!SUB_CHAR_TABLE_P (val)) |
17052 | 435 { |
17324
ed53084a1655
(category-table-p): Check only type and purpose.
Kenichi Handa <handa@m17n.org>
parents:
17187
diff
changeset
|
436 category_set = val = Fcopy_sequence (XCHAR_TABLE (table)->defalt); |
17052 | 437 XCHAR_TABLE (table)->contents[c1] = category_set; |
438 } | |
439 | |
17324
ed53084a1655
(category-table-p): Check only type and purpose.
Kenichi Handa <handa@m17n.org>
parents:
17187
diff
changeset
|
440 if (c2 <= 0) |
17052 | 441 { |
17324
ed53084a1655
(category-table-p): Check only type and purpose.
Kenichi Handa <handa@m17n.org>
parents:
17187
diff
changeset
|
442 if (SUB_CHAR_TABLE_P (val)) |
17052 | 443 /* All characters in C1 group of CHARSET should be the same as |
444 for CATEGORY. */ | |
445 modify_lower_category_set (val, category, set_value); | |
446 else | |
447 SET_CATEGORY_SET (category_set, category, set_value); | |
448 return Qnil; | |
449 } | |
450 | |
451 /* The third (bottom) level table. */ | |
17324
ed53084a1655
(category-table-p): Check only type and purpose.
Kenichi Handa <handa@m17n.org>
parents:
17187
diff
changeset
|
452 if (!SUB_CHAR_TABLE_P (val)) |
17052 | 453 { |
17459
22fc94ab9e79
(Fmodify_category_entry): Delete second arg in call to make_sub_char_table.
Karl Heuer <kwzh@gnu.org>
parents:
17369
diff
changeset
|
454 val = make_sub_char_table (Qnil); |
17052 | 455 XCHAR_TABLE (table)->contents[c1] = val; |
456 /* We must set default category set of CHARSET and C1 in | |
457 `defalt' slot. */ | |
458 XCHAR_TABLE (val)->defalt = category_set; | |
459 } | |
460 table = val; | |
461 | |
462 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
|
463 if (CATEGORY_SET_P (val)) |
ed53084a1655
(category-table-p): Check only type and purpose.
Kenichi Handa <handa@m17n.org>
parents:
17187
diff
changeset
|
464 category_set = val; |
ed53084a1655
(category-table-p): Check only type and purpose.
Kenichi Handa <handa@m17n.org>
parents:
17187
diff
changeset
|
465 else if (!SUB_CHAR_TABLE_P (val)) |
17052 | 466 { |
467 category_set = Fcopy_sequence (XCHAR_TABLE (table)->defalt); | |
468 XCHAR_TABLE (table)->contents[c2] = category_set; | |
469 } | |
470 else | |
471 /* This should never happen. */ | |
472 error ("Invalid category table"); | |
473 | |
474 SET_CATEGORY_SET (category_set, category, set_value); | |
475 | |
476 return Qnil; | |
477 } | |
478 | |
479 /* Return 1 if there is a word boundary between two word-constituent | |
480 characters C1 and C2 if they appear in this order, else return 0. | |
481 Use the macro WORD_BOUNDARY_P instead of calling this function | |
482 directly. */ | |
483 | |
484 int | |
485 word_boundary_p (c1, c2) | |
486 int c1, c2; | |
487 { | |
488 Lisp_Object category_set1, category_set2; | |
489 Lisp_Object tail; | |
490 int default_result; | |
491 | |
492 if (CHAR_CHARSET (c1) == CHAR_CHARSET (c2)) | |
493 { | |
494 tail = Vword_separating_categories; | |
495 default_result = 0; | |
496 } | |
497 else | |
498 { | |
499 tail = Vword_combining_categories; | |
500 default_result = 1; | |
501 } | |
502 | |
503 category_set1 = CATEGORY_SET (c1); | |
504 if (NILP (category_set1)) | |
505 return default_result; | |
506 category_set2 = CATEGORY_SET (c2); | |
507 if (NILP (category_set2)) | |
508 return default_result; | |
509 | |
25662
0a7261c1d487
Use XCAR, XCDR, and XFLOAT_DATA instead of explicit member access.
Ken Raeburn <raeburn@raeburn.org>
parents:
23755
diff
changeset
|
510 for (; CONSP (tail); tail = XCDR (tail)) |
17052 | 511 { |
25662
0a7261c1d487
Use XCAR, XCDR, and XFLOAT_DATA instead of explicit member access.
Ken Raeburn <raeburn@raeburn.org>
parents:
23755
diff
changeset
|
512 Lisp_Object elt = XCAR (tail); |
17052 | 513 |
514 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
|
515 && CATEGORYP (XCAR (elt)) |
0a7261c1d487
Use XCAR, XCDR, and XFLOAT_DATA instead of explicit member access.
Ken Raeburn <raeburn@raeburn.org>
parents:
23755
diff
changeset
|
516 && CATEGORYP (XCDR (elt)) |
0a7261c1d487
Use XCAR, XCDR, and XFLOAT_DATA instead of explicit member access.
Ken Raeburn <raeburn@raeburn.org>
parents:
23755
diff
changeset
|
517 && 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
|
518 && CATEGORY_MEMBER (XFASTINT (XCDR (elt)), category_set2)) |
17052 | 519 return !default_result; |
520 } | |
521 return default_result; | |
522 } | |
523 | |
524 | |
21514 | 525 void |
17052 | 526 init_category_once () |
527 { | |
528 /* This has to be done here, before we call Fmake_char_table. */ | |
529 Qcategory_table = intern ("category-table"); | |
530 staticpro (&Qcategory_table); | |
531 | |
532 /* Intern this now in case it isn't already done. | |
533 Setting this variable twice is harmless. | |
534 But don't staticpro it here--that is done in alloc.c. */ | |
535 Qchar_table_extra_slots = intern ("char-table-extra-slots"); | |
536 | |
537 /* Now we are ready to set up this property, so we can | |
538 create category tables. */ | |
539 Fput (Qcategory_table, Qchar_table_extra_slots, make_number (2)); | |
540 | |
541 Vstandard_category_table = Fmake_char_table (Qcategory_table, Qnil); | |
49600
23a1cea22d13
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
46370
diff
changeset
|
542 /* Set a category set which contains nothing to the default. */ |
17052 | 543 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
|
544 Fset_char_table_extra_slot (Vstandard_category_table, make_number (0), |
17052 | 545 Fmake_vector (make_number (95), Qnil)); |
546 } | |
547 | |
21514 | 548 void |
17052 | 549 syms_of_category () |
550 { | |
551 Qcategoryp = intern ("categoryp"); | |
552 staticpro (&Qcategoryp); | |
553 Qcategorysetp = intern ("categorysetp"); | |
554 staticpro (&Qcategorysetp); | |
555 Qcategory_table_p = intern ("category-table-p"); | |
556 staticpro (&Qcategory_table_p); | |
557 | |
558 DEFVAR_LISP ("word-combining-categories", &Vword_combining_categories, | |
40103
6b389fb978bc
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Janík <Pavel@Janik.cz>
parents:
39748
diff
changeset
|
559 doc: /* List of pair (cons) of categories to determine word boundary. |
6b389fb978bc
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Janík <Pavel@Janik.cz>
parents:
39748
diff
changeset
|
560 |
6b389fb978bc
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Janík <Pavel@Janik.cz>
parents:
39748
diff
changeset
|
561 Emacs treats a sequence of word constituent characters as a single |
78501 | 562 word (i.e. finds no word boundary between them) only if they belong to |
40103
6b389fb978bc
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Janík <Pavel@Janik.cz>
parents:
39748
diff
changeset
|
563 the same charset. But, exceptions are allowed in the following cases. |
6b389fb978bc
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Janík <Pavel@Janik.cz>
parents:
39748
diff
changeset
|
564 |
6b389fb978bc
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Janík <Pavel@Janik.cz>
parents:
39748
diff
changeset
|
565 \(1) The case that characters are in different charsets is controlled |
6b389fb978bc
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Janík <Pavel@Janik.cz>
parents:
39748
diff
changeset
|
566 by the variable `word-combining-categories'. |
6b389fb978bc
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Janík <Pavel@Janik.cz>
parents:
39748
diff
changeset
|
567 |
6b389fb978bc
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Janík <Pavel@Janik.cz>
parents:
39748
diff
changeset
|
568 Emacs finds no word boundary between characters of different charsets |
6b389fb978bc
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Janík <Pavel@Janik.cz>
parents:
39748
diff
changeset
|
569 if they have categories matching some element of this list. |
6b389fb978bc
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Janík <Pavel@Janik.cz>
parents:
39748
diff
changeset
|
570 |
6b389fb978bc
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Janík <Pavel@Janik.cz>
parents:
39748
diff
changeset
|
571 More precisely, if an element of this list is a cons of category CAT1 |
6b389fb978bc
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Janík <Pavel@Janik.cz>
parents:
39748
diff
changeset
|
572 and CAT2, and a multibyte character C1 which has CAT1 is followed by |
6b389fb978bc
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Janík <Pavel@Janik.cz>
parents:
39748
diff
changeset
|
573 C2 which has CAT2, there's no word boundary between C1 and C2. |
6b389fb978bc
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Janík <Pavel@Janik.cz>
parents:
39748
diff
changeset
|
574 |
6b389fb978bc
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Janík <Pavel@Janik.cz>
parents:
39748
diff
changeset
|
575 For instance, to tell that ASCII characters and Latin-1 characters can |
6b389fb978bc
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Janík <Pavel@Janik.cz>
parents:
39748
diff
changeset
|
576 form a single word, the element `(?l . ?l)' should be in this list |
6b389fb978bc
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Janík <Pavel@Janik.cz>
parents:
39748
diff
changeset
|
577 because both characters have the category `l' (Latin characters). |
6b389fb978bc
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Janík <Pavel@Janik.cz>
parents:
39748
diff
changeset
|
578 |
6b389fb978bc
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Janík <Pavel@Janik.cz>
parents:
39748
diff
changeset
|
579 \(2) The case that character are in the same charset is controlled by |
6b389fb978bc
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Janík <Pavel@Janik.cz>
parents:
39748
diff
changeset
|
580 the variable `word-separating-categories'. |
6b389fb978bc
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Janík <Pavel@Janik.cz>
parents:
39748
diff
changeset
|
581 |
6b389fb978bc
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Janík <Pavel@Janik.cz>
parents:
39748
diff
changeset
|
582 Emacs find a word boundary between characters of the same charset |
6b389fb978bc
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Janík <Pavel@Janik.cz>
parents:
39748
diff
changeset
|
583 if they have categories matching some element of this list. |
6b389fb978bc
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Janík <Pavel@Janik.cz>
parents:
39748
diff
changeset
|
584 |
6b389fb978bc
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Janík <Pavel@Janik.cz>
parents:
39748
diff
changeset
|
585 More precisely, if an element of this list is a cons of category CAT1 |
6b389fb978bc
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Janík <Pavel@Janik.cz>
parents:
39748
diff
changeset
|
586 and CAT2, and a multibyte character C1 which has CAT1 is followed by |
6b389fb978bc
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Janík <Pavel@Janik.cz>
parents:
39748
diff
changeset
|
587 C2 which has CAT2, there's a word boundary between C1 and C2. |
6b389fb978bc
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Janík <Pavel@Janik.cz>
parents:
39748
diff
changeset
|
588 |
6b389fb978bc
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Janík <Pavel@Janik.cz>
parents:
39748
diff
changeset
|
589 For instance, to tell that there's a word boundary between Japanese |
6b389fb978bc
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Janík <Pavel@Janik.cz>
parents:
39748
diff
changeset
|
590 Hiragana and Japanese Kanji (both are in the same charset), the |
6b389fb978bc
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Janík <Pavel@Janik.cz>
parents:
39748
diff
changeset
|
591 element `(?H . ?C) should be in this list. */); |
17052 | 592 |
593 Vword_combining_categories = Qnil; | |
594 | |
595 DEFVAR_LISP ("word-separating-categories", &Vword_separating_categories, | |
40103
6b389fb978bc
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Janík <Pavel@Janik.cz>
parents:
39748
diff
changeset
|
596 doc: /* List of pair (cons) of categories to determine word boundary. |
6b389fb978bc
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Janík <Pavel@Janik.cz>
parents:
39748
diff
changeset
|
597 See the documentation of the variable `word-combining-categories'. */); |
17052 | 598 |
599 Vword_separating_categories = Qnil; | |
600 | |
601 defsubr (&Smake_category_set); | |
602 defsubr (&Sdefine_category); | |
603 defsubr (&Scategory_docstring); | |
604 defsubr (&Sget_unused_category); | |
605 defsubr (&Scategory_table_p); | |
606 defsubr (&Scategory_table); | |
607 defsubr (&Sstandard_category_table); | |
608 defsubr (&Scopy_category_table); | |
26841
dfead1ef574c
(word_boundary_p): Delete codes for a composite
Kenichi Handa <handa@m17n.org>
parents:
25835
diff
changeset
|
609 defsubr (&Smake_category_table); |
17052 | 610 defsubr (&Sset_category_table); |
611 defsubr (&Schar_category_set); | |
612 defsubr (&Scategory_set_mnemonics); | |
613 defsubr (&Smodify_category_entry); | |
614 | |
615 category_table_version = 0; | |
616 } | |
52401 | 617 |
618 /* arch-tag: 74ebf524-121b-4d9c-bd68-07f8d708b211 | |
619 (do not change this comment) */ |