annotate lisp/international/robin.el @ 94396:25042b253c8f

*** empty log message ***
author Michael Albinus <michael.albinus@gmx.de>
date Sun, 27 Apr 2008 09:30:36 +0000
parents 3053d89875bb
children 889bc336b89b
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
90124
440c632022e0 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
1 ;;; robin.el --- yet another input method (smaller than quail)
440c632022e0 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
2
91435
3053d89875bb Update copyright years and GPL version.
Glenn Morris <rgm@gnu.org>
parents: 90279
diff changeset
3 ;; Copyright (C) 2003, 2004, 2005, 2006, 2007, 2008
90124
440c632022e0 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
4 ;; National Institute of Advanced Industrial Science and Technology (AIST)
90279
ede12d80b3a5 Copyright fixed.
Kenichi Handa <handa@m17n.org>
parents: 90220
diff changeset
5 ;; Registration Number: H15PRO110
90124
440c632022e0 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
6
440c632022e0 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
7 ;; Author: TAKAHASHI Naoto <ntakahas@m17n.org>
440c632022e0 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
8 ;; Keywords: mule, multilingual, input method
440c632022e0 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
9
91435
3053d89875bb Update copyright years and GPL version.
Glenn Morris <rgm@gnu.org>
parents: 90279
diff changeset
10 ;; This file is part of GNU Emacs.
3053d89875bb Update copyright years and GPL version.
Glenn Morris <rgm@gnu.org>
parents: 90279
diff changeset
11
3053d89875bb Update copyright years and GPL version.
Glenn Morris <rgm@gnu.org>
parents: 90279
diff changeset
12 ;; GNU Emacs is free software; you can redistribute it and/or
90124
440c632022e0 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
13 ;; modify it under the terms of the GNU General Public License as
91435
3053d89875bb Update copyright years and GPL version.
Glenn Morris <rgm@gnu.org>
parents: 90279
diff changeset
14 ;; published by the Free Software Foundation; either version 3, or (at
90124
440c632022e0 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
15 ;; your option) any later version.
440c632022e0 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
16
440c632022e0 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
17 ;; This program is distributed in the hope that it will be useful, but
440c632022e0 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
18 ;; WITHOUT ANY WARRANTY; without even the implied warranty of
440c632022e0 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
19 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
440c632022e0 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
20 ;; General Public License for more details.
440c632022e0 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
21
440c632022e0 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
22 ;; You should have received a copy of the GNU General Public License
91435
3053d89875bb Update copyright years and GPL version.
Glenn Morris <rgm@gnu.org>
parents: 90279
diff changeset
23 ;; along with GNU Emacs; see the file COPYING. If not, write to the
3053d89875bb Update copyright years and GPL version.
Glenn Morris <rgm@gnu.org>
parents: 90279
diff changeset
24 ;; Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
3053d89875bb Update copyright years and GPL version.
Glenn Morris <rgm@gnu.org>
parents: 90279
diff changeset
25 ;; Boston, MA 02110-1301, USA.
90124
440c632022e0 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
26
440c632022e0 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
27 ;;; Comentary:
440c632022e0 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
28
440c632022e0 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
29 ;; Functionalities
440c632022e0 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
30 ;; ---------------
440c632022e0 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
31
440c632022e0 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
32 ;; Robin is a new input method for GNU Emacs. It has three
440c632022e0 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
33 ;; functionalities:
440c632022e0 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
34
440c632022e0 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
35 ;; 1. It serves as a simple input method. When the user types an ASCII
440c632022e0 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
36 ;; key sequence, robin converts it into a string. This functionality
440c632022e0 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
37 ;; is most likely used to input non-ASCII characters.
440c632022e0 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
38
440c632022e0 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
39 ;; 2. It converts existing buffer substring into another string.
440c632022e0 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
40 ;; This functionality is similar to the 1. above, but the input is
440c632022e0 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
41 ;; buffer substring rather than key strokes.
440c632022e0 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
42
440c632022e0 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
43 ;; 3. It offers reverse conversion. Each character produced by a
440c632022e0 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
44 ;; robin rule can hold the original ASCII sequence as a
440c632022e0 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
45 ;; char-code-property.
440c632022e0 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
46
440c632022e0 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
47
440c632022e0 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
48 ;; How to define conversion rules
440c632022e0 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
49 ;; ------------------------------
440c632022e0 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
50
440c632022e0 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
51 ;; Each conversion rule belongs to a robin package. A robin package is
440c632022e0 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
52 ;; identified by a string called package name. Use robin-define-package
440c632022e0 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
53 ;; to define a robin package.
440c632022e0 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
54
440c632022e0 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
55 ;; (robin-define-package NAME DOCTSTRING
440c632022e0 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
56 ;; (INPUT1 OUPUT1)
440c632022e0 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
57 ;; (INPUT2 OUPUT2)
440c632022e0 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
58 ;; ...)
440c632022e0 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
59
440c632022e0 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
60 ;; NAME is a string identifying the robin package. It often starts with a
440c632022e0 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
61 ;; language name and followed by a method name. For example,
440c632022e0 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
62 ;; french-postfix, greek-prefix, etc.
440c632022e0 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
63
440c632022e0 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
64 ;; DOCSTRING is a documentation string for the robin method.
440c632022e0 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
65
440c632022e0 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
66 ;; Each INPUTn is a string. It represents a transliteration of the
440c632022e0 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
67 ;; corresponding OUTPUTn.
440c632022e0 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
68
440c632022e0 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
69 ;; Each OUTPUTn is a string or a character that is to be inserted as the
440c632022e0 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
70 ;; result of conversion.
440c632022e0 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
71
440c632022e0 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
72 ;; Neither INPUT* nor OUTPUT* are evaluated. Do not use a variable or a
440c632022e0 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
73 ;; function in those parts. Instead, use a string or character literal
440c632022e0 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
74 ;; directly.
440c632022e0 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
75
440c632022e0 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
76 ;; If multiple rules have the same input pattern but different output
440c632022e0 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
77 ;; patterns, only the latest definition is effective.
440c632022e0 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
78
440c632022e0 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
79
440c632022e0 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
80 ;; Example
440c632022e0 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
81 ;; -------
440c632022e0 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
82
440c632022e0 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
83 ;; (robin-define-package "german-example"
440c632022e0 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
84 ;; "An example for German
440c632022e0 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
85
440c632022e0 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
86 ;; AE -> Ä OE -> Ö UE -> Ü
440c632022e0 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
87 ;; ae -> ä oe -> ö ue -> ü ss -> ß
440c632022e0 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
88
440c632022e0 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
89 ;; Repeat E or S to input itself.
440c632022e0 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
90
440c632022e0 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
91 ;; AEE -> AE OEE -> OE UEE -> UE
440c632022e0 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
92 ;; aee -> ae oee -> oe uee -> ue sss -> ss"
440c632022e0 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
93
440c632022e0 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
94 ;; ("AE" ?Ä)
440c632022e0 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
95 ;; ("OE" ?Ö)
440c632022e0 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
96 ;; ("UE" ?Ü)
440c632022e0 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
97 ;; ("ae" ?ä)
440c632022e0 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
98 ;; ("oe" ?ö)
440c632022e0 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
99 ;; ("ue" ?ü)
440c632022e0 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
100 ;; ("ss" ?ß)
440c632022e0 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
101
440c632022e0 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
102 ;; ("AEE" "AE")
440c632022e0 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
103 ;; ("OEE" "OE")
440c632022e0 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
104 ;; ("UEE" "UE")
440c632022e0 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
105 ;; ("aee" "ae")
440c632022e0 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
106 ;; ("oee" "oe")
440c632022e0 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
107 ;; ("uee" "ue")
440c632022e0 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
108 ;; ("sss" "ss")
440c632022e0 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
109 ;; )
440c632022e0 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
110
440c632022e0 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
111
440c632022e0 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
112 ;; Using robin as an input method
440c632022e0 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
113 ;; ------------------------------
440c632022e0 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
114
440c632022e0 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
115 ;; To use a defined robin package as an input method, register it with
440c632022e0 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
116 ;; the register-input-method function. For example,
440c632022e0 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
117
440c632022e0 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
118 ;; (register-input-method
440c632022e0 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
119 ;; "german-example"
440c632022e0 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
120 ;; "german"
440c632022e0 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
121 ;; 'robin-use-package
440c632022e0 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
122 ;; "de"
440c632022e0 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
123 ;; "An example for German")
440c632022e0 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
124
440c632022e0 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
125 ;; The first argument is the robin package name.
440c632022e0 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
126
440c632022e0 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
127 ;; The second argument is the language environment for which this robin
440c632022e0 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
128 ;; package is used.
440c632022e0 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
129
440c632022e0 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
130 ;; Use the symbol `robin-use-package' as the third argument.
440c632022e0 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
131
440c632022e0 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
132 ;; The fourth argument is the prompt that appears in modeline when this
440c632022e0 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
133 ;; input method is active.
440c632022e0 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
134
440c632022e0 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
135 ;; The fifth argument is a documentation string; it may or may not be
440c632022e0 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
136 ;; identical to the one that you specified in robin-define-package.
440c632022e0 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
137
440c632022e0 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
138 ;; You can activate the robin input method by typing
440c632022e0 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
139
440c632022e0 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
140 ;; C-u C-\ german-example RET
440c632022e0 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
141
440c632022e0 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
142 ;; Just like a quail package, only C-\ suffices for subsequent
440c632022e0 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
143 ;; invocation.
440c632022e0 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
144
440c632022e0 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
145
440c632022e0 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
146 ;; Using robin as a buffer translator
440c632022e0 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
147 ;; ----------------------------------
440c632022e0 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
148
440c632022e0 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
149 ;; To transliterate buffer substring, use the following functions.
440c632022e0 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
150
440c632022e0 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
151 ;; (robin-convert-buffer &optional name)
440c632022e0 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
152
440c632022e0 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
153 ;; Convert the content of current buffer using a robin package.
440c632022e0 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
154
440c632022e0 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
155 ;; NAME, if given, is a string specifying a robin package. If NAME is
440c632022e0 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
156 ;; not given or nil, the value of `robin-current-package-name' is used.
440c632022e0 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
157
440c632022e0 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
158 ;; (robin-convert-region begin end &optional name)
440c632022e0 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
159
440c632022e0 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
160 ;; Convert the region using a robin package.
440c632022e0 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
161
440c632022e0 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
162 ;; NAME, if given, is a string specifying a robin package. If NAME is
440c632022e0 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
163 ;; not given or nil, the value of `robin-current-package-name' is used.
440c632022e0 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
164
440c632022e0 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
165
440c632022e0 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
166 ;; Reverse conversion
440c632022e0 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
167 ;; ------------------
440c632022e0 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
168
440c632022e0 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
169 ;; If the output pattern defined in a robin rule is a character, robin
440c632022e0 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
170 ;; gives to the character a char-code-property whose key is the symbol
440c632022e0 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
171 ;; representation of the robin package name and whose value is the input
440c632022e0 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
172 ;; pattern of that character. For example, with the "german-example"
440c632022e0 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
173 ;; definition above,
440c632022e0 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
174
440c632022e0 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
175 ;; (get-char-code-property ?Ä 'german-example) => "AE"
440c632022e0 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
176
440c632022e0 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
177 ;; etc.
440c632022e0 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
178
440c632022e0 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
179 ;; If you do not want to assign a char-code-property to a character, use
440c632022e0 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
180 ;; a string of length one as the output pattern, e.g.
440c632022e0 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
181
440c632022e0 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
182 ;; (robin-define-package "german-example2"
440c632022e0 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
183 ;; "Another example for German."
440c632022e0 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
184
440c632022e0 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
185 ;; ("AE" "Ä")
440c632022e0 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
186 ;; ("OE" "Ö")
440c632022e0 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
187 ;; ...)
440c632022e0 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
188
440c632022e0 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
189 ;; Then
440c632022e0 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
190
440c632022e0 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
191 ;; (get-char-code-property ?Ä 'german-example2) => nil
440c632022e0 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
192
440c632022e0 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
193 ;; etc.
440c632022e0 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
194
440c632022e0 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
195 ;; If multiple input patterns in a robin package generate the same
440c632022e0 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
196 ;; character, the lastly used input pattern is given as the value of the
440c632022e0 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
197 ;; char-code-property.
440c632022e0 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
198
440c632022e0 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
199 ;; There are two functions for reverse conversion.
440c632022e0 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
200
440c632022e0 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
201 ;; (robin-invert-buffer &optional name)
440c632022e0 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
202
440c632022e0 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
203 ;; Apply reverse conversion to the content of current buffer. NAME, if
440c632022e0 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
204 ;; given, is a string specifying a robin package. If NAME is not given
440c632022e0 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
205 ;; or nil, the value of `robin-current-package-name' is used.
440c632022e0 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
206
440c632022e0 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
207 ;; (robin-invert-region begin end &optional name)
440c632022e0 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
208
440c632022e0 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
209 ;; Apply reverse conversion to the region. NAME, if given, is a string
440c632022e0 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
210 ;; specifying a robin package. If NAME is not given or nil, the value of
440c632022e0 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
211 ;; `robin-current-package-name' is used.
440c632022e0 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
212
440c632022e0 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
213
440c632022e0 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
214 ;; Modifying an existing rule
440c632022e0 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
215 ;; --------------------------
440c632022e0 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
216
440c632022e0 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
217 ;; Use the robin-modify-package function to modify a rule already defined
440c632022e0 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
218 ;; in a Robin package.
440c632022e0 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
219
440c632022e0 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
220 ;; (robin-modify-package name input output)
440c632022e0 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
221
440c632022e0 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
222 ;; Change a rule in an already defined Robin package.
440c632022e0 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
223 ;; NAME is the string specifying a robin package.
440c632022e0 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
224 ;; INPUT is a string that specifies the input pattern.
440c632022e0 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
225 ;; OUTPUT is either a character or a string to be generated.
440c632022e0 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
226
440c632022e0 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
227
440c632022e0 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
228 ;; The name of the game
440c632022e0 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
229 ;; --------------------
440c632022e0 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
230
440c632022e0 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
231 ;; As stated in Murphy's law, it took longer than expected to develop the
440c632022e0 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
232 ;; very first version of Japanese input subsystem in NEmacs (Nihongo
440c632022e0 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
233 ;; Emacs). So the subsystem was named "TAMAGO", which is an acronym of
440c632022e0 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
234 ;; "TAkusan Matasete GOmennasai" (Sorry to have kept you waiting so
440c632022e0 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
235 ;; long). "Tamago" as a Japanese word means "egg", so the word "egg" was
440c632022e0 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
236 ;; also used for related filenames and function names.
440c632022e0 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
237
440c632022e0 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
238 ;; Since it was designed to input CJK characters, Egg was rather big as a
440c632022e0 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
239 ;; subsystem. So later in Mule (Multilingual Enhancement to GNU Emacs),
440c632022e0 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
240 ;; we designed and implemented a smaller input subsystem. We had to give
440c632022e0 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
241 ;; it a name. "So, what's smaller than an egg?" "A quail egg, of
440c632022e0 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
242 ;; course." Therefore it was named "quail".
440c632022e0 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
243
440c632022e0 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
244 ;; As time went by, quail became more and more complicated. That
440c632022e0 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
245 ;; tendency was inevitable as long as we support CJK input. However, if
440c632022e0 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
246 ;; we can limit ourselves to non-CJK characters, a much simpler
440c632022e0 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
247 ;; transliteration mechanism suffices. So I wrote "robin", whose name
440c632022e0 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
248 ;; was chosen because a robin is smaller than a quail. I could name it
440c632022e0 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
249 ;; "hummingbird" or "nightingale", but those spellings seemed too long.
440c632022e0 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
250
440c632022e0 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
251
440c632022e0 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
252 ;;; Code:
440c632022e0 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
253
440c632022e0 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
254 (defvar robin-package-alist nil
440c632022e0 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
255 "List of robin packages.
440c632022e0 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
256 A robin pacakge is of the form (NAME DOCSTRING &rest RULES).
440c632022e0 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
257 NAME is a string specifying a particular robin package.
440c632022e0 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
258 DOCSTRING is a documentation string for the robin package.
440c632022e0 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
259
440c632022e0 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
260 RULE is of the form (KEY OUTPUT &rest rules).
440c632022e0 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
261 KEY is a string.
440c632022e0 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
262 OUTPUT is a character or a string.
440c632022e0 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
263 For example, if you evaluate the following,
440c632022e0 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
264
440c632022e0 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
265 (robin-define-package \"test\" \"Uppercase input characters\"
440c632022e0 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
266 (\"a\" \"A\")
440c632022e0 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
267 (\"ab\" \"AB\")
440c632022e0 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
268 (\"ac\" \"AC\")
440c632022e0 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
269 (\"acd\" \"ACD\")
440c632022e0 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
270 (\"ace\" \"ACE\")
440c632022e0 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
271 (\"b\" \"B\"))
440c632022e0 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
272
440c632022e0 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
273 this robin package will be the following.
440c632022e0 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
274
440c632022e0 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
275 (\"test\" \"Uppercase input characters\"
440c632022e0 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
276 (?a \"A\"
440c632022e0 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
277 (?b \"AB\")
440c632022e0 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
278 (?c \"AC\"
440c632022e0 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
279 (?d \"ACD\")
440c632022e0 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
280 (?e \"ACE\")))
440c632022e0 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
281 (?b \"B\"))
440c632022e0 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
282 ")
440c632022e0 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
283
440c632022e0 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
284 ;;;###autoload
440c632022e0 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
285 (defmacro robin-define-package (name docstring &rest rules)
440c632022e0 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
286 "Define a robin package.
440c632022e0 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
287
440c632022e0 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
288 NAME is the string of this robin package.
440c632022e0 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
289 DOCSTRING is the documentation string of this robin package.
440c632022e0 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
290 Each RULE is of the form (INPUT OUTPUT) where INPUT is a string and
440c632022e0 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
291 OUTPUT is either a character or a string. RULES are not evaluated.
440c632022e0 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
292
440c632022e0 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
293 If there already exists a robin package whose name is NAME, the new
440c632022e0 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
294 one replaces the old one."
440c632022e0 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
295
90206
4857b75944d3 (robin-define-package): Delete redundant
Kenichi Handa <handa@m17n.org>
parents: 90204
diff changeset
296 (let ((iname (intern name))
90124
440c632022e0 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
297 (new (list name "")) ; "" as a fake output
90220
26b71cf7f16d (robin-define-package): Be sure to call put-char-code-property.
Kenichi Handa <handa@m17n.org>
parents: 90206
diff changeset
298 input output pairs)
90124
440c632022e0 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
299 (dolist (r rules)
440c632022e0 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
300 (setq input (car r)
440c632022e0 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
301 output (cadr r))
440c632022e0 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
302 (robin-add-rule name new input output)
440c632022e0 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
303 (cond
440c632022e0 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
304 ((not (stringp input))
440c632022e0 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
305 (error "Bad input sequence %S" r))
90220
26b71cf7f16d (robin-define-package): Be sure to call put-char-code-property.
Kenichi Handa <handa@m17n.org>
parents: 90206
diff changeset
306 ((characterp output)
26b71cf7f16d (robin-define-package): Be sure to call put-char-code-property.
Kenichi Handa <handa@m17n.org>
parents: 90206
diff changeset
307 (setq pairs
26b71cf7f16d (robin-define-package): Be sure to call put-char-code-property.
Kenichi Handa <handa@m17n.org>
parents: 90206
diff changeset
308 (cons (cons input output)
26b71cf7f16d (robin-define-package): Be sure to call put-char-code-property.
Kenichi Handa <handa@m17n.org>
parents: 90206
diff changeset
309 pairs)))
90124
440c632022e0 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
310 ((not (stringp output))
440c632022e0 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
311 (error "Bad output pattern %S" r))))
440c632022e0 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
312 (setcar (cdr new) docstring) ; replace "" above with real docstring
90204
7eec7b87433c (robin-define-package): Make the expaneded form shorter.
Kenichi Handa <handa@m17n.org>
parents: 90126
diff changeset
313 `(let ((slot (assoc ,name robin-package-alist))
90220
26b71cf7f16d (robin-define-package): Be sure to call put-char-code-property.
Kenichi Handa <handa@m17n.org>
parents: 90206
diff changeset
314 (newdef ',new)
26b71cf7f16d (robin-define-package): Be sure to call put-char-code-property.
Kenichi Handa <handa@m17n.org>
parents: 90206
diff changeset
315 (prop ',iname)
26b71cf7f16d (robin-define-package): Be sure to call put-char-code-property.
Kenichi Handa <handa@m17n.org>
parents: 90206
diff changeset
316 (lst ',pairs))
90204
7eec7b87433c (robin-define-package): Make the expaneded form shorter.
Kenichi Handa <handa@m17n.org>
parents: 90126
diff changeset
317 (if slot
7eec7b87433c (robin-define-package): Make the expaneded form shorter.
Kenichi Handa <handa@m17n.org>
parents: 90126
diff changeset
318 (setcdr slot (cdr newdef))
7eec7b87433c (robin-define-package): Make the expaneded form shorter.
Kenichi Handa <handa@m17n.org>
parents: 90126
diff changeset
319 (setq robin-package-alist
90220
26b71cf7f16d (robin-define-package): Be sure to call put-char-code-property.
Kenichi Handa <handa@m17n.org>
parents: 90206
diff changeset
320 (cons newdef robin-package-alist)))
26b71cf7f16d (robin-define-package): Be sure to call put-char-code-property.
Kenichi Handa <handa@m17n.org>
parents: 90206
diff changeset
321 (dolist (l lst)
26b71cf7f16d (robin-define-package): Be sure to call put-char-code-property.
Kenichi Handa <handa@m17n.org>
parents: 90206
diff changeset
322 (put-char-code-property (cdr l) prop (car l))))))
90124
440c632022e0 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
323
440c632022e0 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
324 ;;;###autoload
440c632022e0 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
325 (defun robin-modify-package (name input output)
440c632022e0 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
326 "Change a rule in an already defined robin package.
440c632022e0 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
327
440c632022e0 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
328 NAME is the string specifying a robin package.
440c632022e0 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
329 INPUT is a string that specifies the input pattern.
440c632022e0 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
330 OUTPUT is either a character or a string to be generated."
440c632022e0 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
331
440c632022e0 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
332 (let ((tree (assoc name robin-package-alist))
440c632022e0 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
333 docstring)
440c632022e0 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
334 (if (not tree)
440c632022e0 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
335 (error "No such robin package")
440c632022e0 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
336 (setq docstring (cadr tree))
440c632022e0 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
337 (setcar (cdr tree) "")
440c632022e0 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
338 (robin-add-rule name tree input output)
440c632022e0 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
339 (setcar (cdr tree) docstring)
440c632022e0 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
340 (if (characterp output)
440c632022e0 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
341 (put-char-code-property output (intern name) input))))
440c632022e0 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
342 output)
440c632022e0 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
343
440c632022e0 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
344 (defun robin-add-rule (name tree input output)
440c632022e0 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
345 "Add translation rule (INPUT OUTPUT) to TREE whose name is NAME.
440c632022e0 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
346 Internal use only."
440c632022e0 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
347
440c632022e0 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
348 (let* ((head (aref input 0))
440c632022e0 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
349 (branch (assoc head tree))
440c632022e0 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
350 (sofar (cadr tree)))
440c632022e0 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
351
440c632022e0 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
352 (if (= (length input) 1)
440c632022e0 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
353 (if branch
440c632022e0 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
354
440c632022e0 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
355 ;; A definition already exists for this input.
90206
4857b75944d3 (robin-define-package): Delete redundant
Kenichi Handa <handa@m17n.org>
parents: 90204
diff changeset
356 ;; We do not cancel old char-code-property of OUTPUT
4857b75944d3 (robin-define-package): Delete redundant
Kenichi Handa <handa@m17n.org>
parents: 90204
diff changeset
357 ;; so that n-to-1 reverse conversion is possible.
4857b75944d3 (robin-define-package): Delete redundant
Kenichi Handa <handa@m17n.org>
parents: 90204
diff changeset
358 (setcar (cdr branch) output)
90124
440c632022e0 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
359
440c632022e0 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
360 ;; New definition for this input.
440c632022e0 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
361 (setcdr (last tree) (list (list head output))))
440c632022e0 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
362
440c632022e0 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
363 (unless branch
440c632022e0 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
364 (if (characterp sofar)
440c632022e0 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
365 (setq sofar (char-to-string sofar)))
440c632022e0 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
366 (setq branch
440c632022e0 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
367 (list head
440c632022e0 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
368 (concat sofar
440c632022e0 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
369 (char-to-string head))))
440c632022e0 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
370 (setcdr (last tree) (list branch)))
440c632022e0 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
371
440c632022e0 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
372 (robin-add-rule name branch (substring input 1) output))))
440c632022e0 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
373
440c632022e0 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
374 ;;; Interactive use
440c632022e0 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
375
440c632022e0 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
376 (defvar robin-mode nil
440c632022e0 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
377 "If non-nil, `robin-input-method' is active.")
440c632022e0 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
378 (make-variable-buffer-local 'robin-mode)
440c632022e0 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
379
440c632022e0 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
380 (defvar robin-current-package-name nil
440c632022e0 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
381 "String representing the name of the current robin package.
440c632022e0 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
382 Nil means no packages is selected.")
440c632022e0 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
383 (make-variable-buffer-local 'robin-current-package-name)
440c632022e0 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
384
440c632022e0 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
385 ;;;###autoload
440c632022e0 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
386 (defun robin-use-package (name)
440c632022e0 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
387 "Start using robin package NAME, which is a string."
440c632022e0 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
388
440c632022e0 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
389 (let ((package (assoc name robin-package-alist)))
440c632022e0 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
390 (unless package
440c632022e0 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
391 (error "No such robin package"))
440c632022e0 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
392 (setq robin-current-package-name name)
440c632022e0 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
393 (robin-activate)))
440c632022e0 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
394
440c632022e0 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
395 (defun robin-inactivate ()
440c632022e0 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
396 "Inactivate robin input method."
440c632022e0 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
397
440c632022e0 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
398 (interactive)
440c632022e0 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
399 (robin-activate -1))
440c632022e0 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
400
440c632022e0 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
401 (defun robin-activate (&optional arg)
440c632022e0 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
402 "Activate robin input method.
440c632022e0 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
403
440c632022e0 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
404 With ARG, activate robin input method iff ARG is positive.
440c632022e0 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
405
440c632022e0 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
406 While this input method is active, the variable
440c632022e0 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
407 `input-method-function' is bound to the function `robin-input-method'."
440c632022e0 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
408 (if (and arg
440c632022e0 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
409 (< (prefix-numeric-value arg) 0))
440c632022e0 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
410
440c632022e0 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
411 ;; inactivate robin input method.
440c632022e0 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
412 (unwind-protect
440c632022e0 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
413 (progn
440c632022e0 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
414 (setq robin-mode nil)
440c632022e0 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
415 (setq describe-current-input-method-function nil)
440c632022e0 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
416 (run-hooks 'robin-inactivate-hook))
440c632022e0 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
417 (kill-local-variable 'input-method-function))
440c632022e0 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
418
440c632022e0 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
419 ;; activate robin input method.
440c632022e0 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
420 (setq robin-mode t
440c632022e0 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
421 describe-current-input-method-function 'robin-help
440c632022e0 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
422 inactivate-current-input-method-function 'robin-inactivate)
440c632022e0 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
423 (if (eq (selected-window) (minibuffer-window))
440c632022e0 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
424 (add-hook 'minibuffer-exit-hook 'robin-exit-from-minibuffer))
440c632022e0 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
425 (run-hooks 'input-method-activate-hook
440c632022e0 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
426 'robin-activate-hook)
440c632022e0 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
427 (set (make-local-variable 'input-method-function)
440c632022e0 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
428 'robin-input-method)))
440c632022e0 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
429
440c632022e0 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
430 (defun robin-exit-from-minibuffer ()
440c632022e0 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
431 (inactivate-input-method)
440c632022e0 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
432 (if (<= (minibuffer-depth) 1)
440c632022e0 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
433 (remove-hook 'minibuffer-exit-hook 'robin-exit-from-minibuffer)))
440c632022e0 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
434
440c632022e0 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
435 (defun robin-input-method (key)
440c632022e0 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
436 "Interpret typed key sequence and insert into buffer."
440c632022e0 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
437
440c632022e0 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
438 (if (or buffer-read-only
440c632022e0 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
439 overriding-terminal-local-map
440c632022e0 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
440 overriding-local-map)
440c632022e0 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
441 (list key)
440c632022e0 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
442
440c632022e0 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
443 (let ((echo-keystrokes 0)
440c632022e0 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
444 (input-method-function nil)
440c632022e0 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
445 (start (point))
440c632022e0 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
446 (tree (cddr (assoc robin-current-package-name robin-package-alist)))
440c632022e0 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
447 branch
440c632022e0 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
448 output)
440c632022e0 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
449
440c632022e0 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
450 (while (setq branch (assq key tree))
440c632022e0 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
451 (delete-region start (point))
440c632022e0 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
452 (insert (setq output (cadr branch)))
440c632022e0 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
453 (setq tree (cddr branch))
440c632022e0 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
454 (if tree
440c632022e0 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
455 (setq key (read-event))
440c632022e0 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
456 (setq key nil)))
440c632022e0 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
457
440c632022e0 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
458 (if (null output)
440c632022e0 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
459 ;; body of the `while' above was not executed
440c632022e0 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
460 (list key)
440c632022e0 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
461 (delete-region start (point))
440c632022e0 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
462 (if key
440c632022e0 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
463 (setq unread-command-events (list key)))
440c632022e0 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
464 (if (stringp output)
440c632022e0 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
465 (string-to-list output)
440c632022e0 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
466 (list output))))))
440c632022e0 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
467
440c632022e0 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
468 (defun robin-help ()
440c632022e0 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
469 "Display the docstring of the current robin package."
440c632022e0 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
470
440c632022e0 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
471 (interactive)
440c632022e0 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
472 (let ((buf (get-buffer-create "*Robin Help*"))
440c632022e0 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
473 (doc (cadr (assoc robin-current-package-name robin-package-alist))))
440c632022e0 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
474 (set-buffer buf)
440c632022e0 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
475 (erase-buffer)
440c632022e0 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
476 (insert doc)
440c632022e0 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
477 (goto-char (point-min))
440c632022e0 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
478 (display-buffer buf)))
440c632022e0 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
479
440c632022e0 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
480 ;;; Batch mode
440c632022e0 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
481
440c632022e0 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
482 (defun robin-convert-buffer (&optional name)
440c632022e0 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
483 "Convert the content of current buffer using a robin package.
440c632022e0 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
484 NAME, if given, is a string specifying a robin package. If NAME
440c632022e0 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
485 is not given or nil, the value of `robin-current-package-name' is
440c632022e0 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
486 used."
440c632022e0 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
487
440c632022e0 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
488 (interactive "*")
440c632022e0 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
489 (robin-convert-region (point-min) (point-max) name))
440c632022e0 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
490
440c632022e0 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
491 (defun robin-convert-region (begin end &optional name)
440c632022e0 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
492 "Convert the region using a robin package.
440c632022e0 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
493 NAME, if given, is a string specifying a robin package. If NAME
440c632022e0 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
494 is not given or nil, the value of `robin-current-package-name' is
440c632022e0 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
495 used."
440c632022e0 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
496
440c632022e0 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
497 (interactive "*r")
440c632022e0 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
498 (or name
440c632022e0 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
499 (setq name robin-current-package-name)
440c632022e0 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
500 (error "No robin package specified"))
440c632022e0 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
501
440c632022e0 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
502 (let ((tree (assoc name robin-package-alist)))
440c632022e0 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
503 (unless tree
440c632022e0 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
504 (error "No such robin package"))
440c632022e0 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
505
440c632022e0 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
506 (save-excursion
440c632022e0 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
507 (save-restriction
440c632022e0 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
508 (narrow-to-region begin end)
440c632022e0 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
509 (goto-char (point-min))
440c632022e0 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
510 (while (not (eobp))
440c632022e0 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
511 (robin-convert-region-internal tree))))))
440c632022e0 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
512
440c632022e0 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
513 (defun robin-convert-region-internal (tree)
440c632022e0 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
514 "Apply a robin rule defined in TREE to the current point.
440c632022e0 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
515 Use the longest match method to select a rule."
440c632022e0 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
516
440c632022e0 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
517 (let ((begin (point))
440c632022e0 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
518 end branch)
440c632022e0 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
519 (while (setq branch (assq (following-char) tree))
440c632022e0 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
520 (setq tree branch)
440c632022e0 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
521 (forward-char 1))
440c632022e0 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
522
440c632022e0 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
523 (setq end (point))
440c632022e0 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
524 (if (= begin end)
440c632022e0 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
525 ;; no matching rule found; leave it as it is
440c632022e0 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
526 (forward-char 1)
440c632022e0 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
527 ;; replace the string
440c632022e0 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
528 (goto-char begin)
440c632022e0 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
529 (insert (cadr tree))
440c632022e0 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
530 (delete-char (- end begin)))))
440c632022e0 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
531
440c632022e0 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
532 ;; for backward compatibility
440c632022e0 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
533
440c632022e0 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
534 (fset 'robin-transliterate-region 'robin-convert-region)
440c632022e0 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
535 (fset 'robin-transliterate-buffer 'robin-convert-buffer)
440c632022e0 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
536
440c632022e0 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
537 ;;; Reverse conversion
440c632022e0 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
538
440c632022e0 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
539 (defun robin-invert-buffer (&optional name)
440c632022e0 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
540 "Apply reverse conversion to the content of current buffer.
440c632022e0 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
541 NAME, if given, is a string specifying a robin package. If NAME
440c632022e0 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
542 is not given or nil, the value of `robin-current-package-name' is
440c632022e0 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
543 used."
440c632022e0 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
544
440c632022e0 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
545 (interactive "*")
440c632022e0 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
546 (robin-invert-region (point-min) (point-max) name))
440c632022e0 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
547
440c632022e0 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
548 (defun robin-invert-region (begin end &optional name)
440c632022e0 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
549 "Apply reverse conversion to the region.
440c632022e0 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
550 NAME, if given, is a string specifying a robin package. If NAME
440c632022e0 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
551 is not given or nil, the value of `robin-current-package-name' is
440c632022e0 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
552 used."
440c632022e0 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
553
440c632022e0 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
554 (interactive "*r")
440c632022e0 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
555 (or name
440c632022e0 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
556 (setq name robin-current-package-name)
440c632022e0 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
557 (error "No robin package specified"))
440c632022e0 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
558
440c632022e0 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
559 (setq name (intern name))
440c632022e0 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
560 (let (str)
440c632022e0 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
561 (save-restriction
440c632022e0 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
562 (narrow-to-region begin end)
440c632022e0 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
563 (goto-char (point-min))
440c632022e0 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
564 (while (not (eobp))
440c632022e0 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
565 (if (not (setq str (get-char-code-property (following-char) name)))
440c632022e0 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
566 (forward-char 1)
440c632022e0 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
567 (insert str)
440c632022e0 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
568 (delete-char 1))))))
440c632022e0 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
569
440c632022e0 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
570 (provide 'robin)
440c632022e0 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
571
440c632022e0 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
572 ;;; Local Variables:
440c632022e0 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
573 ;;; coding: utf-8-emacs
440c632022e0 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
574 ;;; End:
440c632022e0 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
575
90126
8ee106ee2dc8 Changes from arch/CVS synchronization
Miles Bader <miles@gnu.org>
parents: 90124
diff changeset
576 ;; arch-tag: ba995140-7436-4a57-b875-747fc340f605
90124
440c632022e0 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
577 ;;; robin.el ends here