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