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