view leim/quail/sisheng.el @ 81942:7f057e1b1d19
(kmacro-end-macro): When ignoring empty macro
avoid incorrect kmacro-ring-empty-p messages.
author |
Martin Rudalics <rudalics@gmx.at> |
date |
Wed, 18 Jul 2007 08:46:42 +0000 (2007-07-18) |
parents |
f5f322eb227f |
children |
2904684117d6 |
line source
;;; sisheng.el --- sisheng input method for Chinese pinyin transliteration
;; Copyright (C) 2004, 2005, 2006, 2007 Free Software Foundation, Inc.
;; Author: Werner LEMBERG <wl@gnu.org>
;; Keywords: multilingual, input method, Chinese, pinyin, sisheng
;; This program is free software; you can redistribute it and/or modify
;; it under the terms of the GNU General Public License as published by
;; the Free Software Foundation; either version 2, or (at your option)
;; any later version.
;; This program is distributed in the hope that it will be useful,
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
;; GNU General Public License for more details.
;; You should have received a copy of the GNU General Public License
;; along with GNU Emacs; see the file COPYING. If not, write to
;; the Free Software Foundation, 51 Franklin Street, Fifth Floor,
;; Boston, MA 02110-1301, USA.
;;; Commentary:
;;; Code:
(require 'quail)
(defconst sisheng-regexp
"[��朝�笛�]\\|端�")
;; First element is the key,
;; second element is the vowel used for the input sequence,
;; last four elements are the resulting tones.
;;
(defconst sisheng-vowel-table
'(("�" "a" "�" "叩" "�" "�")
("�" "e" "�" "辿" "�" "竪")
("朝" "i" "朝" "鱈" "�" "狸")
("�" "o" "�" "坦" "�" "嘆")
("笛" "u" "笛" "炭" "�" "湛")
("�" "v" "�" "�" "�" "�")
("端�" "ve" "端�" "端辿" "端�" "端竪")))
;; All possible syllables in Mandarin Chinese, presented in the first
;; tone. Note that make-sisheng-rules always constructs rules for all
;; four tones even if some of those tones aren't used in Mandarin.
;;
(defconst sisheng-syllable-table
'("�" "�i" "�n" "�ng" "�o"
"b�" "b�i" "b�n" "b�ng" "b�o"
"b�i" "b�n" "b�ng"
"b朝" "bi�n" "bi�o" "bi�" "b朝n" "b朝ng"
"b�"
"b笛"
"c�" "c�i" "c�n" "c�ng" "c�o"
"c�" "c�n" "c�ng"
"c朝"
"c�ng" "c�u"
"c笛" "cu�n" "cu朝" "c笛n" "cu�"
"ch�" "ch�i" "ch�n" "ch�ng" "ch�o"
"ch�" "ch�n" "ch�ng"
"ch朝"
"ch�ng" "ch�u"
"ch笛" "chu�" "chu�i" "chu�n" "chu�ng" "chu朝" "ch笛n" "chu�"
"d�" "d�i" "d�n" "d�ng" "d�o"
"d�" "d�i" "d�n" "d�ng"
"d朝" "di�n" "di�o" "di�" "d朝ng" "di笛"
"d�ng" "d�u"
"d笛" "du�n" "du朝" "d笛n" "du�"
"�" "�i" "�n" "�ng" "�r"
"f�" "f�n" "f�ng"
"f�i" "f�n" "f�ng"
"fi�o"
"f�" "f�u"
"f笛"
"g�" "g�i" "g�n" "g�ng" "g�o"
"g�" "g�i" "g�n" "g�ng"
"g�ng" "g�u"
"g笛" "gu�" "gu�i" "gu�n" "gu�ng" "gu朝" "g笛n" "gu�"
"h�" "h�i" "h�n" "h�ng" "h�o"
"h�" "h�i" "h�n" "h�ng"
"h�ng" "h�u"
"h笛" "hu�" "hu�i" "hu�n" "hu�ng" "hu朝" "h笛n" "hu�"
"j朝" "ji�" "ji�n" "ji�ng" "ji�o" "ji�" "j朝n" "j朝ng" "ji�ng" "ji笛"
"j笛" "ju�n" "ju�" "j笛n"
"k�" "k�i" "k�n" "k�ng" "k�o"
"k�" "k�i" "k�n" "k�ng"
"k�ng" "k�u"
"k笛" "ku�" "ku�i" "ku�n" "ku�ng" "ku朝" "k笛n" "ku�"
"l�" "l�i" "l�n" "l�ng" "l�o"
"l�" "l�i" "l�ng"
"l朝" "li�" "li�n" "li�ng" "li�o" "li�" "l朝n" "l朝ng" "li笛"
"l�ng" "l�u"
"l笛" "lu�n" "l笛n" "lu�"
"l�" "l端�"
"m�" "m�i" "m�n" "m�ng" "m�o"
"m�" "m�i" "m�n" "m�ng"
"m朝" "mi�n" "mi�o" "mi�" "m朝n" "m朝ng" "mi笛"
"m�" "m�u"
"m笛"
"n�" "n�i" "n�n" "n�ng" "n�o"
"n�" "n�i" "n�n" "n�ng"
"n朝" "ni�n" "ni�ng" "ni�o" "ni�" "n朝n" "n朝ng" "ni笛"
"n�ng" "n�u"
"n笛" "nu�n" "nu�"
"n�" "n端�"
"�" "�u"
"p�" "p�i" "p�n" "p�ng" "p�o"
"p�i" "p�n" "p�ng"
"p朝" "pi�n" "pi�o" "pi�" "p朝n" "p朝ng"
"p�" "p�u"
"p笛"
"q朝" "qi�" "qi�n" "qi�ng" "qi�o" "qi�" "q朝n" "q朝ng" "qi�ng" "qi笛"
"q笛" "qu�n" "qu�" "q笛n"
"r�n" "r�ng" "r�o"
"r�" "r�n" "r�ng"
"r朝"
"r�ng" "r�u"
"r笛" "ru�" "ru�n" "ru朝" "r笛n" "ru�"
"s�" "s�i" "s�n" "s�ng" "s�o"
"s�" "s�n" "s�ng"
"s朝"
"s�ng" "s�u"
"s笛" "su�n" "su朝" "s笛n" "su�"
"sh�" "sh�i" "sh�n" "sh�ng" "sh�o"
"sh�" "sh�i" "sh�n" "sh�ng"
"sh朝"
"sh�u"
"sh笛" "shu�" "shu�i" "shu�n" "shu�ng" "shu朝" "sh笛n" "shu�"
"t�" "t�i" "t�n" "t�ng" "t�o"
"t�" "t�i" "t�ng"
"t朝" "ti�n" "ti�o" "ti�" "t朝ng"
"t�ng" "t�u"
"t笛" "tu�n" "tu朝" "t笛n" "tu�"
"w�" "w�i" "w�n" "w�ng"
"w�i" "w�n" "w�ng"
"w�"
"w笛"
"x朝" "xi�" "xi�n" "xi�ng" "xi�o" "xi�" "x朝n" "x朝ng" "xi�ng" "xi笛"
"x笛" "xu�n" "xu�" "x笛n"
"y�" "y�n" "y�ng" "y�o"
"y�"
"y朝" "y朝n" "y朝ng"
"y�" "y�ng" "y�u"
"y笛" "yu�n" "yu�" "y笛n"
"z�" "z�i" "z�n" "z�ng" "z�o"
"z�" "z�i" "z�n" "z�ng"
"z朝"
"z�ng" "z�u"
"z笛" "zu�n" "zu朝" "z笛n" "zu�"
"zh�" "zh�i" "zh�n" "zh�ng" "zh�o"
"zh�" "zh�i" "zh�n" "zh�ng"
"zh朝"
"zh�ng" "zh�u"
"zh笛" "zhu�" "zhu�i" "zhu�n" "zhu�ng" "zhu朝" "zh笛n" "zhu�"))
;; This function converts e.g.
;;
;; "zhu�"
;;
;; into
;;
;; (("zhuo4" ["zhu嘆"])
;; ("zhuo3" ["zhu�"])
;; ("zhuo2" ["zhu坦"])
;; ("zhuo1" ["zhu�"]))
;;
(defun quail-make-sisheng-rules (syllable)
(let ((case-fold-search t)
vowel-match
vowel-list
input-vowel
base-key
key
value
key-value-list
(i 1))
(string-match sisheng-regexp syllable)
(setq vowel-match (downcase (match-string 0 syllable)))
(setq vowel-list
(cdr (assoc-string vowel-match sisheng-vowel-table)))
(setq input-vowel (car vowel-list))
(setq base-key (replace-match input-vowel nil nil syllable))
(while (<= i 4)
(setq key (concat base-key (number-to-string i)))
(setq value (vector (replace-match (nth i vowel-list) nil nil syllable)))
(push (list key value) key-value-list)
(setq i (1+ i)))
key-value-list))
;; Set up sisheng input method.
;;
(quail-define-package
"chinese-sisheng" ; name
"Chinese" ; language
"�" ; title
t ; guidance
"S狸sh�ng input method for p朝ny朝n transliteration of Chinese.
Examples: shuang1 -> shu�ng
Lv3 -> L�
AN4 -> �N
Use the fifth (unstressed) tone for syllables containing `端'
without a tone mark.
Example: nve5 -> n端e
" ; docstring
nil ; translation-keys
t ; forget-last-selection
nil ; deterministic
nil ; kbd-translate
nil ; show-layout
nil ; create-decode-map
nil ; maximum-shortest
nil ; overlay-plist
nil ; update-translation-function
nil ; conversion-keys
t ; simple
)
;; Call quail-make-sisheng-rules for all syllables in sisheng-syllable-table.
;;
(let ((case-table-save (current-case-table))
sisheng-list)
(set-case-table (standard-case-table))
(dolist (syllable sisheng-syllable-table)
(setq sisheng-list
(append (quail-make-sisheng-rules syllable)
sisheng-list)))
(dolist (syllable sisheng-syllable-table)
(setq sisheng-list
(append (quail-make-sisheng-rules (upcase-initials syllable))
sisheng-list)))
(dolist (syllable sisheng-syllable-table)
(setq sisheng-list
(append (quail-make-sisheng-rules (upcase syllable))
sisheng-list)))
(eval `(quail-define-rules
,@sisheng-list
("lv5" ["l端"])
("lve5" ["l端e"])
("nv5" ["n端"])
("nve5" ["n端e"])
("Lv5" ["L端"])
("Lve5" ["L端e"])
("Nv5" ["N端"])
("Nve5" ["N端e"])
("LV5" ["L�"])
("LVE5" ["L�E"])
("NV5" ["N�"])
("NVE5" ["N�E"])))
(set-case-table case-table-save))
;; Local Variables:
;; coding: utf-8
;; End:
;;; arch-tag: 1fa6ba5f-6747-44bc-bf12-30628ad3e8ad