update.
[chise/ids.git] / install-ids.el
1 ;;; install-ids.el --- installer of IDS files.
2
3 ;;; Code:
4
5 (setq load-ids-simplify nil)
6
7 (defun install-ids-read-file (file simplify soft)
8   (princ "Loading ")
9   (princ file)
10   (princ "...")
11   (ids-read-file file simplify soft)
12   (princ "done.\n"))
13
14
15 ;; (mount-char-attribute-table 'ideographic-products)
16 ;; (map-char-attribute
17 ;;  (lambda (c v)
18 ;;    (remove-char-attribute c 'ideographic-products)
19 ;;    nil)
20 ;;  'ideographic-products)
21
22
23 (install-ids-read-file "IDS-JIS-X0208-1990.txt" load-ids-simplify t)
24
25 (install-ids-read-file "IDS-UCS-Basic.txt" load-ids-simplify t)
26
27 (install-ids-read-file "IDS-UCS-Ext-A.txt" load-ids-simplify t)
28
29 (let ((i 1))
30   (while (<= i 6)
31     (install-ids-read-file (format "IDS-UCS-Ext-B-%d.txt" i)
32                            load-ids-simplify t)
33     (setq i (1+ i))))
34
35 (install-ids-read-file "IDS-UCS-Ext-C.txt" load-ids-simplify t)
36
37 (install-ids-read-file "IDS-UCS-Ext-D.txt" load-ids-simplify t)
38
39 (install-ids-read-file "IDS-UCS-Ext-E.txt" load-ids-simplify t)
40
41 (install-ids-read-file "IDS-UCS-Ext-F.txt" load-ids-simplify t)
42
43 (install-ids-read-file "IDS-UCS-Ext-G.txt" load-ids-simplify t)
44
45 (install-ids-read-file "IDS-UCS-Compat.txt" load-ids-simplify t)
46
47 (let ((i 1))
48   (while (<= i 3)
49     (install-ids-read-file (format "IDS-CNS-%d.txt" i)
50                            load-ids-simplify t)
51     (setq i (1+ i))))
52
53 (let ((i 1))
54   (while (<= i 12)
55     (install-ids-read-file (format "IDS-Daikanwa-%02d.txt" i)
56                            load-ids-simplify t)
57     (setq i (1+ i))))
58
59 (install-ids-read-file "IDS-Daikanwa-dx.txt" load-ids-simplify t)
60
61 (install-ids-read-file "IDS-Daikanwa-ho.txt" load-ids-simplify t)
62
63 (install-ids-read-file "IDS-CBETA.txt" load-ids-simplify t)
64
65 (install-ids-read-file "IDS-CDP.txt" load-ids-simplify t)
66 ;; (let ((i 1))
67 ;;   (while (<= i 12)
68 ;;     (install-ids-read-file (format "IDS-HZK%02d.txt" i)
69 ;;                            load-ids-simplify t)
70 ;;     (setq i (1+ i))))
71
72 (princ "Generating apparent-structure...")
73 (let* ((terminal-coding-system 'utf-8-mcs-er)
74        (feature-dir
75         (expand-file-name
76          "feature"
77          (expand-file-name
78           "character" chise-system-db-directory)))
79        (p-file
80         (expand-file-name "ideographic-products" feature-dir))
81        old-p-file
82        a-str ret)
83   (when (file-exists-p p-file)
84     (setq old-p-file (make-temp-name p-file))
85     (rename-file p-file old-p-file))
86   (ids-update-index 'in-memory)
87
88   (map-char-attribute
89    (lambda (c v)
90      (unless (equal (setq ret (ideographic-structure-compact v)) v)
91        (princ (format "Compact %04X (%c) : %s -> %s\n"
92                       (char-int c)
93                       c
94                       (ideographic-structure-to-ids v)
95                       (ideographic-structure-to-ids ret)))
96        (put-char-attribute c 'ideographic-structure ret)
97        (setq v ret))
98      (unless (setq a-str (get-char-attribute c 'ideographic-structure@apparent))
99        (when (setq a-str (functional-ideographic-structure-to-apparent-structure v))
100          (put-char-attribute c 'ideographic-structure@apparent
101                              (ideographic-structure-compact a-str))))
102      nil)
103    'ideographic-structure)
104
105   (map-char-attribute
106    (lambda (c v)
107      (unless (equal (setq ret (ideographic-structure-compact v)) v)
108        (princ (format "Compact %04X (%c) : [apparent] %s -> %s\n"
109                       (char-int c)
110                       c
111                       (ideographic-structure-to-ids v)
112                       (ideographic-structure-to-ids ret)))
113        (put-char-attribute c 'ideographic-structure@apparent ret)
114        (setq v ret))
115      nil)
116    'ideographic-structure@apparent)
117
118   (map-char-attribute
119    (lambda (c v)
120      (unless (equal (setq ret (ideographic-structure-compact v)) v)
121        (princ (format "Compact %04X (%c) : %s -> %s\n"
122                       (char-int c)
123                       c
124                       (ideographic-structure-to-ids v)
125                       (ideographic-structure-to-ids ret)))
126        (put-char-attribute c 'ideographic-structure ret)
127        (setq v ret))
128      nil)
129    'ideographic-structure)
130   (map-char-attribute
131    (lambda (c v)
132      (unless (equal (setq ret (ideographic-structure-compact v)) v)
133        (princ (format "Compact %04X (%c) : [apparent] %s -> %s\n"
134                       (char-int c)
135                       c
136                       (ideographic-structure-to-ids v)
137                       (ideographic-structure-to-ids ret)))
138        (put-char-attribute c 'ideographic-structure@apparent ret)
139        (setq v ret))
140      nil)
141    'ideographic-structure@apparent)
142   (princ "done.\n")
143
144   (princ "Updating char-feature `ideographic-structure'...")
145   (save-char-attribute-table 'ideographic-structure)
146   (save-char-attribute-table 'ideographic-structure@apparent)
147   (princ "done.\n")
148
149   (princ "Updating char-feature `ideographic-products'...")
150   (ids-update-index)
151   (when old-p-file
152     (delete-file old-p-file)))
153 (princ "done.\n")
154
155 ;;; install-ids.el ends hear