Mercurial > emacs
annotate leim/quail/sisheng.el @ 66119:bc2d2dc9f534
(compilation-goto-locus): Display the
compilation buffer first and the source buffer second, in case they're
in overlapping frames. Don't raise the compilation frame if it was the
selected window upon entry. Pass the `other-window' arg to
pop-to-buffer.
author | Stefan Monnier <monnier@iro.umontreal.ca> |
---|---|
date | Sun, 16 Oct 2005 14:12:50 +0000 |
parents | e055d02d8b97 |
children | f3fbe553f034 |
rev | line source |
---|---|
55629 | 1 ;;; sisheng.el --- sisheng input method for Chinese pinyin transliteration |
2 | |
3 ;; Copyright (C) 2004 Free Software Foundation, Inc. | |
4 | |
5 ;; Author: Werner LEMBERG <wl@gnu.org> | |
6 | |
7 ;; Keywords: multilingual, input method, Chinese, pinyin, sisheng | |
8 | |
9 ;; This program is free software; you can redistribute it and/or modify | |
10 ;; it 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 ;; This program is distributed in the hope that it will be useful, | |
15 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of | |
16 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
17 ;; GNU General Public License for more details. | |
18 | |
19 ;; You should have received a copy of the GNU General Public License | |
20 ;; along with GNU Emacs; see the file COPYING. If not, write to | |
64092 | 21 ;; the Free Software Foundation, 51 Franklin Street, Fifth Floor, |
22 ;; Boston, MA 02110-1301, USA. | |
55629 | 23 |
24 ;;; Commentary: | |
25 | |
26 ;;; Code: | |
27 | |
28 (require 'quail) | |
29 | |
30 (defconst sisheng-regexp | |
31 "[āēīōūǖ]\\|üē") | |
32 | |
33 ;; First element is the key, | |
34 ;; second element is the vowel used for the input sequence, | |
35 ;; last four elements are the resulting tones. | |
36 ;; | |
37 (defconst sisheng-vowel-table | |
38 '(("ā" "a" "ā" "á" "ǎ" "à") | |
39 ("ē" "e" "ē" "é" "ě" "è") | |
40 ("ī" "i" "ī" "í" "ǐ" "ì") | |
41 ("ō" "o" "ō" "ó" "ǒ" "ò") | |
42 ("ū" "u" "ū" "ú" "ǔ" "ù") | |
43 ("ǖ" "v" "ǖ" "ǘ" "ǚ" "ǜ") | |
44 ("üē" "ve" "üē" "üé" "üě" "üè"))) | |
45 | |
46 | |
47 ;; All possible syllables in Mandarin Chinese, presented in the first | |
48 ;; tone. Note that make-sisheng-rules always constructs rules for all | |
49 ;; four tones even if some of those tones aren't used in Mandarin. | |
50 ;; | |
51 (defconst sisheng-syllable-table | |
52 '("ā" "āi" "ān" "āng" "āo" | |
53 | |
54 "bā" "bāi" "bān" "bāng" "bāo" | |
55 "bēi" "bēn" "bēng" | |
56 "bī" "biān" "biāo" "biē" "bīn" "bīng" | |
57 "bō" | |
58 "bū" | |
59 | |
60 "cā" "cāi" "cān" "cāng" "cāo" | |
61 "cē" "cēn" "cēng" | |
62 "cī" | |
63 "cōng" "cōu" | |
64 "cū" "cuān" "cuī" "cūn" "cuō" | |
65 | |
66 "chā" "chāi" "chān" "chāng" "chāo" | |
67 "chē" "chēn" "chēng" | |
68 "chī" | |
69 "chōng" "chōu" | |
70 "chū" "chuā" "chuāi" "chuān" "chuāng" "chuī" "chūn" "chuō" | |
71 | |
72 "dā" "dāi" "dān" "dāng" "dāo" | |
73 "dē" "dēi" "dēn" "dēng" | |
74 "dī" "diān" "diāo" "diē" "dīng" "diū" | |
75 "dōng" "dōu" | |
76 "dū" "duān" "duī" "dūn" "duō" | |
77 | |
78 "ē" "ēi" "ēn" "ēng" "ēr" | |
79 | |
80 "fā" "fān" "fāng" | |
81 "fēi" "fēn" "fēng" | |
82 "fiāo" | |
83 "fō" "fōu" | |
84 "fū" | |
85 | |
86 "gā" "gāi" "gān" "gāng" "gāo" | |
87 "gē" "gēi" "gēn" "gēng" | |
88 "gōng" "gōu" | |
89 "gū" "guā" "guāi" "guān" "guāng" "guī" "gūn" "guō" | |
90 | |
91 "hā" "hāi" "hān" "hāng" "hāo" | |
92 "hē" "hēi" "hēn" "hēng" | |
93 "hōng" "hōu" | |
94 "hū" "huā" "huāi" "huān" "huāng" "huī" "hūn" "huō" | |
95 | |
96 "jī" "jiā" "jiān" "jiāng" "jiāo" "jiē" "jīn" "jīng" "jiōng" "jiū" | |
97 "jū" "juān" "juē" "jūn" | |
98 | |
99 "kā" "kāi" "kān" "kāng" "kāo" | |
100 "kē" "kēi" "kēn" "kēng" | |
101 "kōng" "kōu" | |
102 "kū" "kuā" "kuāi" "kuān" "kuāng" "kuī" "kūn" "kuō" | |
103 | |
104 "lā" "lāi" "lān" "lāng" "lāo" | |
105 "lē" "lēi" "lēng" | |
106 "lī" "liā" "liān" "liāng" "liāo" "liē" "līn" "līng" "liū" | |
107 "lōng" "lōu" | |
108 "lū" "luān" "lūn" "luō" | |
109 "lǖ" "lüē" | |
110 | |
111 "mā" "māi" "mān" "māng" "māo" | |
112 "mē" "mēi" "mēn" "mēng" | |
113 "mī" "miān" "miāo" "miē" "mīn" "mīng" "miū" | |
114 "mō" "mōu" | |
115 "mū" | |
116 | |
117 "nā" "nāi" "nān" "nāng" "nāo" | |
118 "nē" "nēi" "nēn" "nēng" | |
119 "nī" "niān" "niāng" "niāo" "niē" "nīn" "nīng" "niū" | |
120 "nōng" "nōu" | |
121 "nū" "nuān" "nuō" | |
122 "nǖ" "nüē" | |
123 | |
124 "ō" "ōu" | |
125 | |
126 "pā" "pāi" "pān" "pāng" "pāo" | |
127 "pēi" "pēn" "pēng" | |
128 "pī" "piān" "piāo" "piē" "pīn" "pīng" | |
129 "pō" "pōu" | |
130 "pū" | |
131 | |
132 "qī" "qiā" "qiān" "qiāng" "qiāo" "qiē" "qīn" "qīng" "qiōng" "qiū" | |
133 "qū" "quān" "quē" "qūn" | |
134 | |
135 "rān" "rāng" "rāo" | |
136 "rē" "rēn" "rēng" | |
137 "rī" | |
138 "rōng" "rōu" | |
139 "rū" "ruā" "ruān" "ruī" "rūn" "ruō" | |
140 | |
141 "sā" "sāi" "sān" "sāng" "sāo" | |
142 "sē" "sēn" "sēng" | |
143 "sī" | |
144 "sōng" "sōu" | |
145 "sū" "suān" "suī" "sūn" "suō" | |
146 | |
147 "shā" "shāi" "shān" "shāng" "shāo" | |
148 "shē" "shēi" "shēn" "shēng" | |
149 "shī" | |
150 "shōu" | |
151 "shū" "shuā" "shuāi" "shuān" "shuāng" "shuī" "shūn" "shuō" | |
152 | |
153 "tā" "tāi" "tān" "tāng" "tāo" | |
154 "tē" "tēi" "tēng" | |
155 "tī" "tiān" "tiāo" "tiē" "tīng" | |
156 "tōng" "tōu" | |
157 "tū" "tuān" "tuī" "tūn" "tuō" | |
158 | |
159 "wā" "wāi" "wān" "wāng" | |
160 "wēi" "wēn" "wēng" | |
161 "wō" | |
162 "wū" | |
163 | |
164 "xī" "xiā" "xiān" "xiāng" "xiāo" "xiē" "xīn" "xīng" "xiōng" "xiū" | |
165 "xū" "xuān" "xuē" "xūn" | |
166 | |
167 "yā" "yān" "yāng" "yāo" | |
168 "yē" | |
169 "yī" "yīn" "yīng" | |
170 "yō" "yōng" "yōu" | |
171 "yū" "yuān" "yuē" "yūn" | |
172 | |
173 "zā" "zāi" "zān" "zāng" "zāo" | |
174 "zē" "zēi" "zēn" "zēng" | |
175 "zī" | |
176 "zōng" "zōu" | |
177 "zū" "zuān" "zuī" "zūn" "zuō" | |
178 | |
179 "zhā" "zhāi" "zhān" "zhāng" "zhāo" | |
180 "zhē" "zhēi" "zhēn" "zhēng" | |
181 "zhī" | |
182 "zhōng" "zhōu" | |
183 "zhū" "zhuā" "zhuāi" "zhuān" "zhuāng" "zhuī" "zhūn" "zhuō")) | |
184 | |
185 ;; This function converts e.g. | |
186 ;; | |
187 ;; "zhuō" | |
188 ;; | |
189 ;; into | |
190 ;; | |
191 ;; (("zhuo4" ["zhuò"]) | |
192 ;; ("zhuo3" ["zhuǒ"]) | |
193 ;; ("zhuo2" ["zhuó"]) | |
194 ;; ("zhuo1" ["zhuō"])) | |
195 ;; | |
196 (defun quail-make-sisheng-rules (syllable) | |
197 (let ((case-fold-search t) | |
198 vowel-match | |
199 vowel-list | |
200 input-vowel | |
201 base-key | |
202 key | |
203 value | |
204 key-value-list | |
205 (i 1)) | |
206 (string-match sisheng-regexp syllable) | |
207 (setq vowel-match (downcase (match-string 0 syllable))) | |
208 (setq vowel-list | |
209 (cdr (assoc-string vowel-match sisheng-vowel-table))) | |
210 (setq input-vowel (car vowel-list)) | |
211 (setq base-key (replace-match input-vowel nil nil syllable)) | |
212 (while (<= i 4) | |
213 (setq key (concat base-key (number-to-string i))) | |
214 (setq value (vector (replace-match (nth i vowel-list) nil nil syllable))) | |
215 (push (list key value) key-value-list) | |
216 (setq i (1+ i))) | |
217 key-value-list)) | |
218 | |
219 ;; Set up sisheng input method. | |
220 ;; | |
221 (quail-define-package | |
222 "chinese-sisheng" ; name | |
223 "Chinese" ; language | |
224 "ǚ" ; title | |
225 t ; guidance | |
226 "Sìshēng input method for pīnyīn transliteration of Chinese. | |
227 | |
228 Examples: shuang1 -> shuāng | |
229 Lv3 -> Lǚ | |
230 AN4 -> ÀN | |
231 | |
232 Use the fifth (unstressed) tone for syllables containing `ü' | |
233 without a tone mark. | |
234 | |
235 Example: nve5 -> nüe | |
236 " ; docstring | |
237 nil ; translation-keys | |
238 t ; forget-last-selection | |
239 nil ; deterministic | |
240 nil ; kbd-translate | |
241 nil ; show-layout | |
242 nil ; create-decode-map | |
243 nil ; maximum-shortest | |
244 nil ; overlay-plist | |
245 nil ; update-translation-function | |
246 nil ; conversion-keys | |
247 t ; simple | |
248 ) | |
249 | |
250 ;; Call quail-make-sisheng-rules for all syllables in sisheng-syllable-table. | |
251 ;; | |
252 (let ((case-table-save (current-case-table)) | |
253 sisheng-list) | |
254 (set-case-table (standard-case-table)) | |
255 (dolist (syllable sisheng-syllable-table) | |
256 (setq sisheng-list | |
257 (append (quail-make-sisheng-rules syllable) | |
258 sisheng-list))) | |
259 | |
260 (dolist (syllable sisheng-syllable-table) | |
261 (setq sisheng-list | |
262 (append (quail-make-sisheng-rules (upcase-initials syllable)) | |
263 sisheng-list))) | |
264 | |
265 (dolist (syllable sisheng-syllable-table) | |
266 (setq sisheng-list | |
267 (append (quail-make-sisheng-rules (upcase syllable)) | |
268 sisheng-list))) | |
269 | |
270 (eval `(quail-define-rules | |
271 ,@sisheng-list | |
272 | |
273 ("lv5" ["lü"]) | |
274 ("lve5" ["lüe"]) | |
275 ("nv5" ["nü"]) | |
276 ("nve5" ["nüe"]) | |
277 | |
278 ("Lv5" ["Lü"]) | |
279 ("Lve5" ["Lüe"]) | |
280 ("Nv5" ["Nü"]) | |
281 ("Nve5" ["Nüe"]) | |
282 | |
283 ("LV5" ["LÜ"]) | |
284 ("LVE5" ["LÜE"]) | |
285 ("NV5" ["NÜ"]) | |
286 ("NVE5" ["NÜE"]))) | |
287 (set-case-table case-table-save)) | |
288 | |
289 ;; Local Variables: | |
290 ;; coding: utf-8 | |
291 ;; End: | |
55631
68f840eae70b
Changes from arch/CVS synchronization
Miles Bader <miles@gnu.org>
parents:
55629
diff
changeset
|
292 |
68f840eae70b
Changes from arch/CVS synchronization
Miles Bader <miles@gnu.org>
parents:
55629
diff
changeset
|
293 ;;; arch-tag: 1fa6ba5f-6747-44bc-bf12-30628ad3e8ad |