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