annotate src/category.c @ 17052:d0d7b244b1d0

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