1 ;;; chise-subr.el --- basic lisp subroutines for XEmacs CHISE
3 ;; Copyright (C) 1999, 2001, 2002, 2003, 2004, 2005, 2007, 2008, 2009,
4 ;; 2010 MORIOKA Tomohiko.
6 ;; Author: MORIOKA Tomohiko <tomo@kanji.zinbun.kyoto-u.ac.jp>
7 ;; Keywords: CHISE, Character Database, ISO/IEC 10646, UCS, Unicode, MULE.
9 ;; This file is part of XEmacs CHISE.
11 ;; XEmacs CHISE is free software; you can redistribute it and/or
12 ;; modify it under the terms of the GNU General Public License as
13 ;; published by the Free Software Foundation; either version 2, or (at
14 ;; your option) any later version.
16 ;; XEmacs CHISE is distributed in the hope that it will be useful,
17 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
18 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
19 ;; General Public License for more details.
21 ;; You should have received a copy of the GNU General Public License
22 ;; along with XEmacs CHISE; see the file COPYING. If not, write to
23 ;; the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
24 ;; Boston, MA 02111-1307, USA.
28 (defvar char-db-feature-domains
29 '(ucs ucs/compat daikanwa cns gt jis jis/alt jis/a jis/b
30 jis-x0212 jis-x0213 cdp shinjigen misc unknown))
37 (defun expand-char-feature-name (feature domain)
39 (intern (format "%s@%s" feature domain))
43 (defun char-attribute-name< (ka kb)
44 "Return t if symbol KA is less than KB in feature-name sorting order."
46 ((eq '->denotational kb)
48 ((eq '->subsumptive kb)
49 (not (eq '->denotational ka)))
50 ((eq '->denotational ka)
52 ((eq '->subsumptive ka)
55 (string-match "^->" (symbol-name ka)))
56 (cond ((and (symbolp kb)
57 (string-match "^->" (symbol-name kb)))
58 (string< (symbol-name ka)
63 (string-match "^->" (symbol-name kb)))
66 (string-match "^<-" (symbol-name ka)))
68 (cond ((string-match "^<-" (symbol-name kb))
69 (string< (symbol-name ka)
72 ;; ((string-match "^->" (symbol-name kb))
77 (string-match "^<-" (symbol-name kb)))
79 ;; (not (string-match "^->" (symbol-name ka)))
84 (if (setq a-ir (charset-property ka 'iso-ir))
85 (if (setq b-ir (charset-property kb 'iso-ir))
88 (< (charset-id ka)(charset-id kb))
98 (if (charset-property kb 'iso-ir)
100 (< (charset-id ka)(charset-id kb)))))
106 (string< (symbol-name ka)
117 (defun char-ucs (char)
118 "Return code-point of UCS."
119 (or (encode-char char '=ucs 'defined-only)
120 (char-feature char '=>ucs)))
123 (defun char-id (char)
124 (logand (char-int char) #x3FFFFFFF))
131 (defun map-char-family (function char &optional ignore-sisters)
132 (let ((rest (list char))
136 (unless (memq (car rest) checked)
137 (if (setq ret (funcall function (car rest)))
139 (setq checked (cons (car rest) checked)
141 (get-char-attribute (car rest) '->subsumptive)
142 (get-char-attribute (car rest) '->denotational)
143 (get-char-attribute (car rest) '->identical)))
144 (unless ignore-sisters
145 (setq rest (append rest
146 (get-char-attribute (car rest) '<-subsumptive)
147 (get-char-attribute (car rest) '<-denotational)))))
148 (setq rest (cdr rest))))))
155 (defun chise-string< (string1 string2 accessors)
156 (let ((len1 (length string1))
157 (len2 (length string2))
163 (setq len (min len1 len2))
166 (setq c1 (aref string1 i)
168 (setq rest accessors)
170 (setq func (car rest))
171 (setq v1 (funcall func c1)
172 v2 (funcall func c2))
174 (setq rest (cdr rest)))
191 (provide 'chise-subr)
193 ;;; chise-subr.el ends here