comparison lisp/mule/chinese-hooks.el @ 159:3bb7ccffb0c0 r20-3b6

Import from CVS: tag r20-3b6
author cvs
date Mon, 13 Aug 2007 09:41:43 +0200
parents 6608ceec7cf8
children
comparison
equal deleted inserted replaced
158:558dfa75ffb3 159:3bb7ccffb0c0
1 ;;; chinese-hooks.el --- pre-loaded support for Chinese.
2
3 ;; Copyright (C) 1992,93,94,95 Free Software Foundation, Inc.
4 ;; Copyright (C) 1995 Amdahl Corporation.
5 ;; Copyright (C) 1996 Sun Microsystems.
6
7 ;; This file is part of XEmacs.
8
9 ;; XEmacs is free software; you can redistribute it and/or modify it
10 ;; under the terms of the GNU General Public License as published by
11 ;; the Free Software Foundation; either version 2, or (at your option)
12 ;; any later version.
13
14 ;; XEmacs is distributed in the hope that it will be useful, but
15 ;; WITHOUT ANY WARRANTY; without even the implied warranty of
16 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17 ;; General Public License for more details.
18
19 ;; You should have received a copy of the GNU General Public License
20 ;; along with XEmacs; see the file COPYING. If not, write to the
21 ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
22 ;; Boston, MA 02111-1307, USA.
23
24 ;;; Synched up with: Mule 2.3.
25
26 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
27 ;;; CHINESE
28 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
29
30 ;; Syntax of Chinese characters.
31 (modify-syntax-entry 'chinese-gb2312 "w")
32 (loop for row in '(33 34 41)
33 do (modify-syntax-entry `[chinese-gb2312 ,row] "."))
34 ;;(loop for row from 35 to 40
35 ;; do (modify-syntax-entry `[chinese-gb2312 ,row] "w"))
36 ;;(loop for row from 42 to 126
37 ;; do (modify-syntax-entry `[chinese-gb2312 ,row] "w"))
38
39 (modify-syntax-entry 'chinese-cns11643-1 "w")
40 (modify-syntax-entry 'chinese-cns11643-2 "w")
41 (modify-syntax-entry 'chinese-big5-1 "w")
42 (modify-syntax-entry 'chinese-big5-2 "w")
43
44 ;; CNS11643 Plane3 thru Plane7
45 ;; These represent more and more obscure Chinese characters.
46 ;; By the time you get to Plane 7, we're talking about characters
47 ;; that appear once in some ancient manuscript and whose meaning
48 ;; is unknown.
49
50 (flet
51 ((make-chinese-cns11643-charset
52 (name plane final)
53 (make-charset
54 name (concat "Chinese CNS Plane " plane)
55 `(registry
56 ,(concat "CNS11643[.-]\\(.*[.-]\\)?" plane "$")
57 dimension 2
58 chars 94
59 final ,final
60 graphic 0))
61 (modify-syntax-entry name "w")
62 (modify-category-entry name ?t)
63 ))
64 (make-chinese-cns11643-charset 'chinese-cns11643-3 "3" ?I)
65 (make-chinese-cns11643-charset 'chinese-cns11643-4 "4" ?J)
66 (make-chinese-cns11643-charset 'chinese-cns11643-5 "5" ?K)
67 (make-chinese-cns11643-charset 'chinese-cns11643-6 "6" ?L)
68 (make-chinese-cns11643-charset 'chinese-cns11643-7 "7" ?M)
69 )
70
71 ;; PinYin-ZhuYin
72 (make-charset 'sisheng "PinYin-ZhuYin"
73 '(registry "sisheng_cwnn\\|OMRON_UDC_ZH"
74 dimension 1
75 chars 94
76 final ?0
77 graphic 0
78 ))
79
80 (make-coding-system
81 'euc-china 'iso2022
82 "Coding-system of Chinese EUC (Extended Unix Code)."
83 '(charset-g0 ascii
84 charset-g1 chinese-gb2312
85 charset-g2 sisheng
86 charset-g3 t
87 mnemonic "EUC/Zh"
88 ))
89
90 (make-coding-system
91 'hz 'no-conversion
92 "Coding-system of Hz/ZW used for Chinese."
93 '(mnemonic "Hz/ZW"
94 eol-type lf
95 post-read-conversion hz2gb-region
96 pre-write-conversion gb2hz-region))
97
98 (make-coding-system
99 'big5 'big5
100 "Coding-system of BIG5."
101 '(mnemonic "Big5"))
102
103 (copy-coding-system 'big5 'big5-eten)
104
105 ;; If you prefer QUAIL to EGG, please modify below as you wish.
106 ;;(when (and (featurep 'egg) (featurep 'wnn))
107 ;; (setq wnn-server-type 'cserver)
108 ;; (load "its/pinyin")
109 ;; (setq its:*standard-modes*
110 ;; (cons (its:get-mode-map "PinYin") its:*standard-modes*)))
111
112 ;; For QUAIL
113 ;; Please add your own quail package if any.
114
115 ;; For GB character input
116 (add-hook 'quail-package-alist '("py" "quail-py"))
117 (add-hook 'quail-package-alist '("qj" "quail-qj"))
118 (add-hook 'quail-package-alist '("punct" "quail-punct"))
119 (add-hook 'quail-package-alist '("sw" "quail-sw"))
120 (add-hook 'quail-package-alist '("tonepy" "quail-tonepy"))
121 (add-hook 'quail-package-alist '("ccdospy" "quail-ccdospy"))
122 (add-hook 'quail-package-alist '("ctlau" "quail-ctlau"))
123
124 ;; For BIG5 character input
125 ;;(add-hook 'quail-package-alist '("py-b5" "quail-py-b5"))
126 ;;(add-hook 'quail-package-alist '("qj-b5" "quail-qj-b5"))
127 ;;(add-hook 'quail-package-alist '("punct-b5" "quail-punct-b5"))
128 ;;(add-hook 'quail-package-alist '("ctlaub" "quail-ctlaub"))
129 ;;(add-hook 'quail-package-alist '("zozy" "quail-zozy"))
130 ;;(add-hook 'quail-package-alist '("etzy" "quail-etzy"))
131
132 ;; For Big5 handling
133
134 (define-ccl-program ccl-internal-to-big5-1
135 '(((r1 = ((((r0 - #x21) * 94) + r1) - #x21))
136 (r0 = ((r1 / 157) + #xA1))
137 (r1 %= 157)
138 (if (r1 < #x3F) (r1 += #x40) (r1 += #x62))))
139 "CCL program to convert internal Big5 code (level1) to code point of Big5 font.")
140
141 ;; 6280 is the number of characters that got shoved into `chinese-big5-1'.
142 (define-ccl-program ccl-internal-to-big5-2
143 '(((r1 = (((((r0 - #x21) * 94) + r1) - #x21) + 6280))
144 (r0 = ((r1 / 157) + #xA1))
145 (r1 %= 157)
146 (if (r1 < #x3F) (r1 += #x40) (r1 += #x62))))
147 "CCL program to convert internal Big5 code (level2) to code point of Big5 font.")
148
149 (set-charset-ccl-program 'chinese-big5-1 ccl-internal-to-big5-1)
150 (set-charset-ccl-program 'chinese-big5-2 ccl-internal-to-big5-2)
151
152 ;; This isn't used and doesn't work yet because CCL doesn't know
153 ;; how to handle things like 'chinese-big5-1 currently. The
154 ;; original of this program had 152 (the leading byte) in place of
155 ;; chinese-big5-1, etc., but that will never do. No exposing of
156 ;; leading bytes to the Lisp level!
157 ;(define-ccl-program ccl-big5-to-internal
158 ; '(0
159 ; ((if (r0 < #xC9)
160 ; ((r2 = (((r0 - #xA1) * 157) + r1))
161 ; (r0 = chinese-big5-1))
162 ; ((r2 = (((r0 - #xC9) * 157) + r1))
163 ; (r0 = chinese-big5-2)))
164 ; (if (r1 < #x7F) (r2 -= #x40) (r2 -= #x62))
165 ; (r1 = ((r2 / 94) + #x21))
166 ; (r2 = ((r2 % 94) + #x21))
167 ; ))
168 ; "CCL program to convert Big5 code to internal code.")
169
170 (define-language-environment 'chinese
171 "Chinese (includes GB, Big5, and CNS)"
172 (lambda ()
173 (require 'chinese)
174 (set-coding-category-system 'iso-8-2 'euc-china)
175 (set-coding-priority-list '(iso-8-2 big5 iso-8-designate))
176 (set-pathname-coding-system 'euc-china)
177 (set-default-buffer-file-coding-system 'euc-china) ; GB encoding
178 (setq terminal-coding-system 'euc-china)
179 (setq keyboard-coding-system 'euc-china)
180 (add-hook 'comint-exec-hook
181 (lambda ()
182 (let ((proc (get-buffer-process (current-buffer))))
183 (set-process-input-coding-system proc 'euc-china)
184 (set-process-output-coding-system proc 'euc-china))))
185 (set-buffer-file-coding-system-for-read 'automatic-conversion)
186 (set-default-buffer-file-coding-system 'euc-china)
187 (setq keyboard-coding-system 'euc-china)
188 (setq terminal-coding-system 'euc-china)
189 (when (eq 'x (device-type (selected-device)))
190 (x-use-halfwidth-roman-font 'chinese-gb2312 "gb1988"))))
191 ;; (when (featurep 'egg)
192 ;; (setq-default its:*current-map* (its:get-mode-map "PinYin")))
193 ;; (setq-default quail-current-package (assoc "py" quail-package-alist))))
194 ;; ))
195
196 (set-coding-category-system 'big5 'big5)