annotate lisp/mule/mule-category.el @ 142:1856695b1fa9 r20-2b5

Import from CVS: tag r20-2b5
author cvs
date Mon, 13 Aug 2007 09:33:18 +0200
parents fe104dbd9147
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1 ;;; mule-category.el --- category functions for XEmacs/Mule.
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
2
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
3 ;; Copyright (C) 1992,93,94,95 Free Software Foundation, Inc.
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
4 ;; Copyright (C) 1995 Amdahl Corporation.
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
5 ;; Copyright (C) 1995 Sun Microsystems.
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
6
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
7 ;; This file is part of XEmacs.
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
8
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
9 ;; XEmacs is free software; you can redistribute it and/or modify it
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
10 ;; under the terms of the GNU General Public License as published by
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
11 ;; the Free Software Foundation; either version 2, or (at your option)
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
12 ;; any later version.
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
13
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
14 ;; XEmacs is distributed in the hope that it will be useful, but
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
15 ;; WITHOUT ANY WARRANTY; without even the implied warranty of
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
16 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
17 ;; General Public License for more details.
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
18
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
19 ;; You should have received a copy of the GNU General Public License
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
20 ;; along with XEmacs; see the file COPYING. If not, write to the
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
21 ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
22 ;; Boston, MA 02111-1307, USA.
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
23
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
24 ;;; Commentary:
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
25
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
26 ;; Functions for working with category tables, which are a particular
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
27 ;; type of char table. Some function names / arguments should be
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
28 ;; parallel with syntax tables.
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
29
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
30 ;; Written by Ben Wing <wing@666.com>. The initialization code
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
31 ;; at the end of this file comes from Mule.
104
cf808b4c4290 Import from CVS: tag r20-1b4
cvs
parents: 74
diff changeset
32 ;; Some bugfixes by Jareth Hein <jhod@po.iijnet.or.jp>
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
33
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
34 ;;; Code:
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
35
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
36 (defvar defined-category-hashtable (make-hashtable 50))
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
37
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
38 (defun define-category (designator doc-string)
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
39 "Make a new category whose designator is DESIGNATOR.
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
40 DESIGNATOR should be a visible letter of ' ' thru '~'.
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
41 STRING is a doc string for the category.
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
42 Letters of 'a' thru 'z' are already used or kept for the system."
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
43 (check-argument-type 'category-designator-p designator)
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
44 (check-argument-type 'stringp doc-string)
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
45 (puthash designator doc-string defined-category-hashtable))
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
46
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
47 (defun undefine-category (designator)
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
48 "Undefine DESIGNATOR as a designator for a category."
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
49 (check-argument-type 'category-designator-p designator)
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
50 (remhash designator defined-category-hashtable))
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
51
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
52 (defun defined-category-p (designator)
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
53 "Return non-nil if DESIGNATOR is a designator for a defined category."
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
54 (and (category-designator-p designator)
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
55 (gethash designator defined-category-hashtable)))
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
56
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
57 (defun defined-category-list ()
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
58 "Return a list of the currently defined categories.
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
59 Categories are given by their designators."
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
60 (let (list)
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
61 (maphash #'(lambda (key value)
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
62 (setq list (cons key list)))
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
63 defined-category-hashtable)
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
64 (nreverse list)))
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
65
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
66 (defun undefined-category-designator ()
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
67 "Return an undefined category designator, or nil if there are none."
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
68 (let ((a 32) found)
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
69 (while (and (< a 127) (not found))
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
70 (if (gethash a defined-category-hashtable)
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
71 (setq found a))
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
72 (setq a (1+ a)))
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
73 found))
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
74
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
75 (defun category-doc-string (designator)
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
76 "Return the doc-string for the category denoted by DESIGNATOR."
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
77 (check-argument-type 'defined-category-p designator)
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
78 (gethash designator defined-category-hashtable))
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
79
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
80 (defun modify-category-entry (char-range designator &optional table reset)
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
81 "Add a category to the categories associated with CHAR-RANGE.
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
82 CHAR-RANGE is a single character or a range of characters,
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
83 as per `put-char-table'.
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
84 The category is given by a designator character.
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
85 The changes are made in TABLE, which defaults to the current buffer's
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
86 category table.
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
87 If optional fourth argument RESET is non-nil, previous categories associated
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
88 with CHAR-RANGE are removed before adding the specified category."
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
89 (or table (setq table (category-table)))
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
90 (check-argument-type 'category-table-p table)
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
91 (check-argument-type 'defined-category-p designator)
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
92 (if reset
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
93 ;; clear all existing stuff.
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
94 (put-char-table char-range nil table))
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
95 (map-char-table
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
96 #'(lambda (key value)
104
cf808b4c4290 Import from CVS: tag r20-1b4
cvs
parents: 74
diff changeset
97 ;; make sure that this range has a bit-vector assigned to it
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
98 (if (not (bit-vector-p value))
104
cf808b4c4290 Import from CVS: tag r20-1b4
cvs
parents: 74
diff changeset
99 (setq value (make-bit-vector 95 0))
cf808b4c4290 Import from CVS: tag r20-1b4
cvs
parents: 74
diff changeset
100 (setq value (copy-sequence value)))
cf808b4c4290 Import from CVS: tag r20-1b4
cvs
parents: 74
diff changeset
101 ;; set the appropriate bit in that vector.
cf808b4c4290 Import from CVS: tag r20-1b4
cvs
parents: 74
diff changeset
102 (aset value (- designator 32) 1)
cf808b4c4290 Import from CVS: tag r20-1b4
cvs
parents: 74
diff changeset
103 ;; put the vector back, thus assuring we have a unique setting for this range
cf808b4c4290 Import from CVS: tag r20-1b4
cvs
parents: 74
diff changeset
104 (put-char-table key value table))
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
105 table char-range))
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
106
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
107 (defun char-category-list (char &optional table)
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
108 "Return a list of the categories that CHAR is in.
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
109 TABLE defaults to the current buffer's category table.
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
110 The categories are given by their designators."
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
111 (or table (setq table (category-table)))
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
112 (check-argument-type 'category-table-p table)
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
113 (let ((vec (get-char-table char table)))
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
114 (if (null vec) nil
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
115 (let ((a 32) list)
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
116 (while (< a 127)
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
117 (if (= 1 (aref vec (- a 32)))
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
118 (setq list (cons a list)))
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
119 (setq a (1+ a)))
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
120 (nreverse list)))))
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
121
110
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 104
diff changeset
122 ;; implimented in c, file chartab.c (97/3/14 jhod@po.iijnet.or.jp)
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 104
diff changeset
123 ;(defun char-in-category-p (char category &optional table)
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 104
diff changeset
124 ; "Return non-nil if CHAR is in CATEGORY.
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 104
diff changeset
125 ;TABLE defaults to the current buffer's category table.
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 104
diff changeset
126 ;Categories are specified by their designators."
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 104
diff changeset
127 ; (or table (setq table (category-table)))
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 104
diff changeset
128 ; (check-argument-type 'category-table-p table)
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 104
diff changeset
129 ; (check-argument-type 'category-designator-p category)
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 104
diff changeset
130 ; (let ((vec (get-char-table char table)))
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 104
diff changeset
131 ; (if (null vec) nil
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 104
diff changeset
132 ; (= 1 (aref vec (- category 32))))))
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
133
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
134 (defun describe-category ()
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
135 "Describe the category specifications in the category table.
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
136 The descriptions are inserted in a buffer, which is then displayed."
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
137 (interactive)
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
138 (with-output-to-temp-buffer "*Help*"
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
139 (describe-category-table (category-table) standard-output)))
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
140
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
141 (defun describe-category-table (table stream)
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
142 (let (first-char
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
143 last-char
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
144 prev-val
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
145 (describe-one
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
146 (lambda (first last value stream)
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
147 (if (and (bit-vector-p value)
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
148 (> (reduce '+ value) 0))
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
149 (progn
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
150 (if (equal first last)
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
151 (cond ((vectorp first)
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
152 (princ (format "%s, row %d"
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
153 (charset-name
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
154 (aref first 0))
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
155 (aref first 1))
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
156 stream))
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
157 ((charsetp first)
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
158 (princ (charset-name first) stream))
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
159 (t (princ first stream)))
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
160 (cond ((vectorp first)
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
161 (princ (format "%s, rows %d .. %d"
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
162 (charset-name
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
163 (aref first 0))
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
164 (aref first 1)
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
165 (aref last 1))
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
166 stream))
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
167 (t
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
168 (princ (format "%s .. %s" first last)
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
169 stream))))
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
170 (describe-category-code value stream))))))
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
171 (map-char-table
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
172 (lambda (range value)
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
173 (if (and (or
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
174 (and (characterp range)
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
175 (characterp first-char)
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
176 (eq (char-charset range) (char-charset first-char))
110
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 104
diff changeset
177 (= (char-to-int last-char) (1- (char-to-int range))))
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
178 (and (vectorp range)
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
179 (vectorp first-char)
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
180 (eq (aref range 0) (aref first-char 0))
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
181 (= (aref last-char 1) (1- (aref range 1))))
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
182 (equal value prev-val)))
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
183 (setq last-char range)
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
184 (if first-char
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
185 (progn
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
186 (funcall describe-one first-char last-char prev-val stream)
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
187 (setq first-char nil)))
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
188 (funcall describe-one range range value stream))
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
189 nil)
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
190 table)
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
191 (if first-char
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
192 (funcall describe-one first-char last-char prev-val stream))))
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
193
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
194 (defun describe-category-code (code stream)
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
195 (let ((standard-output (or stream standard-output)))
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
196 (princ "\tin categories: ")
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
197 (if (not (bit-vector-p code))
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
198 (princ "(none)")
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
199 (let ((i 0)
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
200 already-matched)
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
201 (while (< i 95)
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
202 (if (= 1 (aref code i))
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
203 (progn
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
204 (if (not already-matched)
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
205 (setq already-matched t)
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
206 (princ " "))
110
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 104
diff changeset
207 (princ (int-to-char (+ 32 i)))))
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
208 (setq i (1+ i)))
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
209 (if (not already-matched)
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
210 (princ "(none)")))
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
211 (let ((i 0))
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
212 (while (< i 95)
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
213 (if (= 1 (aref code i))
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
214 (princ (format "\n\t\tmeaning: %s"
110
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 104
diff changeset
215 (category-doc-string (int-to-char (+ 32 i))))))
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
216 (setq i (1+ i)))))
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
217 (terpri)))
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
218
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
219 (defconst predefined-category-list
74
54cc21c15cbb Import from CVS: tag r20-0b32
cvs
parents: 70
diff changeset
220 '((latin-iso8859-1 ?l "Latin-1 through Latin-5 character set")
54cc21c15cbb Import from CVS: tag r20-0b32
cvs
parents: 70
diff changeset
221 (latin-iso8859-2 ?l)
54cc21c15cbb Import from CVS: tag r20-0b32
cvs
parents: 70
diff changeset
222 (latin-iso8859-3 ?l)
54cc21c15cbb Import from CVS: tag r20-0b32
cvs
parents: 70
diff changeset
223 (latin-iso8859-4 ?l)
54cc21c15cbb Import from CVS: tag r20-0b32
cvs
parents: 70
diff changeset
224 (latin-iso8859-9 ?l)
54cc21c15cbb Import from CVS: tag r20-0b32
cvs
parents: 70
diff changeset
225 (cyrillic-iso8859-5 ?y "Cyrillic character set")
54cc21c15cbb Import from CVS: tag r20-0b32
cvs
parents: 70
diff changeset
226 (arabic-iso8859-6 ?b "Arabic character set")
54cc21c15cbb Import from CVS: tag r20-0b32
cvs
parents: 70
diff changeset
227 (greek-iso8859-7 ?g "Greek character set")
54cc21c15cbb Import from CVS: tag r20-0b32
cvs
parents: 70
diff changeset
228 (hebrew-iso8859-8 ?w "Hebrew character set")
54cc21c15cbb Import from CVS: tag r20-0b32
cvs
parents: 70
diff changeset
229 (katakana-jisx0201 ?k "Japanese 1-byte Katakana character set")
54cc21c15cbb Import from CVS: tag r20-0b32
cvs
parents: 70
diff changeset
230 (latin-jisx0201 ?r "Japanese 1-byte Roman character set")
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
231 (japanese-jisx0208-1978 ?j "Japanese 2-byte character set (old)")
74
54cc21c15cbb Import from CVS: tag r20-0b32
cvs
parents: 70
diff changeset
232 (japanese-jisx0208 ?j "Japanese 2-byte character set")
54cc21c15cbb Import from CVS: tag r20-0b32
cvs
parents: 70
diff changeset
233 (japanese-jisx0212 ?j)
54cc21c15cbb Import from CVS: tag r20-0b32
cvs
parents: 70
diff changeset
234 (chinese-gb2312 ?c "Chinese GB (China, PRC) 2-byte character set")
54cc21c15cbb Import from CVS: tag r20-0b32
cvs
parents: 70
diff changeset
235 (chinese-cns11643-1 ?t "Chinese Taiwan (CNS or Big5) 2-byte character set")
54cc21c15cbb Import from CVS: tag r20-0b32
cvs
parents: 70
diff changeset
236 (chinese-cns11643-2 ?t)
54cc21c15cbb Import from CVS: tag r20-0b32
cvs
parents: 70
diff changeset
237 (chinese-big5-1 ?t)
54cc21c15cbb Import from CVS: tag r20-0b32
cvs
parents: 70
diff changeset
238 (chinese-big5-2 ?t)
54cc21c15cbb Import from CVS: tag r20-0b32
cvs
parents: 70
diff changeset
239 (korean-ksc5601 ?h "Hangul (Korean) 2-byte character set")
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
240 )
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
241 "List of predefined categories.
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
242 Each element is a list of a charset, a designator, and maybe a doc string.")
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
243
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
244 (let (i l)
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
245 (define-category ?a "ASCII character set.")
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
246 (setq i 32)
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
247 (while (< i 127)
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
248 (modify-category-entry i ?a)
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
249 (setq i (1+ i)))
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
250 (setq l predefined-category-list)
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
251 (while l
104
cf808b4c4290 Import from CVS: tag r20-1b4
cvs
parents: 74
diff changeset
252 (if (and (nth 2 (car l))
cf808b4c4290 Import from CVS: tag r20-1b4
cvs
parents: 74
diff changeset
253 (not (defined-category-p (nth 2 (car l)))))
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
254 (define-category (nth 1 (car l)) (nth 2 (car l))))
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
255 (modify-category-entry (car (car l)) (nth 1 (car l)))
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
256 (setq l (cdr l))))
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
257
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
258 ;;; At the present, I know Japanese and Chinese text can
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
259 ;;; break line at any point under a restriction of 'kinsoku'.
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
260 (defvar word-across-newline "\\(\\cj\\|\\cc\\|\\ct\\)"
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
261 "Regular expression of such characters which can be a word across newline.")
110
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 104
diff changeset
262
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 104
diff changeset
263 (defvar ascii-char "[\40-\176]")
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 104
diff changeset
264 (defvar ascii-space "[ \t]")
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 104
diff changeset
265 (defvar ascii-symbols "[\40-\57\72-\100\133-\140\173-\176]")
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 104
diff changeset
266 (defvar ascii-numeric "[\60-\71]")
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 104
diff changeset
267 (defvar ascii-English-Upper "[\101-\132]")
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 104
diff changeset
268 (defvar ascii-English-Lower "[\141-\172]")
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 104
diff changeset
269 (defvar ascii-alphanumeric "[\60-\71\101-\132\141-\172]")
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 104
diff changeset
270
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 104
diff changeset
271 (defvar kanji-char "\\cj")
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 104
diff changeset
272 (defvar kanji-space "$B!!(B")
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 104
diff changeset
273 (defvar kanji-symbols "\\cS")
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 104
diff changeset
274 (defvar kanji-numeric "[$B#0(B-$B#9(B]")
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 104
diff changeset
275 (defvar kanji-English-Upper "[$B#A(B-$B#Z(B]")
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 104
diff changeset
276 (defvar kanji-English-Lower "[$B#a(B-$B#z(B]")
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 104
diff changeset
277 (defvar kanji-hiragana "\\cH")
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 104
diff changeset
278 (defvar kanji-katakana "\\cK")
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 104
diff changeset
279 (defvar kanji-Greek-Upper "[$B&!(B-$B&8(B]")
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 104
diff changeset
280 (defvar kanji-Greek-Lower "[$B&A(B-$B&X(B]")
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 104
diff changeset
281 (defvar kanji-Russian-Upper "[$B'!(B-$B'A(B]")
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 104
diff changeset
282 (defvar kanji-Russian-Lower "[$B'Q(B-$B'q(B]")
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 104
diff changeset
283 (defvar kanji-Kanji-1st-Level "[$B0!(B-$BOS(B]")
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 104
diff changeset
284 (defvar kanji-Kanji-2nd-Level "[$BP!(B-$Bt$(B]")
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 104
diff changeset
285
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 104
diff changeset
286 (defvar kanji-kanji-char "\\(\\cH\\|\\cK\\|\\cC\\)")