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