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