(char-db-coded-charset-priority-list): Add `=>jis-x0208@usual'.
[chise/xemacs-chise.git.1] / lisp / utf-2000 / char-db-util.el
1 ;;; char-db-util.el --- Character Database utility -*- coding: utf-8-er; -*-
2
3 ;; Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006,
4 ;;   2007, 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@cns
177     =>>ucs@unicode
178     =>>ucs@jis
179     =>>ucs@cns
180     =ucs@iso
181     =ucs@unicode
182     =>>big5-cdp
183     =>>gt-k
184     =>gt
185     =>big5-cdp
186     =>daikanwa
187     =big5
188     =big5-eten
189     =zinbun-oracle
190     =>zinbun-oracle
191     =ruimoku-v6
192     =jef-china3
193     =shinjigen))
194
195
196 ;;; @ char-db formatters
197 ;;;
198
199 (defun char-db-make-char-spec (char)
200   (let (ret char-spec)
201     (cond ((characterp char)
202            (cond ((and (setq ret (encode-char char '=ucs 'defined-only))
203                        (not (and (<= #xE000 ret)(<= ret #xF8FF))))
204                   (setq char-spec (list (cons '=ucs ret)))
205                   (cond ((setq ret (get-char-attribute char 'name))
206                          (setq char-spec (cons (cons 'name ret) char-spec))
207                          )
208                         ((setq ret (get-char-attribute char 'name*))
209                          (setq char-spec (cons (cons 'name* ret) char-spec))
210                          ))
211                   )
212                  ((setq ret
213                         (catch 'tag
214                           (let ((rest char-db-coded-charset-priority-list)
215                                 ccs)
216                             (while rest
217                               (setq ccs (charset-name
218                                          (find-charset (car rest))))
219                               (if (setq ret
220                                         (encode-char char ccs
221                                                      'defined-only))
222                                   (throw 'tag (cons ccs ret)))
223                               (setq rest (cdr rest))))))
224                   (setq char-spec (list ret))
225                   (dolist (ccs (delq (car ret) (charset-list)))
226                     (if (and (or (charset-iso-final-char ccs)
227                                  (memq ccs
228                                        '(=daikanwa
229                                          =daikanwa@rev2
230                                          ;; =gt-k
231                                          =jis-x0208@1997
232                                          ))
233                                  (string-match "=ucs@" (symbol-name ccs)))
234                              (setq ccs (charset-name ccs))
235                              (null (assq ccs char-spec))
236                              (setq ret (encode-char char ccs 'defined-only)))
237                         (setq char-spec (cons (cons ccs ret) char-spec))))
238                   (if (null char-spec)
239                       (setq char-spec (split-char char)))
240                   (cond ((setq ret (get-char-attribute char 'name))
241                          (setq char-spec (cons (cons 'name ret) char-spec))
242                          )
243                         ((setq ret (get-char-attribute char 'name*))
244                          (setq char-spec (cons (cons 'name* ret) char-spec))
245                          ))
246                   )
247                  ((setq ret (get-char-attribute
248                              char 'ideographic-combination))
249                   (setq char-spec
250                         (cons (cons 'ideographic-combination ret)
251                               char-spec))
252                   ))
253            char-spec)
254           ((consp char)
255            char))))
256     
257 (defun char-db-insert-char-spec (char &optional readable column
258                                       required-features)
259   (unless column
260     (setq column (current-column)))
261   (let (char-spec temp-char)
262     (setq char-spec (char-db-make-char-spec char))
263     (unless (or (characterp char) ; char
264                 (condition-case nil
265                     (setq char (find-char char-spec))
266                   (error nil)))
267       ;; define temporary character
268       ;;   Current implementation is dirty.
269       (setq temp-char (define-char (cons '(ideograph-daikanwa . 0)
270                                          char-spec)))
271       (remove-char-attribute temp-char 'ideograph-daikanwa)
272       (setq char temp-char))
273     (insert-char-attributes char
274                             readable
275                             (union (mapcar #'car char-spec)
276                                    required-features))
277     (when temp-char
278       ;; undefine temporary character
279       ;;   Current implementation is dirty.
280       (setq char-spec (char-attribute-alist temp-char))
281       (while char-spec
282         (remove-char-attribute temp-char (car (car char-spec)))
283         (setq char-spec (cdr char-spec))))))
284
285 (defun char-db-insert-alist (alist &optional readable column)
286   (unless column
287     (setq column (current-column)))
288   (let ((line-breaking
289          (concat "\n" (make-string (1+ column) ?\ )))
290         name value
291         ret al ; cal
292         key
293         lbs cell rest separator)
294     (insert "(")
295     (while alist
296       (setq name (car (car alist))
297             value (cdr (car alist)))
298       (cond ((eq name 'char)
299              (insert "(char . ")
300              (if (setq ret (condition-case nil
301                                (find-char value)
302                              (error nil)))
303                  (progn
304                    (setq al nil
305                          ;; cal nil
306                          )
307                    (while value
308                      (setq key (car (car value)))
309                      ;; (if (find-charset key)
310                      ;;     (setq cal (cons key cal))
311                      (setq al (cons key al))
312                      ;; )
313                      (setq value (cdr value)))
314                    (insert-char-attributes ret
315                                            readable
316                                            (or al 'none) ; cal
317                                            ))
318                (insert (prin1-to-string value)))
319              (insert ")")
320              (insert line-breaking))
321             ((consp value)
322              (insert (format "(%-18s " name))
323              (setq lbs (concat "\n" (make-string (current-column) ?\ )))
324              (while (consp value)
325                (setq cell (car value))
326                (if (and (consp cell)
327                         (consp (car cell))
328                         (setq ret (condition-case nil
329                                       (find-char cell)
330                                     (error nil)))
331                         )
332                    (progn
333                      (setq rest cell
334                            al nil
335                            ;; cal nil
336                            )
337                      (while rest
338                        (setq key (car (car rest)))
339                        ;; (if (find-charset key)
340                        ;;     (setq cal (cons key cal))
341                        (setq al (cons key al))
342                        ;; )
343                        (setq rest (cdr rest)))
344                      (if separator
345                          (insert lbs))
346                      (insert-char-attributes ret
347                                              readable
348                                              al ; cal
349                                              )
350                      (setq separator lbs))
351                  (if separator
352                      (insert separator))
353                  (insert (prin1-to-string cell))
354                  (setq separator " "))
355                (setq value (cdr value)))
356              (insert ")")
357              (insert line-breaking))
358             (t
359              (insert (format "(%-18s . %S)%s"
360                              name value
361                              line-breaking))))
362       (setq alist (cdr alist))))
363   (insert ")"))
364
365 (defun char-db-insert-char-reference (plist &optional readable column)
366   (unless column
367     (setq column (current-column)))
368   (let ((line-breaking
369          (concat "\n" (make-string (1+ column) ?\ )))
370         (separator "")
371         name value)
372     (insert "(")
373     (while plist
374       (setq name (pop plist))
375       (setq value (pop plist))
376       (cond ((eq name :char)
377              (insert separator)
378              (insert ":char\t")
379              (cond ((numberp value)
380                     (setq value (decode-char '=ucs value)))
381                    ;; ((consp value)
382                    ;;  (setq value (or (find-char value)
383                    ;;                  value)))
384                    )
385              (char-db-insert-char-spec value readable)
386              (insert line-breaking)
387              (setq separator ""))
388             ((eq name :radical)
389              (insert (format "%s%s\t%d ; %c%s"
390                              separator
391                              name value
392                              (ideographic-radical value)
393                              line-breaking))
394              (setq separator ""))
395             (t
396              (insert (format "%s%s\t%S" separator name value))
397              (setq separator line-breaking)))
398       ))
399   (insert ")"))
400
401 (defun char-db-decode-isolated-char (ccs code-point)
402   (let (ret)
403     (setq ret
404           (cond ((eq ccs 'arabic-iso8859-6)
405                  (decode-char ccs code-point))
406                 ((and (memq ccs '(=gt-pj-1
407                                   =gt-pj-2
408                                   =gt-pj-3
409                                   =gt-pj-4
410                                   =gt-pj-5
411                                   =gt-pj-6
412                                   =gt-pj-7
413                                   =gt-pj-8
414                                   =gt-pj-9
415                                   =gt-pj-10
416                                   =gt-pj-11))
417                       (setq ret (decode-char ccs code-point))
418                       (setq ret (encode-char ret '=gt 'defined-only)))
419                  (decode-builtin-char '=gt ret))
420                 (t
421                  (decode-builtin-char ccs code-point))))
422     (cond ((and (<= 0 (char-int ret))
423                 (<= (char-int ret) #x1F))
424            (decode-char '=ucs (+ #x2400 (char-int ret))))
425           ((= (char-int ret) #x7F)
426            ?\u2421)
427           (t ret))))
428
429 (defvar char-db-convert-obsolete-format t)
430
431 (defun char-db-insert-ccs-feature (name value line-breaking)
432   (insert
433    (format
434     (cond ((memq name '(=shinjigen
435                         =shinjigen@1ed
436                         =shinjigen@rev =shinjigen/+p@rev))
437            "(%-18s .  %04d)\t; %c")
438           ((eq name '=shinjigen@1ed/24pr)
439            "(%-18s . %04d)\t; %c")
440           ((or (memq name '(=daikanwa
441                             =daikanwa@rev1 =daikanwa@rev2
442                             =>>daikanwa =>daikanwa
443                             =gt =>>gt =>gt =gt-k =>>gt-k =cbeta
444                             =zinbun-oracle =>zinbun-oracle))
445                (string-match "^=adobe-" (symbol-name name)))
446            "(%-18s . %05d)\t; %c")
447           ((eq name 'mojikyo)
448            "(%-18s . %06d)\t; %c")
449           ((>= (charset-dimension name) 2)
450            "(%-18s . #x%04X)\t; %c")
451           (t
452            "(%-18s . #x%02X)\t; %c"))
453     name
454     (if (= (charset-iso-graphic-plane name) 1)
455         (logior value
456                 (cond ((= (charset-dimension name) 1)
457                        #x80)
458                       ((= (charset-dimension name) 2)
459                        #x8080)
460                       ((= (charset-dimension name) 3)
461                        #x808080)
462                       (t 0)))
463       value)
464     (char-db-decode-isolated-char name value)))
465   (if (and (= (charset-chars name) 94)
466            (= (charset-dimension name) 2))
467       (insert (format " [%02d-%02d]"
468                       (- (lsh value -8) 32)
469                       (- (logand value 255) 32))))
470   (insert line-breaking))
471
472 (defun char-db-insert-relation-feature (char name value line-breaking
473                                              ccss readable)
474   (insert (format "(%-18s%s " name line-breaking))
475   (let ((lbs (concat "\n" (make-string (current-column) ?\ )))
476         separator cell sources required-features
477         ret)
478     (while (consp value)
479       (setq cell (car value))
480       (if (integerp cell)
481           (setq cell (decode-char '=ucs cell)))
482       (cond
483        ((eq name '->subsumptive)
484         (when (or (not (some (lambda (atr)
485                                (get-char-attribute cell atr))
486                              char-db-ignored-attributes))
487                   (some (lambda (ccs)
488                           (encode-char cell ccs 'defined-only))
489                         ccss))
490           (if separator
491               (insert lbs))
492           (let ((char-db-ignored-attributes
493                  (cons '<-subsumptive
494                        char-db-ignored-attributes)))
495             (insert-char-attributes cell readable))
496           (setq separator lbs))
497         )
498        ((characterp cell)
499         (setq sources
500               (get-char-attribute
501                char (intern (format "%s*sources" name))))
502         (setq required-features nil)
503         (dolist (source sources)
504           (cond
505            ((memq source '(JP
506                            JP/Jouyou
507                            shinjigen shinjigen@1ed shinjigen@rev))
508             (setq required-features
509                   (union required-features
510                          '(=jis-x0208
511                            =jis-x0208@1990
512                            =jis-x0213-1@2000
513                            =jis-x0213-1@2004
514                            =jis-x0213-2
515                            =jis-x0212
516                            =jis-x0208@1983
517                            =jis-x0208@1978
518                            =shinjigen))))
519            ((eq source 'CN)
520             (setq required-features
521                   (union required-features
522                          '(=gb2312
523                            =gb12345
524                            =iso-ir165)))))
525           (cond
526            ((find-charset (setq ret (intern (format "=%s" source))))
527             (setq required-features
528                   (cons ret required-features)))
529            (t (setq required-features
530                     (cons source required-features)))))
531         (cond ((string-match "@JP" (symbol-name name))
532                (setq required-features
533                      (union required-features
534                             '(=jis-x0208
535                               =jis-x0208@1990
536                               =jis-x0213-1-2000
537                               =jis-x0213-2-2000
538                               =jis-x0212
539                               =jis-x0208@1983
540                               =jis-x0208@1978))))
541               ((string-match "@CN" (symbol-name name))
542                (setq required-features
543                      (union required-features
544                             '(=gb2312
545                               =gb12345
546                               =iso-ir165)))))
547         (if separator
548             (insert lbs))
549         (if readable
550             (insert (format "%S" cell))
551           (char-db-insert-char-spec cell readable
552                                     nil
553                                     required-features))
554         (setq separator lbs))
555        ((consp cell)
556         (if separator
557             (insert lbs))
558         (if (consp (car cell))
559             (char-db-insert-char-spec cell readable)
560           (char-db-insert-char-reference cell readable))
561         (setq separator lbs))
562        (t
563         (if separator
564             (insert separator))
565         (insert (prin1-to-string cell))
566         (setq separator " ")))
567       (setq value (cdr value)))
568     (insert ")")
569     (insert line-breaking)))
570
571 (defun insert-char-attributes (char &optional readable attributes column)
572   (unless column
573     (setq column (current-column)))
574   (let (name value ; has-long-ccs-name
575         rest
576         radical strokes
577         (line-breaking
578          (concat "\n" (make-string (1+ column) ?\ )))
579         lbs cell separator ret
580         key al cal
581         dest-ccss ; sources required-features
582         ccss)
583     (let (atr-d)
584       (setq attributes
585             (sort (if attributes
586                       (if (consp attributes)
587                           (progn
588                             (dolist (name attributes)
589                               (unless (memq name char-db-ignored-attributes)
590                                 (if (find-charset name)
591                                     (push name ccss))
592                                 (push name atr-d)))
593                             atr-d))
594                     (dolist (name (char-attribute-list))
595                       (unless (memq name char-db-ignored-attributes)
596                         (if (find-charset name)
597                             (push name ccss))
598                         (push name atr-d)))
599                     atr-d)
600                   #'char-attribute-name<)))
601     (insert "(")
602     (when (memq '<-subsumptive attributes)
603       (when readable
604         (when (setq value (get-char-attribute char '<-subsumptive))
605           (char-db-insert-relation-feature char '<-subsumptive value
606                                            line-breaking
607                                            ccss readable)))
608       (setq attributes (delq '<-subsumptive attributes)))
609     (when (and (memq '<-denotational attributes)
610                (setq value (get-char-attribute char '<-denotational)))
611       (char-db-insert-relation-feature char '<-denotational value
612                                        line-breaking
613                                        ccss readable)
614       (setq attributes (delq '<-denotational attributes)))
615     (when (and (memq 'name attributes)
616                (setq value (get-char-attribute char 'name)))
617       (insert (format
618                (if (> (+ (current-column) (length value)) 48)
619                    "(name . %S)%s"
620                  "(name               . %S)%s")
621                value line-breaking))
622       (setq attributes (delq 'name attributes))
623       )
624     (when (and (memq 'name* attributes)
625                (setq value (get-char-attribute char 'name*)))
626       (insert (format
627                (if (> (+ (current-column) (length value)) 48)
628                    "(name* . %S)%s"
629                  "(name*              . %S)%s")
630                value line-breaking))
631       (setq attributes (delq 'name* attributes))
632       )
633     (when (and (memq 'script attributes)
634                (setq value (get-char-attribute char 'script)))
635       (insert (format "(script\t\t%s)%s"
636                       (mapconcat (function prin1-to-string)
637                                  value " ")
638                       line-breaking))
639       (setq attributes (delq 'script attributes))
640       )
641     (dolist (name '(=>ucs =>ucs*))
642       (when (and (memq name attributes)
643                  (setq value (get-char-attribute char name)))
644         (insert (format "(%-18s . #x%04X)\t; %c%s"
645                         name value (decode-char '=ucs value)
646                         line-breaking))
647         (setq attributes (delq name attributes))))
648     (dolist (name '(=>ucs@gb =>ucs@jis =>ucs@ks =>ucs@big5))
649       (when (and (memq name attributes)
650                  (setq value (get-char-attribute char name)))
651         (insert (format "(%-18s . #x%04X)\t; %c%s"
652                         name value
653                         (decode-char (intern
654                                       (concat "="
655                                               (substring
656                                                (symbol-name name) 2)))
657                                      value)
658                         line-breaking))
659         (setq attributes (delq name attributes))
660         ))
661     ;; (dolist (name '(=>daikanwa))
662     ;;   (when (and (memq name attributes)
663     ;;              (setq value (get-char-attribute char name)))
664     ;;     (insert
665     ;;      (if (integerp value)
666     ;;          (format "(%-18s . %05d)\t; %c%s"
667     ;;                  name value (decode-char '=daikanwa value)
668     ;;                  line-breaking)
669     ;;        (format "(%-18s %s)\t; %c%s"
670     ;;                name
671     ;;                (mapconcat (function prin1-to-string)
672     ;;                           value " ")
673     ;;                (char-representative-of-daikanwa char)
674     ;;                line-breaking)))
675     ;;     (setq attributes (delq name attributes))))
676     (when (and (memq 'general-category attributes)
677                (setq value (get-char-attribute char 'general-category)))
678       (insert (format
679                "(general-category\t%s) ; %s%s"
680                (mapconcat (lambda (cell)
681                             (format "%S" cell))
682                           value " ")
683                (cond ((rassoc value unidata-normative-category-alist)
684                       "Normative Category")
685                      ((rassoc value unidata-informative-category-alist)
686                       "Informative Category")
687                      (t
688                       "Unknown Category"))
689                line-breaking))
690       (setq attributes (delq 'general-category attributes))
691       )
692     (when (and (memq 'bidi-category attributes)
693                (setq value (get-char-attribute char 'bidi-category)))
694       (insert (format "(bidi-category\t. %S)%s"
695                       value
696                       line-breaking))
697       (setq attributes (delq 'bidi-category attributes))
698       )
699     (unless (or (not (memq 'mirrored attributes))
700                 (eq (setq value (get-char-attribute char 'mirrored 'empty))
701                     'empty))
702       (insert (format "(mirrored\t\t. %S)%s"
703                       value
704                       line-breaking))
705       (setq attributes (delq 'mirrored attributes))
706       )
707     (cond
708      ((and (memq 'decimal-digit-value attributes)
709            (setq value (get-char-attribute char 'decimal-digit-value)))
710       (insert (format "(decimal-digit-value . %S)%s"
711                       value
712                       line-breaking))
713       (setq attributes (delq 'decimal-digit-value attributes))
714       (when (and (memq 'digit-value attributes)
715                  (setq value (get-char-attribute char 'digit-value)))
716         (insert (format "(digit-value\t . %S)%s"
717                         value
718                         line-breaking))
719         (setq attributes (delq 'digit-value attributes))
720         )
721       (when (and (memq 'numeric-value attributes)
722                  (setq value (get-char-attribute char 'numeric-value)))
723         (insert (format "(numeric-value\t . %S)%s"
724                         value
725                         line-breaking))
726         (setq attributes (delq 'numeric-value attributes))
727         )
728       )
729      (t
730       (when (and (memq 'digit-value attributes)
731                  (setq value (get-char-attribute char 'digit-value)))
732         (insert (format "(digit-value\t. %S)%s"
733                         value
734                         line-breaking))
735         (setq attributes (delq 'digit-value attributes))
736         )
737       (when (and (memq 'numeric-value attributes)
738                  (setq value (get-char-attribute char 'numeric-value)))
739         (insert (format "(numeric-value\t. %S)%s"
740                         value
741                         line-breaking))
742         (setq attributes (delq 'numeric-value attributes))
743         )))
744     (when (and (memq 'iso-10646-comment attributes)
745                (setq value (get-char-attribute char 'iso-10646-comment)))
746       (insert (format "(iso-10646-comment\t. %S)%s"
747                       value
748                       line-breaking))
749       (setq attributes (delq 'iso-10646-comment attributes))
750       )
751     (when (and (memq 'morohashi-daikanwa attributes)
752                (setq value (get-char-attribute char 'morohashi-daikanwa)))
753       (insert (format "(morohashi-daikanwa\t%s)%s"
754                       (mapconcat (function prin1-to-string) value " ")
755                       line-breaking))
756       (setq attributes (delq 'morohashi-daikanwa attributes))
757       )
758     (setq radical nil
759           strokes nil)
760     (when (and (memq 'ideographic-radical attributes)
761                (setq value (get-char-attribute char 'ideographic-radical)))
762       (setq radical value)
763       (insert (format "(ideographic-radical . %S)\t; %c%s"
764                       radical
765                       (ideographic-radical radical)
766                       line-breaking))
767       (setq attributes (delq 'ideographic-radical attributes))
768       )
769     (when (and (memq 'shuowen-radical attributes)
770                (setq value (get-char-attribute char 'shuowen-radical)))
771       (insert (format "(shuowen-radical\t. %S)\t; %c%s"
772                       value
773                       (shuowen-radical value)
774                       line-breaking))
775       (setq attributes (delq 'shuowen-radical attributes))
776       )
777     (let (key)
778       (dolist (domain
779                (append
780                 char-db-feature-domains
781                 (let (dest domain)
782                   (dolist (feature (char-attribute-list))
783                     (setq feature (symbol-name feature))
784                     (when (string-match
785                            "\\(radical\\|strokes\\)@\\([^@*]+\\)\\(\\*\\|$\\)"
786                            feature)
787                       (setq domain (intern (match-string 2 feature)))
788                      (unless (memq domain dest)
789                        (setq dest (cons domain dest)))))
790                   (sort dest #'string<))))
791         (setq key (intern (format "%s@%s" 'ideographic-radical domain)))
792         (when (and (memq key attributes)
793                    (setq value (get-char-attribute char key)))
794           (setq radical value)
795           (insert (format "(%s . %S)\t; %c%s"
796                           key
797                           radical
798                           (ideographic-radical radical)
799                           line-breaking))
800           (setq attributes (delq key attributes))
801           )
802         (setq key (intern (format "%s@%s" 'ideographic-strokes domain)))
803         (when (and (memq key attributes)
804                    (setq value (get-char-attribute char key)))
805           (setq strokes value)
806           (insert (format "(%s . %S)%s"
807                           key
808                           strokes
809                           line-breaking))
810           (setq attributes (delq key attributes))
811           )
812         (setq key (intern (format "%s@%s" 'total-strokes domain)))
813         (when (and (memq key attributes)
814                    (setq value (get-char-attribute char key)))
815           (insert (format "(%s       . %S)%s"
816                           key
817                           value
818                           line-breaking))
819           (setq attributes (delq key attributes))
820           )
821         (dolist (feature '(ideographic-radical
822                            ideographic-strokes
823                            total-strokes))
824           (setq key (intern (format "%s@%s*sources" feature domain)))
825           (when (and (memq key attributes)
826                      (setq value (get-char-attribute char key)))
827             (insert (format "(%s%s" key line-breaking))
828             (dolist (cell value)
829               (insert (format " %s" cell)))
830             (insert ")")
831             (insert line-breaking)
832             (setq attributes (delq key attributes))
833             ))
834         ))
835     (when (and (memq 'ideographic-strokes attributes)
836                (setq value (get-char-attribute char 'ideographic-strokes)))
837       (setq strokes value)
838       (insert (format "(ideographic-strokes . %S)%s"
839                       strokes
840                       line-breaking))
841       (setq attributes (delq 'ideographic-strokes attributes))
842       )
843     (when (and (memq 'kangxi-radical attributes)
844                (setq value (get-char-attribute char 'kangxi-radical)))
845       (unless (eq value radical)
846         (insert (format "(kangxi-radical\t . %S)\t; %c%s"
847                         value
848                         (ideographic-radical value)
849                         line-breaking))
850         (or radical
851             (setq radical value)))
852       (setq attributes (delq 'kangxi-radical attributes))
853       )
854     (when (and (memq 'kangxi-strokes attributes)
855                (setq value (get-char-attribute char 'kangxi-strokes)))
856       (unless (eq value strokes)
857         (insert (format "(kangxi-strokes\t . %S)%s"
858                         value
859                         line-breaking))
860         (or strokes
861             (setq strokes value)))
862       (setq attributes (delq 'kangxi-strokes attributes))
863       )
864     (when (and (memq 'japanese-radical attributes)
865                (setq value (get-char-attribute char 'japanese-radical)))
866       (unless (eq value radical)
867         (insert (format "(japanese-radical\t . %S)\t; %c%s"
868                         value
869                         (ideographic-radical value)
870                         line-breaking))
871         (or radical
872             (setq radical value)))
873       (setq attributes (delq 'japanese-radical attributes))
874       )
875     (when (and (memq 'japanese-strokes attributes)
876                (setq value (get-char-attribute char 'japanese-strokes)))
877       (unless (eq value strokes)
878         (insert (format "(japanese-strokes\t . %S)%s"
879                         value
880                         line-breaking))
881         (or strokes
882             (setq strokes value)))
883       (setq attributes (delq 'japanese-strokes attributes))
884       )
885     (when (and (memq 'cns-radical attributes)
886                (setq value (get-char-attribute char 'cns-radical)))
887       (insert (format "(cns-radical\t . %S)\t; %c%s"
888                       value
889                       (ideographic-radical value)
890                       line-breaking))
891       (setq attributes (delq 'cns-radical attributes))
892       )
893     (when (and (memq 'cns-strokes attributes)
894                (setq value (get-char-attribute char 'cns-strokes)))
895       (unless (eq value strokes)
896         (insert (format "(cns-strokes\t . %S)%s"
897                         value
898                         line-breaking))
899         (or strokes
900             (setq strokes value)))
901       (setq attributes (delq 'cns-strokes attributes))
902       )
903     (when (and (memq 'shinjigen-1-radical attributes)
904                (setq value (get-char-attribute char 'shinjigen-1-radical)))
905       (unless (eq value radical)
906         (insert (format "(shinjigen-1-radical . %S)\t; %c%s"
907                         value
908                         (ideographic-radical value)
909                         line-breaking))
910         (or radical
911             (setq radical value)))
912       (setq attributes (delq 'shinjigen-1-radical attributes))
913       )
914     (when (and (memq 'ideographic- attributes)
915                (setq value (get-char-attribute char 'ideographic-)))
916       (insert "(ideographic-       ")
917       (setq lbs (concat "\n" (make-string (current-column) ?\ ))
918             separator nil)
919       (while (consp value)
920         (setq cell (car value))
921         (if (integerp cell)
922             (setq cell (decode-char '=ucs cell)))
923         (cond ((characterp cell)
924                (if separator
925                    (insert lbs))
926                (if readable
927                    (insert (format "%S" cell))
928                  (char-db-insert-char-spec cell readable))
929                (setq separator lbs))
930               ((consp cell)
931                (if separator
932                    (insert lbs))
933                (if (consp (car cell))
934                    (char-db-insert-char-spec cell readable)
935                  (char-db-insert-char-reference cell readable))
936                (setq separator lbs))
937               (t
938                (if separator
939                    (insert separator))
940                (insert (prin1-to-string cell))
941                (setq separator " ")))
942         (setq value (cdr value)))
943       (insert ")")
944       (insert line-breaking)
945       (setq attributes (delq 'ideographic- attributes)))
946     (when (and (memq 'total-strokes attributes)
947                (setq value (get-char-attribute char 'total-strokes)))
948       (insert (format "(total-strokes       . %S)%s"
949                       value
950                       line-breaking))
951       (setq attributes (delq 'total-strokes attributes))
952       )
953     (when (and (memq '->ideograph attributes)
954                (setq value (get-char-attribute char '->ideograph)))
955       (insert (format "(->ideograph\t%s)%s"
956                       (mapconcat (lambda (code)
957                                    (cond ((symbolp code)
958                                           (symbol-name code))
959                                          ((integerp code)
960                                           (format "#x%04X" code))
961                                          (t
962                                           (format "%s %S"
963                                                   line-breaking code))))
964                                  value " ")
965                       line-breaking))
966       (setq attributes (delq '->ideograph attributes))
967       )
968     ;; (when (and (memq '->decomposition attributes)
969     ;;            (setq value (get-char-attribute char '->decomposition)))
970     ;;   (insert (format "(->decomposition\t%s)%s"
971     ;;                   (mapconcat (lambda (code)
972     ;;                                (cond ((symbolp code)
973     ;;                                       (symbol-name code))
974     ;;                                      ((characterp code)
975     ;;                                       (if readable
976     ;;                                           (format "%S" code)
977     ;;                                         (format "#x%04X"
978     ;;                                                 (char-int code))
979     ;;                                         ))
980     ;;                                      ((integerp code)
981     ;;                                       (format "#x%04X" code))
982     ;;                                      (t
983     ;;                                       (format "%s%S" line-breaking code))))
984     ;;                              value " ")
985     ;;                   line-breaking))
986     ;;   (setq attributes (delq '->decomposition attributes))
987     ;;   )
988     (if (equal (get-char-attribute char '->titlecase)
989                (get-char-attribute char '->uppercase))
990         (setq attributes (delq '->titlecase attributes)))
991     (when (and (memq '->mojikyo attributes)
992                (setq value (get-char-attribute char '->mojikyo)))
993       (insert (format "(->mojikyo\t\t. %06d)\t; %c%s"
994                       value (decode-char 'mojikyo value)
995                       line-breaking))
996       (setq attributes (delq '->mojikyo attributes))
997       )
998     (when (and (memq 'hanyu-dazidian-vol attributes)
999                (setq value (get-char-attribute char 'hanyu-dazidian-vol)))
1000       (insert (format "(hanyu-dazidian-vol  . %d)%s"
1001                       value line-breaking))
1002       (setq attributes (delq 'hanyu-dazidian-vol attributes))
1003       )
1004     (when (and (memq 'hanyu-dazidian-page attributes)
1005                (setq value (get-char-attribute char 'hanyu-dazidian-page)))
1006       (insert (format "(hanyu-dazidian-page . %d)%s"
1007                       value line-breaking))
1008       (setq attributes (delq 'hanyu-dazidian-page attributes))
1009       )
1010     (when (and (memq 'hanyu-dazidian-char attributes)
1011                (setq value (get-char-attribute char 'hanyu-dazidian-char)))
1012       (insert (format "(hanyu-dazidian-char . %d)%s"
1013                       value line-breaking))
1014       (setq attributes (delq 'hanyu-dazidian-char attributes))
1015       )
1016     (unless readable
1017       (dolist (ignored '(composition
1018                          ->denotational <-subsumptive ->ucs-unified
1019                          ->ideographic-component-forms))
1020         (setq attributes (delq ignored attributes))))
1021     (while attributes
1022       (setq name (car attributes))
1023       (if (setq value (get-char-attribute char name))
1024           (cond ((setq ret (find-charset name))
1025                  (setq name (charset-name ret))
1026                  (if (and (not (memq name dest-ccss))
1027                           (prog1
1028                               (setq value (get-char-attribute char name))
1029                             (setq dest-ccss (cons name dest-ccss))))
1030                      (char-db-insert-ccs-feature name value line-breaking))
1031                  )
1032                 ((string-match "^=>ucs@" (symbol-name name))
1033                  (insert (format "(%-18s . #x%04X)\t; %c%s"
1034                                  name value (decode-char '=ucs value)
1035                                  line-breaking))
1036                  )
1037                 ((eq name 'jisx0208-1978/4X)
1038                  (insert (format "(%-18s . #x%04X)%s"
1039                                  name value
1040                                  line-breaking))
1041                  )
1042                 ((and
1043                   (not readable)
1044                   (not (eq name '->subsumptive))
1045                   (not (eq name '->uppercase))
1046                   (not (eq name '->lowercase))
1047                   (not (eq name '->titlecase))
1048                   (not (eq name '->canonical))
1049                   (not (eq name '->Bopomofo))
1050                   (not (eq name '->mistakable))
1051                   (not (eq name '->ideographic-variants))
1052                   (null (get-char-attribute
1053                          char (intern (format "%s*sources" name))))
1054                   (not (string-match "\\*sources$" (symbol-name name)))
1055                   (null (get-char-attribute
1056                          char (intern (format "%s*note" name))))
1057                   (not (string-match "\\*note$" (symbol-name name)))
1058                   (or (eq name '<-identical)
1059                       (eq name '<-uppercase)
1060                       (eq name '<-lowercase)
1061                       (eq name '<-titlecase)
1062                       (eq name '<-canonical)
1063                       (eq name '<-ideographic-variants)
1064                       ;; (eq name '<-synonyms)
1065                       (string-match "^<-synonyms" (symbol-name name))
1066                       (eq name '<-mistakable)
1067                       (when (string-match "^->" (symbol-name name))
1068                         (cond
1069                          ((string-match "^->fullwidth" (symbol-name name))
1070                           (not (and (consp value)
1071                                     (characterp (car value))
1072                                     (encode-char
1073                                      (car value) '=ucs 'defined-only)))
1074                           )
1075                          (t)))
1076                       ))
1077                  )
1078                 ((or (eq name 'ideographic-structure)
1079                      (eq name 'ideographic-combination)
1080                      (eq name 'ideographic-)
1081                      (eq name '=decomposition)
1082                      (string-match "^=>decomposition" (symbol-name name))
1083                      (string-match "^\\(->\\|<-\\)[^*]*$" (symbol-name name))
1084                      (string-match "^\\(->\\|<-\\)[^*]*\\*sources$"
1085                                    (symbol-name name))
1086                      )
1087                  (char-db-insert-relation-feature char name value
1088                                                   line-breaking
1089                                                   ccss readable))
1090                 ((memq name '(ideograph=
1091                               original-ideograph-of
1092                               ancient-ideograph-of
1093                               vulgar-ideograph-of
1094                               wrong-ideograph-of
1095                               ;; simplified-ideograph-of
1096                               ideographic-variants
1097                               ;; ideographic-different-form-of
1098                               ))
1099                  (insert (format "(%-18s%s " name line-breaking))
1100                  (setq lbs (concat "\n" (make-string (current-column) ?\ ))
1101                        separator nil)
1102                  (while (consp value)
1103                    (setq cell (car value))
1104                    (if (and (consp cell)
1105                             (consp (car cell)))
1106                        (progn
1107                          (if separator
1108                              (insert lbs))
1109                          (char-db-insert-alist cell readable)
1110                          (setq separator lbs))
1111                      (if separator
1112                          (insert separator))
1113                      (insert (prin1-to-string cell))
1114                      (setq separator " "))
1115                    (setq value (cdr value)))
1116                  (insert ")")
1117                  (insert line-breaking))
1118                 ((consp value)
1119                  (insert (format "(%-18s " name))
1120                  (setq lbs (concat "\n" (make-string (current-column) ?\ ))
1121                        separator nil)
1122                  (while (consp value)
1123                    (setq cell (car value))
1124                    (if (and (consp cell)
1125                             (consp (car cell))
1126                             (setq ret (condition-case nil
1127                                           (find-char cell)
1128                                         (error nil))))
1129                        (progn
1130                          (setq rest cell
1131                                al nil
1132                                cal nil)
1133                          (while rest
1134                            (setq key (car (car rest)))
1135                            (if (find-charset key)
1136                                (setq cal (cons key cal))
1137                              (setq al (cons key al)))
1138                            (setq rest (cdr rest)))
1139                          (if separator
1140                              (insert lbs))
1141                          (insert-char-attributes ret
1142                                                  readable
1143                                                  al cal)
1144                          (setq separator lbs))
1145                      (setq ret (prin1-to-string cell))
1146                      (if separator
1147                          (if (< (+ (current-column)
1148                                    (length ret)
1149                                    (length separator))
1150                                 76)
1151                              (insert separator)
1152                            (insert lbs)))
1153                      (insert ret)
1154                      (setq separator " "))
1155                    (setq value (cdr value)))
1156                  (insert ")")
1157                  (insert line-breaking))
1158                 (t
1159                  (insert (format "(%-18s" name))
1160                  (setq ret (prin1-to-string value))
1161                  (unless (< (+ (current-column)
1162                                (length ret)
1163                                3)
1164                             76)
1165                    (insert line-breaking))
1166                  (insert " . " ret ")" line-breaking)
1167                  ;; (insert (format "(%-18s . %S)%s"
1168                  ;;                 name value
1169                  ;;                 line-breaking))
1170                  )
1171                 ))
1172       (setq attributes (cdr attributes)))
1173     (insert ")")))
1174
1175 (defun insert-char-data (char &optional readable
1176                               attributes)
1177   (save-restriction
1178     (narrow-to-region (point)(point))
1179     (insert "(define-char
1180   '")
1181     (insert-char-attributes char readable attributes)
1182     (insert ")\n")
1183     (goto-char (point-min))
1184     (while (re-search-forward "[ \t]+$" nil t)
1185       (replace-match ""))
1186     ;; from tabify.
1187     (goto-char (point-min))
1188     (while (re-search-forward "[ \t][ \t][ \t]*" nil t)
1189       (let ((column (current-column))
1190             (indent-tabs-mode t))
1191         (delete-region (match-beginning 0) (point))
1192         (indent-to column)))
1193     (goto-char (point-max))
1194     ;; (tabify (point-min)(point-max))
1195     ))
1196
1197 (defun insert-char-data-with-variant (char &optional printable
1198                                            no-ucs-unified
1199                                            script excluded-script)
1200   (insert-char-data char printable)
1201   (let ((variants (char-variants char))
1202         rest
1203         variant vs ret)
1204     (setq variants (sort variants #'<))
1205     (setq rest variants)
1206     (setq variants (cons char variants))
1207     (while rest
1208       (setq variant (car rest))
1209       (unless (get-char-attribute variant '<-subsumptive)
1210         (if (and (or (null script)
1211                      (null (setq vs (get-char-attribute variant 'script)))
1212                      (memq script vs))
1213                  (or (null excluded-script)
1214                      (null (setq vs (get-char-attribute variant 'script)))
1215                      (not (memq excluded-script vs))))
1216             (unless (and no-ucs-unified (get-char-attribute variant '=ucs))
1217               (insert-char-data variant printable)
1218               (if (setq ret (char-variants variant))
1219                   (while ret
1220                     (or (memq (car ret) variants)
1221                         ;; (get-char-attribute (car ret) '<-subsumptive)
1222                         (setq rest (nconc rest (list (car ret)))))
1223                     (setq ret (cdr ret)))))))
1224       (setq rest (cdr rest)))))
1225
1226 (defun insert-char-range-data (min max &optional script excluded-script)
1227   (let ((code min)
1228         char)
1229     (while (<= code max)
1230       (setq char (decode-char '=ucs code))
1231       (if (encode-char char '=ucs 'defined-only)
1232           (insert-char-data-with-variant char nil 'no-ucs-unified
1233                                          script excluded-script))
1234       (setq code (1+ code)))))
1235
1236 (defun write-char-range-data-to-file (min max file
1237                                           &optional script excluded-script)
1238   (let ((coding-system-for-write char-db-file-coding-system))
1239     (with-temp-buffer
1240       (insert (format ";; -*- coding: %s -*-\n"
1241                       char-db-file-coding-system))
1242       (insert-char-range-data min max script excluded-script)
1243       (write-region (point-min)(point-max) file))))
1244
1245 (defvar what-character-original-window-configuration)
1246
1247 ;;;###autoload
1248 (defun what-char-definition (char)
1249   (interactive (list (char-after)))
1250   (let ((buf (get-buffer-create "*Character Description*"))
1251         (the-buf (current-buffer))
1252         (win-conf (current-window-configuration)))
1253     (pop-to-buffer buf)
1254     (make-local-variable 'what-character-original-window-configuration)
1255     (setq what-character-original-window-configuration win-conf)
1256     (setq buffer-read-only nil)
1257     (erase-buffer)
1258     (condition-case err
1259         (progn
1260           (insert-char-data-with-variant char 'printable)
1261           (unless (char-attribute-alist char)
1262             (insert (format ";; = %c\n"
1263                             (let* ((rest (split-char char))
1264                                    (ccs (pop rest))
1265                                    (code (pop rest)))
1266                               (while rest
1267                                 (setq code (logior (lsh code 8)
1268                                                    (pop rest))))
1269                               (decode-char ccs code)))))
1270           ;; (char-db-update-comment)
1271           (set-buffer-modified-p nil)
1272           (view-mode the-buf (lambda (buf)
1273                                (set-window-configuration
1274                                 what-character-original-window-configuration)
1275                                ))
1276           (goto-char (point-min)))
1277       (error (progn
1278                (set-window-configuration
1279                 what-character-original-window-configuration)
1280                (signal (car err) (cdr err)))))))
1281
1282
1283 ;;; @ end
1284 ;;;
1285
1286 (provide 'char-db-util)
1287
1288 ;;; char-db-util.el ends here