annotate lisp/mule/mule-category.el @ 414:da8ed4261e83 r21-2-15

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