(shuowen-radicals): Add ?日, ?旦, ?倝, ?㫃, ?冥, ?晶, ?月, ?有, ?朙
[chise/xemacs-chise.git.1] / lisp / utf-2000 / char-db-util.el
1 ;;; char-db-util.el --- Character Database utility -*- coding: utf-8-er; -*-
2
3 ;; Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006,
4 ;;   2007 MORIOKA Tomohiko.
5
6 ;; Author: MORIOKA Tomohiko <tomo@kanji.zinbun.kyoto-u.ac.jp>
7 ;; Keywords: CHISE, Character Database, ISO/IEC 10646, UCS, Unicode, MULE.
8
9 ;; This file is part of XEmacs CHISE.
10
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.
15
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.
20
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.
25
26 ;;; Code:
27
28 (require 'alist)
29
30 (defconst unidata-normative-category-alist
31   '(("Lu" letter        uppercase)
32     ("Ll" letter        lowercase)
33     ("Lt" letter        titlecase)
34     ("Mn" mark          non-spacing)
35     ("Mc" mark          spacing-combining)
36     ("Me" mark          enclosing)
37     ("Nd" number        decimal-digit)
38     ("Nl" number        letter)
39     ("No" number        other)
40     ("Zs" separator     space)
41     ("Zl" separator     line)
42     ("Zp" separator     paragraph)
43     ("Cc" other         control)
44     ("Cf" other         format)
45     ("Cs" other         surrogate)
46     ("Co" other         private-use)
47     ("Cn" other         not-assigned)))
48
49 (defconst unidata-informative-category-alist
50   '(("Lm" letter        modifier)
51     ("Lo" letter        other)
52     ("Pc" punctuation   connector)
53     ("Pd" punctuation   dash)
54     ("Ps" punctuation   open)
55     ("Pe" punctuation   close)
56     ("Pi" punctuation   initial-quote)
57     ("Pf" punctuation   final-quote)
58     ("Po" punctuation   other)
59     ("Sm" symbol        math)
60     ("Sc" symbol        currency)
61     ("Sk" symbol        modifier)
62     ("So" symbol        other)
63     ))
64
65 (defconst ideographic-radicals
66   (let ((v (make-vector 215 nil))
67         (i 1))
68     (while (< i 215)
69       (aset v i (decode-char '=ucs (+ #x2EFF i)))
70       (setq i (1+ i)))
71     v))
72
73 (defun ideographic-radical (number)
74   (aref ideographic-radicals number))
75
76 (defconst shuowen-radicals
77   [?一 ?上 ?示 ?三 ?王 ?玉 ?玨 ?气 ?士 ?丨 ; 010
78    ?屮 ?艸 ?蓐 ?茻 ?小 ?八 ?釆 ?半 ?牛 ?犛 ; 020
79    ?告 ?口 ?凵 ?吅 ?哭 ?走 ?止 ?癶 ?步 ?此 ; 030
80    ?正 ?是 ?辵 ?彳 ?廴 ?㢟 ?行 ?齒 ?牙 ?足 ; 040
81    ?疋 ?品 ?龠 ?冊 ?㗊 ?舌 ?干 ?谷 ?只 ?㕯 ; 050
82    ?句 ?丩 ?古 ?十 ?卅 ?言 ?誩 ?音 ?䇂 ?丵 ; 060
83    ?菐 ?𠬞 ?廾 ?共 ?異 ?舁 ?𦥑 ?䢅 ?爨 ?革 ; 070
84    ?鬲 ?䰜 ?爪 ?𠃨 ?鬥 ?又 ?𠂇 ?㕜 ?支 ?𦘒 ; 080
85    ?聿 ?畫 ?隶 ?臤 ?臣 ?殳 ?殺 ?𠘧 ?寸 ?皮 ; 090
86    ?㼱 ?攴 ?敎 ?卜 ?用 ?爻 ?㸚 ?𥄎 ?目 ?䀠 ; 100
87    ?眉 ?盾 ?自 ?白 ?鼻 ?皕 ?習 ?羽 ?隹 ?奞 ; 110
88    ?萑 ?𦫳 ?苜 ?羊 ?羴 ?瞿 ?雔 ?雥 ?鳥 ?烏 ; 120
89    ?𠦒 ?冓 ?幺 ?𢆶 ?叀 ?玄 ?予 ?放 ?𠬪 ?𣦼 ; 130
90    ?歺 ?死 ?冎 ?骨 ?肉 ?筋 ?刀 ?刃 ?㓞 ?丰 ; 140
91    ?耒 ?𧢲 ?竹 ?箕 ?丌 ?左 ?工 ?㠭 ?巫 ?甘 ; 150
92    ?曰 ?乃 ?丂 ?可 ?兮 ?号 ?亏 ?旨 ?喜 ?壴 ; 160
93    ?鼓 ?豈 ?豆 ?豊 ?豐 ?䖒 ?虍 ?虎 ?虤 ?皿 ; 170
94    ?𠙴 ?去 ?血 ?丶 ?丹 ?青 ?井 ?皀 ?鬯 ?食 ; 180
95    ?亼 ?會 ?倉 ?入 ?缶 ?矢 ?高 ?冂 ?𩫏 ?京 ; 190
96    ?亯 ?𣆪 ?畗 ?㐭 ?嗇 ?來 ?麥 ?夊 ?舛 ?䑞 ; 200
97    ?韋 ?弟 ?夂 ?久 ?桀 ?木 ?東 ?林 ?才 ?叒 ; 210
98    ?之 ?帀 ?出 ?𣎵 ?生 ?乇 ?𠂹 ?𠌶 ?華 ?𥝌 ; 220
99    ?稽 ?巢 ?桼 ?束 ?㯻 ?囗 ?員 ?貝 ?邑 ?𨛜 ; 230
100    ?日 ?旦 ?倝 ?㫃 ?冥 ?晶 ?月 ?有 ?朙 ?囧 ; 240
101    ])
102
103 (defun shuowen-radical (number)
104   (aref shuowen-radicals (1- number)))
105
106 (defvar char-db-file-coding-system 'utf-8-mcs-er)
107
108 (defvar char-db-feature-domains
109   '(ucs ucs/compat daikanwa cns gt jis jis/alt jis/a jis/b
110         jis-x0212 jis-x0213 cdp shinjigen misc unknown))
111
112 (defvar char-db-ignored-attributes '(ideographic-products))
113
114 (defun char-attribute-name< (ka kb)
115   (cond
116    ((eq '->denotational kb)
117     t)
118    ((eq '->subsumptive kb)
119     (not (eq '->denotational ka)))
120    ((eq '->denotational ka)
121     nil)
122    ((eq '->subsumptive ka)
123     nil)
124    ((and (symbolp ka)
125          (string-match "^->" (symbol-name ka)))
126     (cond ((and (symbolp kb)
127                 (string-match "^->" (symbol-name kb)))
128            (string< (symbol-name ka)
129                     (symbol-name kb))
130            ))
131     )
132    ((and (symbolp kb)
133          (string-match "^->" (symbol-name kb)))
134     t)
135    ((and (symbolp ka)
136          (string-match "^<-" (symbol-name ka)))
137     (cond ((symbolp kb)
138            (cond ((string-match "^<-" (symbol-name kb))
139                   (string< (symbol-name ka)
140                            (symbol-name kb))
141                   )
142                  ;; ((string-match "^->" (symbol-name kb))
143                  ;;  t)
144                  )))
145     )
146    ((and (symbolp kb)
147          (string-match "^<-" (symbol-name kb)))
148     t
149     ;; (not (string-match "^->" (symbol-name ka)))
150     )
151    ((find-charset ka)
152     (if (find-charset kb)
153         (if (<= (charset-id ka) 1)
154             (if (<= (charset-id kb) 1)
155                 (cond
156                  ((= (charset-dimension ka)
157                      (charset-dimension kb))
158                   (> (charset-id ka)(charset-id kb)))
159                  (t
160                   (> (charset-dimension ka)
161                      (charset-dimension kb))
162                   ))
163               t)
164           (if (<= (charset-id kb) 1)
165               nil
166             (< (charset-id ka)(charset-id kb))))
167       nil))
168    ((find-charset kb)
169     t)
170    ((symbolp ka)
171     (cond ((symbolp kb)
172            (string< (symbol-name ka)
173                     (symbol-name kb)))
174           (t)))
175    ((symbolp kb)
176     nil)))
177
178 (defvar char-db-coded-charset-priority-list
179   '(ascii
180     control-1
181     latin-iso8859-1
182     latin-iso8859-2
183     latin-iso8859-3
184     latin-iso8859-4
185     latin-iso8859-9
186     latin-jisx0201
187     cyrillic-iso8859-5
188     greek-iso8859-7
189     thai-tis620
190     =jis-x0208
191     =jis-x0208@1978
192     =jis-x0208@1983
193     japanese-jisx0212
194     chinese-gb2312
195     =jis-x0208@1990
196     chinese-cns11643-1
197     chinese-cns11643-2
198     chinese-cns11643-3
199     chinese-cns11643-4
200     chinese-cns11643-5
201     chinese-cns11643-6
202     chinese-cns11643-7
203     =jis-x0213-1-2000
204     =jis-x0213-2-2000
205     korean-ksc5601
206     chinese-isoir165
207     katakana-jisx0201
208     hebrew-iso8859-8
209     chinese-gb12345
210     latin-viscii
211     ethiopic-ucs
212     =big5-cdp
213     =gt
214     ideograph-daikanwa-2
215     ideograph-daikanwa
216     =cbeta
217     ideograph-hanziku-1
218     ideograph-hanziku-2
219     ideograph-hanziku-3
220     ideograph-hanziku-4
221     ideograph-hanziku-5
222     ideograph-hanziku-6
223     ideograph-hanziku-7
224     ideograph-hanziku-8
225     ideograph-hanziku-9
226     ideograph-hanziku-10
227     ideograph-hanziku-11
228     ideograph-hanziku-12
229     =gt-k
230     =ucs@iso
231     =ucs@unicode
232     =big5
233     =big5-eten
234     =jis-x0208@1997
235     =zinbun-oracle
236     =ruimoku-v6
237     =jef-china3))
238
239 (defun char-db-make-char-spec (char)
240   (let (ret char-spec)
241     (cond ((characterp char)
242            (cond ((and (setq ret (encode-char char '=ucs 'defined-only))
243                        (not (and (<= #xE000 ret)(<= ret #xF8FF))))
244                   (setq char-spec (list (cons '=ucs ret)))
245                   (cond ((setq ret (get-char-attribute char 'name))
246                          (setq char-spec (cons (cons 'name ret) char-spec))
247                          )
248                         ((setq ret (get-char-attribute char 'name*))
249                          (setq char-spec (cons (cons 'name* ret) char-spec))
250                          ))
251                   )
252                  ((setq ret
253                         (catch 'tag
254                           (let ((rest char-db-coded-charset-priority-list)
255                                 ccs)
256                             (while rest
257                               (setq ccs (charset-name
258                                          (find-charset (car rest))))
259                               (if (setq ret
260                                         (encode-char char ccs
261                                                      'defined-only))
262                                   (throw 'tag (cons ccs ret)))
263                               (setq rest (cdr rest))))))
264                   (setq char-spec (list ret))
265                   (dolist (ccs (delq (car ret) (charset-list)))
266                     (if (and (or (charset-iso-final-char ccs)
267                                  (memq ccs
268                                        '(=daikanwa
269                                          =daikanwa@rev2
270                                          ;; =gt-k
271                                          =jis-x0208@1997
272                                          )))
273                              (setq ccs (charset-name ccs))
274                              (null (assq ccs char-spec))
275                              (setq ret (encode-char char ccs 'defined-only)))
276                         (setq char-spec (cons (cons ccs ret) char-spec))))
277                   (if (null char-spec)
278                       (setq char-spec (split-char char)))
279                   (cond ((setq ret (get-char-attribute char 'name))
280                          (setq char-spec (cons (cons 'name ret) char-spec))
281                          )
282                         ((setq ret (get-char-attribute char 'name*))
283                          (setq char-spec (cons (cons 'name* ret) char-spec))
284                          ))
285                   ))
286            char-spec)
287           ((consp char)
288            char))))
289     
290 (defun char-db-insert-char-spec (char &optional readable column
291                                       required-features)
292   (unless column
293     (setq column (current-column)))
294   (let (char-spec temp-char)
295     (setq char-spec (char-db-make-char-spec char))
296     (unless (or (characterp char) ; char
297                 (condition-case nil
298                     (setq char (find-char char-spec))
299                   (error nil)))
300       ;; define temporary character
301       ;;   Current implementation is dirty.
302       (setq temp-char (define-char (cons '(ideograph-daikanwa . 0)
303                                          char-spec)))
304       (remove-char-attribute temp-char 'ideograph-daikanwa)
305       (setq char temp-char))
306     (insert-char-attributes char
307                             readable
308                             (union (mapcar #'car char-spec)
309                                    required-features))
310     (when temp-char
311       ;; undefine temporary character
312       ;;   Current implementation is dirty.
313       (setq char-spec (char-attribute-alist temp-char))
314       (while char-spec
315         (remove-char-attribute temp-char (car (car char-spec)))
316         (setq char-spec (cdr char-spec))))))
317
318 (defun char-db-insert-alist (alist &optional readable column)
319   (unless column
320     (setq column (current-column)))
321   (let ((line-breaking
322          (concat "\n" (make-string (1+ column) ?\ )))
323         name value
324         ret al ; cal
325         key
326         lbs cell rest separator)
327     (insert "(")
328     (while alist
329       (setq name (car (car alist))
330             value (cdr (car alist)))
331       (cond ((eq name 'char)
332              (insert "(char . ")
333              (if (setq ret (condition-case nil
334                                (find-char value)
335                              (error nil)))
336                  (progn
337                    (setq al nil
338                          ;; cal nil
339                          )
340                    (while value
341                      (setq key (car (car value)))
342                      ;; (if (find-charset key)
343                      ;;     (setq cal (cons key cal))
344                      (setq al (cons key al))
345                      ;; )
346                      (setq value (cdr value)))
347                    (insert-char-attributes ret
348                                            readable
349                                            (or al 'none) ; cal
350                                            ))
351                (insert (prin1-to-string value)))
352              (insert ")")
353              (insert line-breaking))
354             ((consp value)
355              (insert (format "(%-18s " name))
356              (setq lbs (concat "\n" (make-string (current-column) ?\ )))
357              (while (consp value)
358                (setq cell (car value))
359                (if (and (consp cell)
360                         (consp (car cell))
361                         (setq ret (condition-case nil
362                                       (find-char cell)
363                                     (error nil)))
364                         )
365                    (progn
366                      (setq rest cell
367                            al nil
368                            ;; cal nil
369                            )
370                      (while rest
371                        (setq key (car (car rest)))
372                        ;; (if (find-charset key)
373                        ;;     (setq cal (cons key cal))
374                        (setq al (cons key al))
375                        ;; )
376                        (setq rest (cdr rest)))
377                      (if separator
378                          (insert lbs))
379                      (insert-char-attributes ret
380                                              readable
381                                              al ; cal
382                                              )
383                      (setq separator lbs))
384                  (if separator
385                      (insert separator))
386                  (insert (prin1-to-string cell))
387                  (setq separator " "))
388                (setq value (cdr value)))
389              (insert ")")
390              (insert line-breaking))
391             (t
392              (insert (format "(%-18s . %S)%s"
393                              name value
394                              line-breaking))))
395       (setq alist (cdr alist))))
396   (insert ")"))
397
398 (defun char-db-insert-char-reference (plist &optional readable column)
399   (unless column
400     (setq column (current-column)))
401   (let ((line-breaking
402          (concat "\n" (make-string (1+ column) ?\ )))
403         (separator "")
404         name value)
405     (insert "(")
406     (while plist
407       (setq name (pop plist))
408       (setq value (pop plist))
409       (cond ((eq name :char)
410              (insert separator)
411              (insert ":char\t")
412              (cond ((numberp value)
413                     (setq value (decode-char '=ucs value)))
414                    ;; ((consp value)
415                    ;;  (setq value (or (find-char value)
416                    ;;                  value)))
417                    )
418              (char-db-insert-char-spec value readable)
419              (insert line-breaking)
420              (setq separator ""))
421             ((eq name :radical)
422              (insert (format "%s%s\t%d ; %c%s"
423                              separator
424                              name value
425                              (ideographic-radical value)
426                              line-breaking))
427              (setq separator ""))
428             (t
429              (insert (format "%s%s\t%S" separator name value))
430              (setq separator line-breaking)))
431       ))
432   (insert ")"))
433
434 (defun char-db-decode-isolated-char (ccs code-point)
435   (let (ret)
436     (setq ret
437           (cond ((eq ccs 'arabic-iso8859-6)
438                  (decode-char ccs code-point))
439                 ((and (memq ccs '(=gt-pj-1
440                                   =gt-pj-2
441                                   =gt-pj-3
442                                   =gt-pj-4
443                                   =gt-pj-5
444                                   =gt-pj-6
445                                   =gt-pj-7
446                                   =gt-pj-8
447                                   =gt-pj-9
448                                   =gt-pj-10
449                                   =gt-pj-11))
450                       (setq ret (decode-char ccs code-point))
451                       (setq ret (encode-char ret '=gt 'defined-only)))
452                  (decode-builtin-char '=gt ret))
453                 (t
454                  (decode-builtin-char ccs code-point))))
455     (cond ((and (<= 0 (char-int ret))
456                 (<= (char-int ret) #x1F))
457            (decode-char '=ucs (+ #x2400 (char-int ret))))
458           ((= (char-int ret) #x7F)
459            ?\u2421)
460           (t ret))))
461
462 (defvar char-db-convert-obsolete-format t)
463
464 (defun char-db-insert-ccs-feature (name value line-breaking)
465   (insert
466    (format
467     (cond ((or (memq name '(=daikanwa
468                             =daikanwa@rev1 =daikanwa@rev2
469                             =gt =gt-k =cbeta =zinbun-oracle))
470                (string-match "^=adobe-" (symbol-name name)))
471            "(%-18s . %05d)\t; %c")
472           ((eq name 'mojikyo)
473            "(%-18s . %06d)\t; %c")
474           ((>= (charset-dimension name) 2)
475            "(%-18s . #x%04X)\t; %c")
476           (t
477            "(%-18s . #x%02X)\t; %c"))
478     name
479     (if (= (charset-iso-graphic-plane name) 1)
480         (logior value
481                 (cond ((= (charset-dimension name) 1)
482                        #x80)
483                       ((= (charset-dimension name) 2)
484                        #x8080)
485                       ((= (charset-dimension name) 3)
486                        #x808080)
487                       (t 0)))
488       value)
489     (char-db-decode-isolated-char name value)))
490   (if (and (= (charset-chars name) 94)
491            (= (charset-dimension name) 2))
492       (insert (format " [%02d-%02d]"
493                       (- (lsh value -8) 32)
494                       (- (logand value 255) 32))))
495   (insert line-breaking))
496
497 (defun char-db-insert-relation-feature (char name value line-breaking
498                                              ccss readable)
499   (insert (format "(%-18s%s " name line-breaking))
500   (let ((lbs (concat "\n" (make-string (current-column) ?\ )))
501         separator cell sources required-features
502         ret)
503     (while (consp value)
504       (setq cell (car value))
505       (if (integerp cell)
506           (setq cell (decode-char '=ucs cell)))
507       (cond
508        ((eq name '->subsumptive)
509         (when (or (not (some (lambda (atr)
510                                (get-char-attribute cell atr))
511                              char-db-ignored-attributes))
512                   (some (lambda (ccs)
513                           (encode-char cell ccs 'defined-only))
514                         ccss))
515           (if separator
516               (insert lbs))
517           (let ((char-db-ignored-attributes
518                  (cons '<-subsumptive
519                        char-db-ignored-attributes)))
520             (insert-char-attributes cell readable))
521           (setq separator lbs))
522         )
523        ((characterp cell)
524         (setq sources
525               (get-char-attribute
526                char (intern (format "%s*sources" name))))
527         (setq required-features nil)
528         (dolist (source sources)
529           (cond
530            ((memq source '(JP JP/Jouyou shinjigen-1))
531             (setq required-features
532                   (union required-features
533                          '(=jis-x0208
534                            =jis-x0208@1990
535                            =jis-x0213-1-2000
536                            =jis-x0213-2-2000
537                            =jis-x0212
538                            =jis-x0208@1983
539                            =jis-x0208@1978))))
540            ((eq source 'CN)
541             (setq required-features
542                   (union required-features
543                          '(=gb2312
544                            =gb12345
545                            =iso-ir165)))))
546           (cond
547            ((find-charset (setq ret (intern (format "=%s" source))))
548             (setq required-features
549                   (cons ret required-features)))
550            (t (setq required-features
551                     (cons source required-features)))))
552         (cond ((string-match "@JP" (symbol-name name))
553                (setq required-features
554                      (union required-features
555                             '(=jis-x0208
556                               =jis-x0208@1990
557                               =jis-x0213-1-2000
558                               =jis-x0213-2-2000
559                               =jis-x0212
560                               =jis-x0208@1983
561                               =jis-x0208@1978))))
562               ((string-match "@CN" (symbol-name name))
563                (setq required-features
564                      (union required-features
565                             '(=gb2312
566                               =gb12345
567                               =iso-ir165)))))
568         (if separator
569             (insert lbs))
570         (if readable
571             (insert (format "%S" cell))
572           (char-db-insert-char-spec cell readable
573                                     nil
574                                     required-features))
575         (setq separator lbs))
576        ((consp cell)
577         (if separator
578             (insert lbs))
579         (if (consp (car cell))
580             (char-db-insert-char-spec cell readable)
581           (char-db-insert-char-reference cell readable))
582         (setq separator lbs))
583        (t
584         (if separator
585             (insert separator))
586         (insert (prin1-to-string cell))
587         (setq separator " ")))
588       (setq value (cdr value)))
589     (insert ")")
590     (insert line-breaking)))
591
592 (defun insert-char-attributes (char &optional readable attributes column)
593   (unless column
594     (setq column (current-column)))
595   (let (name value ; has-long-ccs-name
596         rest
597         radical strokes
598         (line-breaking
599          (concat "\n" (make-string (1+ column) ?\ )))
600         lbs cell separator ret
601         key al cal
602         dest-ccss ; sources required-features
603         ccss)
604     (let (atr-d)
605       (setq attributes
606             (sort (if attributes
607                       (if (consp attributes)
608                           (progn
609                             (dolist (name attributes)
610                               (unless (memq name char-db-ignored-attributes)
611                                 (if (find-charset name)
612                                     (push name ccss))
613                                 (push name atr-d)))
614                             atr-d))
615                     (dolist (name (char-attribute-list))
616                       (unless (memq name char-db-ignored-attributes)
617                         (if (find-charset name)
618                             (push name ccss))
619                         (push name atr-d)))
620                     atr-d)
621                   #'char-attribute-name<)))
622     (insert "(")
623     (when (memq '<-subsumptive attributes)
624       (when readable
625         (when (setq value (get-char-attribute char '<-subsumptive))
626           (char-db-insert-relation-feature char '<-subsumptive value
627                                            line-breaking
628                                            ccss readable)))
629       (setq attributes (delq '<-subsumptive attributes)))
630     (when (and (memq '<-denotational attributes)
631                (setq value (get-char-attribute char '<-denotational)))
632       (char-db-insert-relation-feature char '<-denotational value
633                                        line-breaking
634                                        ccss readable)
635       (setq attributes (delq '<-denotational attributes)))
636     (when (and (memq 'name attributes)
637                (setq value (get-char-attribute char 'name)))
638       (insert (format
639                (if (> (+ (current-column) (length value)) 48)
640                    "(name . %S)%s"
641                  "(name               . %S)%s")
642                value line-breaking))
643       (setq attributes (delq 'name attributes))
644       )
645     (when (and (memq 'name* attributes)
646                (setq value (get-char-attribute char 'name*)))
647       (insert (format
648                (if (> (+ (current-column) (length value)) 48)
649                    "(name* . %S)%s"
650                  "(name*              . %S)%s")
651                value line-breaking))
652       (setq attributes (delq 'name* attributes))
653       )
654     (when (and (memq 'script attributes)
655                (setq value (get-char-attribute char 'script)))
656       (insert (format "(script\t\t%s)%s"
657                       (mapconcat (function prin1-to-string)
658                                  value " ")
659                       line-breaking))
660       (setq attributes (delq 'script attributes))
661       )
662     (dolist (name '(=>ucs =>ucs*))
663       (when (and (memq name attributes)
664                  (setq value (get-char-attribute char name)))
665         (insert (format "(%-18s . #x%04X)\t; %c%s"
666                         name value (decode-char '=ucs value)
667                         line-breaking))
668         (setq attributes (delq name attributes))))
669     (dolist (name '(=>ucs@gb =>ucs@cns =>ucs@jis =>ucs@ks =>ucs@big5))
670       (when (and (memq name attributes)
671                  (setq value (get-char-attribute char name)))
672         (insert (format "(%-18s . #x%04X)\t; %c%s"
673                         name value
674                         (decode-char (intern
675                                       (concat "="
676                                               (substring
677                                                (symbol-name name) 2)))
678                                      value)
679                         line-breaking))
680         (setq attributes (delq name attributes))
681         ))
682     (dolist (name '(=>daikanwa))
683       (when (and (memq name attributes)
684                  (setq value (get-char-attribute char name)))
685         (insert
686          (if (integerp value)
687              (format "(%-18s . %05d)\t; %c%s"
688                      name value (decode-char '=daikanwa value)
689                      line-breaking)
690            (format "(%-18s %s)\t; %c%s"
691                    name
692                    (mapconcat (function prin1-to-string)
693                               value " ")
694                    (char-representative-of-daikanwa char)
695                    line-breaking)))
696         (setq attributes (delq name attributes))))
697     (when (and (memq 'general-category attributes)
698                (setq value (get-char-attribute char 'general-category)))
699       (insert (format
700                "(general-category\t%s) ; %s%s"
701                (mapconcat (lambda (cell)
702                             (format "%S" cell))
703                           value " ")
704                (cond ((rassoc value unidata-normative-category-alist)
705                       "Normative Category")
706                      ((rassoc value unidata-informative-category-alist)
707                       "Informative Category")
708                      (t
709                       "Unknown Category"))
710                line-breaking))
711       (setq attributes (delq 'general-category attributes))
712       )
713     (when (and (memq 'bidi-category attributes)
714                (setq value (get-char-attribute char 'bidi-category)))
715       (insert (format "(bidi-category\t. %S)%s"
716                       value
717                       line-breaking))
718       (setq attributes (delq 'bidi-category attributes))
719       )
720     (unless (or (not (memq 'mirrored attributes))
721                 (eq (setq value (get-char-attribute char 'mirrored 'empty))
722                     'empty))
723       (insert (format "(mirrored\t\t. %S)%s"
724                       value
725                       line-breaking))
726       (setq attributes (delq 'mirrored attributes))
727       )
728     (cond
729      ((and (memq 'decimal-digit-value attributes)
730            (setq value (get-char-attribute char 'decimal-digit-value)))
731       (insert (format "(decimal-digit-value . %S)%s"
732                       value
733                       line-breaking))
734       (setq attributes (delq 'decimal-digit-value attributes))
735       (when (and (memq 'digit-value attributes)
736                  (setq value (get-char-attribute char 'digit-value)))
737         (insert (format "(digit-value\t . %S)%s"
738                         value
739                         line-breaking))
740         (setq attributes (delq 'digit-value attributes))
741         )
742       (when (and (memq 'numeric-value attributes)
743                  (setq value (get-char-attribute char 'numeric-value)))
744         (insert (format "(numeric-value\t . %S)%s"
745                         value
746                         line-breaking))
747         (setq attributes (delq 'numeric-value attributes))
748         )
749       )
750      (t
751       (when (and (memq 'digit-value attributes)
752                  (setq value (get-char-attribute char 'digit-value)))
753         (insert (format "(digit-value\t. %S)%s"
754                         value
755                         line-breaking))
756         (setq attributes (delq 'digit-value attributes))
757         )
758       (when (and (memq 'numeric-value attributes)
759                  (setq value (get-char-attribute char 'numeric-value)))
760         (insert (format "(numeric-value\t. %S)%s"
761                         value
762                         line-breaking))
763         (setq attributes (delq 'numeric-value attributes))
764         )))
765     (when (and (memq 'iso-10646-comment attributes)
766                (setq value (get-char-attribute char 'iso-10646-comment)))
767       (insert (format "(iso-10646-comment\t. %S)%s"
768                       value
769                       line-breaking))
770       (setq attributes (delq 'iso-10646-comment attributes))
771       )
772     (when (and (memq 'morohashi-daikanwa attributes)
773                (setq value (get-char-attribute char 'morohashi-daikanwa)))
774       (insert (format "(morohashi-daikanwa\t%s)%s"
775                       (mapconcat (function prin1-to-string) value " ")
776                       line-breaking))
777       (setq attributes (delq 'morohashi-daikanwa attributes))
778       )
779     (setq radical nil
780           strokes nil)
781     (when (and (memq 'ideographic-radical attributes)
782                (setq value (get-char-attribute char 'ideographic-radical)))
783       (setq radical value)
784       (insert (format "(ideographic-radical . %S)\t; %c%s"
785                       radical
786                       (ideographic-radical radical)
787                       line-breaking))
788       (setq attributes (delq 'ideographic-radical attributes))
789       )
790     (when (and (memq 'shuowen-radical attributes)
791                (setq value (get-char-attribute char 'shuowen-radical)))
792       (insert (format "(shuowen-radical\t. %S)\t; %c%s"
793                       value
794                       (shuowen-radical value)
795                       line-breaking))
796       (setq attributes (delq 'shuowen-radical attributes))
797       )
798     (let (key)
799       (dolist (domain
800                (append
801                 char-db-feature-domains
802                 (let (dest domain)
803                   (dolist (feature (char-attribute-list))
804                     (setq feature (symbol-name feature))
805                     (when (string-match
806                            "\\(radical\\|strokes\\)@\\([^@*]+\\)\\(\\*\\|$\\)"
807                            feature)
808                       (setq domain (intern (match-string 2 feature)))
809                      (unless (memq domain dest)
810                        (setq dest (cons domain dest)))))
811                   (sort dest #'string<))))
812         (setq key (intern (format "%s@%s" 'ideographic-radical domain)))
813         (when (and (memq key attributes)
814                    (setq value (get-char-attribute char key)))
815           (setq radical value)
816           (insert (format "(%s . %S)\t; %c%s"
817                           key
818                           radical
819                           (ideographic-radical radical)
820                           line-breaking))
821           (setq attributes (delq key attributes))
822           )
823         (setq key (intern (format "%s@%s" 'ideographic-strokes domain)))
824         (when (and (memq key attributes)
825                    (setq value (get-char-attribute char key)))
826           (setq strokes value)
827           (insert (format "(%s . %S)%s"
828                           key
829                           strokes
830                           line-breaking))
831           (setq attributes (delq key attributes))
832           )
833         (setq key (intern (format "%s@%s" 'total-strokes domain)))
834         (when (and (memq key attributes)
835                    (setq value (get-char-attribute char key)))
836           (insert (format "(%s       . %S)%s"
837                           key
838                           value
839                           line-breaking))
840           (setq attributes (delq key attributes))
841           )
842         (dolist (feature '(ideographic-radical
843                            ideographic-strokes
844                            total-strokes))
845           (setq key (intern (format "%s@%s*sources" feature domain)))
846           (when (and (memq key attributes)
847                      (setq value (get-char-attribute char key)))
848             (insert (format "(%s%s" key line-breaking))
849             (dolist (cell value)
850               (insert (format " %s" cell)))
851             (insert ")")
852             (insert line-breaking)
853             (setq attributes (delq key attributes))
854             ))
855         ))
856     (when (and (memq 'ideographic-strokes attributes)
857                (setq value (get-char-attribute char 'ideographic-strokes)))
858       (setq strokes value)
859       (insert (format "(ideographic-strokes . %S)%s"
860                       strokes
861                       line-breaking))
862       (setq attributes (delq 'ideographic-strokes attributes))
863       )
864     (when (and (memq 'kangxi-radical attributes)
865                (setq value (get-char-attribute char 'kangxi-radical)))
866       (unless (eq value radical)
867         (insert (format "(kangxi-radical\t . %S)\t; %c%s"
868                         value
869                         (ideographic-radical value)
870                         line-breaking))
871         (or radical
872             (setq radical value)))
873       (setq attributes (delq 'kangxi-radical attributes))
874       )
875     (when (and (memq 'kangxi-strokes attributes)
876                (setq value (get-char-attribute char 'kangxi-strokes)))
877       (unless (eq value strokes)
878         (insert (format "(kangxi-strokes\t . %S)%s"
879                         value
880                         line-breaking))
881         (or strokes
882             (setq strokes value)))
883       (setq attributes (delq 'kangxi-strokes attributes))
884       )
885     (when (and (memq 'japanese-radical attributes)
886                (setq value (get-char-attribute char 'japanese-radical)))
887       (unless (eq value radical)
888         (insert (format "(japanese-radical\t . %S)\t; %c%s"
889                         value
890                         (ideographic-radical value)
891                         line-breaking))
892         (or radical
893             (setq radical value)))
894       (setq attributes (delq 'japanese-radical attributes))
895       )
896     (when (and (memq 'japanese-strokes attributes)
897                (setq value (get-char-attribute char 'japanese-strokes)))
898       (unless (eq value strokes)
899         (insert (format "(japanese-strokes\t . %S)%s"
900                         value
901                         line-breaking))
902         (or strokes
903             (setq strokes value)))
904       (setq attributes (delq 'japanese-strokes attributes))
905       )
906     (when (and (memq 'cns-radical attributes)
907                (setq value (get-char-attribute char 'cns-radical)))
908       (insert (format "(cns-radical\t . %S)\t; %c%s"
909                       value
910                       (ideographic-radical value)
911                       line-breaking))
912       (setq attributes (delq 'cns-radical attributes))
913       )
914     (when (and (memq 'cns-strokes attributes)
915                (setq value (get-char-attribute char 'cns-strokes)))
916       (unless (eq value strokes)
917         (insert (format "(cns-strokes\t . %S)%s"
918                         value
919                         line-breaking))
920         (or strokes
921             (setq strokes value)))
922       (setq attributes (delq 'cns-strokes attributes))
923       )
924     (when (and (memq 'shinjigen-1-radical attributes)
925                (setq value (get-char-attribute char 'shinjigen-1-radical)))
926       (unless (eq value radical)
927         (insert (format "(shinjigen-1-radical . %S)\t; %c%s"
928                         value
929                         (ideographic-radical value)
930                         line-breaking))
931         (or radical
932             (setq radical value)))
933       (setq attributes (delq 'shinjigen-1-radical attributes))
934       )
935     (when (and (memq 'ideographic- attributes)
936                (setq value (get-char-attribute char 'ideographic-)))
937       (insert "(ideographic-       ")
938       (setq lbs (concat "\n" (make-string (current-column) ?\ ))
939             separator nil)
940       (while (consp value)
941         (setq cell (car value))
942         (if (integerp cell)
943             (setq cell (decode-char '=ucs cell)))
944         (cond ((characterp cell)
945                (if separator
946                    (insert lbs))
947                (if readable
948                    (insert (format "%S" cell))
949                  (char-db-insert-char-spec cell readable))
950                (setq separator lbs))
951               ((consp cell)
952                (if separator
953                    (insert lbs))
954                (if (consp (car cell))
955                    (char-db-insert-char-spec cell readable)
956                  (char-db-insert-char-reference cell readable))
957                (setq separator lbs))
958               (t
959                (if separator
960                    (insert separator))
961                (insert (prin1-to-string cell))
962                (setq separator " ")))
963         (setq value (cdr value)))
964       (insert ")")
965       (insert line-breaking)
966       (setq attributes (delq 'ideographic- attributes)))
967     (when (and (memq 'total-strokes attributes)
968                (setq value (get-char-attribute char 'total-strokes)))
969       (insert (format "(total-strokes       . %S)%s"
970                       value
971                       line-breaking))
972       (setq attributes (delq 'total-strokes attributes))
973       )
974     (when (and (memq '->ideograph attributes)
975                (setq value (get-char-attribute char '->ideograph)))
976       (insert (format "(->ideograph\t%s)%s"
977                       (mapconcat (lambda (code)
978                                    (cond ((symbolp code)
979                                           (symbol-name code))
980                                          ((integerp code)
981                                           (format "#x%04X" code))
982                                          (t
983                                           (format "%s %S"
984                                                   line-breaking code))))
985                                  value " ")
986                       line-breaking))
987       (setq attributes (delq '->ideograph attributes))
988       )
989     ;; (when (and (memq '->decomposition attributes)
990     ;;            (setq value (get-char-attribute char '->decomposition)))
991     ;;   (insert (format "(->decomposition\t%s)%s"
992     ;;                   (mapconcat (lambda (code)
993     ;;                                (cond ((symbolp code)
994     ;;                                       (symbol-name code))
995     ;;                                      ((characterp code)
996     ;;                                       (if readable
997     ;;                                           (format "%S" code)
998     ;;                                         (format "#x%04X"
999     ;;                                                 (char-int code))
1000     ;;                                         ))
1001     ;;                                      ((integerp code)
1002     ;;                                       (format "#x%04X" code))
1003     ;;                                      (t
1004     ;;                                       (format "%s%S" line-breaking code))))
1005     ;;                              value " ")
1006     ;;                   line-breaking))
1007     ;;   (setq attributes (delq '->decomposition attributes))
1008     ;;   )
1009     (if (equal (get-char-attribute char '->titlecase)
1010                (get-char-attribute char '->uppercase))
1011         (setq attributes (delq '->titlecase attributes)))
1012     (when (and (memq '->mojikyo attributes)
1013                (setq value (get-char-attribute char '->mojikyo)))
1014       (insert (format "(->mojikyo\t\t. %06d)\t; %c%s"
1015                       value (decode-char 'mojikyo value)
1016                       line-breaking))
1017       (setq attributes (delq '->mojikyo attributes))
1018       )
1019     (when (and (memq 'hanyu-dazidian-vol attributes)
1020                (setq value (get-char-attribute char 'hanyu-dazidian-vol)))
1021       (insert (format "(hanyu-dazidian-vol  . %d)%s"
1022                       value line-breaking))
1023       (setq attributes (delq 'hanyu-dazidian-vol attributes))
1024       )
1025     (when (and (memq 'hanyu-dazidian-page attributes)
1026                (setq value (get-char-attribute char 'hanyu-dazidian-page)))
1027       (insert (format "(hanyu-dazidian-page . %d)%s"
1028                       value line-breaking))
1029       (setq attributes (delq 'hanyu-dazidian-page attributes))
1030       )
1031     (when (and (memq 'hanyu-dazidian-char attributes)
1032                (setq value (get-char-attribute char 'hanyu-dazidian-char)))
1033       (insert (format "(hanyu-dazidian-char . %d)%s"
1034                       value line-breaking))
1035       (setq attributes (delq 'hanyu-dazidian-char attributes))
1036       )
1037     (unless readable
1038       (dolist (ignored '(composition
1039                          ->denotational <-subsumptive ->ucs-unified
1040                          ->ideographic-component-forms))
1041         (setq attributes (delq ignored attributes))))
1042     (while attributes
1043       (setq name (car attributes))
1044       (if (setq value (get-char-attribute char name))
1045           (cond ((setq ret (find-charset name))
1046                  (setq name (charset-name ret))
1047                  (if (and (not (memq name dest-ccss))
1048                           (prog1
1049                               (setq value (get-char-attribute char name))
1050                             (setq dest-ccss (cons name dest-ccss))))
1051                      (char-db-insert-ccs-feature name value line-breaking))
1052                  )
1053                 ((string-match "^=>ucs@" (symbol-name name))
1054                  (insert (format "(%-18s . #x%04X)\t; %c%s"
1055                                  name value (decode-char '=ucs value)
1056                                  line-breaking))
1057                  )
1058                 ((eq name 'jisx0208-1978/4X)
1059                  (insert (format "(%-18s . #x%04X)%s"
1060                                  name value
1061                                  line-breaking))
1062                  )
1063                 ((and
1064                   (not readable)
1065                   (not (eq name '->subsumptive))
1066                   (not (eq name '->uppercase))
1067                   (not (eq name '->lowercase))
1068                   (not (eq name '->titlecase))
1069                   (not (eq name '->canonical))
1070                   (not (eq name '->Bopomofo))
1071                   (not (eq name '->mistakable))
1072                   (not (eq name '->ideographic-variants))
1073                   (null (get-char-attribute
1074                          char (intern (format "%s*sources" name))))
1075                   (not (string-match "\\*sources$" (symbol-name name)))
1076                   (null (get-char-attribute
1077                          char (intern (format "%s*note" name))))
1078                   (not (string-match "\\*note$" (symbol-name name)))
1079                   (or (eq name '<-identical)
1080                       (eq name '<-uppercase)
1081                       (eq name '<-lowercase)
1082                       (eq name '<-titlecase)
1083                       (eq name '<-canonical)
1084                       (eq name '<-ideographic-variants)
1085                       ;; (eq name '<-synonyms)
1086                       (string-match "^<-synonyms" (symbol-name name))
1087                       (eq name '<-mistakable)
1088                       (when (string-match "^->" (symbol-name name))
1089                         (cond
1090                          ((string-match "^->fullwidth" (symbol-name name))
1091                           (not (and (consp value)
1092                                     (characterp (car value))
1093                                     (encode-char
1094                                      (car value) '=ucs 'defined-only)))
1095                           )
1096                          (t)))
1097                       ))
1098                  )
1099                 ((or (eq name 'ideographic-structure)
1100                      (eq name 'ideographic-combination)
1101                      (eq name 'ideographic-)
1102                      (eq name '=decomposition)
1103                      (string-match "^=>decomposition" (symbol-name name))
1104                      (string-match "^\\(->\\|<-\\)[^*]*$" (symbol-name name))
1105                      (string-match "^\\(->\\|<-\\)[^*]*\\*sources$"
1106                                    (symbol-name name))
1107                      )
1108                  (char-db-insert-relation-feature char name value
1109                                                   line-breaking
1110                                                   ccss readable))
1111                 ((memq name '(ideograph=
1112                               original-ideograph-of
1113                               ancient-ideograph-of
1114                               vulgar-ideograph-of
1115                               wrong-ideograph-of
1116                               ;; simplified-ideograph-of
1117                               ideographic-variants
1118                               ;; ideographic-different-form-of
1119                               ))
1120                  (insert (format "(%-18s%s " name line-breaking))
1121                  (setq lbs (concat "\n" (make-string (current-column) ?\ ))
1122                        separator nil)
1123                  (while (consp value)
1124                    (setq cell (car value))
1125                    (if (and (consp cell)
1126                             (consp (car cell)))
1127                        (progn
1128                          (if separator
1129                              (insert lbs))
1130                          (char-db-insert-alist cell readable)
1131                          (setq separator lbs))
1132                      (if separator
1133                          (insert separator))
1134                      (insert (prin1-to-string cell))
1135                      (setq separator " "))
1136                    (setq value (cdr value)))
1137                  (insert ")")
1138                  (insert line-breaking))
1139                 ((consp value)
1140                  (insert (format "(%-18s " name))
1141                  (setq lbs (concat "\n" (make-string (current-column) ?\ ))
1142                        separator nil)
1143                  (while (consp value)
1144                    (setq cell (car value))
1145                    (if (and (consp cell)
1146                             (consp (car cell))
1147                             (setq ret (condition-case nil
1148                                           (find-char cell)
1149                                         (error nil))))
1150                        (progn
1151                          (setq rest cell
1152                                al nil
1153                                cal nil)
1154                          (while rest
1155                            (setq key (car (car rest)))
1156                            (if (find-charset key)
1157                                (setq cal (cons key cal))
1158                              (setq al (cons key al)))
1159                            (setq rest (cdr rest)))
1160                          (if separator
1161                              (insert lbs))
1162                          (insert-char-attributes ret
1163                                                  readable
1164                                                  al cal)
1165                          (setq separator lbs))
1166                      (setq ret (prin1-to-string cell))
1167                      (if separator
1168                          (if (< (+ (current-column)
1169                                    (length ret)
1170                                    (length separator))
1171                                 76)
1172                              (insert separator)
1173                            (insert lbs)))
1174                      (insert ret)
1175                      (setq separator " "))
1176                    (setq value (cdr value)))
1177                  (insert ")")
1178                  (insert line-breaking))
1179                 (t
1180                  (insert (format "(%-18s" name))
1181                  (setq ret (prin1-to-string value))
1182                  (unless (< (+ (current-column)
1183                                (length ret)
1184                                3)
1185                             76)
1186                    (insert line-breaking))
1187                  (insert " . " ret ")" line-breaking)
1188                  ;; (insert (format "(%-18s . %S)%s"
1189                  ;;                 name value
1190                  ;;                 line-breaking))
1191                  )
1192                 ))
1193       (setq attributes (cdr attributes)))
1194     (insert ")")))
1195
1196 (defun insert-char-data (char &optional readable
1197                               attributes)
1198   (save-restriction
1199     (narrow-to-region (point)(point))
1200     (insert "(define-char
1201   '")
1202     (insert-char-attributes char readable attributes)
1203     (insert ")\n")
1204     (goto-char (point-min))
1205     (while (re-search-forward "[ \t]+$" nil t)
1206       (replace-match ""))
1207     ;; from tabify.
1208     (goto-char (point-min))
1209     (while (re-search-forward "[ \t][ \t][ \t]*" nil t)
1210       (let ((column (current-column))
1211             (indent-tabs-mode t))
1212         (delete-region (match-beginning 0) (point))
1213         (indent-to column)))
1214     (goto-char (point-max))
1215     ;; (tabify (point-min)(point-max))
1216     ))
1217
1218 (defun insert-char-data-with-variant (char &optional printable
1219                                            no-ucs-unified
1220                                            script excluded-script)
1221   (insert-char-data char printable)
1222   (let ((variants (char-variants char))
1223         rest
1224         variant vs ret)
1225     (setq variants (sort variants #'<))
1226     (setq rest variants)
1227     (setq variants (cons char variants))
1228     (while rest
1229       (setq variant (car rest))
1230       (unless (get-char-attribute variant '<-subsumptive)
1231         (if (and (or (null script)
1232                      (null (setq vs (get-char-attribute variant 'script)))
1233                      (memq script vs))
1234                  (or (null excluded-script)
1235                      (null (setq vs (get-char-attribute variant 'script)))
1236                      (not (memq excluded-script vs))))
1237             (unless (and no-ucs-unified (get-char-attribute variant '=ucs))
1238               (insert-char-data variant printable)
1239               (if (setq ret (char-variants variant))
1240                   (while ret
1241                     (or (memq (car ret) variants)
1242                         ;; (get-char-attribute (car ret) '<-subsumptive)
1243                         (setq rest (nconc rest (list (car ret)))))
1244                     (setq ret (cdr ret)))))))
1245       (setq rest (cdr rest)))))
1246
1247 (defun insert-char-range-data (min max &optional script excluded-script)
1248   (let ((code min)
1249         char)
1250     (while (<= code max)
1251       (setq char (decode-char '=ucs code))
1252       (if (encode-char char '=ucs 'defined-only)
1253           (insert-char-data-with-variant char nil 'no-ucs-unified
1254                                          script excluded-script))
1255       (setq code (1+ code)))))
1256
1257 (defun write-char-range-data-to-file (min max file
1258                                           &optional script excluded-script)
1259   (let ((coding-system-for-write char-db-file-coding-system))
1260     (with-temp-buffer
1261       (insert (format ";; -*- coding: %s -*-\n"
1262                       char-db-file-coding-system))
1263       (insert-char-range-data min max script excluded-script)
1264       (write-region (point-min)(point-max) file))))
1265
1266 (defvar what-character-original-window-configuration)
1267
1268 ;;;###autoload
1269 (defun what-char-definition (char)
1270   (interactive (list (char-after)))
1271   (let ((buf (get-buffer-create "*Character Description*"))
1272         (the-buf (current-buffer))
1273         (win-conf (current-window-configuration)))
1274     (pop-to-buffer buf)
1275     (make-local-variable 'what-character-original-window-configuration)
1276     (setq what-character-original-window-configuration win-conf)
1277     (setq buffer-read-only nil)
1278     (erase-buffer)
1279     (condition-case err
1280         (progn
1281           (insert-char-data-with-variant char 'printable)
1282           (unless (char-attribute-alist char)
1283             (insert (format ";; = %c\n"
1284                             (let* ((rest (split-char char))
1285                                    (ccs (pop rest))
1286                                    (code (pop rest)))
1287                               (while rest
1288                                 (setq code (logior (lsh code 8)
1289                                                    (pop rest))))
1290                               (decode-char ccs code)))))
1291           ;; (char-db-update-comment)
1292           (set-buffer-modified-p nil)
1293           (view-mode the-buf (lambda (buf)
1294                                (set-window-configuration
1295                                 what-character-original-window-configuration)
1296                                ))
1297           (goto-char (point-min)))
1298       (error (progn
1299                (set-window-configuration
1300                 what-character-original-window-configuration)
1301                (signal (car err) (cdr err)))))))
1302
1303 (provide 'char-db-util)
1304
1305 ;;; char-db-util.el ends here