Mercurial > emacs
annotate lisp/international/quail.el @ 19649:b2bf3c43c86a
(get-language-info): Accept a symbol
as the arg LANGUAGE-NAME.
(set-language-info): Likewise.
(set-language-info-alist): Likewise.
(register-input-method): Accept a symbol as the args INPUT-METHOD
and LANGUAGE-NAME.
(activate-input-method): Accept a symbol as the args INPUT-METHOD.
(describe-input-method): Likewise.
(read-multilingual-string): Likewise.
(set-language-environment): Accept a symbol as the arg
LANGUAGE-NAME.
(describe-language-environment): Likewise.
author | Kenichi Handa <handa@m17n.org> |
---|---|
date | Mon, 01 Sep 1997 07:19:38 +0000 |
parents | 9b9af28bee8d |
children | 47d11f4bbc6c |
rev | line source |
---|---|
17315
a3ca5e15c82a
Fix the format of the first line.
Kenichi Handa <handa@m17n.org>
parents:
17174
diff
changeset
|
1 ;;; quail.el --- Provides simple input method for multilingual text |
17052 | 2 |
3 ;; Copyright (C) 1995 Electrotechnical Laboratory, JAPAN. | |
18377
8b4a66c66dd6
Change copyright notice.
Richard M. Stallman <rms@gnu.org>
parents:
18349
diff
changeset
|
4 ;; Licensed to the Free Software Foundation. |
17052 | 5 |
6 ;; Author: Kenichi HANDA <handa@etl.go.jp> | |
7 ;; Naoto TAKAHASHI <ntakahas@etl.go.jp> | |
8 ;; Maintainer: Kenichi HANDA <handa@etl.go.jp> | |
9 ;; Keywords: mule, multilingual, input method | |
10 | |
11 ;; This file is part of GNU Emacs. | |
12 | |
13 ;; GNU Emacs is free software; you can redistribute it and/or modify | |
14 ;; it under the terms of the GNU General Public License as published by | |
15 ;; the Free Software Foundation; either version 2, or (at your option) | |
16 ;; any later version. | |
17 | |
18 ;; GNU Emacs is distributed in the hope that it will be useful, | |
19 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of | |
20 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
21 ;; GNU General Public License for more details. | |
22 | |
23 ;; You should have received a copy of the GNU General Public License | |
17071 | 24 ;; along with GNU Emacs; see the file COPYING. If not, write to the |
25 ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330, | |
26 ;; Boston, MA 02111-1307, USA. | |
17052 | 27 |
28 ;;; Commentary: | |
29 | |
30 ;; In Quail minor mode, you can input multilingual text easily. By | |
31 ;; defining a translation table (named Quail map) which maps ASCII key | |
32 ;; string to multilingual character or string, you can input any text | |
33 ;; from ASCII keyboard. | |
34 ;; | |
35 ;; We use words "translation" and "conversion" differently. The | |
36 ;; former is done by Quail package itself, the latter is the further | |
37 ;; process of converting a translated text to some more desirable | |
38 ;; text. For instance, Quail package for Japanese (`quail-jp') | |
39 ;; translates Roman text (transliteration of Japanese in Latin | |
40 ;; alphabets) to Hiragana text, which is then converted to | |
41 ;; Kanji-and-Kana mixed text or Katakana text by commands specified in | |
42 ;; CONVERSION-KEYS argument of the Quail package. | |
43 | |
44 ;;; Code: | |
45 | |
46 (require 'faces) | |
47 | |
48 ;; Buffer local variables | |
49 | |
50 (defvar quail-current-package nil | |
19391
763bc03e7797
(quail-guidance-buf): Now a permanent local.
Richard M. Stallman <rms@gnu.org>
parents:
19327
diff
changeset
|
51 "The current Quail package, which depends on the current input method. |
17052 | 52 See the documentation of `quail-package-alist' for the format.") |
53 (make-variable-buffer-local 'quail-current-package) | |
54 (put 'quail-current-package 'permanent-local t) | |
55 | |
56 ;; Quail uses the following two buffers to assist users. | |
57 ;; A buffer to show available key sequence or translation list. | |
58 (defvar quail-guidance-buf nil) | |
59 ;; A buffer to show completion list of the current key sequence. | |
60 (defvar quail-completion-buf nil) | |
61 | |
18556
99e8ae18137f
(quail-guidance-buf): Make it buffer
Kenichi Handa <handa@m17n.org>
parents:
18377
diff
changeset
|
62 ;; Each buffer in which Quail is activated should use different |
99e8ae18137f
(quail-guidance-buf): Make it buffer
Kenichi Handa <handa@m17n.org>
parents:
18377
diff
changeset
|
63 ;; guidance buffers. |
99e8ae18137f
(quail-guidance-buf): Make it buffer
Kenichi Handa <handa@m17n.org>
parents:
18377
diff
changeset
|
64 (make-variable-buffer-local 'quail-guidance-buf) |
19391
763bc03e7797
(quail-guidance-buf): Now a permanent local.
Richard M. Stallman <rms@gnu.org>
parents:
19327
diff
changeset
|
65 (put 'quail-guidance-buf 'permanent-local t) |
18556
99e8ae18137f
(quail-guidance-buf): Make it buffer
Kenichi Handa <handa@m17n.org>
parents:
18377
diff
changeset
|
66 |
99e8ae18137f
(quail-guidance-buf): Make it buffer
Kenichi Handa <handa@m17n.org>
parents:
18377
diff
changeset
|
67 ;; A main window showing Quail guidance buffer. |
99e8ae18137f
(quail-guidance-buf): Make it buffer
Kenichi Handa <handa@m17n.org>
parents:
18377
diff
changeset
|
68 (defvar quail-guidance-win nil) |
99e8ae18137f
(quail-guidance-buf): Make it buffer
Kenichi Handa <handa@m17n.org>
parents:
18377
diff
changeset
|
69 (make-variable-buffer-local 'quail-guidance-win) |
99e8ae18137f
(quail-guidance-buf): Make it buffer
Kenichi Handa <handa@m17n.org>
parents:
18377
diff
changeset
|
70 |
17052 | 71 (defvar quail-mode nil |
72 "Non-nil if in Quail minor mode.") | |
73 (make-variable-buffer-local 'quail-mode) | |
74 (put 'quail-mode 'permanent-local t) | |
75 | |
76 (defvar quail-overlay nil | |
77 "Overlay which covers the current translation region of Quail.") | |
78 (make-variable-buffer-local 'quail-overlay) | |
79 | |
80 (defvar quail-conv-overlay nil | |
81 "Overlay which covers the text to be converted in Quail mode.") | |
82 (make-variable-buffer-local 'quail-conv-overlay) | |
83 | |
84 (defvar quail-current-key nil | |
85 "Current key for translation in Quail mode.") | |
86 | |
87 (defvar quail-current-str nil | |
88 "Currently selected translation of the current key.") | |
89 | |
90 (defvar quail-current-translations nil | |
18556
99e8ae18137f
(quail-guidance-buf): Make it buffer
Kenichi Handa <handa@m17n.org>
parents:
18377
diff
changeset
|
91 "Cons of indices and vector of possible translations of the current key. |
99e8ae18137f
(quail-guidance-buf): Make it buffer
Kenichi Handa <handa@m17n.org>
parents:
18377
diff
changeset
|
92 Indices is a list of (CURRENT START END BLOCK BLOCKS), where |
99e8ae18137f
(quail-guidance-buf): Make it buffer
Kenichi Handa <handa@m17n.org>
parents:
18377
diff
changeset
|
93 CURRENT is an index of the current translation, |
99e8ae18137f
(quail-guidance-buf): Make it buffer
Kenichi Handa <handa@m17n.org>
parents:
18377
diff
changeset
|
94 START and END are indices of the start and end of the current block, |
99e8ae18137f
(quail-guidance-buf): Make it buffer
Kenichi Handa <handa@m17n.org>
parents:
18377
diff
changeset
|
95 BLOCK is the current block index, |
99e8ae18137f
(quail-guidance-buf): Make it buffer
Kenichi Handa <handa@m17n.org>
parents:
18377
diff
changeset
|
96 BLOCKS is a number of blocks of translation.") |
17052 | 97 |
18297
5c8e37591da5
(quail-current-data): New variable.
Kenichi Handa <handa@m17n.org>
parents:
18201
diff
changeset
|
98 (defvar quail-current-data nil |
5c8e37591da5
(quail-current-data): New variable.
Kenichi Handa <handa@m17n.org>
parents:
18201
diff
changeset
|
99 "Any Lisp object holding information of current translation status. |
5c8e37591da5
(quail-current-data): New variable.
Kenichi Handa <handa@m17n.org>
parents:
18201
diff
changeset
|
100 When a key sequence is mapped to TRANS and TRANS is a cons |
5c8e37591da5
(quail-current-data): New variable.
Kenichi Handa <handa@m17n.org>
parents:
18201
diff
changeset
|
101 of actual translation and some Lisp object to be refered |
5c8e37591da5
(quail-current-data): New variable.
Kenichi Handa <handa@m17n.org>
parents:
18201
diff
changeset
|
102 for translating the longer key sequence, this variable is set |
5c8e37591da5
(quail-current-data): New variable.
Kenichi Handa <handa@m17n.org>
parents:
18201
diff
changeset
|
103 to that Lisp object.") |
18556
99e8ae18137f
(quail-guidance-buf): Make it buffer
Kenichi Handa <handa@m17n.org>
parents:
18377
diff
changeset
|
104 (make-variable-buffer-local 'quail-current-data) |
18297
5c8e37591da5
(quail-current-data): New variable.
Kenichi Handa <handa@m17n.org>
parents:
18201
diff
changeset
|
105 |
17052 | 106 ;; A flag to control conversion region. Normally nil, but if set to |
107 ;; t, it means we must start the new conversion region if new key to | |
108 ;; be translated is input. | |
109 (defvar quail-reset-conversion-region nil) | |
110 | |
111 ;; Quail package handlers. | |
112 | |
113 (defvar quail-package-alist nil | |
114 "List of Quail packages. | |
115 A Quail package is a list of these elements: | |
116 NAME, TITLE, QUAIL-MAP, GUIDANCE, DOCSTRING, TRANSLATION-KEYS, | |
117 FORGET-LAST-SELECTION, DETERMINISTIC, KBD-TRANSLATE, SHOW-LAYOUT, | |
118 DECODE-MAP, MAXIMUM-SHORTEST, OVERLAY-PLIST, UPDATE-TRANSLATION-FUNCTION, | |
119 CONVERSION-KEYS. | |
120 | |
121 QUAIL-MAP is a data structure to map key strings to translations. For | |
122 the format, see the documentation of `quail-map-p'. | |
123 | |
124 DECODE-MAP is an alist of translations and corresponding keys. | |
125 | |
126 See the documentation of `quail-define-package' for the other elements.") | |
127 | |
128 ;; Return various slots in the current quail-package. | |
129 | |
130 (defsubst quail-name () | |
131 "Return the name of the current Quail package." | |
132 (nth 0 quail-current-package)) | |
133 (defsubst quail-title () | |
134 "Return the title of the current Quail package." | |
135 (nth 1 quail-current-package)) | |
136 (defsubst quail-map () | |
137 "Return the translation map of the current Quail package." | |
138 (nth 2 quail-current-package)) | |
139 (defsubst quail-guidance () | |
140 "Return an object used for `guidance' feature of the current Quail package. | |
141 See also the documentation of `quail-define-package'." | |
142 (nth 3 quail-current-package)) | |
143 (defsubst quail-docstring () | |
144 "Return the documentation string of the current Quail package." | |
145 (nth 4 quail-current-package)) | |
146 (defsubst quail-translation-keymap () | |
147 "Return translation keymap in the current Quail package. | |
148 Translation keymap is a keymap used while translation region is active." | |
149 (nth 5 quail-current-package)) | |
150 (defsubst quail-forget-last-selection () | |
151 "Return `forget-last-selection' flag of the current Quail package. | |
152 See also the documentation of `quail-define-package'." | |
153 (nth 6 quail-current-package)) | |
154 (defsubst quail-deterministic () | |
155 "Return `deterministic' flag of the current Quail package. | |
156 See also the documentation of `quail-define-package'." | |
157 (nth 7 quail-current-package)) | |
158 (defsubst quail-kbd-translate () | |
159 "Return `kbd-translate' flag of the current Quail package. | |
160 See also the documentation of `quail-define-package'." | |
161 (nth 8 quail-current-package)) | |
162 (defsubst quail-show-layout () | |
163 "Return `show-layout' flag of the current Quail package. | |
164 See also the documentation of `quail-define-package'." | |
165 (nth 9 quail-current-package)) | |
166 (defsubst quail-decode-map () | |
167 "Return decode map of the current Quail package. | |
168 It is an alist of translations and corresponding keys." | |
169 (nth 10 quail-current-package)) | |
170 (defsubst quail-maximum-shortest () | |
171 "Return `maximum-shortest' flag of the current Quail package. | |
172 See also the documentation of `quail-define-package'." | |
173 (nth 11 quail-current-package)) | |
174 (defsubst quail-overlay-plist () | |
175 "Return property list of an overly used in the current Quail package." | |
176 (nth 12 quail-current-package)) | |
177 (defsubst quail-update-translation-function () | |
178 "Return a function for updating translation in the current Quail package." | |
179 (nth 13 quail-current-package)) | |
180 (defsubst quail-conversion-keymap () | |
181 "Return conversion keymap in the current Quail package. | |
182 Conversion keymap is a keymap used while conversion region is active | |
183 but translation region is not active." | |
184 (nth 14 quail-current-package)) | |
185 | |
186 (defsubst quail-package (name) | |
187 "Return Quail package named NAME." | |
188 (assoc name quail-package-alist)) | |
189 | |
190 (defun quail-add-package (package) | |
191 "Add Quail package PACKAGE to `quail-package-alist'." | |
192 (let ((pac (quail-package (car package)))) | |
193 (if pac | |
194 (setcdr pac (cdr package)) | |
195 (setq quail-package-alist (cons package quail-package-alist))))) | |
196 | |
197 (defun quail-select-package (name) | |
198 "Select Quail package named NAME as the current Quail package." | |
199 (let ((package (quail-package name))) | |
200 (if (null package) | |
201 (error "No Quail package `%s'" name)) | |
202 (setq quail-current-package package) | |
203 (setq-default quail-current-package package) | |
204 name)) | |
205 | |
206 ;;;###autoload | |
207 (defun quail-use-package (package-name &rest libraries) | |
208 "Start using Quail package PACKAGE-NAME. | |
209 The remaining arguments are libraries to be loaded before using the package." | |
18297
5c8e37591da5
(quail-current-data): New variable.
Kenichi Handa <handa@m17n.org>
parents:
18201
diff
changeset
|
210 (let ((package (quail-package package-name))) |
5c8e37591da5
(quail-current-data): New variable.
Kenichi Handa <handa@m17n.org>
parents:
18201
diff
changeset
|
211 (if (null package) |
5c8e37591da5
(quail-current-data): New variable.
Kenichi Handa <handa@m17n.org>
parents:
18201
diff
changeset
|
212 ;; Perhaps we have not yet loaded necessary libraries. |
5c8e37591da5
(quail-current-data): New variable.
Kenichi Handa <handa@m17n.org>
parents:
18201
diff
changeset
|
213 (while libraries |
5c8e37591da5
(quail-current-data): New variable.
Kenichi Handa <handa@m17n.org>
parents:
18201
diff
changeset
|
214 (if (not (load (car libraries) t)) |
5c8e37591da5
(quail-current-data): New variable.
Kenichi Handa <handa@m17n.org>
parents:
18201
diff
changeset
|
215 (progn |
5c8e37591da5
(quail-current-data): New variable.
Kenichi Handa <handa@m17n.org>
parents:
18201
diff
changeset
|
216 (with-output-to-temp-buffer "*Help*" |
5c8e37591da5
(quail-current-data): New variable.
Kenichi Handa <handa@m17n.org>
parents:
18201
diff
changeset
|
217 (princ "Quail package \"") |
5c8e37591da5
(quail-current-data): New variable.
Kenichi Handa <handa@m17n.org>
parents:
18201
diff
changeset
|
218 (princ package-name) |
5c8e37591da5
(quail-current-data): New variable.
Kenichi Handa <handa@m17n.org>
parents:
18201
diff
changeset
|
219 (princ "\" can't be activated\n because library \"") |
5c8e37591da5
(quail-current-data): New variable.
Kenichi Handa <handa@m17n.org>
parents:
18201
diff
changeset
|
220 (princ (car libraries)) |
5c8e37591da5
(quail-current-data): New variable.
Kenichi Handa <handa@m17n.org>
parents:
18201
diff
changeset
|
221 (princ "\" is not in `load-path'. |
17052 | 222 |
223 The most common case is that you have not yet installed appropriate | |
224 libraries in LEIM (Libraries of Emacs Input Method) which is | |
225 distributed separately from Emacs. | |
226 | |
227 LEIM is available from the same ftp directory as Emacs.")) | |
18297
5c8e37591da5
(quail-current-data): New variable.
Kenichi Handa <handa@m17n.org>
parents:
18201
diff
changeset
|
228 (error "Can't use the Quail package `%s'" package-name)) |
5c8e37591da5
(quail-current-data): New variable.
Kenichi Handa <handa@m17n.org>
parents:
18201
diff
changeset
|
229 (setq libraries (cdr libraries)))))) |
17052 | 230 (quail-select-package package-name) |
231 (setq current-input-method-title (quail-title)) | |
232 (quail-mode 1)) | |
233 | |
234 (defun quail-inactivate () | |
235 "Turn off Quail input method." | |
236 (interactive) | |
19404
8901359ae445
(quail-inactivate): Turn Quail mode off
Kenichi Handa <handa@m17n.org>
parents:
19391
diff
changeset
|
237 (setq overriding-terminal-local-map nil) |
8901359ae445
(quail-inactivate): Turn Quail mode off
Kenichi Handa <handa@m17n.org>
parents:
19391
diff
changeset
|
238 (quail-mode -1)) |
17052 | 239 |
240 (or (assq 'quail-mode minor-mode-alist) | |
241 (setq minor-mode-alist | |
242 (cons '(quail-mode " Quail") minor-mode-alist))) | |
243 | |
244 (defvar quail-mode-map | |
245 (let ((map (make-keymap)) | |
246 (i ? )) | |
247 (while (< i 127) | |
248 (define-key map (char-to-string i) 'quail-start-translation) | |
249 (setq i (1+ i))) | |
19647
9b9af28bee8d
(quail-translation-keymap): Do not bind
Kenichi Handa <handa@m17n.org>
parents:
19619
diff
changeset
|
250 (setq i 128) |
9b9af28bee8d
(quail-translation-keymap): Do not bind
Kenichi Handa <handa@m17n.org>
parents:
19619
diff
changeset
|
251 (while (< i 256) |
9b9af28bee8d
(quail-translation-keymap): Do not bind
Kenichi Handa <handa@m17n.org>
parents:
19619
diff
changeset
|
252 (define-key map (vector i) 'quail-start-translation) |
9b9af28bee8d
(quail-translation-keymap): Do not bind
Kenichi Handa <handa@m17n.org>
parents:
19619
diff
changeset
|
253 (setq i (1+ i))) |
17052 | 254 map) |
255 "Keymap for Quail mode.") | |
256 | |
257 (or (assq 'quail-mode minor-mode-map-alist) | |
258 (setq minor-mode-map-alist | |
259 (cons (cons 'quail-mode quail-mode-map) minor-mode-map-alist))) | |
260 | |
17095
b57415dcc114
Add quail-mode to default value of
Kenichi Handa <handa@m17n.org>
parents:
17071
diff
changeset
|
261 ;; Since some Emacs Lisp programs (e.g. viper.el) make |
b57415dcc114
Add quail-mode to default value of
Kenichi Handa <handa@m17n.org>
parents:
17071
diff
changeset
|
262 ;; minor-mode-map-alist buffer-local, we must be sure to register |
b57415dcc114
Add quail-mode to default value of
Kenichi Handa <handa@m17n.org>
parents:
17071
diff
changeset
|
263 ;; quail-mode-map in default-value of minor-mode-map-alist. |
b57415dcc114
Add quail-mode to default value of
Kenichi Handa <handa@m17n.org>
parents:
17071
diff
changeset
|
264 (if (local-variable-p 'minor-mode-map-alist) |
b57415dcc114
Add quail-mode to default value of
Kenichi Handa <handa@m17n.org>
parents:
17071
diff
changeset
|
265 (let ((map (default-value 'minor-mode-map-alist))) |
b57415dcc114
Add quail-mode to default value of
Kenichi Handa <handa@m17n.org>
parents:
17071
diff
changeset
|
266 (or (assq 'quail-mode map) |
b57415dcc114
Add quail-mode to default value of
Kenichi Handa <handa@m17n.org>
parents:
17071
diff
changeset
|
267 (set-default 'minor-mode-map-alist (cons 'quail-mode map))))) |
b57415dcc114
Add quail-mode to default value of
Kenichi Handa <handa@m17n.org>
parents:
17071
diff
changeset
|
268 |
17052 | 269 (defvar quail-translation-keymap |
270 (let ((map (make-keymap)) | |
271 (i 0)) | |
272 (while (< i ?\ ) | |
273 (define-key map (char-to-string i) 'quail-execute-non-quail-command) | |
274 (setq i (1+ i))) | |
275 (while (< i 127) | |
276 (define-key map (char-to-string i) 'quail-self-insert-command) | |
277 (setq i (1+ i))) | |
19647
9b9af28bee8d
(quail-translation-keymap): Do not bind
Kenichi Handa <handa@m17n.org>
parents:
19619
diff
changeset
|
278 (setq i 128) |
9b9af28bee8d
(quail-translation-keymap): Do not bind
Kenichi Handa <handa@m17n.org>
parents:
19619
diff
changeset
|
279 (while (< i 127) |
9b9af28bee8d
(quail-translation-keymap): Do not bind
Kenichi Handa <handa@m17n.org>
parents:
19619
diff
changeset
|
280 (define-key map (vector i) 'quail-self-insert-command) |
9b9af28bee8d
(quail-translation-keymap): Do not bind
Kenichi Handa <handa@m17n.org>
parents:
19619
diff
changeset
|
281 (setq i (1+ i))) |
17052 | 282 (define-key map "\177" 'quail-delete-last-char) |
283 (define-key map "\C-f" 'quail-next-translation) | |
284 (define-key map "\C-b" 'quail-prev-translation) | |
285 (define-key map "\C-n" 'quail-next-translation-block) | |
286 (define-key map "\C-p" 'quail-prev-translation-block) | |
287 (define-key map "\C-i" 'quail-completion) | |
288 (define-key map "\C-@" 'quail-select-current) | |
289 (define-key map "\C-h" 'quail-translation-help) | |
17174
9c1191812679
(quail-translation-keymap): Add entry for escape key.
Kenichi Handa <handa@m17n.org>
parents:
17095
diff
changeset
|
290 (define-key map "\e" '(keymap (t . quail-execute-non-quail-command))) |
17052 | 291 (define-key map [tab] 'quail-completion) |
292 (define-key map [delete] 'quail-delete-last-char) | |
293 (define-key map [backspace] 'quail-delete-last-char) | |
294 ;; At last, define default key binding. | |
295 (append map '((t . quail-execute-non-quail-command)))) | |
19619
b033d0b34c71
(quail-define-package): New arg SIMPLE.
Richard M. Stallman <rms@gnu.org>
parents:
19605
diff
changeset
|
296 "Keymap used processing translation in complex Quail modes. |
b033d0b34c71
(quail-define-package): New arg SIMPLE.
Richard M. Stallman <rms@gnu.org>
parents:
19605
diff
changeset
|
297 Only a few especially complex input methods use this map; |
b033d0b34c71
(quail-define-package): New arg SIMPLE.
Richard M. Stallman <rms@gnu.org>
parents:
19605
diff
changeset
|
298 most use `quail-simple-translation-keymap' instead. |
b033d0b34c71
(quail-define-package): New arg SIMPLE.
Richard M. Stallman <rms@gnu.org>
parents:
19605
diff
changeset
|
299 This map is activated while translation region is active.") |
b033d0b34c71
(quail-define-package): New arg SIMPLE.
Richard M. Stallman <rms@gnu.org>
parents:
19605
diff
changeset
|
300 |
b033d0b34c71
(quail-define-package): New arg SIMPLE.
Richard M. Stallman <rms@gnu.org>
parents:
19605
diff
changeset
|
301 (defvar quail-simple-translation-keymap |
b033d0b34c71
(quail-define-package): New arg SIMPLE.
Richard M. Stallman <rms@gnu.org>
parents:
19605
diff
changeset
|
302 (let ((map (make-keymap)) |
b033d0b34c71
(quail-define-package): New arg SIMPLE.
Richard M. Stallman <rms@gnu.org>
parents:
19605
diff
changeset
|
303 (i 0)) |
b033d0b34c71
(quail-define-package): New arg SIMPLE.
Richard M. Stallman <rms@gnu.org>
parents:
19605
diff
changeset
|
304 (while (< i ?\ ) |
b033d0b34c71
(quail-define-package): New arg SIMPLE.
Richard M. Stallman <rms@gnu.org>
parents:
19605
diff
changeset
|
305 (define-key map (char-to-string i) 'quail-execute-non-quail-command) |
b033d0b34c71
(quail-define-package): New arg SIMPLE.
Richard M. Stallman <rms@gnu.org>
parents:
19605
diff
changeset
|
306 (setq i (1+ i))) |
b033d0b34c71
(quail-define-package): New arg SIMPLE.
Richard M. Stallman <rms@gnu.org>
parents:
19605
diff
changeset
|
307 (while (< i 127) |
b033d0b34c71
(quail-define-package): New arg SIMPLE.
Richard M. Stallman <rms@gnu.org>
parents:
19605
diff
changeset
|
308 (define-key map (char-to-string i) 'quail-self-insert-command) |
b033d0b34c71
(quail-define-package): New arg SIMPLE.
Richard M. Stallman <rms@gnu.org>
parents:
19605
diff
changeset
|
309 (setq i (1+ i))) |
b033d0b34c71
(quail-define-package): New arg SIMPLE.
Richard M. Stallman <rms@gnu.org>
parents:
19605
diff
changeset
|
310 (define-key map "\177" 'quail-delete-last-char) |
b033d0b34c71
(quail-define-package): New arg SIMPLE.
Richard M. Stallman <rms@gnu.org>
parents:
19605
diff
changeset
|
311 (define-key map "\e" '(keymap (t . quail-execute-non-quail-command))) |
b033d0b34c71
(quail-define-package): New arg SIMPLE.
Richard M. Stallman <rms@gnu.org>
parents:
19605
diff
changeset
|
312 ;; At last, define default key binding. |
b033d0b34c71
(quail-define-package): New arg SIMPLE.
Richard M. Stallman <rms@gnu.org>
parents:
19605
diff
changeset
|
313 (append map '((t . quail-execute-non-quail-command)))) |
b033d0b34c71
(quail-define-package): New arg SIMPLE.
Richard M. Stallman <rms@gnu.org>
parents:
19605
diff
changeset
|
314 "Keymap used while processing translation in simple Quail modes. |
b033d0b34c71
(quail-define-package): New arg SIMPLE.
Richard M. Stallman <rms@gnu.org>
parents:
19605
diff
changeset
|
315 A few especially complex input methods use `quail--translation-keymap' instead. |
17052 | 316 This map is activated while translation region is active.") |
317 | |
318 (defvar quail-conversion-keymap | |
319 (let ((map (make-keymap)) | |
320 (i 0)) | |
321 (while (< i ?\ ) | |
322 (define-key map (char-to-string i) 'quail-execute-non-quail-command) | |
323 (setq i (1+ i))) | |
324 (while (< i 127) | |
325 (define-key map (char-to-string i) | |
326 'quail-start-translation-in-conversion-mode) | |
327 (setq i (1+ i))) | |
19647
9b9af28bee8d
(quail-translation-keymap): Do not bind
Kenichi Handa <handa@m17n.org>
parents:
19619
diff
changeset
|
328 (setq i 128) |
9b9af28bee8d
(quail-translation-keymap): Do not bind
Kenichi Handa <handa@m17n.org>
parents:
19619
diff
changeset
|
329 (while (< i 127) |
9b9af28bee8d
(quail-translation-keymap): Do not bind
Kenichi Handa <handa@m17n.org>
parents:
19619
diff
changeset
|
330 (define-key map (vector i) 'quail-start-translation-in-conversion-mode) |
9b9af28bee8d
(quail-translation-keymap): Do not bind
Kenichi Handa <handa@m17n.org>
parents:
19619
diff
changeset
|
331 (setq i (1+ i))) |
17052 | 332 (define-key map "\C-b" 'quail-conversion-backward-char) |
333 (define-key map "\C-f" 'quail-conversion-forward-char) | |
334 (define-key map "\C-a" 'quail-conversion-beginning-of-region) | |
335 (define-key map "\C-e" 'quail-conversion-end-of-region) | |
336 (define-key map "\C-d" 'quail-conversion-delete-char) | |
337 (define-key map "\C-h" 'quail-conversion-help) | |
17174
9c1191812679
(quail-translation-keymap): Add entry for escape key.
Kenichi Handa <handa@m17n.org>
parents:
17095
diff
changeset
|
338 (define-key map "\e" '(keymap (t . quail-execute-non-quail-command))) |
17052 | 339 (define-key map "\177" 'quail-conversion-backward-delete-char) |
340 (define-key map [delete] 'quail-conversion-backward-delete-char) | |
341 (define-key map [backspace] 'quail-conversion-backward-delete-char) | |
342 ;; At last, define default key binding. | |
343 (append map '((t . quail-execute-non-quail-command)))) | |
344 "Keymap used for processing conversion in Quail mode. | |
345 This map is activated while convesion region is active but translation | |
346 region is not active.") | |
347 | |
18297
5c8e37591da5
(quail-current-data): New variable.
Kenichi Handa <handa@m17n.org>
parents:
18201
diff
changeset
|
348 ;;;###autoload |
17052 | 349 (defun quail-define-package (name language title |
350 &optional guidance docstring translation-keys | |
351 forget-last-selection deterministic | |
352 kbd-translate show-layout create-decode-map | |
353 maximum-shortest overlay-plist | |
354 update-translation-function | |
19619
b033d0b34c71
(quail-define-package): New arg SIMPLE.
Richard M. Stallman <rms@gnu.org>
parents:
19605
diff
changeset
|
355 conversion-keys simple) |
17052 | 356 "Define NAME as a new Quail package for input LANGUAGE. |
357 TITLE is a string to be displayed at mode-line to indicate this package. | |
358 Optional arguments are GUIDANCE, DOCSTRING, TRANLSATION-KEYS, | |
359 FORGET-LAST-SELECTION, DETERMINISTIC, KBD-TRANSLATE, SHOW-LAYOUT, | |
360 CREATE-DECODE-MAP, MAXIMUM-SHORTEST, OVERLAY-PLIST, | |
19619
b033d0b34c71
(quail-define-package): New arg SIMPLE.
Richard M. Stallman <rms@gnu.org>
parents:
19605
diff
changeset
|
361 UPDATE-TRANSLATION-FUNCTION, CONVERSION-KEYS and SIMPLE. |
17052 | 362 |
363 GUIDANCE specifies how a guidance string is shown in echo area. | |
364 If it is t, list of all possible translations for the current key is shown | |
365 with the currently selected translation being highlighted. | |
366 If it is an alist, the element has the form (CHAR . STRING). Each character | |
367 in the current key is searched in the list and the corresponding string is | |
368 shown. | |
369 If it is nil, the current key is shown. | |
370 | |
371 DOCSTRING is the documentation string of this package. | |
372 | |
373 TRANSLATION-KEYS specifies additional key bindings used while translation | |
374 region is active. It is an alist of single key character vs. corresponding | |
375 command to be called. | |
376 | |
377 FORGET-LAST-SELECTION non-nil means a selected translation is not kept | |
378 for the future to translate the same key. If this flag is nil, a | |
379 translation selected for a key is remembered so that it can be the | |
380 first candidate when the same key is entered later. | |
381 | |
382 DETERMINISTIC non-nil means the first candidate of translation is | |
383 selected automatically without allowing users to select another | |
384 translation for a key. In this case, unselected translations are of | |
385 no use for an interactive use of Quail but can be used by some other | |
386 programs. If this flag is non-nil, FORGET-LAST-SELECTION is also set | |
387 to t. | |
388 | |
389 KBD-TRANSLATE non-nil means input characters are translated from a | |
390 user's keyboard layout to the standard keyboard layout. See the | |
391 documentation of `quail-keyboard-layout' and | |
392 `quail-keyboard-layout-standard' for more detail. | |
393 | |
394 SHOW-LAYOUT non-nil means the `quail-help' command should show | |
395 the user's keyboard layout visually with translated characters. | |
396 If KBD-TRANSLATE is set, it is desirable to set also this flag unless | |
397 this package defines no translations for single character keys. | |
398 | |
399 CREATE-DECODE-MAP non-nil means decode map is also created. A decode | |
400 map is an alist of translations and corresponding original keys. | |
401 Although this map is not used by Quail itself, it can be used by some | |
402 other programs. For instance, Vietnamese supporting needs this map to | |
403 convert Vietnamese text to VIQR format which uses only ASCII | |
404 characters to represent Vietnamese characters. | |
405 | |
406 MAXIMUM-SHORTEST non-nil means break key sequence to get maximum | |
407 length of the shortest sequence. When we don't have a translation of | |
408 key \"..ABCD\" but have translations of \"..AB\" and \"CD..\", break | |
409 the key at \"..AB\" and start translation of \"CD..\". Hangul | |
410 packages, for instance, use this facility. If this flag is nil, we | |
411 break the key just at \"..ABC\" and start translation of \"D..\". | |
412 | |
413 OVERLAY-PLIST if non-nil is a property list put on an overlay which | |
414 covers Quail translation region. | |
415 | |
416 UPDATE-TRANSLATION-FUNCTION if non-nil is a function to call to update | |
417 the current translation region accoding to a new translation data. By | |
418 default, a tranlated text or a user's key sequence (if no transltion | |
419 for it) is inserted. | |
420 | |
421 CONVERSION-KEYS specifies additional key bindings used while | |
422 conversion region is active. It is an alist of single key character | |
19619
b033d0b34c71
(quail-define-package): New arg SIMPLE.
Richard M. Stallman <rms@gnu.org>
parents:
19605
diff
changeset
|
423 vs. corresponding command to be called. |
b033d0b34c71
(quail-define-package): New arg SIMPLE.
Richard M. Stallman <rms@gnu.org>
parents:
19605
diff
changeset
|
424 |
b033d0b34c71
(quail-define-package): New arg SIMPLE.
Richard M. Stallman <rms@gnu.org>
parents:
19605
diff
changeset
|
425 If SIMPLE is non-nil, then we do not alter the meanings of |
b033d0b34c71
(quail-define-package): New arg SIMPLE.
Richard M. Stallman <rms@gnu.org>
parents:
19605
diff
changeset
|
426 commands such as C-f, C-b, C-n, C-p and TAB; they are treated as |
b033d0b34c71
(quail-define-package): New arg SIMPLE.
Richard M. Stallman <rms@gnu.org>
parents:
19605
diff
changeset
|
427 non-Quail commands." |
17052 | 428 (let (translation-keymap conversion-keymap) |
429 (if deterministic (setq forget-last-selection t)) | |
430 (if translation-keys | |
19404
8901359ae445
(quail-inactivate): Turn Quail mode off
Kenichi Handa <handa@m17n.org>
parents:
19391
diff
changeset
|
431 (progn |
19619
b033d0b34c71
(quail-define-package): New arg SIMPLE.
Richard M. Stallman <rms@gnu.org>
parents:
19605
diff
changeset
|
432 (setq translation-keymap (copy-keymap |
b033d0b34c71
(quail-define-package): New arg SIMPLE.
Richard M. Stallman <rms@gnu.org>
parents:
19605
diff
changeset
|
433 (if simple quail-simple-translation-keymap |
b033d0b34c71
(quail-define-package): New arg SIMPLE.
Richard M. Stallman <rms@gnu.org>
parents:
19605
diff
changeset
|
434 quail-translation-keymap))) |
19404
8901359ae445
(quail-inactivate): Turn Quail mode off
Kenichi Handa <handa@m17n.org>
parents:
19391
diff
changeset
|
435 (while translation-keys |
8901359ae445
(quail-inactivate): Turn Quail mode off
Kenichi Handa <handa@m17n.org>
parents:
19391
diff
changeset
|
436 (define-key translation-keymap |
8901359ae445
(quail-inactivate): Turn Quail mode off
Kenichi Handa <handa@m17n.org>
parents:
19391
diff
changeset
|
437 (car (car translation-keys)) (cdr (car translation-keys))) |
8901359ae445
(quail-inactivate): Turn Quail mode off
Kenichi Handa <handa@m17n.org>
parents:
19391
diff
changeset
|
438 (setq translation-keys (cdr translation-keys)))) |
19619
b033d0b34c71
(quail-define-package): New arg SIMPLE.
Richard M. Stallman <rms@gnu.org>
parents:
19605
diff
changeset
|
439 (setq translation-keymap |
b033d0b34c71
(quail-define-package): New arg SIMPLE.
Richard M. Stallman <rms@gnu.org>
parents:
19605
diff
changeset
|
440 (if simple quail-simple-translation-keymap |
b033d0b34c71
(quail-define-package): New arg SIMPLE.
Richard M. Stallman <rms@gnu.org>
parents:
19605
diff
changeset
|
441 quail-translation-keymap))) |
19404
8901359ae445
(quail-inactivate): Turn Quail mode off
Kenichi Handa <handa@m17n.org>
parents:
19391
diff
changeset
|
442 (when conversion-keys |
8901359ae445
(quail-inactivate): Turn Quail mode off
Kenichi Handa <handa@m17n.org>
parents:
19391
diff
changeset
|
443 (setq conversion-keymap (copy-keymap quail-conversion-keymap)) |
8901359ae445
(quail-inactivate): Turn Quail mode off
Kenichi Handa <handa@m17n.org>
parents:
19391
diff
changeset
|
444 (while conversion-keys |
8901359ae445
(quail-inactivate): Turn Quail mode off
Kenichi Handa <handa@m17n.org>
parents:
19391
diff
changeset
|
445 (define-key conversion-keymap |
8901359ae445
(quail-inactivate): Turn Quail mode off
Kenichi Handa <handa@m17n.org>
parents:
19391
diff
changeset
|
446 (car (car conversion-keys)) (cdr (car conversion-keys))) |
8901359ae445
(quail-inactivate): Turn Quail mode off
Kenichi Handa <handa@m17n.org>
parents:
19391
diff
changeset
|
447 (setq conversion-keys (cdr conversion-keys)))) |
17052 | 448 (quail-add-package |
449 (list name title (list nil) guidance (or docstring "") | |
450 translation-keymap | |
451 forget-last-selection deterministic kbd-translate show-layout | |
452 (if create-decode-map (list 'decode-map) nil) | |
453 maximum-shortest overlay-plist update-translation-function | |
18297
5c8e37591da5
(quail-current-data): New variable.
Kenichi Handa <handa@m17n.org>
parents:
18201
diff
changeset
|
454 conversion-keymap)) |
18556
99e8ae18137f
(quail-guidance-buf): Make it buffer
Kenichi Handa <handa@m17n.org>
parents:
18377
diff
changeset
|
455 |
99e8ae18137f
(quail-guidance-buf): Make it buffer
Kenichi Handa <handa@m17n.org>
parents:
18377
diff
changeset
|
456 ;; Update input-method-alist. |
99e8ae18137f
(quail-guidance-buf): Make it buffer
Kenichi Handa <handa@m17n.org>
parents:
18377
diff
changeset
|
457 (let ((slot (assoc name input-method-alist)) |
99e8ae18137f
(quail-guidance-buf): Make it buffer
Kenichi Handa <handa@m17n.org>
parents:
18377
diff
changeset
|
458 (val (list language 'quail-use-package title docstring))) |
99e8ae18137f
(quail-guidance-buf): Make it buffer
Kenichi Handa <handa@m17n.org>
parents:
18377
diff
changeset
|
459 (if slot (setcdr slot val) |
99e8ae18137f
(quail-guidance-buf): Make it buffer
Kenichi Handa <handa@m17n.org>
parents:
18377
diff
changeset
|
460 (setq input-method-alist (cons (cons name val) input-method-alist))))) |
99e8ae18137f
(quail-guidance-buf): Make it buffer
Kenichi Handa <handa@m17n.org>
parents:
18377
diff
changeset
|
461 |
17052 | 462 (quail-select-package name)) |
463 | |
464 ;; Quail minor mode handlers. | |
465 | |
466 ;; Setup overlays used in Quail mode. | |
19404
8901359ae445
(quail-inactivate): Turn Quail mode off
Kenichi Handa <handa@m17n.org>
parents:
19391
diff
changeset
|
467 (defun quail-setup-overlays (conversion-mode) |
17052 | 468 (let ((pos (point))) |
469 (if (overlayp quail-overlay) | |
470 (move-overlay quail-overlay pos pos) | |
471 (setq quail-overlay (make-overlay pos pos nil nil t)) | |
19404
8901359ae445
(quail-inactivate): Turn Quail mode off
Kenichi Handa <handa@m17n.org>
parents:
19391
diff
changeset
|
472 (if input-method-highlight-flag |
8901359ae445
(quail-inactivate): Turn Quail mode off
Kenichi Handa <handa@m17n.org>
parents:
19391
diff
changeset
|
473 (overlay-put quail-overlay 'face 'underline)) |
17052 | 474 (let ((l (quail-overlay-plist))) |
475 (while l | |
476 (overlay-put quail-overlay (car l) (car (cdr l))) | |
477 (setq l (cdr (cdr l)))))) | |
19404
8901359ae445
(quail-inactivate): Turn Quail mode off
Kenichi Handa <handa@m17n.org>
parents:
19391
diff
changeset
|
478 (if conversion-mode |
8901359ae445
(quail-inactivate): Turn Quail mode off
Kenichi Handa <handa@m17n.org>
parents:
19391
diff
changeset
|
479 (if (overlayp quail-conv-overlay) |
8901359ae445
(quail-inactivate): Turn Quail mode off
Kenichi Handa <handa@m17n.org>
parents:
19391
diff
changeset
|
480 (if (not (overlay-start quail-conv-overlay)) |
8901359ae445
(quail-inactivate): Turn Quail mode off
Kenichi Handa <handa@m17n.org>
parents:
19391
diff
changeset
|
481 (move-overlay quail-conv-overlay pos pos)) |
8901359ae445
(quail-inactivate): Turn Quail mode off
Kenichi Handa <handa@m17n.org>
parents:
19391
diff
changeset
|
482 (setq quail-conv-overlay (make-overlay pos pos nil nil t)) |
8901359ae445
(quail-inactivate): Turn Quail mode off
Kenichi Handa <handa@m17n.org>
parents:
19391
diff
changeset
|
483 (if input-method-highlight-flag |
8901359ae445
(quail-inactivate): Turn Quail mode off
Kenichi Handa <handa@m17n.org>
parents:
19391
diff
changeset
|
484 (overlay-put quail-conv-overlay 'face 'underline)))))) |
17052 | 485 |
486 ;; Delete overlays used in Quail mode. | |
487 (defun quail-delete-overlays () | |
488 (if (overlayp quail-overlay) | |
489 (delete-overlay quail-overlay)) | |
490 (if (overlayp quail-conv-overlay) | |
491 (delete-overlay quail-conv-overlay))) | |
492 | |
19432
4492653b04e8
(quail-exit-from-minibuffer): Call
Kenichi Handa <handa@m17n.org>
parents:
19404
diff
changeset
|
493 ;; Kill Quail guidance buffer. Set in kill-buffer-hook. |
4492653b04e8
(quail-exit-from-minibuffer): Call
Kenichi Handa <handa@m17n.org>
parents:
19404
diff
changeset
|
494 (defun quail-kill-guidance-buf () |
4492653b04e8
(quail-exit-from-minibuffer): Call
Kenichi Handa <handa@m17n.org>
parents:
19404
diff
changeset
|
495 (if (buffer-live-p quail-guidance-buf) |
4492653b04e8
(quail-exit-from-minibuffer): Call
Kenichi Handa <handa@m17n.org>
parents:
19404
diff
changeset
|
496 (kill-buffer quail-guidance-buf))) |
4492653b04e8
(quail-exit-from-minibuffer): Call
Kenichi Handa <handa@m17n.org>
parents:
19404
diff
changeset
|
497 |
17052 | 498 (defun quail-mode (&optional arg) |
499 "Toggle Quail minor mode. | |
500 With arg, turn Quail mode on if and only if arg is positive. | |
19432
4492653b04e8
(quail-exit-from-minibuffer): Call
Kenichi Handa <handa@m17n.org>
parents:
19404
diff
changeset
|
501 |
4492653b04e8
(quail-exit-from-minibuffer): Call
Kenichi Handa <handa@m17n.org>
parents:
19404
diff
changeset
|
502 You should not turn on and off Quail mode manually, instead use |
4492653b04e8
(quail-exit-from-minibuffer): Call
Kenichi Handa <handa@m17n.org>
parents:
19404
diff
changeset
|
503 the commands `toggle-input-method' or `select-input-methods' (which |
4492653b04e8
(quail-exit-from-minibuffer): Call
Kenichi Handa <handa@m17n.org>
parents:
19404
diff
changeset
|
504 see). They automatically turn on or off this mode. |
4492653b04e8
(quail-exit-from-minibuffer): Call
Kenichi Handa <handa@m17n.org>
parents:
19404
diff
changeset
|
505 |
4492653b04e8
(quail-exit-from-minibuffer): Call
Kenichi Handa <handa@m17n.org>
parents:
19404
diff
changeset
|
506 Try \\[describe-bindings] in Quail mode to see the available key bindings. |
17052 | 507 The command \\[describe-input-method] describes the current Quail package." |
508 (setq quail-mode | |
509 (if (null arg) (null quail-mode) | |
510 (> (prefix-numeric-value arg) 0))) | |
511 (if (null quail-mode) | |
512 ;; Let's turn off Quail mode. | |
513 (progn | |
514 (quail-hide-guidance-buf) | |
515 (quail-delete-overlays) | |
516 (setq describe-current-input-method-function nil) | |
19404
8901359ae445
(quail-inactivate): Turn Quail mode off
Kenichi Handa <handa@m17n.org>
parents:
19391
diff
changeset
|
517 (run-hooks 'quail-mode-exit-hook)) |
17052 | 518 ;; Let's turn on Quail mode. |
17764
561a8476368f
(use-quail-package): Error message added.
Kenichi Handa <handa@m17n.org>
parents:
17315
diff
changeset
|
519 ;; At first, be sure that quail-mode is at the first element of |
561a8476368f
(use-quail-package): Error message added.
Kenichi Handa <handa@m17n.org>
parents:
17315
diff
changeset
|
520 ;; minor-mode-map-alist. |
561a8476368f
(use-quail-package): Error message added.
Kenichi Handa <handa@m17n.org>
parents:
17315
diff
changeset
|
521 (or (eq (car minor-mode-map-alist) 'quail-mode) |
561a8476368f
(use-quail-package): Error message added.
Kenichi Handa <handa@m17n.org>
parents:
17315
diff
changeset
|
522 (let ((l minor-mode-map-alist)) |
561a8476368f
(use-quail-package): Error message added.
Kenichi Handa <handa@m17n.org>
parents:
17315
diff
changeset
|
523 (while (cdr l) |
561a8476368f
(use-quail-package): Error message added.
Kenichi Handa <handa@m17n.org>
parents:
17315
diff
changeset
|
524 (if (eq (car (cdr l)) 'quail-mode) |
561a8476368f
(use-quail-package): Error message added.
Kenichi Handa <handa@m17n.org>
parents:
17315
diff
changeset
|
525 (progn |
561a8476368f
(use-quail-package): Error message added.
Kenichi Handa <handa@m17n.org>
parents:
17315
diff
changeset
|
526 (setcdr l (cdr (cdr l))) |
561a8476368f
(use-quail-package): Error message added.
Kenichi Handa <handa@m17n.org>
parents:
17315
diff
changeset
|
527 (setq l nil)) |
561a8476368f
(use-quail-package): Error message added.
Kenichi Handa <handa@m17n.org>
parents:
17315
diff
changeset
|
528 (setq l (cdr l)))) |
561a8476368f
(use-quail-package): Error message added.
Kenichi Handa <handa@m17n.org>
parents:
17315
diff
changeset
|
529 (setq minor-mode-map-alist (cons 'quail-mode minor-mode-map-alist)))) |
17052 | 530 (if (null quail-current-package) |
531 ;; Quail package is not yet selected. Select one now. | |
532 (let (name) | |
533 (if quail-package-alist | |
534 (setq name (car (car quail-package-alist))) | |
535 (setq quail-mode nil) | |
536 (error "No Quail package loaded")) | |
537 (quail-select-package name))) | |
19404
8901359ae445
(quail-inactivate): Turn Quail mode off
Kenichi Handa <handa@m17n.org>
parents:
19391
diff
changeset
|
538 (setq inactivate-current-input-method-function 'quail-inactivate) |
17052 | 539 (setq describe-current-input-method-function 'quail-help) |
540 (quail-delete-overlays) | |
541 (quail-show-guidance-buf) | |
19432
4492653b04e8
(quail-exit-from-minibuffer): Call
Kenichi Handa <handa@m17n.org>
parents:
19404
diff
changeset
|
542 ;; If we are in minibuffer, turn off the current input method |
4492653b04e8
(quail-exit-from-minibuffer): Call
Kenichi Handa <handa@m17n.org>
parents:
19404
diff
changeset
|
543 ;; before exiting. |
17052 | 544 (if (eq (selected-window) (minibuffer-window)) |
545 (add-hook 'minibuffer-exit-hook 'quail-exit-from-minibuffer)) | |
546 (make-local-hook 'post-command-hook) | |
19432
4492653b04e8
(quail-exit-from-minibuffer): Call
Kenichi Handa <handa@m17n.org>
parents:
19404
diff
changeset
|
547 (make-local-hook 'kill-buffer-hook) |
4492653b04e8
(quail-exit-from-minibuffer): Call
Kenichi Handa <handa@m17n.org>
parents:
19404
diff
changeset
|
548 (add-hook 'kill-buffer-hook 'quail-kill-guidance-buf nil t) |
19404
8901359ae445
(quail-inactivate): Turn Quail mode off
Kenichi Handa <handa@m17n.org>
parents:
19391
diff
changeset
|
549 (run-hooks 'quail-mode-hook)) |
17052 | 550 (force-mode-line-update)) |
551 | |
552 (defun quail-exit-from-minibuffer () | |
19432
4492653b04e8
(quail-exit-from-minibuffer): Call
Kenichi Handa <handa@m17n.org>
parents:
19404
diff
changeset
|
553 (inactivate-input-method) |
17052 | 554 (if (<= (minibuffer-depth) 1) |
555 (remove-hook 'minibuffer-exit-hook 'quail-exit-from-minibuffer))) | |
556 | |
19404
8901359ae445
(quail-inactivate): Turn Quail mode off
Kenichi Handa <handa@m17n.org>
parents:
19391
diff
changeset
|
557 (defvar quail-saved-current-map nil) |
17052 | 558 (defvar quail-saved-current-buffer nil) |
559 | |
19404
8901359ae445
(quail-inactivate): Turn Quail mode off
Kenichi Handa <handa@m17n.org>
parents:
19391
diff
changeset
|
560 ;; Toggle Quail mode. This function is added to `post-command-hook' |
8901359ae445
(quail-inactivate): Turn Quail mode off
Kenichi Handa <handa@m17n.org>
parents:
19391
diff
changeset
|
561 ;; in Quail mode, to turn Quail mode temporarily off, or back on after |
8901359ae445
(quail-inactivate): Turn Quail mode off
Kenichi Handa <handa@m17n.org>
parents:
19391
diff
changeset
|
562 ;; one non-Quail command. |
17052 | 563 (defun quail-toggle-mode-temporarily () |
564 (if quail-mode | |
565 ;; We are going to handle following events out of Quail mode. | |
19404
8901359ae445
(quail-inactivate): Turn Quail mode off
Kenichi Handa <handa@m17n.org>
parents:
19391
diff
changeset
|
566 (setq quail-saved-current-buffer (current-buffer) |
8901359ae445
(quail-inactivate): Turn Quail mode off
Kenichi Handa <handa@m17n.org>
parents:
19391
diff
changeset
|
567 quail-saved-current-map overriding-terminal-local-map |
8901359ae445
(quail-inactivate): Turn Quail mode off
Kenichi Handa <handa@m17n.org>
parents:
19391
diff
changeset
|
568 quail-mode nil |
8901359ae445
(quail-inactivate): Turn Quail mode off
Kenichi Handa <handa@m17n.org>
parents:
19391
diff
changeset
|
569 overriding-terminal-local-map nil) |
17052 | 570 ;; We have just executed one non-Quail command. We don't need |
571 ;; this hook any more. | |
572 (remove-hook 'post-command-hook 'quail-toggle-mode-temporarily t) | |
19404
8901359ae445
(quail-inactivate): Turn Quail mode off
Kenichi Handa <handa@m17n.org>
parents:
19391
diff
changeset
|
573 (if (eq (current-buffer) quail-saved-current-buffer) |
8901359ae445
(quail-inactivate): Turn Quail mode off
Kenichi Handa <handa@m17n.org>
parents:
19391
diff
changeset
|
574 ;; We should go back to Quail mode only when the current input |
8901359ae445
(quail-inactivate): Turn Quail mode off
Kenichi Handa <handa@m17n.org>
parents:
19391
diff
changeset
|
575 ;; method was not turned off by the last command. |
8901359ae445
(quail-inactivate): Turn Quail mode off
Kenichi Handa <handa@m17n.org>
parents:
19391
diff
changeset
|
576 (when current-input-method |
8901359ae445
(quail-inactivate): Turn Quail mode off
Kenichi Handa <handa@m17n.org>
parents:
19391
diff
changeset
|
577 (setq quail-mode t |
8901359ae445
(quail-inactivate): Turn Quail mode off
Kenichi Handa <handa@m17n.org>
parents:
19391
diff
changeset
|
578 overriding-terminal-local-map quail-saved-current-map) |
8901359ae445
(quail-inactivate): Turn Quail mode off
Kenichi Handa <handa@m17n.org>
parents:
19391
diff
changeset
|
579 (if input-method-exit-on-invalid-key |
8901359ae445
(quail-inactivate): Turn Quail mode off
Kenichi Handa <handa@m17n.org>
parents:
19391
diff
changeset
|
580 (inactivate-input-method))) |
8901359ae445
(quail-inactivate): Turn Quail mode off
Kenichi Handa <handa@m17n.org>
parents:
19391
diff
changeset
|
581 ;; The last command changed the current buffer, we should not go |
8901359ae445
(quail-inactivate): Turn Quail mode off
Kenichi Handa <handa@m17n.org>
parents:
19391
diff
changeset
|
582 ;; back to Quail mode in this new buffer, but should turn on |
8901359ae445
(quail-inactivate): Turn Quail mode off
Kenichi Handa <handa@m17n.org>
parents:
19391
diff
changeset
|
583 ;; Quail mode in the original buffer. |
8901359ae445
(quail-inactivate): Turn Quail mode off
Kenichi Handa <handa@m17n.org>
parents:
19391
diff
changeset
|
584 (save-excursion |
8901359ae445
(quail-inactivate): Turn Quail mode off
Kenichi Handa <handa@m17n.org>
parents:
19391
diff
changeset
|
585 (set-buffer quail-saved-current-buffer) |
8901359ae445
(quail-inactivate): Turn Quail mode off
Kenichi Handa <handa@m17n.org>
parents:
19391
diff
changeset
|
586 (setq quail-mode t) |
8901359ae445
(quail-inactivate): Turn Quail mode off
Kenichi Handa <handa@m17n.org>
parents:
19391
diff
changeset
|
587 (quail-delete-overlays))))) |
17052 | 588 |
589 (defun quail-execute-non-quail-command () | |
19404
8901359ae445
(quail-inactivate): Turn Quail mode off
Kenichi Handa <handa@m17n.org>
parents:
19391
diff
changeset
|
590 "Execute one non-Quail command out of Quail mode. |
17052 | 591 The current translation and conversion are terminated." |
592 (interactive) | |
593 (setq unread-command-events (cons last-input-event unread-command-events)) | |
594 (quail-delete-overlays) | |
19404
8901359ae445
(quail-inactivate): Turn Quail mode off
Kenichi Handa <handa@m17n.org>
parents:
19391
diff
changeset
|
595 (setq overriding-terminal-local-map nil) |
17052 | 596 (if (buffer-live-p quail-guidance-buf) |
597 (save-excursion | |
598 (set-buffer quail-guidance-buf) | |
599 (erase-buffer))) | |
19404
8901359ae445
(quail-inactivate): Turn Quail mode off
Kenichi Handa <handa@m17n.org>
parents:
19391
diff
changeset
|
600 (add-hook 'post-command-hook 'quail-toggle-mode-temporarily nil t)) |
17052 | 601 |
602 ;; Keyboard layout translation handlers. | |
603 | |
604 ;; Some Quail packages provide localized keyboard simulation which | |
605 ;; requires a particular keyboard layout. In this case, what we need | |
606 ;; is locations of keys the user entered, not character codes | |
607 ;; generated by those keys. However, for the moment, there's no | |
608 ;; common way to get such information. So, we ask a user to give | |
609 ;; information of his own keyboard layout, then translate it to the | |
610 ;; standard layout which we defined so that all Quail packages depend | |
611 ;; just on it. | |
612 | |
613 (defconst quail-keyboard-layout-standard | |
614 "\ | |
17174
9c1191812679
(quail-translation-keymap): Add entry for escape key.
Kenichi Handa <handa@m17n.org>
parents:
17095
diff
changeset
|
615 \ |
17052 | 616 1!2@3#4$5%6^7&8*9(0)-_=+`~ \ |
617 qQwWeErRtTyYuUiIoOpP[{]} \ | |
618 aAsSdDfFgGhHjJkKlL;:'\"\\| \ | |
17174
9c1191812679
(quail-translation-keymap): Add entry for escape key.
Kenichi Handa <handa@m17n.org>
parents:
17095
diff
changeset
|
619 zZxXcCvVbBnNmM,<.>/? \ |
9c1191812679
(quail-translation-keymap): Add entry for escape key.
Kenichi Handa <handa@m17n.org>
parents:
17095
diff
changeset
|
620 " |
17052 | 621 "Standard keyboard layout of printable characters Quail assumes. |
622 See the documentation of `quail-keyboard-layout' for this format. | |
623 This layout is almost the same as that of VT100, | |
624 but the location of key \\ (backslash) is just right of key ' (single-quote), | |
625 not right of RETURN key.") | |
626 | |
627 (defvar quail-keyboard-layout quail-keyboard-layout-standard | |
628 "A string which represents physical key layout of a particular keyboard. | |
17174
9c1191812679
(quail-translation-keymap): Add entry for escape key.
Kenichi Handa <handa@m17n.org>
parents:
17095
diff
changeset
|
629 We assume there are six rows and each row has 15 keys (columns), |
9c1191812679
(quail-translation-keymap): Add entry for escape key.
Kenichi Handa <handa@m17n.org>
parents:
17095
diff
changeset
|
630 the first row is above the `1' - `0' row, |
9c1191812679
(quail-translation-keymap): Add entry for escape key.
Kenichi Handa <handa@m17n.org>
parents:
17095
diff
changeset
|
631 the first column of the second row is left of key `1', |
9c1191812679
(quail-translation-keymap): Add entry for escape key.
Kenichi Handa <handa@m17n.org>
parents:
17095
diff
changeset
|
632 the first column of the third row is left of key `q', |
9c1191812679
(quail-translation-keymap): Add entry for escape key.
Kenichi Handa <handa@m17n.org>
parents:
17095
diff
changeset
|
633 the first column of the fourth row is left of key `a', |
9c1191812679
(quail-translation-keymap): Add entry for escape key.
Kenichi Handa <handa@m17n.org>
parents:
17095
diff
changeset
|
634 the first column of the fifth row is left of key `z', |
9c1191812679
(quail-translation-keymap): Add entry for escape key.
Kenichi Handa <handa@m17n.org>
parents:
17095
diff
changeset
|
635 the sixth row is below the `z' - `/' row. |
17052 | 636 Nth (N is even) and (N+1)th characters in the string are non-shifted |
637 and shifted characters respectively at the same location. | |
19391
763bc03e7797
(quail-guidance-buf): Now a permanent local.
Richard M. Stallman <rms@gnu.org>
parents:
19327
diff
changeset
|
638 The location of Nth character is row (N / 30) and column ((N mod 30) / 2). |
763bc03e7797
(quail-guidance-buf): Now a permanent local.
Richard M. Stallman <rms@gnu.org>
parents:
19327
diff
changeset
|
639 The command `quail-set-keyboard-layout' usually sets this variable.") |
17052 | 640 |
17174
9c1191812679
(quail-translation-keymap): Add entry for escape key.
Kenichi Handa <handa@m17n.org>
parents:
17095
diff
changeset
|
641 (defconst quail-keyboard-layout-len 180) |
17052 | 642 |
643 ;; Here we provide several examples of famous keyboard layouts. | |
644 | |
645 (defvar quail-keyboard-layout-alist | |
646 (list | |
647 '("sun-type3" . "\ | |
17174
9c1191812679
(quail-translation-keymap): Add entry for escape key.
Kenichi Handa <handa@m17n.org>
parents:
17095
diff
changeset
|
648 \ |
17052 | 649 1!2@3#4$5%6^7&8*9(0)-_=+\\|`~\ |
650 qQwWeErRtTyYuUiIoOpP[{]} \ | |
651 aAsSdDfFgGhHjJkKlL;:'\" \ | |
17174
9c1191812679
(quail-translation-keymap): Add entry for escape key.
Kenichi Handa <handa@m17n.org>
parents:
17095
diff
changeset
|
652 zZxXcCvVbBnNmM,<.>/? \ |
9c1191812679
(quail-translation-keymap): Add entry for escape key.
Kenichi Handa <handa@m17n.org>
parents:
17095
diff
changeset
|
653 ") |
17052 | 654 (cons "standard" quail-keyboard-layout-standard)) |
655 "Alist of keyboard names and corresponding layout strings. | |
656 See the documentation of `quail-keyboard-layout' for the format of | |
657 the layout string.") | |
658 | |
659 (defun quail-set-keyboard-layout (kbd-type) | |
660 "Set the current keyboard layout to the same as keyboard KBD-TYPE. | |
661 | |
662 Since some Quail packages depends on a physical layout of keys (not | |
663 characters generated by them), those are created by assuming the | |
664 standard layout defined in `quail-keyboard-layout-standard'. This | |
665 function tells Quail system the layout of your keyboard so that what | |
666 you type is correctly handled." | |
667 (interactive | |
668 (let* ((completing-ignore-case t) | |
669 (type (completing-read "Keyboard type: " | |
670 quail-keyboard-layout-alist))) | |
671 (list type))) | |
672 (let ((layout (assoc kbd-type quail-keyboard-layout-alist))) | |
673 (if (null layout) | |
674 ;; Here, we had better ask a user to define his own keyboard | |
675 ;; layout interactively. | |
676 (error "Unknown keyboard type `%s'" kbd-type)) | |
677 (setq quail-keyboard-layout (cdr layout)))) | |
678 | |
679 (defun quail-keyboard-translate (ch) | |
680 "Translate CHAR according to `quail-keyboard-layout' and return the result." | |
681 (if (eq quail-keyboard-layout quail-keyboard-layout-standard) | |
682 ch | |
683 (let ((i 0)) | |
684 (while (and (< i quail-keyboard-layout-len) | |
685 (/= ch (aref quail-keyboard-layout i))) | |
686 (setq i (1+ i))) | |
687 (if (= i quail-keyboard-layout-len) | |
688 (error "Character `%c' not found in your keyboard layout" ch)) | |
689 (aref quail-keyboard-layout-standard i)))) | |
690 | |
691 ;; Quail map | |
692 | |
693 (defsubst quail-map-p (object) | |
694 "Return t if OBJECT is a Quail map. | |
695 | |
696 A Quail map holds information how a particular key should be translated. | |
697 Its format is (TRANSLATION . ALIST). | |
698 TRANSLATION is either a character, or a cons (INDEX . VECTOR). | |
699 In the latter case, each element of VECTOR is a candidate for the translation, | |
700 and INDEX points the currently selected translation. | |
701 | |
702 ALIST is normally a list of elements that look like (CHAR . DEFN), | |
703 where DEFN is another Quail map for a longer key (CHAR added to the | |
704 current key). It may also be a symbol of a function which returns an | |
705 alist of the above format. | |
706 | |
707 Just after a Quail package is read, TRANSLATION may be a string or a | |
708 vector. Then each element of the string or vector is a candidate for | |
709 the translation. These objects are transformed to cons cells in the | |
710 format \(INDEX . VECTOR), as described above." | |
711 (and (consp object) | |
712 (let ((translation (car object))) | |
18297
5c8e37591da5
(quail-current-data): New variable.
Kenichi Handa <handa@m17n.org>
parents:
18201
diff
changeset
|
713 (or (integerp translation) (null translation) |
17052 | 714 (vectorp translation) (stringp translation) |
18297
5c8e37591da5
(quail-current-data): New variable.
Kenichi Handa <handa@m17n.org>
parents:
18201
diff
changeset
|
715 (symbolp translation) |
5c8e37591da5
(quail-current-data): New variable.
Kenichi Handa <handa@m17n.org>
parents:
18201
diff
changeset
|
716 (and (consp translation) (not (vectorp (cdr translation)))))) |
17052 | 717 (let ((alist (cdr object))) |
18297
5c8e37591da5
(quail-current-data): New variable.
Kenichi Handa <handa@m17n.org>
parents:
18201
diff
changeset
|
718 (or (and (listp alist) (consp (car alist))) |
5c8e37591da5
(quail-current-data): New variable.
Kenichi Handa <handa@m17n.org>
parents:
18201
diff
changeset
|
719 (symbolp alist))))) |
17052 | 720 |
18297
5c8e37591da5
(quail-current-data): New variable.
Kenichi Handa <handa@m17n.org>
parents:
18201
diff
changeset
|
721 ;;;###autoload |
17052 | 722 (defmacro quail-define-rules (&rest rules) |
723 "Define translation rules of the current Quail package. | |
724 Each argument is a list of KEY and TRANSLATION. | |
725 KEY is a string meaning a sequence of keystrokes to be translated. | |
726 TRANSLATION is a character, a string, a vector, a Quail map, or a function. | |
727 It it is a character, it is the sole translation of KEY. | |
728 If it is a string, each character is a candidate for the translation. | |
729 If it is a vector, each element (string or character) is a candidate | |
730 for the translation. | |
731 In these cases, a key specific Quail map is generated and assigned to KEY. | |
732 | |
733 If TRANSLATION is a Quail map or a function symbol which returns a Quail map, | |
734 it is used to handle KEY." | |
735 `(quail-install-map | |
736 ',(let ((l rules) | |
737 (map (list nil))) | |
738 (while l | |
739 (quail-defrule-internal (car (car l)) (car (cdr (car l))) map) | |
740 (setq l (cdr l))) | |
741 map))) | |
742 | |
18297
5c8e37591da5
(quail-current-data): New variable.
Kenichi Handa <handa@m17n.org>
parents:
18201
diff
changeset
|
743 ;;;###autoload |
17052 | 744 (defun quail-install-map (map) |
745 "Install the Quail map MAP in the current Quail package. | |
746 The installed map can be referred by the function `quail-map'." | |
747 (if (null quail-current-package) | |
748 (error "No current Quail package")) | |
749 (if (null (quail-map-p map)) | |
750 (error "Invalid Quail map `%s'" map)) | |
751 (setcar (cdr (cdr quail-current-package)) map)) | |
752 | |
18297
5c8e37591da5
(quail-current-data): New variable.
Kenichi Handa <handa@m17n.org>
parents:
18201
diff
changeset
|
753 ;;;###autoload |
17052 | 754 (defun quail-defrule (key translation &optional name) |
755 "Add one translation rule, KEY to TRANSLATION, in the current Quail package. | |
756 KEY is a string meaning a sequence of keystrokes to be translated. | |
18297
5c8e37591da5
(quail-current-data): New variable.
Kenichi Handa <handa@m17n.org>
parents:
18201
diff
changeset
|
757 TRANSLATION is a character, a string, a vector, a Quail map, |
18556
99e8ae18137f
(quail-guidance-buf): Make it buffer
Kenichi Handa <handa@m17n.org>
parents:
18377
diff
changeset
|
758 a function, or a cons. |
17052 | 759 It it is a character, it is the sole translation of KEY. |
760 If it is a string, each character is a candidate for the translation. | |
761 If it is a vector, each element (string or character) is a candidate | |
18556
99e8ae18137f
(quail-guidance-buf): Make it buffer
Kenichi Handa <handa@m17n.org>
parents:
18377
diff
changeset
|
762 for the translation. |
18297
5c8e37591da5
(quail-current-data): New variable.
Kenichi Handa <handa@m17n.org>
parents:
18201
diff
changeset
|
763 If it is a cons, the car is one of the above and the cdr is a function |
18556
99e8ae18137f
(quail-guidance-buf): Make it buffer
Kenichi Handa <handa@m17n.org>
parents:
18377
diff
changeset
|
764 to call when translating KEY (the return value is assigned to the |
99e8ae18137f
(quail-guidance-buf): Make it buffer
Kenichi Handa <handa@m17n.org>
parents:
18377
diff
changeset
|
765 variable `quail-current-data'). If the cdr part is not a function, |
99e8ae18137f
(quail-guidance-buf): Make it buffer
Kenichi Handa <handa@m17n.org>
parents:
18377
diff
changeset
|
766 the value itself is assigned to `quail-current-data'. |
17052 | 767 In these cases, a key specific Quail map is generated and assigned to KEY. |
768 | |
769 If TRANSLATION is a Quail map or a function symbol which returns a Quail map, | |
770 it is used to handle KEY. | |
771 Optional argument NAME, if specified, says which Quail package | |
772 to define this translation rule in. The default is to define it in the | |
773 current Quail package." | |
774 (if name | |
775 (let ((package (quail-package name))) | |
776 (if (null package) | |
777 (error "No Quail package `%s'" name)) | |
778 (setq quail-current-package package))) | |
779 (quail-defrule-internal key translation (quail-map))) | |
780 | |
18297
5c8e37591da5
(quail-current-data): New variable.
Kenichi Handa <handa@m17n.org>
parents:
18201
diff
changeset
|
781 ;;;###autoload |
17052 | 782 (defun quail-defrule-internal (key trans map) |
18556
99e8ae18137f
(quail-guidance-buf): Make it buffer
Kenichi Handa <handa@m17n.org>
parents:
18377
diff
changeset
|
783 "Define KEY as TRANS in a Quail map MAP." |
17052 | 784 (if (null (stringp key)) |
785 "Invalid Quail key `%s'" key) | |
786 (if (not (or (numberp trans) (stringp trans) (vectorp trans) | |
18297
5c8e37591da5
(quail-current-data): New variable.
Kenichi Handa <handa@m17n.org>
parents:
18201
diff
changeset
|
787 (consp trans) |
17052 | 788 (symbolp trans) |
789 (quail-map-p trans))) | |
790 (error "Invalid Quail translation `%s'" trans)) | |
791 (if (null (quail-map-p map)) | |
792 (error "Invalid Quail map `%s'" map)) | |
793 (let ((len (length key)) | |
794 (idx 0) | |
795 ch entry) | |
18297
5c8e37591da5
(quail-current-data): New variable.
Kenichi Handa <handa@m17n.org>
parents:
18201
diff
changeset
|
796 ;; Make a map for registering TRANS if necessary. |
17052 | 797 (while (< idx len) |
798 (if (null (consp map)) | |
799 ;; We come here, for example, when we try to define a rule | |
800 ;; for "ABC" but a rule for "AB" is already defined as a | |
801 ;; symbol. | |
802 (error "Quail key %s is too long" key)) | |
803 (setq ch (aref key idx) | |
804 entry (assq ch (cdr map))) | |
805 (if (null entry) | |
806 (progn | |
807 (setq entry (cons ch (list nil))) | |
808 (setcdr map (cons entry (cdr map))))) | |
809 (setq map (cdr entry)) | |
810 (setq idx (1+ idx))) | |
811 (if (symbolp trans) | |
812 (if (cdr map) | |
813 ;; We come here, for example, when we try to define a rule | |
814 ;; for "AB" as a symbol but a rule for "ABC" is already | |
815 ;; defined. | |
816 (error "Quail key %s is too short" key) | |
817 (setcdr entry trans)) | |
818 (if (quail-map-p trans) | |
819 (if (not (listp (cdr map))) | |
820 ;; We come here, for example, when we try to define a rule | |
821 ;; for "AB" as a symbol but a rule for "ABC" is already | |
822 ;; defined. | |
823 (error "Quail key %s is too short" key) | |
824 (if (not (listp (cdr trans))) | |
825 (if (cdr map) | |
826 ;; We come here, for example, when we try to | |
827 ;; define a rule for "AB" as a symbol but a rule | |
828 ;; for "ABC" is already defined. | |
829 (error "Quail key %s is too short" key) | |
830 (setcdr entry trans)) | |
831 (setcdr entry (append trans (cdr map))))) | |
832 (setcar map trans))))) | |
833 | |
18297
5c8e37591da5
(quail-current-data): New variable.
Kenichi Handa <handa@m17n.org>
parents:
18201
diff
changeset
|
834 (defun quail-get-translation (def key len) |
5c8e37591da5
(quail-current-data): New variable.
Kenichi Handa <handa@m17n.org>
parents:
18201
diff
changeset
|
835 "Return the translation specified as DEF for KEY of length LEN. |
17052 | 836 The translation is either a character or a cons of the form (INDEX . VECTOR), |
837 where VECTOR is a vector of candidates (character or string) for | |
838 the translation, and INDEX points into VECTOR to specify the currently | |
839 selected translation." | |
18297
5c8e37591da5
(quail-current-data): New variable.
Kenichi Handa <handa@m17n.org>
parents:
18201
diff
changeset
|
840 (if (and def (symbolp def)) |
5c8e37591da5
(quail-current-data): New variable.
Kenichi Handa <handa@m17n.org>
parents:
18201
diff
changeset
|
841 ;; DEF is a symbol of a function which returns valid translation. |
5c8e37591da5
(quail-current-data): New variable.
Kenichi Handa <handa@m17n.org>
parents:
18201
diff
changeset
|
842 (setq def (funcall def key len))) |
5c8e37591da5
(quail-current-data): New variable.
Kenichi Handa <handa@m17n.org>
parents:
18201
diff
changeset
|
843 (if (and (consp def) (not (vectorp (cdr def)))) |
5c8e37591da5
(quail-current-data): New variable.
Kenichi Handa <handa@m17n.org>
parents:
18201
diff
changeset
|
844 (setq def (car def))) |
17052 | 845 |
18297
5c8e37591da5
(quail-current-data): New variable.
Kenichi Handa <handa@m17n.org>
parents:
18201
diff
changeset
|
846 (cond |
5c8e37591da5
(quail-current-data): New variable.
Kenichi Handa <handa@m17n.org>
parents:
18201
diff
changeset
|
847 ((or (integerp def) (consp def)) |
5c8e37591da5
(quail-current-data): New variable.
Kenichi Handa <handa@m17n.org>
parents:
18201
diff
changeset
|
848 def) |
5c8e37591da5
(quail-current-data): New variable.
Kenichi Handa <handa@m17n.org>
parents:
18201
diff
changeset
|
849 |
5c8e37591da5
(quail-current-data): New variable.
Kenichi Handa <handa@m17n.org>
parents:
18201
diff
changeset
|
850 ((null def) |
5c8e37591da5
(quail-current-data): New variable.
Kenichi Handa <handa@m17n.org>
parents:
18201
diff
changeset
|
851 ;; No translation. |
5c8e37591da5
(quail-current-data): New variable.
Kenichi Handa <handa@m17n.org>
parents:
18201
diff
changeset
|
852 nil) |
17052 | 853 |
18297
5c8e37591da5
(quail-current-data): New variable.
Kenichi Handa <handa@m17n.org>
parents:
18201
diff
changeset
|
854 ((stringp def) |
5c8e37591da5
(quail-current-data): New variable.
Kenichi Handa <handa@m17n.org>
parents:
18201
diff
changeset
|
855 ;; Each character in DEF is a candidate of translation. Reform |
18556
99e8ae18137f
(quail-guidance-buf): Make it buffer
Kenichi Handa <handa@m17n.org>
parents:
18377
diff
changeset
|
856 ;; it as (INDICES . VECTOR). |
18297
5c8e37591da5
(quail-current-data): New variable.
Kenichi Handa <handa@m17n.org>
parents:
18201
diff
changeset
|
857 (setq def (string-to-vector def)) |
5c8e37591da5
(quail-current-data): New variable.
Kenichi Handa <handa@m17n.org>
parents:
18201
diff
changeset
|
858 ;; But if the length is 1, we don't need vector but a single |
5c8e37591da5
(quail-current-data): New variable.
Kenichi Handa <handa@m17n.org>
parents:
18201
diff
changeset
|
859 ;; candidate as the translation. |
5c8e37591da5
(quail-current-data): New variable.
Kenichi Handa <handa@m17n.org>
parents:
18201
diff
changeset
|
860 (if (= (length def) 1) |
5c8e37591da5
(quail-current-data): New variable.
Kenichi Handa <handa@m17n.org>
parents:
18201
diff
changeset
|
861 (aref def 0) |
18556
99e8ae18137f
(quail-guidance-buf): Make it buffer
Kenichi Handa <handa@m17n.org>
parents:
18377
diff
changeset
|
862 (cons (list 0 0 0 0 nil) def))) |
17052 | 863 |
18297
5c8e37591da5
(quail-current-data): New variable.
Kenichi Handa <handa@m17n.org>
parents:
18201
diff
changeset
|
864 ((vectorp def) |
5c8e37591da5
(quail-current-data): New variable.
Kenichi Handa <handa@m17n.org>
parents:
18201
diff
changeset
|
865 ;; Each element (string or character) in DEF is a candidate of |
18556
99e8ae18137f
(quail-guidance-buf): Make it buffer
Kenichi Handa <handa@m17n.org>
parents:
18377
diff
changeset
|
866 ;; translation. Reform it as (INDICES . VECTOR). |
99e8ae18137f
(quail-guidance-buf): Make it buffer
Kenichi Handa <handa@m17n.org>
parents:
18377
diff
changeset
|
867 (cons (list 0 0 0 0 nil) def)) |
17052 | 868 |
18297
5c8e37591da5
(quail-current-data): New variable.
Kenichi Handa <handa@m17n.org>
parents:
18201
diff
changeset
|
869 (t |
5c8e37591da5
(quail-current-data): New variable.
Kenichi Handa <handa@m17n.org>
parents:
18201
diff
changeset
|
870 (error "Invalid object in Quail map: %s" def)))) |
17052 | 871 |
18556
99e8ae18137f
(quail-guidance-buf): Make it buffer
Kenichi Handa <handa@m17n.org>
parents:
18377
diff
changeset
|
872 (defun quail-lookup-key (key &optional len) |
17052 | 873 "Lookup KEY of length LEN in the current Quail map and return the definition. |
874 The returned value is a Quail map specific to KEY." | |
18556
99e8ae18137f
(quail-guidance-buf): Make it buffer
Kenichi Handa <handa@m17n.org>
parents:
18377
diff
changeset
|
875 (or len |
99e8ae18137f
(quail-guidance-buf): Make it buffer
Kenichi Handa <handa@m17n.org>
parents:
18377
diff
changeset
|
876 (setq len (length key))) |
17052 | 877 (let ((idx 0) |
878 (map (quail-map)) | |
879 (kbd-translate (quail-kbd-translate)) | |
18297
5c8e37591da5
(quail-current-data): New variable.
Kenichi Handa <handa@m17n.org>
parents:
18201
diff
changeset
|
880 slot ch translation def) |
17052 | 881 (while (and map (< idx len)) |
882 (setq ch (if kbd-translate (quail-keyboard-translate (aref key idx)) | |
883 (aref key idx))) | |
884 (setq idx (1+ idx)) | |
885 (if (and (cdr map) (symbolp (cdr map))) | |
886 (setcdr map (funcall (cdr map) key idx))) | |
887 (setq slot (assq ch (cdr map))) | |
888 (if (and (cdr slot) (symbolp (cdr slot))) | |
889 (setcdr slot (funcall (cdr slot) key idx))) | |
890 (setq map (cdr slot))) | |
18297
5c8e37591da5
(quail-current-data): New variable.
Kenichi Handa <handa@m17n.org>
parents:
18201
diff
changeset
|
891 (setq def (car map)) |
18556
99e8ae18137f
(quail-guidance-buf): Make it buffer
Kenichi Handa <handa@m17n.org>
parents:
18377
diff
changeset
|
892 (setq quail-current-translations nil) |
18297
5c8e37591da5
(quail-current-data): New variable.
Kenichi Handa <handa@m17n.org>
parents:
18201
diff
changeset
|
893 (if (and map (setq translation (quail-get-translation def key len))) |
17052 | 894 (progn |
18297
5c8e37591da5
(quail-current-data): New variable.
Kenichi Handa <handa@m17n.org>
parents:
18201
diff
changeset
|
895 (if (and (consp def) (not (vectorp (cdr def)))) |
5c8e37591da5
(quail-current-data): New variable.
Kenichi Handa <handa@m17n.org>
parents:
18201
diff
changeset
|
896 (progn |
5c8e37591da5
(quail-current-data): New variable.
Kenichi Handa <handa@m17n.org>
parents:
18201
diff
changeset
|
897 (if (not (equal (car def) translation)) |
5c8e37591da5
(quail-current-data): New variable.
Kenichi Handa <handa@m17n.org>
parents:
18201
diff
changeset
|
898 ;; We must reflect TRANSLATION to car part of DEF. |
5c8e37591da5
(quail-current-data): New variable.
Kenichi Handa <handa@m17n.org>
parents:
18201
diff
changeset
|
899 (setcar def translation)) |
5c8e37591da5
(quail-current-data): New variable.
Kenichi Handa <handa@m17n.org>
parents:
18201
diff
changeset
|
900 (setq quail-current-data |
5c8e37591da5
(quail-current-data): New variable.
Kenichi Handa <handa@m17n.org>
parents:
18201
diff
changeset
|
901 (if (functionp (cdr def)) |
5c8e37591da5
(quail-current-data): New variable.
Kenichi Handa <handa@m17n.org>
parents:
18201
diff
changeset
|
902 (funcall (cdr def)) |
5c8e37591da5
(quail-current-data): New variable.
Kenichi Handa <handa@m17n.org>
parents:
18201
diff
changeset
|
903 (cdr def)))) |
5c8e37591da5
(quail-current-data): New variable.
Kenichi Handa <handa@m17n.org>
parents:
18201
diff
changeset
|
904 (if (not (equal def translation)) |
5c8e37591da5
(quail-current-data): New variable.
Kenichi Handa <handa@m17n.org>
parents:
18201
diff
changeset
|
905 ;; We must reflect TRANSLATION to car part of MAP. |
5c8e37591da5
(quail-current-data): New variable.
Kenichi Handa <handa@m17n.org>
parents:
18201
diff
changeset
|
906 (setcar map translation))) |
5c8e37591da5
(quail-current-data): New variable.
Kenichi Handa <handa@m17n.org>
parents:
18201
diff
changeset
|
907 (if (and (consp translation) (vectorp (cdr translation))) |
17052 | 908 (progn |
909 (setq quail-current-translations translation) | |
910 (if (quail-forget-last-selection) | |
18556
99e8ae18137f
(quail-guidance-buf): Make it buffer
Kenichi Handa <handa@m17n.org>
parents:
18377
diff
changeset
|
911 (setcar (car quail-current-translations) 0)))) |
17052 | 912 ;; We may have to reform cdr part of MAP. |
913 (if (and (cdr map) (symbolp (cdr map))) | |
914 (progn | |
915 (setcdr map (funcall (cdr map) key len)))) | |
916 )) | |
917 map)) | |
918 | |
919 ;; If set to non-nil, exit conversion mode before starting new translation. | |
920 (defvar quail-exit-conversion-mode nil) | |
921 | |
18201
feea31893155
(quail-prefix-arg): New variable.
Kenichi Handa <handa@m17n.org>
parents:
17764
diff
changeset
|
922 (defvar quail-prefix-arg nil) |
feea31893155
(quail-prefix-arg): New variable.
Kenichi Handa <handa@m17n.org>
parents:
17764
diff
changeset
|
923 |
feea31893155
(quail-prefix-arg): New variable.
Kenichi Handa <handa@m17n.org>
parents:
17764
diff
changeset
|
924 (defun quail-start-translation (arg) |
17052 | 925 "Start translating the typed character in Quail mode." |
18201
feea31893155
(quail-prefix-arg): New variable.
Kenichi Handa <handa@m17n.org>
parents:
17764
diff
changeset
|
926 (interactive "*p") |
feea31893155
(quail-prefix-arg): New variable.
Kenichi Handa <handa@m17n.org>
parents:
17764
diff
changeset
|
927 (setq prefix-arg arg) |
feea31893155
(quail-prefix-arg): New variable.
Kenichi Handa <handa@m17n.org>
parents:
17764
diff
changeset
|
928 (setq quail-prefix-arg arg) |
17052 | 929 (setq unread-command-events |
930 (cons last-command-event unread-command-events)) | |
931 ;; Check the possibility of translating the last key. | |
19432
4492653b04e8
(quail-exit-from-minibuffer): Call
Kenichi Handa <handa@m17n.org>
parents:
19404
diff
changeset
|
932 (if (and (integerp last-command-event) |
4492653b04e8
(quail-exit-from-minibuffer): Call
Kenichi Handa <handa@m17n.org>
parents:
19404
diff
changeset
|
933 (assq (if (quail-kbd-translate) |
4492653b04e8
(quail-exit-from-minibuffer): Call
Kenichi Handa <handa@m17n.org>
parents:
19404
diff
changeset
|
934 (quail-keyboard-translate last-command-event) |
4492653b04e8
(quail-exit-from-minibuffer): Call
Kenichi Handa <handa@m17n.org>
parents:
19404
diff
changeset
|
935 last-command-event) |
4492653b04e8
(quail-exit-from-minibuffer): Call
Kenichi Handa <handa@m17n.org>
parents:
19404
diff
changeset
|
936 (cdr (quail-map)))) |
17052 | 937 ;; Ok, we can start translation. |
19404
8901359ae445
(quail-inactivate): Turn Quail mode off
Kenichi Handa <handa@m17n.org>
parents:
19391
diff
changeset
|
938 (if (quail-conversion-keymap) |
8901359ae445
(quail-inactivate): Turn Quail mode off
Kenichi Handa <handa@m17n.org>
parents:
19391
diff
changeset
|
939 ;; We must start translation in conversion mode. |
8901359ae445
(quail-inactivate): Turn Quail mode off
Kenichi Handa <handa@m17n.org>
parents:
19391
diff
changeset
|
940 (setq quail-exit-conversion-mode nil |
8901359ae445
(quail-inactivate): Turn Quail mode off
Kenichi Handa <handa@m17n.org>
parents:
19391
diff
changeset
|
941 overriding-terminal-local-map (quail-conversion-keymap)) |
8901359ae445
(quail-inactivate): Turn Quail mode off
Kenichi Handa <handa@m17n.org>
parents:
19391
diff
changeset
|
942 (quail-setup-overlays nil) |
8901359ae445
(quail-inactivate): Turn Quail mode off
Kenichi Handa <handa@m17n.org>
parents:
19391
diff
changeset
|
943 (setq quail-current-key "") |
8901359ae445
(quail-inactivate): Turn Quail mode off
Kenichi Handa <handa@m17n.org>
parents:
19391
diff
changeset
|
944 (setq overriding-terminal-local-map (quail-translation-keymap))) |
8901359ae445
(quail-inactivate): Turn Quail mode off
Kenichi Handa <handa@m17n.org>
parents:
19391
diff
changeset
|
945 ;; Since the last event doesn't start any translation, handle it |
8901359ae445
(quail-inactivate): Turn Quail mode off
Kenichi Handa <handa@m17n.org>
parents:
19391
diff
changeset
|
946 ;; out of Quail mode. We come back to Quail mode later by setting |
8901359ae445
(quail-inactivate): Turn Quail mode off
Kenichi Handa <handa@m17n.org>
parents:
19391
diff
changeset
|
947 ;; function `quail-toggle-mode-temporarily' in |
17052 | 948 ;; `post-command-hook'. |
949 (add-hook 'post-command-hook 'quail-toggle-mode-temporarily nil t))) | |
950 | |
951 (defsubst quail-point-in-conversion-region () | |
952 "Return non-nil value if the point is in conversion region of Quail mode." | |
953 (let (start pos) | |
954 (and (setq start (overlay-start quail-conv-overlay)) | |
955 (>= (setq pos (point)) start) | |
956 (<= pos (overlay-end quail-conv-overlay))))) | |
957 | |
958 (defun quail-start-translation-in-conversion-mode () | |
959 "Start translating the typed character in conversion mode of Quail mode." | |
960 (interactive "*") | |
961 (setq unread-command-events | |
962 (cons last-command-event unread-command-events)) | |
963 ;; Check the possibility of translating the last key. | |
19432
4492653b04e8
(quail-exit-from-minibuffer): Call
Kenichi Handa <handa@m17n.org>
parents:
19404
diff
changeset
|
964 (if (and (integerp last-command-event) |
4492653b04e8
(quail-exit-from-minibuffer): Call
Kenichi Handa <handa@m17n.org>
parents:
19404
diff
changeset
|
965 (assq (if (quail-kbd-translate) |
4492653b04e8
(quail-exit-from-minibuffer): Call
Kenichi Handa <handa@m17n.org>
parents:
19404
diff
changeset
|
966 (quail-keyboard-translate last-command-event) |
4492653b04e8
(quail-exit-from-minibuffer): Call
Kenichi Handa <handa@m17n.org>
parents:
19404
diff
changeset
|
967 last-command-event) |
4492653b04e8
(quail-exit-from-minibuffer): Call
Kenichi Handa <handa@m17n.org>
parents:
19404
diff
changeset
|
968 (cdr (quail-map)))) |
17052 | 969 ;; Ok, we can start translation. |
19404
8901359ae445
(quail-inactivate): Turn Quail mode off
Kenichi Handa <handa@m17n.org>
parents:
19391
diff
changeset
|
970 (progn |
8901359ae445
(quail-inactivate): Turn Quail mode off
Kenichi Handa <handa@m17n.org>
parents:
19391
diff
changeset
|
971 (quail-setup-overlays t) |
17052 | 972 (setq quail-current-key "") |
19404
8901359ae445
(quail-inactivate): Turn Quail mode off
Kenichi Handa <handa@m17n.org>
parents:
19391
diff
changeset
|
973 (setq overriding-terminal-local-map (quail-translation-keymap)) |
8901359ae445
(quail-inactivate): Turn Quail mode off
Kenichi Handa <handa@m17n.org>
parents:
19391
diff
changeset
|
974 (move-overlay quail-overlay (point) (point))) |
8901359ae445
(quail-inactivate): Turn Quail mode off
Kenichi Handa <handa@m17n.org>
parents:
19391
diff
changeset
|
975 ;; Since the last event doesn't start any translation, handle it |
8901359ae445
(quail-inactivate): Turn Quail mode off
Kenichi Handa <handa@m17n.org>
parents:
19391
diff
changeset
|
976 ;; out of Quail mode. We come back to Quail mode later by setting |
8901359ae445
(quail-inactivate): Turn Quail mode off
Kenichi Handa <handa@m17n.org>
parents:
19391
diff
changeset
|
977 ;; function `quail-toggle-mode-temporarily' in |
17052 | 978 ;; `post-command-hook'. |
979 (add-hook 'post-command-hook 'quail-toggle-mode-temporarily nil t))) | |
980 | |
18201
feea31893155
(quail-prefix-arg): New variable.
Kenichi Handa <handa@m17n.org>
parents:
17764
diff
changeset
|
981 (defsubst quail-delete-region () |
feea31893155
(quail-prefix-arg): New variable.
Kenichi Handa <handa@m17n.org>
parents:
17764
diff
changeset
|
982 "Delete the text in the current translation region of Quail." |
19404
8901359ae445
(quail-inactivate): Turn Quail mode off
Kenichi Handa <handa@m17n.org>
parents:
19391
diff
changeset
|
983 (if (overlay-start quail-overlay) |
8901359ae445
(quail-inactivate): Turn Quail mode off
Kenichi Handa <handa@m17n.org>
parents:
19391
diff
changeset
|
984 (delete-region (overlay-start quail-overlay) |
8901359ae445
(quail-inactivate): Turn Quail mode off
Kenichi Handa <handa@m17n.org>
parents:
19391
diff
changeset
|
985 (overlay-end quail-overlay)))) |
18201
feea31893155
(quail-prefix-arg): New variable.
Kenichi Handa <handa@m17n.org>
parents:
17764
diff
changeset
|
986 |
17052 | 987 (defun quail-terminate-translation () |
19519
1c0ecc266e38
(quail-terminate-translation): Doc-string
Kenichi Handa <handa@m17n.org>
parents:
19453
diff
changeset
|
988 "Terminate the translation of the current key." |
17052 | 989 (let ((start (overlay-start quail-overlay))) |
990 (if (and start | |
991 (< start (overlay-end quail-overlay))) | |
992 ;; Here we simulate self-insert-command. | |
18201
feea31893155
(quail-prefix-arg): New variable.
Kenichi Handa <handa@m17n.org>
parents:
17764
diff
changeset
|
993 (let ((seq (string-to-sequence |
feea31893155
(quail-prefix-arg): New variable.
Kenichi Handa <handa@m17n.org>
parents:
17764
diff
changeset
|
994 (buffer-substring (overlay-start quail-overlay) |
feea31893155
(quail-prefix-arg): New variable.
Kenichi Handa <handa@m17n.org>
parents:
17764
diff
changeset
|
995 (overlay-end quail-overlay)) |
feea31893155
(quail-prefix-arg): New variable.
Kenichi Handa <handa@m17n.org>
parents:
17764
diff
changeset
|
996 'list)) |
feea31893155
(quail-prefix-arg): New variable.
Kenichi Handa <handa@m17n.org>
parents:
17764
diff
changeset
|
997 last-command-char) |
17052 | 998 (goto-char start) |
18201
feea31893155
(quail-prefix-arg): New variable.
Kenichi Handa <handa@m17n.org>
parents:
17764
diff
changeset
|
999 (quail-delete-region) |
feea31893155
(quail-prefix-arg): New variable.
Kenichi Handa <handa@m17n.org>
parents:
17764
diff
changeset
|
1000 (setq last-command-char (car seq)) |
feea31893155
(quail-prefix-arg): New variable.
Kenichi Handa <handa@m17n.org>
parents:
17764
diff
changeset
|
1001 (self-insert-command (or quail-prefix-arg 1)) |
19519
1c0ecc266e38
(quail-terminate-translation): Doc-string
Kenichi Handa <handa@m17n.org>
parents:
19453
diff
changeset
|
1002 (setq quail-prefix-arg nil) |
18201
feea31893155
(quail-prefix-arg): New variable.
Kenichi Handa <handa@m17n.org>
parents:
17764
diff
changeset
|
1003 (setq seq (cdr seq)) |
feea31893155
(quail-prefix-arg): New variable.
Kenichi Handa <handa@m17n.org>
parents:
17764
diff
changeset
|
1004 (while seq |
feea31893155
(quail-prefix-arg): New variable.
Kenichi Handa <handa@m17n.org>
parents:
17764
diff
changeset
|
1005 (setq last-command-char (car seq)) |
feea31893155
(quail-prefix-arg): New variable.
Kenichi Handa <handa@m17n.org>
parents:
17764
diff
changeset
|
1006 (self-insert-command 1) |
feea31893155
(quail-prefix-arg): New variable.
Kenichi Handa <handa@m17n.org>
parents:
17764
diff
changeset
|
1007 (setq seq (cdr seq)))))) |
17052 | 1008 (delete-overlay quail-overlay) |
1009 (if (buffer-live-p quail-guidance-buf) | |
1010 (save-excursion | |
1011 (set-buffer quail-guidance-buf) | |
1012 (erase-buffer))) | |
19404
8901359ae445
(quail-inactivate): Turn Quail mode off
Kenichi Handa <handa@m17n.org>
parents:
19391
diff
changeset
|
1013 (setq overriding-terminal-local-map |
19453
e6134c179b4c
(quail-terminate-translation): Run
Kenichi Handa <handa@m17n.org>
parents:
19432
diff
changeset
|
1014 (quail-conversion-keymap)) |
e6134c179b4c
(quail-terminate-translation): Run
Kenichi Handa <handa@m17n.org>
parents:
19432
diff
changeset
|
1015 ;; Run this hook only when the current input method doesn't require |
19519
1c0ecc266e38
(quail-terminate-translation): Doc-string
Kenichi Handa <handa@m17n.org>
parents:
19453
diff
changeset
|
1016 ;; conversion. When conversion is required, the conversion function |
1c0ecc266e38
(quail-terminate-translation): Doc-string
Kenichi Handa <handa@m17n.org>
parents:
19453
diff
changeset
|
1017 ;; should run this hook at a proper timing. |
19453
e6134c179b4c
(quail-terminate-translation): Run
Kenichi Handa <handa@m17n.org>
parents:
19432
diff
changeset
|
1018 (unless (quail-conversion-keymap) |
e6134c179b4c
(quail-terminate-translation): Run
Kenichi Handa <handa@m17n.org>
parents:
19432
diff
changeset
|
1019 (run-hooks 'input-method-after-insert-chunk-hook))) |
17052 | 1020 |
1021 (defun quail-select-current () | |
1022 "Select the current text shown in Quail translation region." | |
1023 (interactive) | |
1024 (quail-terminate-translation)) | |
1025 | |
1026 ;; Update the current translation status according to CONTROL-FLAG. | |
1027 ;; If CONTROL-FLAG is integer value, it is the number of keys in the | |
1028 ;; head quail-current-key which can be translated. The remaining keys | |
1029 ;; are put back to unread-command-events to be handled again. | |
1030 ;; If CONTROL-FLAG is t, terminate the translation for the whole keys | |
1031 ;; in quail-current-key. | |
1032 ;; If CONTROL-FLAG is nil, proceed the translation with more keys. | |
1033 | |
1034 (defun quail-update-translation (control-flag) | |
1035 (quail-delete-region) | |
1036 (let ((func (quail-update-translation-function))) | |
1037 (if func | |
1038 (funcall func control-flag) | |
1039 (if (numberp control-flag) | |
1040 (let ((len (length quail-current-key))) | |
1041 (while (> len control-flag) | |
1042 (setq len (1- len)) | |
1043 (setq unread-command-events | |
1044 (cons (aref quail-current-key len) | |
1045 unread-command-events))) | |
1046 (insert (or quail-current-str | |
1047 (substring quail-current-key 0 len)))) | |
1048 (insert (or quail-current-str quail-current-key))))) | |
1049 (quail-update-guidance) | |
19432
4492653b04e8
(quail-exit-from-minibuffer): Call
Kenichi Handa <handa@m17n.org>
parents:
19404
diff
changeset
|
1050 (if control-flag |
4492653b04e8
(quail-exit-from-minibuffer): Call
Kenichi Handa <handa@m17n.org>
parents:
19404
diff
changeset
|
1051 (quail-terminate-translation))) |
17052 | 1052 |
1053 (defun quail-self-insert-command () | |
1054 "Add the typed character to the key for translation." | |
1055 (interactive "*") | |
1056 (setq quail-current-key | |
1057 (concat quail-current-key (char-to-string last-command-event))) | |
19519
1c0ecc266e38
(quail-terminate-translation): Doc-string
Kenichi Handa <handa@m17n.org>
parents:
19453
diff
changeset
|
1058 (unless (catch 'quail-tag |
1c0ecc266e38
(quail-terminate-translation): Doc-string
Kenichi Handa <handa@m17n.org>
parents:
19453
diff
changeset
|
1059 (quail-update-translation (quail-translate-key)) |
1c0ecc266e38
(quail-terminate-translation): Doc-string
Kenichi Handa <handa@m17n.org>
parents:
19453
diff
changeset
|
1060 t) |
1c0ecc266e38
(quail-terminate-translation): Doc-string
Kenichi Handa <handa@m17n.org>
parents:
19453
diff
changeset
|
1061 ;; If someone throws for `quail-tag' by value nil, we exit from |
1c0ecc266e38
(quail-terminate-translation): Doc-string
Kenichi Handa <handa@m17n.org>
parents:
19453
diff
changeset
|
1062 ;; translation mode. |
1c0ecc266e38
(quail-terminate-translation): Doc-string
Kenichi Handa <handa@m17n.org>
parents:
19453
diff
changeset
|
1063 (setq overriding-terminal-local-map nil))) |
17052 | 1064 |
18556
99e8ae18137f
(quail-guidance-buf): Make it buffer
Kenichi Handa <handa@m17n.org>
parents:
18377
diff
changeset
|
1065 ;; Return the actual definition part of Quail map MAP. |
99e8ae18137f
(quail-guidance-buf): Make it buffer
Kenichi Handa <handa@m17n.org>
parents:
18377
diff
changeset
|
1066 (defun quail-map-definition (map) |
99e8ae18137f
(quail-guidance-buf): Make it buffer
Kenichi Handa <handa@m17n.org>
parents:
18377
diff
changeset
|
1067 (let ((def (car map))) |
99e8ae18137f
(quail-guidance-buf): Make it buffer
Kenichi Handa <handa@m17n.org>
parents:
18377
diff
changeset
|
1068 (if (and (consp def) (not (vectorp (cdr def)))) |
99e8ae18137f
(quail-guidance-buf): Make it buffer
Kenichi Handa <handa@m17n.org>
parents:
18377
diff
changeset
|
1069 (setq def (car def))) |
99e8ae18137f
(quail-guidance-buf): Make it buffer
Kenichi Handa <handa@m17n.org>
parents:
18377
diff
changeset
|
1070 def)) |
99e8ae18137f
(quail-guidance-buf): Make it buffer
Kenichi Handa <handa@m17n.org>
parents:
18377
diff
changeset
|
1071 |
99e8ae18137f
(quail-guidance-buf): Make it buffer
Kenichi Handa <handa@m17n.org>
parents:
18377
diff
changeset
|
1072 ;; Return a string to be shown as the current translation of key |
99e8ae18137f
(quail-guidance-buf): Make it buffer
Kenichi Handa <handa@m17n.org>
parents:
18377
diff
changeset
|
1073 ;; sequence of length LEN. DEF is a definition part of Quail map for |
99e8ae18137f
(quail-guidance-buf): Make it buffer
Kenichi Handa <handa@m17n.org>
parents:
18377
diff
changeset
|
1074 ;; the sequence. |
99e8ae18137f
(quail-guidance-buf): Make it buffer
Kenichi Handa <handa@m17n.org>
parents:
18377
diff
changeset
|
1075 (defun quail-get-current-str (len def) |
99e8ae18137f
(quail-guidance-buf): Make it buffer
Kenichi Handa <handa@m17n.org>
parents:
18377
diff
changeset
|
1076 (or (and (consp def) (aref (cdr def) (car (car def)))) |
99e8ae18137f
(quail-guidance-buf): Make it buffer
Kenichi Handa <handa@m17n.org>
parents:
18377
diff
changeset
|
1077 def |
99e8ae18137f
(quail-guidance-buf): Make it buffer
Kenichi Handa <handa@m17n.org>
parents:
18377
diff
changeset
|
1078 (and (> len 1) |
99e8ae18137f
(quail-guidance-buf): Make it buffer
Kenichi Handa <handa@m17n.org>
parents:
18377
diff
changeset
|
1079 (let ((str (quail-get-current-str |
99e8ae18137f
(quail-guidance-buf): Make it buffer
Kenichi Handa <handa@m17n.org>
parents:
18377
diff
changeset
|
1080 (1- len) |
99e8ae18137f
(quail-guidance-buf): Make it buffer
Kenichi Handa <handa@m17n.org>
parents:
18377
diff
changeset
|
1081 (quail-map-definition (quail-lookup-key |
99e8ae18137f
(quail-guidance-buf): Make it buffer
Kenichi Handa <handa@m17n.org>
parents:
18377
diff
changeset
|
1082 quail-current-key (1- len)))))) |
99e8ae18137f
(quail-guidance-buf): Make it buffer
Kenichi Handa <handa@m17n.org>
parents:
18377
diff
changeset
|
1083 (if str |
99e8ae18137f
(quail-guidance-buf): Make it buffer
Kenichi Handa <handa@m17n.org>
parents:
18377
diff
changeset
|
1084 (concat (if (stringp str) str (char-to-string str)) |
99e8ae18137f
(quail-guidance-buf): Make it buffer
Kenichi Handa <handa@m17n.org>
parents:
18377
diff
changeset
|
1085 (substring quail-current-key (1- len) len))))))) |
99e8ae18137f
(quail-guidance-buf): Make it buffer
Kenichi Handa <handa@m17n.org>
parents:
18377
diff
changeset
|
1086 |
99e8ae18137f
(quail-guidance-buf): Make it buffer
Kenichi Handa <handa@m17n.org>
parents:
18377
diff
changeset
|
1087 (defvar quail-guidance-translations-starting-column 20) |
99e8ae18137f
(quail-guidance-buf): Make it buffer
Kenichi Handa <handa@m17n.org>
parents:
18377
diff
changeset
|
1088 |
99e8ae18137f
(quail-guidance-buf): Make it buffer
Kenichi Handa <handa@m17n.org>
parents:
18377
diff
changeset
|
1089 ;; Update `quail-current-translations' to make RELATIVE-INDEX the |
99e8ae18137f
(quail-guidance-buf): Make it buffer
Kenichi Handa <handa@m17n.org>
parents:
18377
diff
changeset
|
1090 ;; current translation. |
99e8ae18137f
(quail-guidance-buf): Make it buffer
Kenichi Handa <handa@m17n.org>
parents:
18377
diff
changeset
|
1091 (defun quail-update-current-translations (&optional relative-index) |
99e8ae18137f
(quail-guidance-buf): Make it buffer
Kenichi Handa <handa@m17n.org>
parents:
18377
diff
changeset
|
1092 (let* ((indices (car quail-current-translations)) |
99e8ae18137f
(quail-guidance-buf): Make it buffer
Kenichi Handa <handa@m17n.org>
parents:
18377
diff
changeset
|
1093 (cur (car indices)) |
99e8ae18137f
(quail-guidance-buf): Make it buffer
Kenichi Handa <handa@m17n.org>
parents:
18377
diff
changeset
|
1094 (start (nth 1 indices)) |
99e8ae18137f
(quail-guidance-buf): Make it buffer
Kenichi Handa <handa@m17n.org>
parents:
18377
diff
changeset
|
1095 (end (nth 2 indices))) |
99e8ae18137f
(quail-guidance-buf): Make it buffer
Kenichi Handa <handa@m17n.org>
parents:
18377
diff
changeset
|
1096 ;; Validate the index number of current translation. |
99e8ae18137f
(quail-guidance-buf): Make it buffer
Kenichi Handa <handa@m17n.org>
parents:
18377
diff
changeset
|
1097 (if (< cur 0) |
99e8ae18137f
(quail-guidance-buf): Make it buffer
Kenichi Handa <handa@m17n.org>
parents:
18377
diff
changeset
|
1098 (setcar indices (setq cur 0)) |
99e8ae18137f
(quail-guidance-buf): Make it buffer
Kenichi Handa <handa@m17n.org>
parents:
18377
diff
changeset
|
1099 (if (>= cur (length (cdr quail-current-translations))) |
99e8ae18137f
(quail-guidance-buf): Make it buffer
Kenichi Handa <handa@m17n.org>
parents:
18377
diff
changeset
|
1100 (setcar indices |
99e8ae18137f
(quail-guidance-buf): Make it buffer
Kenichi Handa <handa@m17n.org>
parents:
18377
diff
changeset
|
1101 (setq cur (1- (length (cdr quail-current-translations))))))) |
99e8ae18137f
(quail-guidance-buf): Make it buffer
Kenichi Handa <handa@m17n.org>
parents:
18377
diff
changeset
|
1102 |
99e8ae18137f
(quail-guidance-buf): Make it buffer
Kenichi Handa <handa@m17n.org>
parents:
18377
diff
changeset
|
1103 (if (or (null end) ; We have not yet calculated END. |
99e8ae18137f
(quail-guidance-buf): Make it buffer
Kenichi Handa <handa@m17n.org>
parents:
18377
diff
changeset
|
1104 (< cur start) ; We moved to the previous block. |
99e8ae18137f
(quail-guidance-buf): Make it buffer
Kenichi Handa <handa@m17n.org>
parents:
18377
diff
changeset
|
1105 (>= cur end)) ; We moved to the next block. |
99e8ae18137f
(quail-guidance-buf): Make it buffer
Kenichi Handa <handa@m17n.org>
parents:
18377
diff
changeset
|
1106 (let ((len (length (cdr quail-current-translations))) |
99e8ae18137f
(quail-guidance-buf): Make it buffer
Kenichi Handa <handa@m17n.org>
parents:
18377
diff
changeset
|
1107 (maxcol (- (window-width quail-guidance-win) |
99e8ae18137f
(quail-guidance-buf): Make it buffer
Kenichi Handa <handa@m17n.org>
parents:
18377
diff
changeset
|
1108 quail-guidance-translations-starting-column)) |
99e8ae18137f
(quail-guidance-buf): Make it buffer
Kenichi Handa <handa@m17n.org>
parents:
18377
diff
changeset
|
1109 (block (nth 3 indices)) |
99e8ae18137f
(quail-guidance-buf): Make it buffer
Kenichi Handa <handa@m17n.org>
parents:
18377
diff
changeset
|
1110 col idx width trans num-items blocks) |
99e8ae18137f
(quail-guidance-buf): Make it buffer
Kenichi Handa <handa@m17n.org>
parents:
18377
diff
changeset
|
1111 (if (< cur start) |
99e8ae18137f
(quail-guidance-buf): Make it buffer
Kenichi Handa <handa@m17n.org>
parents:
18377
diff
changeset
|
1112 ;; We must calculate from the head. |
99e8ae18137f
(quail-guidance-buf): Make it buffer
Kenichi Handa <handa@m17n.org>
parents:
18377
diff
changeset
|
1113 (setq start 0 block 0) |
99e8ae18137f
(quail-guidance-buf): Make it buffer
Kenichi Handa <handa@m17n.org>
parents:
18377
diff
changeset
|
1114 (if end ; i.e. (>= cur end) |
99e8ae18137f
(quail-guidance-buf): Make it buffer
Kenichi Handa <handa@m17n.org>
parents:
18377
diff
changeset
|
1115 (setq start end))) |
99e8ae18137f
(quail-guidance-buf): Make it buffer
Kenichi Handa <handa@m17n.org>
parents:
18377
diff
changeset
|
1116 (setq idx start col 0 end start num-items 0) |
99e8ae18137f
(quail-guidance-buf): Make it buffer
Kenichi Handa <handa@m17n.org>
parents:
18377
diff
changeset
|
1117 ;; Loop until we hit the tail, or reach the block of CUR. |
99e8ae18137f
(quail-guidance-buf): Make it buffer
Kenichi Handa <handa@m17n.org>
parents:
18377
diff
changeset
|
1118 (while (and (< idx len) (>= cur end)) |
99e8ae18137f
(quail-guidance-buf): Make it buffer
Kenichi Handa <handa@m17n.org>
parents:
18377
diff
changeset
|
1119 (if (= num-items 0) |
99e8ae18137f
(quail-guidance-buf): Make it buffer
Kenichi Handa <handa@m17n.org>
parents:
18377
diff
changeset
|
1120 (setq start idx col 0 block (1+ block))) |
99e8ae18137f
(quail-guidance-buf): Make it buffer
Kenichi Handa <handa@m17n.org>
parents:
18377
diff
changeset
|
1121 (setq trans (aref (cdr quail-current-translations) idx)) |
99e8ae18137f
(quail-guidance-buf): Make it buffer
Kenichi Handa <handa@m17n.org>
parents:
18377
diff
changeset
|
1122 (setq width (if (integerp trans) (char-width trans) |
99e8ae18137f
(quail-guidance-buf): Make it buffer
Kenichi Handa <handa@m17n.org>
parents:
18377
diff
changeset
|
1123 (string-width trans))) |
99e8ae18137f
(quail-guidance-buf): Make it buffer
Kenichi Handa <handa@m17n.org>
parents:
18377
diff
changeset
|
1124 (setq col (+ col width 3) num-items (1+ num-items)) |
99e8ae18137f
(quail-guidance-buf): Make it buffer
Kenichi Handa <handa@m17n.org>
parents:
18377
diff
changeset
|
1125 (if (and (> num-items 0) |
99e8ae18137f
(quail-guidance-buf): Make it buffer
Kenichi Handa <handa@m17n.org>
parents:
18377
diff
changeset
|
1126 (or (>= col maxcol) (> num-items 10))) |
99e8ae18137f
(quail-guidance-buf): Make it buffer
Kenichi Handa <handa@m17n.org>
parents:
18377
diff
changeset
|
1127 (setq end idx num-items 0) |
99e8ae18137f
(quail-guidance-buf): Make it buffer
Kenichi Handa <handa@m17n.org>
parents:
18377
diff
changeset
|
1128 (setq idx (1+ idx)))) |
99e8ae18137f
(quail-guidance-buf): Make it buffer
Kenichi Handa <handa@m17n.org>
parents:
18377
diff
changeset
|
1129 (setcar (nthcdr 3 indices) block) |
99e8ae18137f
(quail-guidance-buf): Make it buffer
Kenichi Handa <handa@m17n.org>
parents:
18377
diff
changeset
|
1130 (if (>= idx len) |
99e8ae18137f
(quail-guidance-buf): Make it buffer
Kenichi Handa <handa@m17n.org>
parents:
18377
diff
changeset
|
1131 (progn |
99e8ae18137f
(quail-guidance-buf): Make it buffer
Kenichi Handa <handa@m17n.org>
parents:
18377
diff
changeset
|
1132 ;; We hit the tail before reaching MAXCOL. |
99e8ae18137f
(quail-guidance-buf): Make it buffer
Kenichi Handa <handa@m17n.org>
parents:
18377
diff
changeset
|
1133 (setq end idx) |
99e8ae18137f
(quail-guidance-buf): Make it buffer
Kenichi Handa <handa@m17n.org>
parents:
18377
diff
changeset
|
1134 (setcar (nthcdr 4 indices) block))) |
99e8ae18137f
(quail-guidance-buf): Make it buffer
Kenichi Handa <handa@m17n.org>
parents:
18377
diff
changeset
|
1135 (setcar (cdr indices) start) |
99e8ae18137f
(quail-guidance-buf): Make it buffer
Kenichi Handa <handa@m17n.org>
parents:
18377
diff
changeset
|
1136 (setcar (nthcdr 2 indices) end))) |
99e8ae18137f
(quail-guidance-buf): Make it buffer
Kenichi Handa <handa@m17n.org>
parents:
18377
diff
changeset
|
1137 (if relative-index |
99e8ae18137f
(quail-guidance-buf): Make it buffer
Kenichi Handa <handa@m17n.org>
parents:
18377
diff
changeset
|
1138 (if (>= (+ start relative-index) end) |
99e8ae18137f
(quail-guidance-buf): Make it buffer
Kenichi Handa <handa@m17n.org>
parents:
18377
diff
changeset
|
1139 (setcar indices end) |
99e8ae18137f
(quail-guidance-buf): Make it buffer
Kenichi Handa <handa@m17n.org>
parents:
18377
diff
changeset
|
1140 (setcar indices (+ start relative-index)))) |
99e8ae18137f
(quail-guidance-buf): Make it buffer
Kenichi Handa <handa@m17n.org>
parents:
18377
diff
changeset
|
1141 (setq quail-current-str |
99e8ae18137f
(quail-guidance-buf): Make it buffer
Kenichi Handa <handa@m17n.org>
parents:
18377
diff
changeset
|
1142 (aref (cdr quail-current-translations) (car indices))))) |
99e8ae18137f
(quail-guidance-buf): Make it buffer
Kenichi Handa <handa@m17n.org>
parents:
18377
diff
changeset
|
1143 |
17052 | 1144 (defun quail-translate-key () |
1145 "Translate the current key sequence according to the current Quail map. | |
1146 Return t if we can terminate the translation. | |
1147 Return nil if the current key sequence may be followed by more keys. | |
1148 Return number if we can't find any translation for the current key | |
1149 sequence. The number is the count of valid keys in the current | |
1150 sequence counting from the head." | |
1151 (let* ((len (length quail-current-key)) | |
1152 (map (quail-lookup-key quail-current-key len)) | |
1153 def ch) | |
1154 (if map | |
18556
99e8ae18137f
(quail-guidance-buf): Make it buffer
Kenichi Handa <handa@m17n.org>
parents:
18377
diff
changeset
|
1155 (let ((def (quail-map-definition map))) |
99e8ae18137f
(quail-guidance-buf): Make it buffer
Kenichi Handa <handa@m17n.org>
parents:
18377
diff
changeset
|
1156 (setq quail-current-str (quail-get-current-str len def)) |
17052 | 1157 ;; Return t only if we can terminate the current translation. |
1158 (and | |
1159 ;; No alternative translations. | |
1160 (or (null (consp def)) (= (length (cdr def)) 1)) | |
1161 ;; No translation for the longer key. | |
1162 (null (cdr map)) | |
1163 ;; No shorter breaking point. | |
1164 (or (null (quail-maximum-shortest)) | |
1165 (< len 3) | |
1166 (null (quail-lookup-key quail-current-key (1- len))) | |
1167 (null (quail-lookup-key | |
1168 (substring quail-current-key -2 -1) 1))))) | |
1169 | |
1170 ;; There's no translation for the current key sequence. Before | |
1171 ;; giving up, we must check two possibilities. | |
1172 (cond ((and | |
1173 (quail-maximum-shortest) | |
1174 (>= len 4) | |
18556
99e8ae18137f
(quail-guidance-buf): Make it buffer
Kenichi Handa <handa@m17n.org>
parents:
18377
diff
changeset
|
1175 (setq def (quail-map-definition |
99e8ae18137f
(quail-guidance-buf): Make it buffer
Kenichi Handa <handa@m17n.org>
parents:
18377
diff
changeset
|
1176 (quail-lookup-key quail-current-key (- len 2)))) |
17052 | 1177 (quail-lookup-key (substring quail-current-key -2) 2)) |
1178 ;; Now the sequence is "...ABCD", which can be split into | |
1179 ;; "...AB" and "CD..." to get valid translation. | |
1180 ;; At first, get translation of "...AB". | |
18556
99e8ae18137f
(quail-guidance-buf): Make it buffer
Kenichi Handa <handa@m17n.org>
parents:
18377
diff
changeset
|
1181 (setq quail-current-str (quail-get-current-str (- len 2) def)) |
17052 | 1182 ;; Then, return the length of "...AB". |
1183 (- len 2)) | |
1184 | |
18797
e9aa787f0154
(quail-translate-key): Fix previous change.
Kenichi Handa <handa@m17n.org>
parents:
18642
diff
changeset
|
1185 ((and (> len 0) |
e9aa787f0154
(quail-translate-key): Fix previous change.
Kenichi Handa <handa@m17n.org>
parents:
18642
diff
changeset
|
1186 (quail-lookup-key (substring quail-current-key 0 -1)) |
e9aa787f0154
(quail-translate-key): Fix previous change.
Kenichi Handa <handa@m17n.org>
parents:
18642
diff
changeset
|
1187 quail-current-translations |
17052 | 1188 (not (quail-deterministic)) |
1189 (setq ch (aref quail-current-key (1- len))) | |
1190 (>= ch ?0) (<= ch ?9)) | |
1191 ;; A numeric key is entered to select a desirable translation. | |
1192 (setq quail-current-key (substring quail-current-key 0 -1)) | |
18556
99e8ae18137f
(quail-guidance-buf): Make it buffer
Kenichi Handa <handa@m17n.org>
parents:
18377
diff
changeset
|
1193 ;; We treat key 1,2..,9,0 as specifying 0,1,..8,9. |
99e8ae18137f
(quail-guidance-buf): Make it buffer
Kenichi Handa <handa@m17n.org>
parents:
18377
diff
changeset
|
1194 (setq ch (if (= ch ?0) 9 (- ch ?1))) |
99e8ae18137f
(quail-guidance-buf): Make it buffer
Kenichi Handa <handa@m17n.org>
parents:
18377
diff
changeset
|
1195 (quail-update-current-translations ch) |
17052 | 1196 ;; And, we can terminate the current translation. |
1197 t) | |
1198 | |
1199 (t | |
1200 ;; No way to handle the last character in this context. | |
1201 (1- len)))))) | |
1202 | |
1203 (defun quail-next-translation () | |
1204 "Select next translation in the current batch of candidates." | |
1205 (interactive) | |
1206 (if quail-current-translations | |
18556
99e8ae18137f
(quail-guidance-buf): Make it buffer
Kenichi Handa <handa@m17n.org>
parents:
18377
diff
changeset
|
1207 (let ((indices (car quail-current-translations))) |
99e8ae18137f
(quail-guidance-buf): Make it buffer
Kenichi Handa <handa@m17n.org>
parents:
18377
diff
changeset
|
1208 (if (= (1+ (car indices)) (length (cdr quail-current-translations))) |
19084
9f4b95f30c4f
(quail-next-translation): Call
Kenichi Handa <handa@m17n.org>
parents:
18983
diff
changeset
|
1209 ;; We are already at the tail. |
18556
99e8ae18137f
(quail-guidance-buf): Make it buffer
Kenichi Handa <handa@m17n.org>
parents:
18377
diff
changeset
|
1210 (beep) |
99e8ae18137f
(quail-guidance-buf): Make it buffer
Kenichi Handa <handa@m17n.org>
parents:
18377
diff
changeset
|
1211 (setcar indices (1+ (car indices))) |
99e8ae18137f
(quail-guidance-buf): Make it buffer
Kenichi Handa <handa@m17n.org>
parents:
18377
diff
changeset
|
1212 (quail-update-current-translations) |
99e8ae18137f
(quail-guidance-buf): Make it buffer
Kenichi Handa <handa@m17n.org>
parents:
18377
diff
changeset
|
1213 (quail-update-translation nil))) |
19084
9f4b95f30c4f
(quail-next-translation): Call
Kenichi Handa <handa@m17n.org>
parents:
18983
diff
changeset
|
1214 (quail-execute-non-quail-command))) |
17052 | 1215 |
1216 (defun quail-prev-translation () | |
1217 "Select previous translation in the current batch of candidates." | |
1218 (interactive) | |
1219 (if quail-current-translations | |
18556
99e8ae18137f
(quail-guidance-buf): Make it buffer
Kenichi Handa <handa@m17n.org>
parents:
18377
diff
changeset
|
1220 (let ((indices (car quail-current-translations))) |
99e8ae18137f
(quail-guidance-buf): Make it buffer
Kenichi Handa <handa@m17n.org>
parents:
18377
diff
changeset
|
1221 (if (= (car indices) 0) |
99e8ae18137f
(quail-guidance-buf): Make it buffer
Kenichi Handa <handa@m17n.org>
parents:
18377
diff
changeset
|
1222 ;; We are already at the head. |
99e8ae18137f
(quail-guidance-buf): Make it buffer
Kenichi Handa <handa@m17n.org>
parents:
18377
diff
changeset
|
1223 (beep) |
99e8ae18137f
(quail-guidance-buf): Make it buffer
Kenichi Handa <handa@m17n.org>
parents:
18377
diff
changeset
|
1224 (setcar indices (1- (car indices))) |
99e8ae18137f
(quail-guidance-buf): Make it buffer
Kenichi Handa <handa@m17n.org>
parents:
18377
diff
changeset
|
1225 (quail-update-current-translations) |
99e8ae18137f
(quail-guidance-buf): Make it buffer
Kenichi Handa <handa@m17n.org>
parents:
18377
diff
changeset
|
1226 (quail-update-translation nil))) |
19084
9f4b95f30c4f
(quail-next-translation): Call
Kenichi Handa <handa@m17n.org>
parents:
18983
diff
changeset
|
1227 (quail-execute-non-quail-command))) |
17052 | 1228 |
1229 (defun quail-next-translation-block () | |
18556
99e8ae18137f
(quail-guidance-buf): Make it buffer
Kenichi Handa <handa@m17n.org>
parents:
18377
diff
changeset
|
1230 "Select from the next block of translations." |
17052 | 1231 (interactive) |
1232 (if quail-current-translations | |
18556
99e8ae18137f
(quail-guidance-buf): Make it buffer
Kenichi Handa <handa@m17n.org>
parents:
18377
diff
changeset
|
1233 (let* ((indices (car quail-current-translations)) |
99e8ae18137f
(quail-guidance-buf): Make it buffer
Kenichi Handa <handa@m17n.org>
parents:
18377
diff
changeset
|
1234 (offset (- (car indices) (nth 1 indices)))) |
99e8ae18137f
(quail-guidance-buf): Make it buffer
Kenichi Handa <handa@m17n.org>
parents:
18377
diff
changeset
|
1235 (if (>= (nth 2 indices) (length (cdr quail-current-translations))) |
99e8ae18137f
(quail-guidance-buf): Make it buffer
Kenichi Handa <handa@m17n.org>
parents:
18377
diff
changeset
|
1236 ;; We are already at the last block. |
99e8ae18137f
(quail-guidance-buf): Make it buffer
Kenichi Handa <handa@m17n.org>
parents:
18377
diff
changeset
|
1237 (beep) |
99e8ae18137f
(quail-guidance-buf): Make it buffer
Kenichi Handa <handa@m17n.org>
parents:
18377
diff
changeset
|
1238 (setcar indices (+ (nth 2 indices) offset)) |
99e8ae18137f
(quail-guidance-buf): Make it buffer
Kenichi Handa <handa@m17n.org>
parents:
18377
diff
changeset
|
1239 (quail-update-current-translations) |
99e8ae18137f
(quail-guidance-buf): Make it buffer
Kenichi Handa <handa@m17n.org>
parents:
18377
diff
changeset
|
1240 (quail-update-translation nil))) |
19084
9f4b95f30c4f
(quail-next-translation): Call
Kenichi Handa <handa@m17n.org>
parents:
18983
diff
changeset
|
1241 (quail-execute-non-quail-command))) |
17052 | 1242 |
1243 (defun quail-prev-translation-block () | |
1244 "Select the previous batch of 10 translation candidates." | |
1245 (interactive) | |
18556
99e8ae18137f
(quail-guidance-buf): Make it buffer
Kenichi Handa <handa@m17n.org>
parents:
18377
diff
changeset
|
1246 (if quail-current-translations |
99e8ae18137f
(quail-guidance-buf): Make it buffer
Kenichi Handa <handa@m17n.org>
parents:
18377
diff
changeset
|
1247 (let* ((indices (car quail-current-translations)) |
99e8ae18137f
(quail-guidance-buf): Make it buffer
Kenichi Handa <handa@m17n.org>
parents:
18377
diff
changeset
|
1248 (offset (- (car indices) (nth 1 indices)))) |
99e8ae18137f
(quail-guidance-buf): Make it buffer
Kenichi Handa <handa@m17n.org>
parents:
18377
diff
changeset
|
1249 (if (= (nth 1 indices) 0) |
99e8ae18137f
(quail-guidance-buf): Make it buffer
Kenichi Handa <handa@m17n.org>
parents:
18377
diff
changeset
|
1250 ;; We are already at the first block. |
99e8ae18137f
(quail-guidance-buf): Make it buffer
Kenichi Handa <handa@m17n.org>
parents:
18377
diff
changeset
|
1251 (beep) |
99e8ae18137f
(quail-guidance-buf): Make it buffer
Kenichi Handa <handa@m17n.org>
parents:
18377
diff
changeset
|
1252 (setcar indices (1- (nth 1 indices))) |
99e8ae18137f
(quail-guidance-buf): Make it buffer
Kenichi Handa <handa@m17n.org>
parents:
18377
diff
changeset
|
1253 (quail-update-current-translations) |
99e8ae18137f
(quail-guidance-buf): Make it buffer
Kenichi Handa <handa@m17n.org>
parents:
18377
diff
changeset
|
1254 (if (< (+ (nth 1 indices) offset) (nth 2 indices)) |
99e8ae18137f
(quail-guidance-buf): Make it buffer
Kenichi Handa <handa@m17n.org>
parents:
18377
diff
changeset
|
1255 (progn |
99e8ae18137f
(quail-guidance-buf): Make it buffer
Kenichi Handa <handa@m17n.org>
parents:
18377
diff
changeset
|
1256 (setcar indices (+ (nth 1 indices) offset)) |
99e8ae18137f
(quail-guidance-buf): Make it buffer
Kenichi Handa <handa@m17n.org>
parents:
18377
diff
changeset
|
1257 (quail-update-current-translations))) |
99e8ae18137f
(quail-guidance-buf): Make it buffer
Kenichi Handa <handa@m17n.org>
parents:
18377
diff
changeset
|
1258 (quail-update-translation nil))) |
19084
9f4b95f30c4f
(quail-next-translation): Call
Kenichi Handa <handa@m17n.org>
parents:
18983
diff
changeset
|
1259 (quail-execute-non-quail-command))) |
17052 | 1260 |
1261 (defun quail-abort-translation () | |
1262 "Abort translation and delete the current Quail key sequence." | |
1263 (interactive) | |
1264 (quail-delete-region) | |
1265 (quail-terminate-translation)) | |
1266 | |
1267 (defun quail-delete-last-char () | |
1268 "Delete the last input character from the current Quail key sequence." | |
1269 (interactive) | |
1270 (if (= (length quail-current-key) 1) | |
1271 (quail-abort-translation) | |
1272 (setq quail-current-key (substring quail-current-key 0 -1)) | |
1273 (quail-update-translation (quail-translate-key)))) | |
1274 | |
1275 ;; For conversion mode. | |
1276 | |
1277 (defun quail-conversion-backward-char () | |
1278 (interactive) | |
1279 (if (<= (point) (overlay-start quail-conv-overlay)) | |
1280 (error "Beginning of conversion region")) | |
1281 (forward-char -1)) | |
1282 | |
1283 (defun quail-conversion-forward-char () | |
1284 (interactive) | |
1285 (if (>= (point) (overlay-end quail-conv-overlay)) | |
1286 (error "End of conversion region")) | |
1287 (forward-char 1)) | |
1288 | |
1289 (defun quail-conversion-beginning-of-region () | |
1290 (interactive) | |
1291 (goto-char (overlay-start quail-conv-overlay))) | |
1292 | |
1293 (defun quail-conversion-end-of-region () | |
1294 (interactive) | |
1295 (goto-char (overlay-end quail-conv-overlay))) | |
1296 | |
1297 (defun quail-conversion-delete-char () | |
1298 (interactive) | |
1299 (if (>= (point) (overlay-end quail-conv-overlay)) | |
1300 (error "End of conversion region")) | |
1301 (delete-char 1) | |
19404
8901359ae445
(quail-inactivate): Turn Quail mode off
Kenichi Handa <handa@m17n.org>
parents:
19391
diff
changeset
|
1302 (when (= (overlay-start quail-conv-overlay) |
8901359ae445
(quail-inactivate): Turn Quail mode off
Kenichi Handa <handa@m17n.org>
parents:
19391
diff
changeset
|
1303 (overlay-end quail-conv-overlay)) |
8901359ae445
(quail-inactivate): Turn Quail mode off
Kenichi Handa <handa@m17n.org>
parents:
19391
diff
changeset
|
1304 (quail-delete-overlays) |
8901359ae445
(quail-inactivate): Turn Quail mode off
Kenichi Handa <handa@m17n.org>
parents:
19391
diff
changeset
|
1305 (setq overriding-terminal-local-map nil))) |
17052 | 1306 |
1307 (defun quail-conversion-backward-delete-char () | |
1308 (interactive) | |
1309 (if (<= (point) (overlay-start quail-conv-overlay)) | |
1310 (error "Beginning of conversion region")) | |
1311 (delete-char -1) | |
19404
8901359ae445
(quail-inactivate): Turn Quail mode off
Kenichi Handa <handa@m17n.org>
parents:
19391
diff
changeset
|
1312 (when (= (overlay-start quail-conv-overlay) |
8901359ae445
(quail-inactivate): Turn Quail mode off
Kenichi Handa <handa@m17n.org>
parents:
19391
diff
changeset
|
1313 (overlay-end quail-conv-overlay)) |
8901359ae445
(quail-inactivate): Turn Quail mode off
Kenichi Handa <handa@m17n.org>
parents:
19391
diff
changeset
|
1314 (quail-delete-overlays) |
8901359ae445
(quail-inactivate): Turn Quail mode off
Kenichi Handa <handa@m17n.org>
parents:
19391
diff
changeset
|
1315 (setq overriding-terminal-local-map nil))) |
17052 | 1316 |
1317 (defun quail-do-conversion (func &rest args) | |
1318 "Call FUNC to convert text in the current conversion region of Quail. | |
1319 Remaining args are for FUNC." | |
1320 (delete-overlay quail-overlay) | |
1321 (apply func args)) | |
1322 | |
1323 (defun quail-no-conversion () | |
1324 "Do no conversion of the current conversion region of Quail." | |
1325 (interactive) | |
19404
8901359ae445
(quail-inactivate): Turn Quail mode off
Kenichi Handa <handa@m17n.org>
parents:
19391
diff
changeset
|
1326 (quail-delete-overlays) |
19453
e6134c179b4c
(quail-terminate-translation): Run
Kenichi Handa <handa@m17n.org>
parents:
19432
diff
changeset
|
1327 (setq overriding-terminal-local-map nil) |
e6134c179b4c
(quail-terminate-translation): Run
Kenichi Handa <handa@m17n.org>
parents:
19432
diff
changeset
|
1328 (run-hooks 'input-method-after-insert-chunk-hook)) |
17052 | 1329 |
1330 ;; Guidance, Completion, and Help buffer handlers. | |
1331 | |
18556
99e8ae18137f
(quail-guidance-buf): Make it buffer
Kenichi Handa <handa@m17n.org>
parents:
18377
diff
changeset
|
1332 ;; Make a new one-line frame for Quail guidance buffer. |
99e8ae18137f
(quail-guidance-buf): Make it buffer
Kenichi Handa <handa@m17n.org>
parents:
18377
diff
changeset
|
1333 (defun quail-make-guidance-frame (buf) |
99e8ae18137f
(quail-guidance-buf): Make it buffer
Kenichi Handa <handa@m17n.org>
parents:
18377
diff
changeset
|
1334 (let* ((fparam (frame-parameters)) |
99e8ae18137f
(quail-guidance-buf): Make it buffer
Kenichi Handa <handa@m17n.org>
parents:
18377
diff
changeset
|
1335 (top (cdr (assq 'top fparam))) |
99e8ae18137f
(quail-guidance-buf): Make it buffer
Kenichi Handa <handa@m17n.org>
parents:
18377
diff
changeset
|
1336 (border (cdr (assq 'border-width fparam))) |
99e8ae18137f
(quail-guidance-buf): Make it buffer
Kenichi Handa <handa@m17n.org>
parents:
18377
diff
changeset
|
1337 (internal-border (cdr (assq 'internal-border-width fparam))) |
99e8ae18137f
(quail-guidance-buf): Make it buffer
Kenichi Handa <handa@m17n.org>
parents:
18377
diff
changeset
|
1338 (newtop (- top |
99e8ae18137f
(quail-guidance-buf): Make it buffer
Kenichi Handa <handa@m17n.org>
parents:
18377
diff
changeset
|
1339 (frame-char-height) (* internal-border 2) (* border 2)))) |
99e8ae18137f
(quail-guidance-buf): Make it buffer
Kenichi Handa <handa@m17n.org>
parents:
18377
diff
changeset
|
1340 (if (< newtop 0) |
99e8ae18137f
(quail-guidance-buf): Make it buffer
Kenichi Handa <handa@m17n.org>
parents:
18377
diff
changeset
|
1341 (setq newtop (+ top (frame-pixel-height)))) |
99e8ae18137f
(quail-guidance-buf): Make it buffer
Kenichi Handa <handa@m17n.org>
parents:
18377
diff
changeset
|
1342 (let* ((frame (make-frame (append '((user-position . t) (height . 1) |
99e8ae18137f
(quail-guidance-buf): Make it buffer
Kenichi Handa <handa@m17n.org>
parents:
18377
diff
changeset
|
1343 (minibuffer) (menu-bar-lines . 0)) |
99e8ae18137f
(quail-guidance-buf): Make it buffer
Kenichi Handa <handa@m17n.org>
parents:
18377
diff
changeset
|
1344 (cons (cons 'top newtop) fparam)))) |
99e8ae18137f
(quail-guidance-buf): Make it buffer
Kenichi Handa <handa@m17n.org>
parents:
18377
diff
changeset
|
1345 (win (frame-first-window frame))) |
99e8ae18137f
(quail-guidance-buf): Make it buffer
Kenichi Handa <handa@m17n.org>
parents:
18377
diff
changeset
|
1346 (set-window-buffer win buf) |
99e8ae18137f
(quail-guidance-buf): Make it buffer
Kenichi Handa <handa@m17n.org>
parents:
18377
diff
changeset
|
1347 (set-window-dedicated-p win t)))) |
17052 | 1348 |
19432
4492653b04e8
(quail-exit-from-minibuffer): Call
Kenichi Handa <handa@m17n.org>
parents:
19404
diff
changeset
|
1349 ;; Setup Quail completion buffer. |
4492653b04e8
(quail-exit-from-minibuffer): Call
Kenichi Handa <handa@m17n.org>
parents:
19404
diff
changeset
|
1350 (defun quail-setup-completion-buf () |
4492653b04e8
(quail-exit-from-minibuffer): Call
Kenichi Handa <handa@m17n.org>
parents:
19404
diff
changeset
|
1351 (unless (buffer-live-p quail-completion-buf) |
4492653b04e8
(quail-exit-from-minibuffer): Call
Kenichi Handa <handa@m17n.org>
parents:
19404
diff
changeset
|
1352 (setq quail-completion-buf (get-buffer-create "*Quail Completions*")) |
4492653b04e8
(quail-exit-from-minibuffer): Call
Kenichi Handa <handa@m17n.org>
parents:
19404
diff
changeset
|
1353 (save-excursion |
4492653b04e8
(quail-exit-from-minibuffer): Call
Kenichi Handa <handa@m17n.org>
parents:
19404
diff
changeset
|
1354 (set-buffer quail-completion-buf) |
4492653b04e8
(quail-exit-from-minibuffer): Call
Kenichi Handa <handa@m17n.org>
parents:
19404
diff
changeset
|
1355 (setq quail-overlay (make-overlay 1 1)) |
4492653b04e8
(quail-exit-from-minibuffer): Call
Kenichi Handa <handa@m17n.org>
parents:
19404
diff
changeset
|
1356 (overlay-put quail-overlay 'face 'highlight)))) |
4492653b04e8
(quail-exit-from-minibuffer): Call
Kenichi Handa <handa@m17n.org>
parents:
19404
diff
changeset
|
1357 |
18556
99e8ae18137f
(quail-guidance-buf): Make it buffer
Kenichi Handa <handa@m17n.org>
parents:
18377
diff
changeset
|
1358 (defun quail-show-guidance-buf () |
99e8ae18137f
(quail-guidance-buf): Make it buffer
Kenichi Handa <handa@m17n.org>
parents:
18377
diff
changeset
|
1359 "Display a guidance buffer for Quail input method in some window. |
99e8ae18137f
(quail-guidance-buf): Make it buffer
Kenichi Handa <handa@m17n.org>
parents:
18377
diff
changeset
|
1360 Create the buffer if it does not exist yet. |
99e8ae18137f
(quail-guidance-buf): Make it buffer
Kenichi Handa <handa@m17n.org>
parents:
18377
diff
changeset
|
1361 The buffer is normally displayed at the echo area, |
99e8ae18137f
(quail-guidance-buf): Make it buffer
Kenichi Handa <handa@m17n.org>
parents:
18377
diff
changeset
|
1362 but if the current buffer is a minibuffer, it is shown in |
99e8ae18137f
(quail-guidance-buf): Make it buffer
Kenichi Handa <handa@m17n.org>
parents:
18377
diff
changeset
|
1363 the bottom-most ordinary window of the same frame, |
99e8ae18137f
(quail-guidance-buf): Make it buffer
Kenichi Handa <handa@m17n.org>
parents:
18377
diff
changeset
|
1364 or in a newly created frame (if the selected frame has no other windows)." |
19391
763bc03e7797
(quail-guidance-buf): Now a permanent local.
Richard M. Stallman <rms@gnu.org>
parents:
19327
diff
changeset
|
1365 (if (and (not input-method-verbose-flag) |
18556
99e8ae18137f
(quail-guidance-buf): Make it buffer
Kenichi Handa <handa@m17n.org>
parents:
18377
diff
changeset
|
1366 (eq (selected-window) (minibuffer-window))) |
99e8ae18137f
(quail-guidance-buf): Make it buffer
Kenichi Handa <handa@m17n.org>
parents:
18377
diff
changeset
|
1367 ;; We don't need the guidance buffer. |
99e8ae18137f
(quail-guidance-buf): Make it buffer
Kenichi Handa <handa@m17n.org>
parents:
18377
diff
changeset
|
1368 nil |
99e8ae18137f
(quail-guidance-buf): Make it buffer
Kenichi Handa <handa@m17n.org>
parents:
18377
diff
changeset
|
1369 ;; At first, setup a guidance buffer. |
99e8ae18137f
(quail-guidance-buf): Make it buffer
Kenichi Handa <handa@m17n.org>
parents:
18377
diff
changeset
|
1370 (or (buffer-live-p quail-guidance-buf) |
99e8ae18137f
(quail-guidance-buf): Make it buffer
Kenichi Handa <handa@m17n.org>
parents:
18377
diff
changeset
|
1371 (setq quail-guidance-buf (generate-new-buffer " *Quail-guidance*"))) |
99e8ae18137f
(quail-guidance-buf): Make it buffer
Kenichi Handa <handa@m17n.org>
parents:
18377
diff
changeset
|
1372 (let ((title (quail-title))) |
99e8ae18137f
(quail-guidance-buf): Make it buffer
Kenichi Handa <handa@m17n.org>
parents:
18377
diff
changeset
|
1373 (save-excursion |
99e8ae18137f
(quail-guidance-buf): Make it buffer
Kenichi Handa <handa@m17n.org>
parents:
18377
diff
changeset
|
1374 (set-buffer quail-guidance-buf) |
99e8ae18137f
(quail-guidance-buf): Make it buffer
Kenichi Handa <handa@m17n.org>
parents:
18377
diff
changeset
|
1375 ;; To show the title of Quail package. |
99e8ae18137f
(quail-guidance-buf): Make it buffer
Kenichi Handa <handa@m17n.org>
parents:
18377
diff
changeset
|
1376 (setq current-input-method t |
99e8ae18137f
(quail-guidance-buf): Make it buffer
Kenichi Handa <handa@m17n.org>
parents:
18377
diff
changeset
|
1377 current-input-method-title title) |
99e8ae18137f
(quail-guidance-buf): Make it buffer
Kenichi Handa <handa@m17n.org>
parents:
18377
diff
changeset
|
1378 (erase-buffer) |
99e8ae18137f
(quail-guidance-buf): Make it buffer
Kenichi Handa <handa@m17n.org>
parents:
18377
diff
changeset
|
1379 (or (overlayp quail-overlay) |
99e8ae18137f
(quail-guidance-buf): Make it buffer
Kenichi Handa <handa@m17n.org>
parents:
18377
diff
changeset
|
1380 (progn |
99e8ae18137f
(quail-guidance-buf): Make it buffer
Kenichi Handa <handa@m17n.org>
parents:
18377
diff
changeset
|
1381 (setq quail-overlay (make-overlay 1 1)) |
99e8ae18137f
(quail-guidance-buf): Make it buffer
Kenichi Handa <handa@m17n.org>
parents:
18377
diff
changeset
|
1382 (overlay-put quail-overlay 'face 'highlight))) |
99e8ae18137f
(quail-guidance-buf): Make it buffer
Kenichi Handa <handa@m17n.org>
parents:
18377
diff
changeset
|
1383 (delete-overlay quail-overlay) |
99e8ae18137f
(quail-guidance-buf): Make it buffer
Kenichi Handa <handa@m17n.org>
parents:
18377
diff
changeset
|
1384 (set-buffer-modified-p nil))) |
99e8ae18137f
(quail-guidance-buf): Make it buffer
Kenichi Handa <handa@m17n.org>
parents:
18377
diff
changeset
|
1385 (bury-buffer quail-guidance-buf) |
17052 | 1386 |
18556
99e8ae18137f
(quail-guidance-buf): Make it buffer
Kenichi Handa <handa@m17n.org>
parents:
18377
diff
changeset
|
1387 ;; Then, display it in an appropriate window. |
99e8ae18137f
(quail-guidance-buf): Make it buffer
Kenichi Handa <handa@m17n.org>
parents:
18377
diff
changeset
|
1388 (let ((win (minibuffer-window))) |
99e8ae18137f
(quail-guidance-buf): Make it buffer
Kenichi Handa <handa@m17n.org>
parents:
18377
diff
changeset
|
1389 (if (eq (selected-window) win) |
99e8ae18137f
(quail-guidance-buf): Make it buffer
Kenichi Handa <handa@m17n.org>
parents:
18377
diff
changeset
|
1390 ;; Since we are in minibuffer, we can't use it for guidance. |
99e8ae18137f
(quail-guidance-buf): Make it buffer
Kenichi Handa <handa@m17n.org>
parents:
18377
diff
changeset
|
1391 (if (eq win (frame-root-window)) |
99e8ae18137f
(quail-guidance-buf): Make it buffer
Kenichi Handa <handa@m17n.org>
parents:
18377
diff
changeset
|
1392 ;; Create a frame. It is sure that we are using some |
99e8ae18137f
(quail-guidance-buf): Make it buffer
Kenichi Handa <handa@m17n.org>
parents:
18377
diff
changeset
|
1393 ;; window system. |
99e8ae18137f
(quail-guidance-buf): Make it buffer
Kenichi Handa <handa@m17n.org>
parents:
18377
diff
changeset
|
1394 (quail-make-guidance-frame quail-guidance-buf) |
99e8ae18137f
(quail-guidance-buf): Make it buffer
Kenichi Handa <handa@m17n.org>
parents:
18377
diff
changeset
|
1395 ;; Find the bottom window and split it if necessary. |
99e8ae18137f
(quail-guidance-buf): Make it buffer
Kenichi Handa <handa@m17n.org>
parents:
18377
diff
changeset
|
1396 (let (height) |
99e8ae18137f
(quail-guidance-buf): Make it buffer
Kenichi Handa <handa@m17n.org>
parents:
18377
diff
changeset
|
1397 (setq win (window-at 0 (- (frame-height) 2))) |
99e8ae18137f
(quail-guidance-buf): Make it buffer
Kenichi Handa <handa@m17n.org>
parents:
18377
diff
changeset
|
1398 (setq height (window-height win)) |
99e8ae18137f
(quail-guidance-buf): Make it buffer
Kenichi Handa <handa@m17n.org>
parents:
18377
diff
changeset
|
1399 ;; If WIN is tall enough, split it vertically and use |
99e8ae18137f
(quail-guidance-buf): Make it buffer
Kenichi Handa <handa@m17n.org>
parents:
18377
diff
changeset
|
1400 ;; the lower one. |
99e8ae18137f
(quail-guidance-buf): Make it buffer
Kenichi Handa <handa@m17n.org>
parents:
18377
diff
changeset
|
1401 (if (>= height 4) |
99e8ae18137f
(quail-guidance-buf): Make it buffer
Kenichi Handa <handa@m17n.org>
parents:
18377
diff
changeset
|
1402 (let ((window-min-height 2)) |
99e8ae18137f
(quail-guidance-buf): Make it buffer
Kenichi Handa <handa@m17n.org>
parents:
18377
diff
changeset
|
1403 ;; Here, `split-window' returns a lower window |
99e8ae18137f
(quail-guidance-buf): Make it buffer
Kenichi Handa <handa@m17n.org>
parents:
18377
diff
changeset
|
1404 ;; which is what we wanted. |
99e8ae18137f
(quail-guidance-buf): Make it buffer
Kenichi Handa <handa@m17n.org>
parents:
18377
diff
changeset
|
1405 (setq win (split-window win (- height 2))))) |
99e8ae18137f
(quail-guidance-buf): Make it buffer
Kenichi Handa <handa@m17n.org>
parents:
18377
diff
changeset
|
1406 (set-window-buffer win quail-guidance-buf) |
99e8ae18137f
(quail-guidance-buf): Make it buffer
Kenichi Handa <handa@m17n.org>
parents:
18377
diff
changeset
|
1407 (set-window-dedicated-p win t))) |
99e8ae18137f
(quail-guidance-buf): Make it buffer
Kenichi Handa <handa@m17n.org>
parents:
18377
diff
changeset
|
1408 (set-window-buffer win quail-guidance-buf)) |
99e8ae18137f
(quail-guidance-buf): Make it buffer
Kenichi Handa <handa@m17n.org>
parents:
18377
diff
changeset
|
1409 (setq quail-guidance-win win))) |
17052 | 1410 |
1411 ;; And, create a buffer for completion. | |
19432
4492653b04e8
(quail-exit-from-minibuffer): Call
Kenichi Handa <handa@m17n.org>
parents:
19404
diff
changeset
|
1412 (quail-setup-completion-buf) |
17052 | 1413 (bury-buffer quail-completion-buf)) |
1414 | |
1415 (defun quail-hide-guidance-buf () | |
1416 "Hide the Quail guidance buffer." | |
18556
99e8ae18137f
(quail-guidance-buf): Make it buffer
Kenichi Handa <handa@m17n.org>
parents:
18377
diff
changeset
|
1417 (if (buffer-live-p quail-guidance-buf) |
99e8ae18137f
(quail-guidance-buf): Make it buffer
Kenichi Handa <handa@m17n.org>
parents:
18377
diff
changeset
|
1418 (let ((win-list (get-buffer-window-list quail-guidance-buf t t)) |
99e8ae18137f
(quail-guidance-buf): Make it buffer
Kenichi Handa <handa@m17n.org>
parents:
18377
diff
changeset
|
1419 win) |
99e8ae18137f
(quail-guidance-buf): Make it buffer
Kenichi Handa <handa@m17n.org>
parents:
18377
diff
changeset
|
1420 (while win-list |
99e8ae18137f
(quail-guidance-buf): Make it buffer
Kenichi Handa <handa@m17n.org>
parents:
18377
diff
changeset
|
1421 (setq win (car win-list) win-list (cdr win-list)) |
99e8ae18137f
(quail-guidance-buf): Make it buffer
Kenichi Handa <handa@m17n.org>
parents:
18377
diff
changeset
|
1422 (if (eq win (minibuffer-window)) |
99e8ae18137f
(quail-guidance-buf): Make it buffer
Kenichi Handa <handa@m17n.org>
parents:
18377
diff
changeset
|
1423 ;; We are using echo area for the guidance buffer. |
99e8ae18137f
(quail-guidance-buf): Make it buffer
Kenichi Handa <handa@m17n.org>
parents:
18377
diff
changeset
|
1424 ;; Vacate it to the deepest minibuffer. |
99e8ae18137f
(quail-guidance-buf): Make it buffer
Kenichi Handa <handa@m17n.org>
parents:
18377
diff
changeset
|
1425 (set-window-buffer win |
99e8ae18137f
(quail-guidance-buf): Make it buffer
Kenichi Handa <handa@m17n.org>
parents:
18377
diff
changeset
|
1426 (format " *Minibuf-%d*" (minibuffer-depth))) |
99e8ae18137f
(quail-guidance-buf): Make it buffer
Kenichi Handa <handa@m17n.org>
parents:
18377
diff
changeset
|
1427 (if (eq win (frame-root-window (window-frame win))) |
99e8ae18137f
(quail-guidance-buf): Make it buffer
Kenichi Handa <handa@m17n.org>
parents:
18377
diff
changeset
|
1428 (progn |
99e8ae18137f
(quail-guidance-buf): Make it buffer
Kenichi Handa <handa@m17n.org>
parents:
18377
diff
changeset
|
1429 ;; We are using a separate frame for guidance buffer. |
99e8ae18137f
(quail-guidance-buf): Make it buffer
Kenichi Handa <handa@m17n.org>
parents:
18377
diff
changeset
|
1430 ;;(set-window-dedicated-p win nil) |
99e8ae18137f
(quail-guidance-buf): Make it buffer
Kenichi Handa <handa@m17n.org>
parents:
18377
diff
changeset
|
1431 (delete-frame (window-frame win))) |
99e8ae18137f
(quail-guidance-buf): Make it buffer
Kenichi Handa <handa@m17n.org>
parents:
18377
diff
changeset
|
1432 (set-window-dedicated-p win nil) |
99e8ae18137f
(quail-guidance-buf): Make it buffer
Kenichi Handa <handa@m17n.org>
parents:
18377
diff
changeset
|
1433 (delete-window win))))))) |
17052 | 1434 |
1435 (defun quail-update-guidance () | |
1436 "Update the Quail guidance buffer and completion buffer (if displayed now)." | |
1437 ;; Update guidance buffer. | |
19391
763bc03e7797
(quail-guidance-buf): Now a permanent local.
Richard M. Stallman <rms@gnu.org>
parents:
19327
diff
changeset
|
1438 (if (or input-method-verbose-flag |
17052 | 1439 (not (eq (selected-window) (minibuffer-window)))) |
1440 (let ((guidance (quail-guidance))) | |
1441 (cond ((eq guidance t) | |
1442 ;; Show the current possible translations. | |
1443 (quail-show-translations)) | |
1444 ((null guidance) | |
1445 ;; Show the current input keys. | |
1446 (let ((key quail-current-key)) | |
1447 (save-excursion | |
1448 (set-buffer quail-guidance-buf) | |
1449 (erase-buffer) | |
1450 (insert key)))) | |
1451 ((listp guidance) | |
1452 ;; Show alternative characters specified in this alist. | |
1453 (let* ((key quail-current-key) | |
1454 (len (length key)) | |
1455 (i 0) | |
1456 ch alternative) | |
1457 (save-excursion | |
1458 (set-buffer quail-guidance-buf) | |
1459 (erase-buffer) | |
1460 (while (< i len) | |
1461 (setq ch (aref key i)) | |
1462 (setq alternative (cdr (assoc ch guidance))) | |
1463 (insert (or alternative ch)) | |
1464 (setq i (1+ i))))))))) | |
1465 | |
1466 ;; Update completion buffer if displayed now. We highlight the | |
1467 ;; selected candidate string in *Completion* buffer if any. | |
1468 (let ((win (get-buffer-window quail-completion-buf)) | |
1469 key str pos) | |
1470 (if win | |
1471 (save-excursion | |
1472 (setq str (if (stringp quail-current-str) | |
1473 quail-current-str | |
1474 (if (numberp quail-current-str) | |
1475 (char-to-string quail-current-str))) | |
1476 key quail-current-key) | |
1477 (set-buffer quail-completion-buf) | |
1478 (goto-char (point-min)) | |
1479 (if (null (search-forward (concat " " key ":") nil t)) | |
1480 (delete-overlay quail-overlay) | |
1481 (setq pos (point)) | |
1482 (if (and str (search-forward (concat "." str) nil t)) | |
1483 (move-overlay quail-overlay (1+ (match-beginning 0)) (point)) | |
1484 (move-overlay quail-overlay (match-beginning 0) (point))) | |
1485 ;; Now POS points end of KEY and (point) points end of STR. | |
1486 (if (pos-visible-in-window-p (point) win) | |
1487 ;; STR is already visible. | |
1488 nil | |
1489 ;; We want to make both KEY and STR visible, but if the | |
1490 ;; window is too short, make at least STR visible. | |
1491 (setq pos (progn (point) (goto-char pos))) | |
1492 (beginning-of-line) | |
1493 (set-window-start win (point)) | |
1494 (if (not (pos-visible-in-window-p pos win)) | |
1495 (set-window-start win pos)) | |
1496 )))))) | |
1497 | |
1498 (defun quail-show-translations () | |
1499 "Show the current possible translations." | |
18297
5c8e37591da5
(quail-current-data): New variable.
Kenichi Handa <handa@m17n.org>
parents:
18201
diff
changeset
|
1500 (let* ((key quail-current-key) |
18556
99e8ae18137f
(quail-guidance-buf): Make it buffer
Kenichi Handa <handa@m17n.org>
parents:
18377
diff
changeset
|
1501 (map (quail-lookup-key quail-current-key))) |
99e8ae18137f
(quail-guidance-buf): Make it buffer
Kenichi Handa <handa@m17n.org>
parents:
18377
diff
changeset
|
1502 (if quail-current-translations |
99e8ae18137f
(quail-guidance-buf): Make it buffer
Kenichi Handa <handa@m17n.org>
parents:
18377
diff
changeset
|
1503 (quail-update-current-translations)) |
17052 | 1504 (save-excursion |
1505 (set-buffer quail-guidance-buf) | |
1506 (erase-buffer) | |
1507 | |
1508 ;; Show the current key. | |
1509 (insert key) | |
1510 | |
18556
99e8ae18137f
(quail-guidance-buf): Make it buffer
Kenichi Handa <handa@m17n.org>
parents:
18377
diff
changeset
|
1511 ;; Show followable keys. |
17052 | 1512 (if (cdr map) |
1513 (let ((l (cdr map))) | |
1514 (insert "[") | |
1515 (while l | |
1516 (insert (car (car l))) | |
1517 (setq l (cdr l))) | |
1518 (insert "]"))) | |
1519 | |
1520 ;; Show list of translations. | |
18556
99e8ae18137f
(quail-guidance-buf): Make it buffer
Kenichi Handa <handa@m17n.org>
parents:
18377
diff
changeset
|
1521 (if quail-current-translations |
99e8ae18137f
(quail-guidance-buf): Make it buffer
Kenichi Handa <handa@m17n.org>
parents:
18377
diff
changeset
|
1522 (let* ((indices (car quail-current-translations)) |
99e8ae18137f
(quail-guidance-buf): Make it buffer
Kenichi Handa <handa@m17n.org>
parents:
18377
diff
changeset
|
1523 (cur (car indices)) |
99e8ae18137f
(quail-guidance-buf): Make it buffer
Kenichi Handa <handa@m17n.org>
parents:
18377
diff
changeset
|
1524 (start (nth 1 indices)) |
99e8ae18137f
(quail-guidance-buf): Make it buffer
Kenichi Handa <handa@m17n.org>
parents:
18377
diff
changeset
|
1525 (end (nth 2 indices)) |
99e8ae18137f
(quail-guidance-buf): Make it buffer
Kenichi Handa <handa@m17n.org>
parents:
18377
diff
changeset
|
1526 (idx start)) |
99e8ae18137f
(quail-guidance-buf): Make it buffer
Kenichi Handa <handa@m17n.org>
parents:
18377
diff
changeset
|
1527 (indent-to (- quail-guidance-translations-starting-column 7)) |
99e8ae18137f
(quail-guidance-buf): Make it buffer
Kenichi Handa <handa@m17n.org>
parents:
18377
diff
changeset
|
1528 (insert (format "(%02d/"(nth 3 indices)) |
99e8ae18137f
(quail-guidance-buf): Make it buffer
Kenichi Handa <handa@m17n.org>
parents:
18377
diff
changeset
|
1529 (if (nth 4 indices) |
99e8ae18137f
(quail-guidance-buf): Make it buffer
Kenichi Handa <handa@m17n.org>
parents:
18377
diff
changeset
|
1530 (format "%02d)" (nth 4 indices)) |
99e8ae18137f
(quail-guidance-buf): Make it buffer
Kenichi Handa <handa@m17n.org>
parents:
18377
diff
changeset
|
1531 "??)")) |
99e8ae18137f
(quail-guidance-buf): Make it buffer
Kenichi Handa <handa@m17n.org>
parents:
18377
diff
changeset
|
1532 (while (< idx end) |
99e8ae18137f
(quail-guidance-buf): Make it buffer
Kenichi Handa <handa@m17n.org>
parents:
18377
diff
changeset
|
1533 (insert (format " %d." (if (= (- idx start) 9) 0 |
99e8ae18137f
(quail-guidance-buf): Make it buffer
Kenichi Handa <handa@m17n.org>
parents:
18377
diff
changeset
|
1534 (1+ (- idx start))))) |
17052 | 1535 (let ((pos (point))) |
18556
99e8ae18137f
(quail-guidance-buf): Make it buffer
Kenichi Handa <handa@m17n.org>
parents:
18377
diff
changeset
|
1536 (insert (aref (cdr quail-current-translations) idx)) |
99e8ae18137f
(quail-guidance-buf): Make it buffer
Kenichi Handa <handa@m17n.org>
parents:
18377
diff
changeset
|
1537 (if (= idx cur) |
17052 | 1538 (move-overlay quail-overlay pos (point)))) |
18556
99e8ae18137f
(quail-guidance-buf): Make it buffer
Kenichi Handa <handa@m17n.org>
parents:
18377
diff
changeset
|
1539 (setq idx (1+ idx))))) |
17052 | 1540 ))) |
1541 | |
1542 (defun quail-completion () | |
1543 "List all completions for the current key. | |
1544 All possible translations of the current key and whole possible longer keys | |
1545 are shown." | |
1546 (interactive) | |
19432
4492653b04e8
(quail-exit-from-minibuffer): Call
Kenichi Handa <handa@m17n.org>
parents:
19404
diff
changeset
|
1547 (quail-setup-completion-buf) |
17052 | 1548 (let ((key quail-current-key) |
18556
99e8ae18137f
(quail-guidance-buf): Make it buffer
Kenichi Handa <handa@m17n.org>
parents:
18377
diff
changeset
|
1549 (map (quail-lookup-key quail-current-key))) |
17052 | 1550 (save-excursion |
1551 (set-buffer quail-completion-buf) | |
1552 (erase-buffer) | |
1553 (insert "Possible completion and corresponding translations are:\n") | |
1554 (quail-completion-1 key map 1) | |
1555 (goto-char (point-min)) | |
1556 (display-buffer (current-buffer))) | |
1557 (quail-update-guidance))) | |
1558 | |
1559 ;; List all completions of KEY in MAP with indentation INDENT. | |
1560 (defun quail-completion-1 (key map indent) | |
1561 (let ((len (length key))) | |
1562 (indent-to indent) | |
1563 (insert key ":") | |
1564 (if (and (symbolp map) (fboundp map)) | |
1565 (setq map (funcall map key len))) | |
1566 (if (car map) | |
1567 (quail-completion-list-translations map key (+ indent len 1)) | |
1568 (insert " -\n")) | |
1569 (setq indent (+ indent 2)) | |
1570 (if (cdr map) | |
1571 (let ((l (cdr map)) | |
1572 (newkey (make-string (1+ len) 0)) | |
1573 (i 0)) | |
1574 ;; Set KEY in the first LEN characters of NEWKEY. | |
1575 (while (< i len) | |
1576 (aset newkey i (aref key i)) | |
1577 (setq i (1+ i))) | |
1578 (while l ; L = ((CHAR . DEFN) ....) ; | |
1579 (aset newkey len (car (car l))) | |
1580 (quail-completion-1 newkey (cdr (car l)) indent) | |
1581 (setq l (cdr l))))))) | |
1582 | |
1583 ;; List all possible translations of KEY in Quail map MAP with | |
17764
561a8476368f
(use-quail-package): Error message added.
Kenichi Handa <handa@m17n.org>
parents:
17315
diff
changeset
|
1584 ;; indentation INDENT. |
17052 | 1585 (defun quail-completion-list-translations (map key indent) |
1586 (let ((translations | |
18297
5c8e37591da5
(quail-current-data): New variable.
Kenichi Handa <handa@m17n.org>
parents:
18201
diff
changeset
|
1587 (quail-get-translation (car map) key (length key)))) |
17052 | 1588 (if (integerp translations) |
1589 (insert "(1/1) 1." translations "\n") | |
1590 ;; We need only vector part. | |
1591 (setq translations (cdr translations)) | |
1592 ;; Insert every 10 elements with indices in a line. | |
1593 (let ((len (length translations)) | |
1594 (i 0) | |
1595 (first t) | |
1596 num) | |
1597 (while (< i len) | |
1598 (if first | |
1599 (progn | |
1600 (insert "(1/1)") | |
1601 (setq first nil)) | |
1602 (if (= (% i 10) 0) | |
1603 (progn | |
1604 (newline) | |
1605 (indent-to indent) | |
1606 (insert (format "(%d/%d)" (1+ (/ i 10)) (1+ (/ len 10))))))) | |
1607 ;; We show the last digit of FROM while converting | |
1608 ;; 0,1,..,9 to 1,2,..,0. | |
1609 (insert (format " %d." (if (= (% i 10) 9) 0 (1+ (% i 10))))) | |
1610 (insert (aref translations i)) | |
1611 (setq i (1+ i))) | |
1612 (newline))))) | |
1613 | |
1614 (defun quail-help () | |
1615 "Show brief description of the current Quail package." | |
1616 (interactive) | |
18349
f468344dd2bd
(quail-help): Use with-output-to-temp-buffer.
Kenichi Handa <handa@m17n.org>
parents:
18297
diff
changeset
|
1617 (let ((package quail-current-package)) |
f468344dd2bd
(quail-help): Use with-output-to-temp-buffer.
Kenichi Handa <handa@m17n.org>
parents:
18297
diff
changeset
|
1618 (with-output-to-temp-buffer "*Quail-Help*" |
f468344dd2bd
(quail-help): Use with-output-to-temp-buffer.
Kenichi Handa <handa@m17n.org>
parents:
18297
diff
changeset
|
1619 (save-excursion |
f468344dd2bd
(quail-help): Use with-output-to-temp-buffer.
Kenichi Handa <handa@m17n.org>
parents:
18297
diff
changeset
|
1620 (set-buffer standard-output) |
f468344dd2bd
(quail-help): Use with-output-to-temp-buffer.
Kenichi Handa <handa@m17n.org>
parents:
18297
diff
changeset
|
1621 (let ((quail-current-package package)) |
f468344dd2bd
(quail-help): Use with-output-to-temp-buffer.
Kenichi Handa <handa@m17n.org>
parents:
18297
diff
changeset
|
1622 (insert "Quail input method (name:" |
f468344dd2bd
(quail-help): Use with-output-to-temp-buffer.
Kenichi Handa <handa@m17n.org>
parents:
18297
diff
changeset
|
1623 (quail-name) |
f468344dd2bd
(quail-help): Use with-output-to-temp-buffer.
Kenichi Handa <handa@m17n.org>
parents:
18297
diff
changeset
|
1624 ", mode line indicator:[" |
f468344dd2bd
(quail-help): Use with-output-to-temp-buffer.
Kenichi Handa <handa@m17n.org>
parents:
18297
diff
changeset
|
1625 (quail-title) |
f468344dd2bd
(quail-help): Use with-output-to-temp-buffer.
Kenichi Handa <handa@m17n.org>
parents:
18297
diff
changeset
|
1626 "])\n---- Documentation ----\n" |
f468344dd2bd
(quail-help): Use with-output-to-temp-buffer.
Kenichi Handa <handa@m17n.org>
parents:
18297
diff
changeset
|
1627 (quail-docstring)) |
f468344dd2bd
(quail-help): Use with-output-to-temp-buffer.
Kenichi Handa <handa@m17n.org>
parents:
18297
diff
changeset
|
1628 (newline) |
f468344dd2bd
(quail-help): Use with-output-to-temp-buffer.
Kenichi Handa <handa@m17n.org>
parents:
18297
diff
changeset
|
1629 (if (quail-show-layout) (quail-show-kbd-layout)) |
f468344dd2bd
(quail-help): Use with-output-to-temp-buffer.
Kenichi Handa <handa@m17n.org>
parents:
18297
diff
changeset
|
1630 (quail-help-insert-keymap-description |
f468344dd2bd
(quail-help): Use with-output-to-temp-buffer.
Kenichi Handa <handa@m17n.org>
parents:
18297
diff
changeset
|
1631 quail-mode-map |
f468344dd2bd
(quail-help): Use with-output-to-temp-buffer.
Kenichi Handa <handa@m17n.org>
parents:
18297
diff
changeset
|
1632 "---- Key bindings (before starting translation) ---- |
17052 | 1633 key binding |
1634 --- -------\n") | |
18349
f468344dd2bd
(quail-help): Use with-output-to-temp-buffer.
Kenichi Handa <handa@m17n.org>
parents:
18297
diff
changeset
|
1635 (quail-help-insert-keymap-description |
f468344dd2bd
(quail-help): Use with-output-to-temp-buffer.
Kenichi Handa <handa@m17n.org>
parents:
18297
diff
changeset
|
1636 (quail-translation-keymap) |
f468344dd2bd
(quail-help): Use with-output-to-temp-buffer.
Kenichi Handa <handa@m17n.org>
parents:
18297
diff
changeset
|
1637 "--- Key bindings (while translating) --- |
17052 | 1638 key binding |
1639 --- -------\n") | |
18349
f468344dd2bd
(quail-help): Use with-output-to-temp-buffer.
Kenichi Handa <handa@m17n.org>
parents:
18297
diff
changeset
|
1640 (if (quail-conversion-keymap) |
f468344dd2bd
(quail-help): Use with-output-to-temp-buffer.
Kenichi Handa <handa@m17n.org>
parents:
18297
diff
changeset
|
1641 (quail-help-insert-keymap-description |
f468344dd2bd
(quail-help): Use with-output-to-temp-buffer.
Kenichi Handa <handa@m17n.org>
parents:
18297
diff
changeset
|
1642 (quail-conversion-keymap) |
f468344dd2bd
(quail-help): Use with-output-to-temp-buffer.
Kenichi Handa <handa@m17n.org>
parents:
18297
diff
changeset
|
1643 "--- Key bindings (while converting) --- |
17052 | 1644 key binding |
1645 --- -------\n")) | |
18349
f468344dd2bd
(quail-help): Use with-output-to-temp-buffer.
Kenichi Handa <handa@m17n.org>
parents:
18297
diff
changeset
|
1646 (help-mode)))))) |
f468344dd2bd
(quail-help): Use with-output-to-temp-buffer.
Kenichi Handa <handa@m17n.org>
parents:
18297
diff
changeset
|
1647 |
17052 | 1648 (defun quail-help-insert-keymap-description (keymap &optional header) |
1649 (let (from to) | |
1650 (if header | |
1651 (insert header)) | |
1652 (save-excursion | |
1653 (save-window-excursion | |
19404
8901359ae445
(quail-inactivate): Turn Quail mode off
Kenichi Handa <handa@m17n.org>
parents:
19391
diff
changeset
|
1654 (let ((overriding-terminal-local-map keymap)) |
17052 | 1655 (describe-bindings)) |
1656 (set-buffer "*Help*") | |
1657 (goto-char (point-min)) | |
1658 (forward-line 4) | |
1659 (setq from (point)) | |
1660 (search-forward "Global Bindings:" nil 'move) | |
1661 (beginning-of-line) | |
1662 (setq to (point)))) | |
1663 (insert-buffer-substring "*Help*" from to))) | |
1664 | |
1665 (defun quail-show-kbd-layout () | |
1666 "Show keyboard layout with key tops of multilingual characters." | |
1667 (insert "--- Keyboard layout ---\n") | |
1668 (let* ((i 0) ch) | |
1669 (while (< i quail-keyboard-layout-len) | |
1670 (if (= (% i 30) 0) | |
1671 (progn | |
1672 (newline) | |
1673 (indent-to (/ i 30))) | |
1674 (if (= (% i 2) 0) | |
1675 (insert " "))) | |
1676 (setq ch (aref quail-keyboard-layout i)) | |
1677 (if (= ch ?\ ) | |
1678 (insert ch) | |
17095
b57415dcc114
Add quail-mode to default value of
Kenichi Handa <handa@m17n.org>
parents:
17071
diff
changeset
|
1679 (let* ((map (cdr (assq ch (cdr (quail-map))))) |
b57415dcc114
Add quail-mode to default value of
Kenichi Handa <handa@m17n.org>
parents:
17071
diff
changeset
|
1680 (translation (and map (quail-get-translation |
18297
5c8e37591da5
(quail-current-data): New variable.
Kenichi Handa <handa@m17n.org>
parents:
18201
diff
changeset
|
1681 (car map) (char-to-string ch) 1)))) |
17095
b57415dcc114
Add quail-mode to default value of
Kenichi Handa <handa@m17n.org>
parents:
17071
diff
changeset
|
1682 (if (integerp translation) |
b57415dcc114
Add quail-mode to default value of
Kenichi Handa <handa@m17n.org>
parents:
17071
diff
changeset
|
1683 (insert translation) |
b57415dcc114
Add quail-mode to default value of
Kenichi Handa <handa@m17n.org>
parents:
17071
diff
changeset
|
1684 (if (consp translation) |
b57415dcc114
Add quail-mode to default value of
Kenichi Handa <handa@m17n.org>
parents:
17071
diff
changeset
|
1685 (insert (aref (cdr translation) (car translation))) |
b57415dcc114
Add quail-mode to default value of
Kenichi Handa <handa@m17n.org>
parents:
17071
diff
changeset
|
1686 (insert ch))))) |
17052 | 1687 (setq i (1+ i)))) |
1688 (newline)) | |
1689 | |
1690 (defun quail-translation-help () | |
1691 "Show help message while translating in Quail mode." | |
1692 (interactive) | |
1693 (let ((package quail-current-package) | |
18349
f468344dd2bd
(quail-help): Use with-output-to-temp-buffer.
Kenichi Handa <handa@m17n.org>
parents:
18297
diff
changeset
|
1694 (current-key quail-current-key)) |
f468344dd2bd
(quail-help): Use with-output-to-temp-buffer.
Kenichi Handa <handa@m17n.org>
parents:
18297
diff
changeset
|
1695 (with-output-to-temp-buffer "*Quail-Help*" |
f468344dd2bd
(quail-help): Use with-output-to-temp-buffer.
Kenichi Handa <handa@m17n.org>
parents:
18297
diff
changeset
|
1696 (save-excursion |
f468344dd2bd
(quail-help): Use with-output-to-temp-buffer.
Kenichi Handa <handa@m17n.org>
parents:
18297
diff
changeset
|
1697 (set-buffer standard-output) |
f468344dd2bd
(quail-help): Use with-output-to-temp-buffer.
Kenichi Handa <handa@m17n.org>
parents:
18297
diff
changeset
|
1698 (let ((quail-current-package package)) |
f468344dd2bd
(quail-help): Use with-output-to-temp-buffer.
Kenichi Handa <handa@m17n.org>
parents:
18297
diff
changeset
|
1699 (princ "You are translating the key sequence ") |
f468344dd2bd
(quail-help): Use with-output-to-temp-buffer.
Kenichi Handa <handa@m17n.org>
parents:
18297
diff
changeset
|
1700 (prin1 quail-current-key) |
f468344dd2bd
(quail-help): Use with-output-to-temp-buffer.
Kenichi Handa <handa@m17n.org>
parents:
18297
diff
changeset
|
1701 (princ" in Quail mode.\n") |
f468344dd2bd
(quail-help): Use with-output-to-temp-buffer.
Kenichi Handa <handa@m17n.org>
parents:
18297
diff
changeset
|
1702 (quail-help-insert-keymap-description |
f468344dd2bd
(quail-help): Use with-output-to-temp-buffer.
Kenichi Handa <handa@m17n.org>
parents:
18297
diff
changeset
|
1703 (quail-translation-keymap) |
f468344dd2bd
(quail-help): Use with-output-to-temp-buffer.
Kenichi Handa <handa@m17n.org>
parents:
18297
diff
changeset
|
1704 "----------------------- |
17052 | 1705 key binding |
18349
f468344dd2bd
(quail-help): Use with-output-to-temp-buffer.
Kenichi Handa <handa@m17n.org>
parents:
18297
diff
changeset
|
1706 --- -------\n")) |
f468344dd2bd
(quail-help): Use with-output-to-temp-buffer.
Kenichi Handa <handa@m17n.org>
parents:
18297
diff
changeset
|
1707 (help-mode))))) |
f468344dd2bd
(quail-help): Use with-output-to-temp-buffer.
Kenichi Handa <handa@m17n.org>
parents:
18297
diff
changeset
|
1708 |
17052 | 1709 (defun quail-conversion-help () |
1710 "Show help message while converting in Quail mode." | |
1711 (interactive) | |
1712 (let ((package quail-current-package) | |
1713 (str (buffer-substring (overlay-start quail-conv-overlay) | |
18642
0fc832264117
(quail-conversion-help): Source code indentation changed.
Kenichi Handa <handa@m17n.org>
parents:
18556
diff
changeset
|
1714 (overlay-end quail-conv-overlay)))) |
18349
f468344dd2bd
(quail-help): Use with-output-to-temp-buffer.
Kenichi Handa <handa@m17n.org>
parents:
18297
diff
changeset
|
1715 (with-output-to-temp-buffer "*Quail-Help*" |
f468344dd2bd
(quail-help): Use with-output-to-temp-buffer.
Kenichi Handa <handa@m17n.org>
parents:
18297
diff
changeset
|
1716 (save-excursion |
f468344dd2bd
(quail-help): Use with-output-to-temp-buffer.
Kenichi Handa <handa@m17n.org>
parents:
18297
diff
changeset
|
1717 (set-buffer standard-output) |
f468344dd2bd
(quail-help): Use with-output-to-temp-buffer.
Kenichi Handa <handa@m17n.org>
parents:
18297
diff
changeset
|
1718 (let ((quail-current-package package)) |
f468344dd2bd
(quail-help): Use with-output-to-temp-buffer.
Kenichi Handa <handa@m17n.org>
parents:
18297
diff
changeset
|
1719 (princ "You are converting the string ") |
f468344dd2bd
(quail-help): Use with-output-to-temp-buffer.
Kenichi Handa <handa@m17n.org>
parents:
18297
diff
changeset
|
1720 (prin1 str) |
f468344dd2bd
(quail-help): Use with-output-to-temp-buffer.
Kenichi Handa <handa@m17n.org>
parents:
18297
diff
changeset
|
1721 (princ " in Quail mode.\n") |
f468344dd2bd
(quail-help): Use with-output-to-temp-buffer.
Kenichi Handa <handa@m17n.org>
parents:
18297
diff
changeset
|
1722 (quail-help-insert-keymap-description |
f468344dd2bd
(quail-help): Use with-output-to-temp-buffer.
Kenichi Handa <handa@m17n.org>
parents:
18297
diff
changeset
|
1723 (quail-conversion-keymap) |
18642
0fc832264117
(quail-conversion-help): Source code indentation changed.
Kenichi Handa <handa@m17n.org>
parents:
18556
diff
changeset
|
1724 "----------------------- |
17052 | 1725 key binding |
18349
f468344dd2bd
(quail-help): Use with-output-to-temp-buffer.
Kenichi Handa <handa@m17n.org>
parents:
18297
diff
changeset
|
1726 --- -------\n")) |
f468344dd2bd
(quail-help): Use with-output-to-temp-buffer.
Kenichi Handa <handa@m17n.org>
parents:
18297
diff
changeset
|
1727 (help-mode))))) |
17052 | 1728 |
18297
5c8e37591da5
(quail-current-data): New variable.
Kenichi Handa <handa@m17n.org>
parents:
18201
diff
changeset
|
1729 |
5c8e37591da5
(quail-current-data): New variable.
Kenichi Handa <handa@m17n.org>
parents:
18201
diff
changeset
|
1730 (defvar quail-directory-name "quail" |
5c8e37591da5
(quail-current-data): New variable.
Kenichi Handa <handa@m17n.org>
parents:
18201
diff
changeset
|
1731 "Name of Quail directory which cotains Quail packages. |
5c8e37591da5
(quail-current-data): New variable.
Kenichi Handa <handa@m17n.org>
parents:
18201
diff
changeset
|
1732 This is a sub-directory of LEIM directory.") |
5c8e37591da5
(quail-current-data): New variable.
Kenichi Handa <handa@m17n.org>
parents:
18201
diff
changeset
|
1733 |
5c8e37591da5
(quail-current-data): New variable.
Kenichi Handa <handa@m17n.org>
parents:
18201
diff
changeset
|
1734 ;;;###autoload |
19605
3b700b203cfd
(quail-update-leim-list-file): Make it
Kenichi Handa <handa@m17n.org>
parents:
19519
diff
changeset
|
1735 (defun quail-update-leim-list-file (dirname &rest dirnames) |
3b700b203cfd
(quail-update-leim-list-file): Make it
Kenichi Handa <handa@m17n.org>
parents:
19519
diff
changeset
|
1736 "Update entries for Quail packages in `LEIM' list file in directory DIRNAME. |
3b700b203cfd
(quail-update-leim-list-file): Make it
Kenichi Handa <handa@m17n.org>
parents:
19519
diff
changeset
|
1737 DIRNAME is a directory containing Emacs input methods; |
19200
74ec766c0ada
(quail-update-leim-list-file):
Richard M. Stallman <rms@gnu.org>
parents:
19144
diff
changeset
|
1738 normally, it should specify the `leim' subdirectory |
19605
3b700b203cfd
(quail-update-leim-list-file): Make it
Kenichi Handa <handa@m17n.org>
parents:
19519
diff
changeset
|
1739 of the Emacs source tree. |
3b700b203cfd
(quail-update-leim-list-file): Make it
Kenichi Handa <handa@m17n.org>
parents:
19519
diff
changeset
|
1740 |
3b700b203cfd
(quail-update-leim-list-file): Make it
Kenichi Handa <handa@m17n.org>
parents:
19519
diff
changeset
|
1741 It searches for Quail packages under `quail' subdirectory of DIRNAME, |
3b700b203cfd
(quail-update-leim-list-file): Make it
Kenichi Handa <handa@m17n.org>
parents:
19519
diff
changeset
|
1742 and update the file \"leim-list.el\" in DIRNAME. |
3b700b203cfd
(quail-update-leim-list-file): Make it
Kenichi Handa <handa@m17n.org>
parents:
19519
diff
changeset
|
1743 |
3b700b203cfd
(quail-update-leim-list-file): Make it
Kenichi Handa <handa@m17n.org>
parents:
19519
diff
changeset
|
1744 When called from a program, the remaining arguments are additional |
3b700b203cfd
(quail-update-leim-list-file): Make it
Kenichi Handa <handa@m17n.org>
parents:
19519
diff
changeset
|
1745 directory names to search for Quail packages under `quail' subdirectory |
3b700b203cfd
(quail-update-leim-list-file): Make it
Kenichi Handa <handa@m17n.org>
parents:
19519
diff
changeset
|
1746 of each directory." |
18297
5c8e37591da5
(quail-current-data): New variable.
Kenichi Handa <handa@m17n.org>
parents:
18201
diff
changeset
|
1747 (interactive "FDirectory of LEIM: ") |
19605
3b700b203cfd
(quail-update-leim-list-file): Make it
Kenichi Handa <handa@m17n.org>
parents:
19519
diff
changeset
|
1748 (setq dirname (expand-file-name dirname)) |
3b700b203cfd
(quail-update-leim-list-file): Make it
Kenichi Handa <handa@m17n.org>
parents:
19519
diff
changeset
|
1749 (let ((leim-list (expand-file-name leim-list-file-name dirname)) |
3b700b203cfd
(quail-update-leim-list-file): Make it
Kenichi Handa <handa@m17n.org>
parents:
19519
diff
changeset
|
1750 quail-dirs list-buf pkg-list pkg-buf pos) |
3b700b203cfd
(quail-update-leim-list-file): Make it
Kenichi Handa <handa@m17n.org>
parents:
19519
diff
changeset
|
1751 (if (not (file-writable-p leim-list)) |
3b700b203cfd
(quail-update-leim-list-file): Make it
Kenichi Handa <handa@m17n.org>
parents:
19519
diff
changeset
|
1752 (error "Can't write to file \"%s\"" leim-list)) |
3b700b203cfd
(quail-update-leim-list-file): Make it
Kenichi Handa <handa@m17n.org>
parents:
19519
diff
changeset
|
1753 (message "Updating %s ..." leim-list) |
3b700b203cfd
(quail-update-leim-list-file): Make it
Kenichi Handa <handa@m17n.org>
parents:
19519
diff
changeset
|
1754 (setq list-buf (find-file-noselect leim-list)) |
3b700b203cfd
(quail-update-leim-list-file): Make it
Kenichi Handa <handa@m17n.org>
parents:
19519
diff
changeset
|
1755 |
3b700b203cfd
(quail-update-leim-list-file): Make it
Kenichi Handa <handa@m17n.org>
parents:
19519
diff
changeset
|
1756 ;; At first, clean up the file. |
3b700b203cfd
(quail-update-leim-list-file): Make it
Kenichi Handa <handa@m17n.org>
parents:
19519
diff
changeset
|
1757 (save-excursion |
3b700b203cfd
(quail-update-leim-list-file): Make it
Kenichi Handa <handa@m17n.org>
parents:
19519
diff
changeset
|
1758 (set-buffer list-buf) |
3b700b203cfd
(quail-update-leim-list-file): Make it
Kenichi Handa <handa@m17n.org>
parents:
19519
diff
changeset
|
1759 (goto-char 1) |
18297
5c8e37591da5
(quail-current-data): New variable.
Kenichi Handa <handa@m17n.org>
parents:
18201
diff
changeset
|
1760 |
19605
3b700b203cfd
(quail-update-leim-list-file): Make it
Kenichi Handa <handa@m17n.org>
parents:
19519
diff
changeset
|
1761 ;; Insert the correct header. |
3b700b203cfd
(quail-update-leim-list-file): Make it
Kenichi Handa <handa@m17n.org>
parents:
19519
diff
changeset
|
1762 (if (looking-at (regexp-quote leim-list-header)) |
3b700b203cfd
(quail-update-leim-list-file): Make it
Kenichi Handa <handa@m17n.org>
parents:
19519
diff
changeset
|
1763 (goto-char (match-end 0)) |
3b700b203cfd
(quail-update-leim-list-file): Make it
Kenichi Handa <handa@m17n.org>
parents:
19519
diff
changeset
|
1764 (insert leim-list-header)) |
3b700b203cfd
(quail-update-leim-list-file): Make it
Kenichi Handa <handa@m17n.org>
parents:
19519
diff
changeset
|
1765 (setq pos (point)) |
3b700b203cfd
(quail-update-leim-list-file): Make it
Kenichi Handa <handa@m17n.org>
parents:
19519
diff
changeset
|
1766 (if (not (re-search-forward leim-list-entry-regexp nil t)) |
3b700b203cfd
(quail-update-leim-list-file): Make it
Kenichi Handa <handa@m17n.org>
parents:
19519
diff
changeset
|
1767 nil |
3b700b203cfd
(quail-update-leim-list-file): Make it
Kenichi Handa <handa@m17n.org>
parents:
19519
diff
changeset
|
1768 |
3b700b203cfd
(quail-update-leim-list-file): Make it
Kenichi Handa <handa@m17n.org>
parents:
19519
diff
changeset
|
1769 ;; Remove garbages after the header. |
3b700b203cfd
(quail-update-leim-list-file): Make it
Kenichi Handa <handa@m17n.org>
parents:
19519
diff
changeset
|
1770 (goto-char (match-beginning 0)) |
3b700b203cfd
(quail-update-leim-list-file): Make it
Kenichi Handa <handa@m17n.org>
parents:
19519
diff
changeset
|
1771 (if (< pos (point)) |
3b700b203cfd
(quail-update-leim-list-file): Make it
Kenichi Handa <handa@m17n.org>
parents:
19519
diff
changeset
|
1772 (delete-region pos (point))) |
18297
5c8e37591da5
(quail-current-data): New variable.
Kenichi Handa <handa@m17n.org>
parents:
18201
diff
changeset
|
1773 |
19605
3b700b203cfd
(quail-update-leim-list-file): Make it
Kenichi Handa <handa@m17n.org>
parents:
19519
diff
changeset
|
1774 ;; Remove all entries for Quail. |
3b700b203cfd
(quail-update-leim-list-file): Make it
Kenichi Handa <handa@m17n.org>
parents:
19519
diff
changeset
|
1775 (while (re-search-forward leim-list-entry-regexp nil 'move) |
3b700b203cfd
(quail-update-leim-list-file): Make it
Kenichi Handa <handa@m17n.org>
parents:
19519
diff
changeset
|
1776 (goto-char (match-beginning 0)) |
3b700b203cfd
(quail-update-leim-list-file): Make it
Kenichi Handa <handa@m17n.org>
parents:
19519
diff
changeset
|
1777 (setq pos (point)) |
3b700b203cfd
(quail-update-leim-list-file): Make it
Kenichi Handa <handa@m17n.org>
parents:
19519
diff
changeset
|
1778 (condition-case nil |
3b700b203cfd
(quail-update-leim-list-file): Make it
Kenichi Handa <handa@m17n.org>
parents:
19519
diff
changeset
|
1779 (let ((form (read list-buf))) |
3b700b203cfd
(quail-update-leim-list-file): Make it
Kenichi Handa <handa@m17n.org>
parents:
19519
diff
changeset
|
1780 (when (equal (nth 3 form) ''quail-use-package) |
3b700b203cfd
(quail-update-leim-list-file): Make it
Kenichi Handa <handa@m17n.org>
parents:
19519
diff
changeset
|
1781 (if (eolp) (forward-line 1)) |
3b700b203cfd
(quail-update-leim-list-file): Make it
Kenichi Handa <handa@m17n.org>
parents:
19519
diff
changeset
|
1782 (delete-region pos (point)))) |
3b700b203cfd
(quail-update-leim-list-file): Make it
Kenichi Handa <handa@m17n.org>
parents:
19519
diff
changeset
|
1783 (error |
3b700b203cfd
(quail-update-leim-list-file): Make it
Kenichi Handa <handa@m17n.org>
parents:
19519
diff
changeset
|
1784 ;; Delete the remaining contents because it seems that |
3b700b203cfd
(quail-update-leim-list-file): Make it
Kenichi Handa <handa@m17n.org>
parents:
19519
diff
changeset
|
1785 ;; this file is broken. |
3b700b203cfd
(quail-update-leim-list-file): Make it
Kenichi Handa <handa@m17n.org>
parents:
19519
diff
changeset
|
1786 (message "Garbages in %s deleted" leim-list) |
3b700b203cfd
(quail-update-leim-list-file): Make it
Kenichi Handa <handa@m17n.org>
parents:
19519
diff
changeset
|
1787 (delete-region pos (point-max))))))) |
18297
5c8e37591da5
(quail-current-data): New variable.
Kenichi Handa <handa@m17n.org>
parents:
18201
diff
changeset
|
1788 |
19605
3b700b203cfd
(quail-update-leim-list-file): Make it
Kenichi Handa <handa@m17n.org>
parents:
19519
diff
changeset
|
1789 ;; Search for `quail' subdirector under each DIRNAMES. |
3b700b203cfd
(quail-update-leim-list-file): Make it
Kenichi Handa <handa@m17n.org>
parents:
19519
diff
changeset
|
1790 (setq dirnames (cons dirname dirnames)) |
3b700b203cfd
(quail-update-leim-list-file): Make it
Kenichi Handa <handa@m17n.org>
parents:
19519
diff
changeset
|
1791 (let ((l dirnames)) |
3b700b203cfd
(quail-update-leim-list-file): Make it
Kenichi Handa <handa@m17n.org>
parents:
19519
diff
changeset
|
1792 (while l |
3b700b203cfd
(quail-update-leim-list-file): Make it
Kenichi Handa <handa@m17n.org>
parents:
19519
diff
changeset
|
1793 (setcar l (expand-file-name (car l))) |
3b700b203cfd
(quail-update-leim-list-file): Make it
Kenichi Handa <handa@m17n.org>
parents:
19519
diff
changeset
|
1794 (setq dirname (expand-file-name quail-directory-name (car l))) |
3b700b203cfd
(quail-update-leim-list-file): Make it
Kenichi Handa <handa@m17n.org>
parents:
19519
diff
changeset
|
1795 (if (file-readable-p dirname) |
3b700b203cfd
(quail-update-leim-list-file): Make it
Kenichi Handa <handa@m17n.org>
parents:
19519
diff
changeset
|
1796 (setq quail-dirs (cons dirname quail-dirs)) |
3b700b203cfd
(quail-update-leim-list-file): Make it
Kenichi Handa <handa@m17n.org>
parents:
19519
diff
changeset
|
1797 (message "%s doesn't has `%s' subdirectory, just ignored" |
3b700b203cfd
(quail-update-leim-list-file): Make it
Kenichi Handa <handa@m17n.org>
parents:
19519
diff
changeset
|
1798 (car l) quail-directory-name) |
3b700b203cfd
(quail-update-leim-list-file): Make it
Kenichi Handa <handa@m17n.org>
parents:
19519
diff
changeset
|
1799 (setq quail-dirs (cons nil quail-dirs))) |
3b700b203cfd
(quail-update-leim-list-file): Make it
Kenichi Handa <handa@m17n.org>
parents:
19519
diff
changeset
|
1800 (setq l (cdr l))) |
3b700b203cfd
(quail-update-leim-list-file): Make it
Kenichi Handa <handa@m17n.org>
parents:
19519
diff
changeset
|
1801 (setq quail-dirs (nreverse quail-dirs))) |
18297
5c8e37591da5
(quail-current-data): New variable.
Kenichi Handa <handa@m17n.org>
parents:
18201
diff
changeset
|
1802 |
19605
3b700b203cfd
(quail-update-leim-list-file): Make it
Kenichi Handa <handa@m17n.org>
parents:
19519
diff
changeset
|
1803 ;; Insert input method registering forms. |
3b700b203cfd
(quail-update-leim-list-file): Make it
Kenichi Handa <handa@m17n.org>
parents:
19519
diff
changeset
|
1804 (while quail-dirs |
3b700b203cfd
(quail-update-leim-list-file): Make it
Kenichi Handa <handa@m17n.org>
parents:
19519
diff
changeset
|
1805 (setq dirname (car quail-dirs)) |
3b700b203cfd
(quail-update-leim-list-file): Make it
Kenichi Handa <handa@m17n.org>
parents:
19519
diff
changeset
|
1806 (when dirname |
3b700b203cfd
(quail-update-leim-list-file): Make it
Kenichi Handa <handa@m17n.org>
parents:
19519
diff
changeset
|
1807 (setq pkg-list (directory-files dirname 'full "\\.el$" 'nosort)) |
3b700b203cfd
(quail-update-leim-list-file): Make it
Kenichi Handa <handa@m17n.org>
parents:
19519
diff
changeset
|
1808 (while pkg-list |
3b700b203cfd
(quail-update-leim-list-file): Make it
Kenichi Handa <handa@m17n.org>
parents:
19519
diff
changeset
|
1809 (message "Checking %s ..." (car pkg-list)) |
3b700b203cfd
(quail-update-leim-list-file): Make it
Kenichi Handa <handa@m17n.org>
parents:
19519
diff
changeset
|
1810 (with-temp-buffer |
3b700b203cfd
(quail-update-leim-list-file): Make it
Kenichi Handa <handa@m17n.org>
parents:
19519
diff
changeset
|
1811 (insert-file-contents (car pkg-list)) |
3b700b203cfd
(quail-update-leim-list-file): Make it
Kenichi Handa <handa@m17n.org>
parents:
19519
diff
changeset
|
1812 (goto-char (point-min)) |
3b700b203cfd
(quail-update-leim-list-file): Make it
Kenichi Handa <handa@m17n.org>
parents:
19519
diff
changeset
|
1813 (while (search-forward "(quail-define-package" nil t) |
3b700b203cfd
(quail-update-leim-list-file): Make it
Kenichi Handa <handa@m17n.org>
parents:
19519
diff
changeset
|
1814 (goto-char (match-beginning 0)) |
3b700b203cfd
(quail-update-leim-list-file): Make it
Kenichi Handa <handa@m17n.org>
parents:
19519
diff
changeset
|
1815 (condition-case nil |
3b700b203cfd
(quail-update-leim-list-file): Make it
Kenichi Handa <handa@m17n.org>
parents:
19519
diff
changeset
|
1816 (let ((form (read (current-buffer)))) |
3b700b203cfd
(quail-update-leim-list-file): Make it
Kenichi Handa <handa@m17n.org>
parents:
19519
diff
changeset
|
1817 (save-excursion |
3b700b203cfd
(quail-update-leim-list-file): Make it
Kenichi Handa <handa@m17n.org>
parents:
19519
diff
changeset
|
1818 (set-buffer list-buf) |
3b700b203cfd
(quail-update-leim-list-file): Make it
Kenichi Handa <handa@m17n.org>
parents:
19519
diff
changeset
|
1819 (insert |
3b700b203cfd
(quail-update-leim-list-file): Make it
Kenichi Handa <handa@m17n.org>
parents:
19519
diff
changeset
|
1820 (format "(register-input-method |
18297
5c8e37591da5
(quail-current-data): New variable.
Kenichi Handa <handa@m17n.org>
parents:
18201
diff
changeset
|
1821 %S %S '%s |
5c8e37591da5
(quail-current-data): New variable.
Kenichi Handa <handa@m17n.org>
parents:
18201
diff
changeset
|
1822 %S %S |
19200
74ec766c0ada
(quail-update-leim-list-file):
Richard M. Stallman <rms@gnu.org>
parents:
19144
diff
changeset
|
1823 %S)\n" |
19605
3b700b203cfd
(quail-update-leim-list-file): Make it
Kenichi Handa <handa@m17n.org>
parents:
19519
diff
changeset
|
1824 (nth 1 form) ; PACKAGE-NAME |
3b700b203cfd
(quail-update-leim-list-file): Make it
Kenichi Handa <handa@m17n.org>
parents:
19519
diff
changeset
|
1825 (nth 2 form) ; LANGUAGE |
3b700b203cfd
(quail-update-leim-list-file): Make it
Kenichi Handa <handa@m17n.org>
parents:
19519
diff
changeset
|
1826 'quail-use-package ; ACTIVATE-FUNC |
3b700b203cfd
(quail-update-leim-list-file): Make it
Kenichi Handa <handa@m17n.org>
parents:
19519
diff
changeset
|
1827 (nth 3 form) ; PACKAGE-TITLE |
3b700b203cfd
(quail-update-leim-list-file): Make it
Kenichi Handa <handa@m17n.org>
parents:
19519
diff
changeset
|
1828 (progn ; PACKAGE-DESCRIPTION (one line) |
3b700b203cfd
(quail-update-leim-list-file): Make it
Kenichi Handa <handa@m17n.org>
parents:
19519
diff
changeset
|
1829 (string-match ".*" (nth 5 form)) |
3b700b203cfd
(quail-update-leim-list-file): Make it
Kenichi Handa <handa@m17n.org>
parents:
19519
diff
changeset
|
1830 (match-string 0 (nth 5 form))) |
3b700b203cfd
(quail-update-leim-list-file): Make it
Kenichi Handa <handa@m17n.org>
parents:
19519
diff
changeset
|
1831 (file-relative-name ; PACKAGE-FILENAME |
3b700b203cfd
(quail-update-leim-list-file): Make it
Kenichi Handa <handa@m17n.org>
parents:
19519
diff
changeset
|
1832 (file-name-sans-extension (car pkg-list)) |
3b700b203cfd
(quail-update-leim-list-file): Make it
Kenichi Handa <handa@m17n.org>
parents:
19519
diff
changeset
|
1833 (car dirnames)))))) |
3b700b203cfd
(quail-update-leim-list-file): Make it
Kenichi Handa <handa@m17n.org>
parents:
19519
diff
changeset
|
1834 (error |
3b700b203cfd
(quail-update-leim-list-file): Make it
Kenichi Handa <handa@m17n.org>
parents:
19519
diff
changeset
|
1835 ;; Ignore the remaining contents of this file. |
3b700b203cfd
(quail-update-leim-list-file): Make it
Kenichi Handa <handa@m17n.org>
parents:
19519
diff
changeset
|
1836 (goto-char (point-max)) |
3b700b203cfd
(quail-update-leim-list-file): Make it
Kenichi Handa <handa@m17n.org>
parents:
19519
diff
changeset
|
1837 (message "Some part of \"%s\" is broken" dirname))))) |
3b700b203cfd
(quail-update-leim-list-file): Make it
Kenichi Handa <handa@m17n.org>
parents:
19519
diff
changeset
|
1838 (setq pkg-list (cdr pkg-list))) |
3b700b203cfd
(quail-update-leim-list-file): Make it
Kenichi Handa <handa@m17n.org>
parents:
19519
diff
changeset
|
1839 (setq quail-dirs (cdr quail-dirs) dirnames (cdr dirnames)))) |
3b700b203cfd
(quail-update-leim-list-file): Make it
Kenichi Handa <handa@m17n.org>
parents:
19519
diff
changeset
|
1840 |
3b700b203cfd
(quail-update-leim-list-file): Make it
Kenichi Handa <handa@m17n.org>
parents:
19519
diff
changeset
|
1841 ;; At last, write out LEIM list file. |
3b700b203cfd
(quail-update-leim-list-file): Make it
Kenichi Handa <handa@m17n.org>
parents:
19519
diff
changeset
|
1842 (save-excursion |
3b700b203cfd
(quail-update-leim-list-file): Make it
Kenichi Handa <handa@m17n.org>
parents:
19519
diff
changeset
|
1843 (set-buffer list-buf) |
3b700b203cfd
(quail-update-leim-list-file): Make it
Kenichi Handa <handa@m17n.org>
parents:
19519
diff
changeset
|
1844 (setq buffer-file-coding-system 'iso-2022-7bit) |
3b700b203cfd
(quail-update-leim-list-file): Make it
Kenichi Handa <handa@m17n.org>
parents:
19519
diff
changeset
|
1845 (save-buffer 0)) |
3b700b203cfd
(quail-update-leim-list-file): Make it
Kenichi Handa <handa@m17n.org>
parents:
19519
diff
changeset
|
1846 (kill-buffer list-buf) |
3b700b203cfd
(quail-update-leim-list-file): Make it
Kenichi Handa <handa@m17n.org>
parents:
19519
diff
changeset
|
1847 (message "Updating %s ... done" leim-list))) |
17052 | 1848 ;; |
1849 (provide 'quail) | |
1850 | |
1851 ;;; quail.el ends here |