Mercurial > emacs
annotate lisp/international/quail.el @ 30543:cae243d66bbe
(gomoku-font-lock-O-face, gomoku-font-lock-X-face)
(gomoku-plot-square, gomoku-init-display): Don't use window-system.
author | Eli Zaretskii <eliz@gnu.org> |
---|---|
date | Mon, 31 Jul 2000 15:38:35 +0000 |
parents | a81355bcaaeb |
children | 321084a896d1 |
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-overlay nil |
72 "Overlay which covers the current translation region of Quail.") | |
73 (make-variable-buffer-local 'quail-overlay) | |
74 | |
75 (defvar quail-conv-overlay nil | |
76 "Overlay which covers the text to be converted in Quail mode.") | |
77 (make-variable-buffer-local 'quail-conv-overlay) | |
78 | |
79 (defvar quail-current-key nil | |
80 "Current key for translation in Quail mode.") | |
22765
7cf2c3800e8f
(quail-mode): This variable deleted.
Kenichi Handa <handa@m17n.org>
parents:
22124
diff
changeset
|
81 (make-variable-buffer-local 'quail-current-key) |
17052 | 82 |
83 (defvar quail-current-str nil | |
84 "Currently selected translation of the current key.") | |
22765
7cf2c3800e8f
(quail-mode): This variable deleted.
Kenichi Handa <handa@m17n.org>
parents:
22124
diff
changeset
|
85 (make-variable-buffer-local 'quail-current-str) |
17052 | 86 |
87 (defvar quail-current-translations nil | |
18556
99e8ae18137f
(quail-guidance-buf): Make it buffer
Kenichi Handa <handa@m17n.org>
parents:
18377
diff
changeset
|
88 "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
|
89 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
|
90 CURRENT is an index of the current translation, |
99e8ae18137f
(quail-guidance-buf): Make it buffer
Kenichi Handa <handa@m17n.org>
parents:
18377
diff
changeset
|
91 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
|
92 BLOCK is the current block index, |
99e8ae18137f
(quail-guidance-buf): Make it buffer
Kenichi Handa <handa@m17n.org>
parents:
18377
diff
changeset
|
93 BLOCKS is a number of blocks of translation.") |
22765
7cf2c3800e8f
(quail-mode): This variable deleted.
Kenichi Handa <handa@m17n.org>
parents:
22124
diff
changeset
|
94 (make-variable-buffer-local 'quail-current-translations) |
17052 | 95 |
18297
5c8e37591da5
(quail-current-data): New variable.
Kenichi Handa <handa@m17n.org>
parents:
18201
diff
changeset
|
96 (defvar quail-current-data nil |
5c8e37591da5
(quail-current-data): New variable.
Kenichi Handa <handa@m17n.org>
parents:
18201
diff
changeset
|
97 "Any Lisp object holding information of current translation status. |
5c8e37591da5
(quail-current-data): New variable.
Kenichi Handa <handa@m17n.org>
parents:
18201
diff
changeset
|
98 When a key sequence is mapped to TRANS and TRANS is a cons |
23176 | 99 of actual translation and some Lisp object to be referred |
18297
5c8e37591da5
(quail-current-data): New variable.
Kenichi Handa <handa@m17n.org>
parents:
18201
diff
changeset
|
100 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
|
101 to that Lisp object.") |
18556
99e8ae18137f
(quail-guidance-buf): Make it buffer
Kenichi Handa <handa@m17n.org>
parents:
18377
diff
changeset
|
102 (make-variable-buffer-local 'quail-current-data) |
18297
5c8e37591da5
(quail-current-data): New variable.
Kenichi Handa <handa@m17n.org>
parents:
18201
diff
changeset
|
103 |
17052 | 104 ;; Quail package handlers. |
105 | |
106 (defvar quail-package-alist nil | |
107 "List of Quail packages. | |
108 A Quail package is a list of these elements: | |
109 NAME, TITLE, QUAIL-MAP, GUIDANCE, DOCSTRING, TRANSLATION-KEYS, | |
110 FORGET-LAST-SELECTION, DETERMINISTIC, KBD-TRANSLATE, SHOW-LAYOUT, | |
111 DECODE-MAP, MAXIMUM-SHORTEST, OVERLAY-PLIST, UPDATE-TRANSLATION-FUNCTION, | |
19849
1c5164d81426
(quail-simple): New function.
Kenichi Handa <handa@m17n.org>
parents:
19844
diff
changeset
|
112 CONVERSION-KEYS, SIMPLE. |
17052 | 113 |
114 QUAIL-MAP is a data structure to map key strings to translations. For | |
115 the format, see the documentation of `quail-map-p'. | |
116 | |
117 DECODE-MAP is an alist of translations and corresponding keys. | |
118 | |
119 See the documentation of `quail-define-package' for the other elements.") | |
120 | |
121 ;; Return various slots in the current quail-package. | |
122 | |
123 (defsubst quail-name () | |
124 "Return the name of the current Quail package." | |
125 (nth 0 quail-current-package)) | |
126 (defsubst quail-title () | |
127 "Return the title of the current Quail package." | |
128 (nth 1 quail-current-package)) | |
129 (defsubst quail-map () | |
130 "Return the translation map of the current Quail package." | |
131 (nth 2 quail-current-package)) | |
132 (defsubst quail-guidance () | |
133 "Return an object used for `guidance' feature of the current Quail package. | |
134 See also the documentation of `quail-define-package'." | |
135 (nth 3 quail-current-package)) | |
136 (defsubst quail-docstring () | |
137 "Return the documentation string of the current Quail package." | |
138 (nth 4 quail-current-package)) | |
139 (defsubst quail-translation-keymap () | |
140 "Return translation keymap in the current Quail package. | |
141 Translation keymap is a keymap used while translation region is active." | |
142 (nth 5 quail-current-package)) | |
143 (defsubst quail-forget-last-selection () | |
144 "Return `forget-last-selection' flag of the current Quail package. | |
145 See also the documentation of `quail-define-package'." | |
146 (nth 6 quail-current-package)) | |
147 (defsubst quail-deterministic () | |
148 "Return `deterministic' flag of the current Quail package. | |
149 See also the documentation of `quail-define-package'." | |
150 (nth 7 quail-current-package)) | |
151 (defsubst quail-kbd-translate () | |
152 "Return `kbd-translate' flag of the current Quail package. | |
153 See also the documentation of `quail-define-package'." | |
154 (nth 8 quail-current-package)) | |
155 (defsubst quail-show-layout () | |
156 "Return `show-layout' flag of the current Quail package. | |
157 See also the documentation of `quail-define-package'." | |
158 (nth 9 quail-current-package)) | |
159 (defsubst quail-decode-map () | |
160 "Return decode map of the current Quail package. | |
161 It is an alist of translations and corresponding keys." | |
162 (nth 10 quail-current-package)) | |
163 (defsubst quail-maximum-shortest () | |
164 "Return `maximum-shortest' flag of the current Quail package. | |
165 See also the documentation of `quail-define-package'." | |
166 (nth 11 quail-current-package)) | |
167 (defsubst quail-overlay-plist () | |
168 "Return property list of an overly used in the current Quail package." | |
169 (nth 12 quail-current-package)) | |
170 (defsubst quail-update-translation-function () | |
171 "Return a function for updating translation in the current Quail package." | |
172 (nth 13 quail-current-package)) | |
173 (defsubst quail-conversion-keymap () | |
174 "Return conversion keymap in the current Quail package. | |
175 Conversion keymap is a keymap used while conversion region is active | |
176 but translation region is not active." | |
177 (nth 14 quail-current-package)) | |
19849
1c5164d81426
(quail-simple): New function.
Kenichi Handa <handa@m17n.org>
parents:
19844
diff
changeset
|
178 (defsubst quail-simple () |
1c5164d81426
(quail-simple): New function.
Kenichi Handa <handa@m17n.org>
parents:
19844
diff
changeset
|
179 "Return t if the current Quail package is simple." |
1c5164d81426
(quail-simple): New function.
Kenichi Handa <handa@m17n.org>
parents:
19844
diff
changeset
|
180 (nth 15 quail-current-package)) |
17052 | 181 |
182 (defsubst quail-package (name) | |
183 "Return Quail package named NAME." | |
184 (assoc name quail-package-alist)) | |
185 | |
186 (defun quail-add-package (package) | |
187 "Add Quail package PACKAGE to `quail-package-alist'." | |
188 (let ((pac (quail-package (car package)))) | |
189 (if pac | |
190 (setcdr pac (cdr package)) | |
191 (setq quail-package-alist (cons package quail-package-alist))))) | |
192 | |
193 (defun quail-select-package (name) | |
194 "Select Quail package named NAME as the current Quail package." | |
195 (let ((package (quail-package name))) | |
196 (if (null package) | |
197 (error "No Quail package `%s'" name)) | |
198 (setq quail-current-package package) | |
199 (setq-default quail-current-package package) | |
200 name)) | |
201 | |
202 ;;;###autoload | |
203 (defun quail-use-package (package-name &rest libraries) | |
204 "Start using Quail package PACKAGE-NAME. | |
205 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
|
206 (let ((package (quail-package package-name))) |
5c8e37591da5
(quail-current-data): New variable.
Kenichi Handa <handa@m17n.org>
parents:
18201
diff
changeset
|
207 (if (null package) |
5c8e37591da5
(quail-current-data): New variable.
Kenichi Handa <handa@m17n.org>
parents:
18201
diff
changeset
|
208 ;; Perhaps we have not yet loaded necessary libraries. |
5c8e37591da5
(quail-current-data): New variable.
Kenichi Handa <handa@m17n.org>
parents:
18201
diff
changeset
|
209 (while libraries |
5c8e37591da5
(quail-current-data): New variable.
Kenichi Handa <handa@m17n.org>
parents:
18201
diff
changeset
|
210 (if (not (load (car libraries) t)) |
5c8e37591da5
(quail-current-data): New variable.
Kenichi Handa <handa@m17n.org>
parents:
18201
diff
changeset
|
211 (progn |
5c8e37591da5
(quail-current-data): New variable.
Kenichi Handa <handa@m17n.org>
parents:
18201
diff
changeset
|
212 (with-output-to-temp-buffer "*Help*" |
5c8e37591da5
(quail-current-data): New variable.
Kenichi Handa <handa@m17n.org>
parents:
18201
diff
changeset
|
213 (princ "Quail package \"") |
5c8e37591da5
(quail-current-data): New variable.
Kenichi Handa <handa@m17n.org>
parents:
18201
diff
changeset
|
214 (princ package-name) |
5c8e37591da5
(quail-current-data): New variable.
Kenichi Handa <handa@m17n.org>
parents:
18201
diff
changeset
|
215 (princ "\" can't be activated\n because library \"") |
5c8e37591da5
(quail-current-data): New variable.
Kenichi Handa <handa@m17n.org>
parents:
18201
diff
changeset
|
216 (princ (car libraries)) |
5c8e37591da5
(quail-current-data): New variable.
Kenichi Handa <handa@m17n.org>
parents:
18201
diff
changeset
|
217 (princ "\" is not in `load-path'. |
17052 | 218 |
219 The most common case is that you have not yet installed appropriate | |
220 libraries in LEIM (Libraries of Emacs Input Method) which is | |
221 distributed separately from Emacs. | |
222 | |
223 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
|
224 (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
|
225 (setq libraries (cdr libraries)))))) |
17052 | 226 (quail-select-package package-name) |
227 (setq current-input-method-title (quail-title)) | |
22765
7cf2c3800e8f
(quail-mode): This variable deleted.
Kenichi Handa <handa@m17n.org>
parents:
22124
diff
changeset
|
228 (quail-activate)) |
17052 | 229 |
22917
00f3497854c4
(quail-translation-keymap): Declare it as
Kenichi Handa <handa@m17n.org>
parents:
22883
diff
changeset
|
230 (defvar quail-translation-keymap |
17052 | 231 (let ((map (make-keymap)) |
22917
00f3497854c4
(quail-translation-keymap): Declare it as
Kenichi Handa <handa@m17n.org>
parents:
22883
diff
changeset
|
232 (i 0)) |
00f3497854c4
(quail-translation-keymap): Declare it as
Kenichi Handa <handa@m17n.org>
parents:
22883
diff
changeset
|
233 (while (< i ?\ ) |
00f3497854c4
(quail-translation-keymap): Declare it as
Kenichi Handa <handa@m17n.org>
parents:
22883
diff
changeset
|
234 (define-key map (char-to-string i) 'quail-other-command) |
00f3497854c4
(quail-translation-keymap): Declare it as
Kenichi Handa <handa@m17n.org>
parents:
22883
diff
changeset
|
235 (setq i (1+ i))) |
17052 | 236 (while (< i 127) |
237 (define-key map (char-to-string i) 'quail-self-insert-command) | |
238 (setq i (1+ i))) | |
19647
9b9af28bee8d
(quail-translation-keymap): Do not bind
Kenichi Handa <handa@m17n.org>
parents:
19619
diff
changeset
|
239 (setq i 128) |
19655
47d11f4bbc6c
(quail-translation-keymap): Fix previous
Kenichi Handa <handa@m17n.org>
parents:
19647
diff
changeset
|
240 (while (< i 256) |
19647
9b9af28bee8d
(quail-translation-keymap): Do not bind
Kenichi Handa <handa@m17n.org>
parents:
19619
diff
changeset
|
241 (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
|
242 (setq i (1+ i))) |
17052 | 243 (define-key map "\177" 'quail-delete-last-char) |
244 (define-key map "\C-f" 'quail-next-translation) | |
245 (define-key map "\C-b" 'quail-prev-translation) | |
246 (define-key map "\C-n" 'quail-next-translation-block) | |
247 (define-key map "\C-p" 'quail-prev-translation-block) | |
19987
470e157b3e8a
(quail-translation-keymap): Bind right, left, down, and up keys.
Kenichi Handa <handa@m17n.org>
parents:
19951
diff
changeset
|
248 (define-key map [right] 'quail-next-translation) |
470e157b3e8a
(quail-translation-keymap): Bind right, left, down, and up keys.
Kenichi Handa <handa@m17n.org>
parents:
19951
diff
changeset
|
249 (define-key map [left] 'quail-prev-translation) |
470e157b3e8a
(quail-translation-keymap): Bind right, left, down, and up keys.
Kenichi Handa <handa@m17n.org>
parents:
19951
diff
changeset
|
250 (define-key map [down] 'quail-next-translation-block) |
470e157b3e8a
(quail-translation-keymap): Bind right, left, down, and up keys.
Kenichi Handa <handa@m17n.org>
parents:
19951
diff
changeset
|
251 (define-key map [up] 'quail-prev-translation-block) |
17052 | 252 (define-key map "\C-i" 'quail-completion) |
253 (define-key map "\C-@" 'quail-select-current) | |
20169
d938bdf82445
(quail-translation-keymap): KP_Enter key
Kenichi Handa <handa@m17n.org>
parents:
20160
diff
changeset
|
254 ;; Following simple.el, Enter key on numeric keypad selects the |
d938bdf82445
(quail-translation-keymap): KP_Enter key
Kenichi Handa <handa@m17n.org>
parents:
20160
diff
changeset
|
255 ;; current translation just like `C-SPC', and `mouse-2' chooses |
d938bdf82445
(quail-translation-keymap): KP_Enter key
Kenichi Handa <handa@m17n.org>
parents:
20160
diff
changeset
|
256 ;; any completion visible in the *Quail Completions* buffer. |
d938bdf82445
(quail-translation-keymap): KP_Enter key
Kenichi Handa <handa@m17n.org>
parents:
20160
diff
changeset
|
257 (define-key map [kp-enter] 'quail-select-current) |
d938bdf82445
(quail-translation-keymap): KP_Enter key
Kenichi Handa <handa@m17n.org>
parents:
20160
diff
changeset
|
258 (define-key map [mouse-2] 'quail-mouse-choose-completion) |
d938bdf82445
(quail-translation-keymap): KP_Enter key
Kenichi Handa <handa@m17n.org>
parents:
20160
diff
changeset
|
259 (define-key map [down-mouse-2] nil) |
17052 | 260 (define-key map "\C-h" 'quail-translation-help) |
20638
c3360a392ae4
Change "?\C-\ " to "?\C- " because "\ " is changed
Kenichi Handa <handa@m17n.org>
parents:
20294
diff
changeset
|
261 (define-key map [?\C- ] 'quail-select-current) |
17052 | 262 (define-key map [tab] 'quail-completion) |
263 (define-key map [delete] 'quail-delete-last-char) | |
264 (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
|
265 map) |
19619
b033d0b34c71
(quail-define-package): New arg SIMPLE.
Richard M. Stallman <rms@gnu.org>
parents:
19605
diff
changeset
|
266 "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
|
267 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
|
268 most use `quail-simple-translation-keymap' instead. |
b033d0b34c71
(quail-define-package): New arg SIMPLE.
Richard M. Stallman <rms@gnu.org>
parents:
19605
diff
changeset
|
269 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
|
270 |
22917
00f3497854c4
(quail-translation-keymap): Declare it as
Kenichi Handa <handa@m17n.org>
parents:
22883
diff
changeset
|
271 (defvar quail-simple-translation-keymap |
19619
b033d0b34c71
(quail-define-package): New arg SIMPLE.
Richard M. Stallman <rms@gnu.org>
parents:
19605
diff
changeset
|
272 (let ((map (make-keymap)) |
22917
00f3497854c4
(quail-translation-keymap): Declare it as
Kenichi Handa <handa@m17n.org>
parents:
22883
diff
changeset
|
273 (i 0)) |
00f3497854c4
(quail-translation-keymap): Declare it as
Kenichi Handa <handa@m17n.org>
parents:
22883
diff
changeset
|
274 (while (< i ?\ ) |
00f3497854c4
(quail-translation-keymap): Declare it as
Kenichi Handa <handa@m17n.org>
parents:
22883
diff
changeset
|
275 (define-key map (char-to-string i) 'quail-other-command) |
00f3497854c4
(quail-translation-keymap): Declare it as
Kenichi Handa <handa@m17n.org>
parents:
22883
diff
changeset
|
276 (setq i (1+ i))) |
19619
b033d0b34c71
(quail-define-package): New arg SIMPLE.
Richard M. Stallman <rms@gnu.org>
parents:
19605
diff
changeset
|
277 (while (< i 127) |
b033d0b34c71
(quail-define-package): New arg SIMPLE.
Richard M. Stallman <rms@gnu.org>
parents:
19605
diff
changeset
|
278 (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
|
279 (setq i (1+ i))) |
29073
b46c4dc8c51a
(quail-simple-translation-keymap): Map
Kenichi Handa <handa@m17n.org>
parents:
28213
diff
changeset
|
280 (setq i 128) |
b46c4dc8c51a
(quail-simple-translation-keymap): Map
Kenichi Handa <handa@m17n.org>
parents:
28213
diff
changeset
|
281 (while (< i 256) |
b46c4dc8c51a
(quail-simple-translation-keymap): Map
Kenichi Handa <handa@m17n.org>
parents:
28213
diff
changeset
|
282 (define-key map (vector i) 'quail-self-insert-command) |
b46c4dc8c51a
(quail-simple-translation-keymap): Map
Kenichi Handa <handa@m17n.org>
parents:
28213
diff
changeset
|
283 (setq i (1+ i))) |
19619
b033d0b34c71
(quail-define-package): New arg SIMPLE.
Richard M. Stallman <rms@gnu.org>
parents:
19605
diff
changeset
|
284 (define-key map "\177" 'quail-delete-last-char) |
19951
820fc18dd520
(quail-simple-translation-keymap):
Richard M. Stallman <rms@gnu.org>
parents:
19949
diff
changeset
|
285 (define-key map [delete] 'quail-delete-last-char) |
820fc18dd520
(quail-simple-translation-keymap):
Richard M. Stallman <rms@gnu.org>
parents:
19949
diff
changeset
|
286 (define-key map [backspace] 'quail-delete-last-char) |
22917
00f3497854c4
(quail-translation-keymap): Declare it as
Kenichi Handa <handa@m17n.org>
parents:
22883
diff
changeset
|
287 ;;(let ((meta-map (make-sparse-keymap))) |
00f3497854c4
(quail-translation-keymap): Declare it as
Kenichi Handa <handa@m17n.org>
parents:
22883
diff
changeset
|
288 ;;(define-key map (char-to-string meta-prefix-char) meta-map) |
00f3497854c4
(quail-translation-keymap): Declare it as
Kenichi Handa <handa@m17n.org>
parents:
22883
diff
changeset
|
289 ;;(define-key map [escape] meta-map)) |
19878
a69ae37e6932
(quail-update-translation): Fix previous change.
Richard M. Stallman <rms@gnu.org>
parents:
19849
diff
changeset
|
290 map) |
19619
b033d0b34c71
(quail-define-package): New arg SIMPLE.
Richard M. Stallman <rms@gnu.org>
parents:
19605
diff
changeset
|
291 "Keymap used while processing translation in simple Quail modes. |
22793
c3ab1de66dfc
(quail-simple-translation-keymap): Typo
Kenichi Handa <handa@m17n.org>
parents:
22777
diff
changeset
|
292 A few especially complex input methods use `quail-translation-keymap' instead. |
17052 | 293 This map is activated while translation region is active.") |
294 | |
22917
00f3497854c4
(quail-translation-keymap): Declare it as
Kenichi Handa <handa@m17n.org>
parents:
22883
diff
changeset
|
295 (defvar quail-conversion-keymap |
17052 | 296 (let ((map (make-keymap)) |
22765
7cf2c3800e8f
(quail-mode): This variable deleted.
Kenichi Handa <handa@m17n.org>
parents:
22124
diff
changeset
|
297 (i ?\ )) |
17052 | 298 (while (< i 127) |
22765
7cf2c3800e8f
(quail-mode): This variable deleted.
Kenichi Handa <handa@m17n.org>
parents:
22124
diff
changeset
|
299 (define-key map (char-to-string i) 'quail-self-insert-command) |
17052 | 300 (setq i (1+ i))) |
19647
9b9af28bee8d
(quail-translation-keymap): Do not bind
Kenichi Handa <handa@m17n.org>
parents:
19619
diff
changeset
|
301 (setq i 128) |
19655
47d11f4bbc6c
(quail-translation-keymap): Fix previous
Kenichi Handa <handa@m17n.org>
parents:
19647
diff
changeset
|
302 (while (< i 256) |
22765
7cf2c3800e8f
(quail-mode): This variable deleted.
Kenichi Handa <handa@m17n.org>
parents:
22124
diff
changeset
|
303 (define-key map (vector i) 'quail-self-insert-command) |
19647
9b9af28bee8d
(quail-translation-keymap): Do not bind
Kenichi Handa <handa@m17n.org>
parents:
19619
diff
changeset
|
304 (setq i (1+ i))) |
17052 | 305 (define-key map "\C-b" 'quail-conversion-backward-char) |
306 (define-key map "\C-f" 'quail-conversion-forward-char) | |
307 (define-key map "\C-a" 'quail-conversion-beginning-of-region) | |
308 (define-key map "\C-e" 'quail-conversion-end-of-region) | |
309 (define-key map "\C-d" 'quail-conversion-delete-char) | |
22777
1b0761cbc15b
(quail-conversion-keymap): New binding
Kenichi Handa <handa@m17n.org>
parents:
22765
diff
changeset
|
310 (define-key map "\C-k" 'quail-conversion-delete-tail) |
22917
00f3497854c4
(quail-translation-keymap): Declare it as
Kenichi Handa <handa@m17n.org>
parents:
22883
diff
changeset
|
311 (define-key map "\C-h" 'quail-translation-help) |
17052 | 312 (define-key map "\177" 'quail-conversion-backward-delete-char) |
313 (define-key map [delete] 'quail-conversion-backward-delete-char) | |
314 (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
|
315 map) |
17052 | 316 "Keymap used for processing conversion in Quail mode. |
23176 | 317 This map is activated while conversion region is active but translation |
17052 | 318 region is not active.") |
319 | |
18297
5c8e37591da5
(quail-current-data): New variable.
Kenichi Handa <handa@m17n.org>
parents:
18201
diff
changeset
|
320 ;;;###autoload |
17052 | 321 (defun quail-define-package (name language title |
322 &optional guidance docstring translation-keys | |
323 forget-last-selection deterministic | |
324 kbd-translate show-layout create-decode-map | |
325 maximum-shortest overlay-plist | |
326 update-translation-function | |
19619
b033d0b34c71
(quail-define-package): New arg SIMPLE.
Richard M. Stallman <rms@gnu.org>
parents:
19605
diff
changeset
|
327 conversion-keys simple) |
17052 | 328 "Define NAME as a new Quail package for input LANGUAGE. |
329 TITLE is a string to be displayed at mode-line to indicate this package. | |
22917
00f3497854c4
(quail-translation-keymap): Declare it as
Kenichi Handa <handa@m17n.org>
parents:
22883
diff
changeset
|
330 Optional arguments are GUIDANCE, DOCSTRING, TRANSLATION-KEYS, |
17052 | 331 FORGET-LAST-SELECTION, DETERMINISTIC, KBD-TRANSLATE, SHOW-LAYOUT, |
332 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
|
333 UPDATE-TRANSLATION-FUNCTION, CONVERSION-KEYS and SIMPLE. |
17052 | 334 |
335 GUIDANCE specifies how a guidance string is shown in echo area. | |
336 If it is t, list of all possible translations for the current key is shown | |
337 with the currently selected translation being highlighted. | |
338 If it is an alist, the element has the form (CHAR . STRING). Each character | |
339 in the current key is searched in the list and the corresponding string is | |
340 shown. | |
341 If it is nil, the current key is shown. | |
342 | |
343 DOCSTRING is the documentation string of this package. | |
344 | |
345 TRANSLATION-KEYS specifies additional key bindings used while translation | |
346 region is active. It is an alist of single key character vs. corresponding | |
347 command to be called. | |
348 | |
349 FORGET-LAST-SELECTION non-nil means a selected translation is not kept | |
350 for the future to translate the same key. If this flag is nil, a | |
351 translation selected for a key is remembered so that it can be the | |
352 first candidate when the same key is entered later. | |
353 | |
354 DETERMINISTIC non-nil means the first candidate of translation is | |
355 selected automatically without allowing users to select another | |
356 translation for a key. In this case, unselected translations are of | |
357 no use for an interactive use of Quail but can be used by some other | |
358 programs. If this flag is non-nil, FORGET-LAST-SELECTION is also set | |
359 to t. | |
360 | |
361 KBD-TRANSLATE non-nil means input characters are translated from a | |
362 user's keyboard layout to the standard keyboard layout. See the | |
363 documentation of `quail-keyboard-layout' and | |
364 `quail-keyboard-layout-standard' for more detail. | |
365 | |
366 SHOW-LAYOUT non-nil means the `quail-help' command should show | |
367 the user's keyboard layout visually with translated characters. | |
368 If KBD-TRANSLATE is set, it is desirable to set also this flag unless | |
369 this package defines no translations for single character keys. | |
370 | |
371 CREATE-DECODE-MAP non-nil means decode map is also created. A decode | |
372 map is an alist of translations and corresponding original keys. | |
373 Although this map is not used by Quail itself, it can be used by some | |
374 other programs. For instance, Vietnamese supporting needs this map to | |
375 convert Vietnamese text to VIQR format which uses only ASCII | |
376 characters to represent Vietnamese characters. | |
377 | |
378 MAXIMUM-SHORTEST non-nil means break key sequence to get maximum | |
379 length of the shortest sequence. When we don't have a translation of | |
380 key \"..ABCD\" but have translations of \"..AB\" and \"CD..\", break | |
381 the key at \"..AB\" and start translation of \"CD..\". Hangul | |
382 packages, for instance, use this facility. If this flag is nil, we | |
383 break the key just at \"..ABC\" and start translation of \"D..\". | |
384 | |
385 OVERLAY-PLIST if non-nil is a property list put on an overlay which | |
386 covers Quail translation region. | |
387 | |
388 UPDATE-TRANSLATION-FUNCTION if non-nil is a function to call to update | |
23176 | 389 the current translation region according to a new translation data. By |
390 default, a translated text or a user's key sequence (if no translation | |
17052 | 391 for it) is inserted. |
392 | |
393 CONVERSION-KEYS specifies additional key bindings used while | |
394 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
|
395 vs. corresponding command to be called. |
b033d0b34c71
(quail-define-package): New arg SIMPLE.
Richard M. Stallman <rms@gnu.org>
parents:
19605
diff
changeset
|
396 |
b033d0b34c71
(quail-define-package): New arg SIMPLE.
Richard M. Stallman <rms@gnu.org>
parents:
19605
diff
changeset
|
397 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
|
398 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
|
399 non-Quail commands." |
17052 | 400 (let (translation-keymap conversion-keymap) |
401 (if deterministic (setq forget-last-selection t)) | |
402 (if translation-keys | |
19404
8901359ae445
(quail-inactivate): Turn Quail mode off
Kenichi Handa <handa@m17n.org>
parents:
19391
diff
changeset
|
403 (progn |
19619
b033d0b34c71
(quail-define-package): New arg SIMPLE.
Richard M. Stallman <rms@gnu.org>
parents:
19605
diff
changeset
|
404 (setq translation-keymap (copy-keymap |
b033d0b34c71
(quail-define-package): New arg SIMPLE.
Richard M. Stallman <rms@gnu.org>
parents:
19605
diff
changeset
|
405 (if simple quail-simple-translation-keymap |
b033d0b34c71
(quail-define-package): New arg SIMPLE.
Richard M. Stallman <rms@gnu.org>
parents:
19605
diff
changeset
|
406 quail-translation-keymap))) |
19404
8901359ae445
(quail-inactivate): Turn Quail mode off
Kenichi Handa <handa@m17n.org>
parents:
19391
diff
changeset
|
407 (while translation-keys |
8901359ae445
(quail-inactivate): Turn Quail mode off
Kenichi Handa <handa@m17n.org>
parents:
19391
diff
changeset
|
408 (define-key translation-keymap |
8901359ae445
(quail-inactivate): Turn Quail mode off
Kenichi Handa <handa@m17n.org>
parents:
19391
diff
changeset
|
409 (car (car translation-keys)) (cdr (car translation-keys))) |
8901359ae445
(quail-inactivate): Turn Quail mode off
Kenichi Handa <handa@m17n.org>
parents:
19391
diff
changeset
|
410 (setq translation-keys (cdr translation-keys)))) |
19619
b033d0b34c71
(quail-define-package): New arg SIMPLE.
Richard M. Stallman <rms@gnu.org>
parents:
19605
diff
changeset
|
411 (setq translation-keymap |
b033d0b34c71
(quail-define-package): New arg SIMPLE.
Richard M. Stallman <rms@gnu.org>
parents:
19605
diff
changeset
|
412 (if simple quail-simple-translation-keymap |
b033d0b34c71
(quail-define-package): New arg SIMPLE.
Richard M. Stallman <rms@gnu.org>
parents:
19605
diff
changeset
|
413 quail-translation-keymap))) |
19404
8901359ae445
(quail-inactivate): Turn Quail mode off
Kenichi Handa <handa@m17n.org>
parents:
19391
diff
changeset
|
414 (when conversion-keys |
8901359ae445
(quail-inactivate): Turn Quail mode off
Kenichi Handa <handa@m17n.org>
parents:
19391
diff
changeset
|
415 (setq conversion-keymap (copy-keymap quail-conversion-keymap)) |
8901359ae445
(quail-inactivate): Turn Quail mode off
Kenichi Handa <handa@m17n.org>
parents:
19391
diff
changeset
|
416 (while conversion-keys |
8901359ae445
(quail-inactivate): Turn Quail mode off
Kenichi Handa <handa@m17n.org>
parents:
19391
diff
changeset
|
417 (define-key conversion-keymap |
8901359ae445
(quail-inactivate): Turn Quail mode off
Kenichi Handa <handa@m17n.org>
parents:
19391
diff
changeset
|
418 (car (car conversion-keys)) (cdr (car conversion-keys))) |
8901359ae445
(quail-inactivate): Turn Quail mode off
Kenichi Handa <handa@m17n.org>
parents:
19391
diff
changeset
|
419 (setq conversion-keys (cdr conversion-keys)))) |
17052 | 420 (quail-add-package |
421 (list name title (list nil) guidance (or docstring "") | |
422 translation-keymap | |
423 forget-last-selection deterministic kbd-translate show-layout | |
424 (if create-decode-map (list 'decode-map) nil) | |
425 maximum-shortest overlay-plist update-translation-function | |
19849
1c5164d81426
(quail-simple): New function.
Kenichi Handa <handa@m17n.org>
parents:
19844
diff
changeset
|
426 conversion-keymap simple)) |
18556
99e8ae18137f
(quail-guidance-buf): Make it buffer
Kenichi Handa <handa@m17n.org>
parents:
18377
diff
changeset
|
427 |
99e8ae18137f
(quail-guidance-buf): Make it buffer
Kenichi Handa <handa@m17n.org>
parents:
18377
diff
changeset
|
428 ;; Update input-method-alist. |
99e8ae18137f
(quail-guidance-buf): Make it buffer
Kenichi Handa <handa@m17n.org>
parents:
18377
diff
changeset
|
429 (let ((slot (assoc name input-method-alist)) |
99e8ae18137f
(quail-guidance-buf): Make it buffer
Kenichi Handa <handa@m17n.org>
parents:
18377
diff
changeset
|
430 (val (list language 'quail-use-package title docstring))) |
99e8ae18137f
(quail-guidance-buf): Make it buffer
Kenichi Handa <handa@m17n.org>
parents:
18377
diff
changeset
|
431 (if slot (setcdr slot val) |
99e8ae18137f
(quail-guidance-buf): Make it buffer
Kenichi Handa <handa@m17n.org>
parents:
18377
diff
changeset
|
432 (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
|
433 |
17052 | 434 (quail-select-package name)) |
435 | |
436 ;; Quail minor mode handlers. | |
437 | |
438 ;; Setup overlays used in Quail mode. | |
19404
8901359ae445
(quail-inactivate): Turn Quail mode off
Kenichi Handa <handa@m17n.org>
parents:
19391
diff
changeset
|
439 (defun quail-setup-overlays (conversion-mode) |
17052 | 440 (let ((pos (point))) |
441 (if (overlayp quail-overlay) | |
442 (move-overlay quail-overlay pos pos) | |
443 (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
|
444 (if input-method-highlight-flag |
8901359ae445
(quail-inactivate): Turn Quail mode off
Kenichi Handa <handa@m17n.org>
parents:
19391
diff
changeset
|
445 (overlay-put quail-overlay 'face 'underline)) |
17052 | 446 (let ((l (quail-overlay-plist))) |
447 (while l | |
448 (overlay-put quail-overlay (car l) (car (cdr l))) | |
449 (setq l (cdr (cdr l)))))) | |
19404
8901359ae445
(quail-inactivate): Turn Quail mode off
Kenichi Handa <handa@m17n.org>
parents:
19391
diff
changeset
|
450 (if conversion-mode |
8901359ae445
(quail-inactivate): Turn Quail mode off
Kenichi Handa <handa@m17n.org>
parents:
19391
diff
changeset
|
451 (if (overlayp quail-conv-overlay) |
8901359ae445
(quail-inactivate): Turn Quail mode off
Kenichi Handa <handa@m17n.org>
parents:
19391
diff
changeset
|
452 (if (not (overlay-start quail-conv-overlay)) |
8901359ae445
(quail-inactivate): Turn Quail mode off
Kenichi Handa <handa@m17n.org>
parents:
19391
diff
changeset
|
453 (move-overlay quail-conv-overlay pos pos)) |
8901359ae445
(quail-inactivate): Turn Quail mode off
Kenichi Handa <handa@m17n.org>
parents:
19391
diff
changeset
|
454 (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
|
455 (if input-method-highlight-flag |
8901359ae445
(quail-inactivate): Turn Quail mode off
Kenichi Handa <handa@m17n.org>
parents:
19391
diff
changeset
|
456 (overlay-put quail-conv-overlay 'face 'underline)))))) |
17052 | 457 |
458 ;; Delete overlays used in Quail mode. | |
459 (defun quail-delete-overlays () | |
22765
7cf2c3800e8f
(quail-mode): This variable deleted.
Kenichi Handa <handa@m17n.org>
parents:
22124
diff
changeset
|
460 (if (and (overlayp quail-overlay) (overlay-start quail-overlay)) |
17052 | 461 (delete-overlay quail-overlay)) |
22765
7cf2c3800e8f
(quail-mode): This variable deleted.
Kenichi Handa <handa@m17n.org>
parents:
22124
diff
changeset
|
462 (if (and (overlayp quail-conv-overlay) (overlay-start quail-conv-overlay)) |
17052 | 463 (delete-overlay quail-conv-overlay))) |
464 | |
19432
4492653b04e8
(quail-exit-from-minibuffer): Call
Kenichi Handa <handa@m17n.org>
parents:
19404
diff
changeset
|
465 ;; Kill Quail guidance buffer. Set in kill-buffer-hook. |
4492653b04e8
(quail-exit-from-minibuffer): Call
Kenichi Handa <handa@m17n.org>
parents:
19404
diff
changeset
|
466 (defun quail-kill-guidance-buf () |
4492653b04e8
(quail-exit-from-minibuffer): Call
Kenichi Handa <handa@m17n.org>
parents:
19404
diff
changeset
|
467 (if (buffer-live-p quail-guidance-buf) |
4492653b04e8
(quail-exit-from-minibuffer): Call
Kenichi Handa <handa@m17n.org>
parents:
19404
diff
changeset
|
468 (kill-buffer quail-guidance-buf))) |
4492653b04e8
(quail-exit-from-minibuffer): Call
Kenichi Handa <handa@m17n.org>
parents:
19404
diff
changeset
|
469 |
22765
7cf2c3800e8f
(quail-mode): This variable deleted.
Kenichi Handa <handa@m17n.org>
parents:
22124
diff
changeset
|
470 (defun quail-inactivate () |
7cf2c3800e8f
(quail-mode): This variable deleted.
Kenichi Handa <handa@m17n.org>
parents:
22124
diff
changeset
|
471 "Inactivate Quail input method." |
7cf2c3800e8f
(quail-mode): This variable deleted.
Kenichi Handa <handa@m17n.org>
parents:
22124
diff
changeset
|
472 (interactive) |
7cf2c3800e8f
(quail-mode): This variable deleted.
Kenichi Handa <handa@m17n.org>
parents:
22124
diff
changeset
|
473 (quail-activate -1)) |
7cf2c3800e8f
(quail-mode): This variable deleted.
Kenichi Handa <handa@m17n.org>
parents:
22124
diff
changeset
|
474 |
7cf2c3800e8f
(quail-mode): This variable deleted.
Kenichi Handa <handa@m17n.org>
parents:
22124
diff
changeset
|
475 (defun quail-activate (&optional arg) |
7cf2c3800e8f
(quail-mode): This variable deleted.
Kenichi Handa <handa@m17n.org>
parents:
22124
diff
changeset
|
476 "Activate Quail input method. |
7cf2c3800e8f
(quail-mode): This variable deleted.
Kenichi Handa <handa@m17n.org>
parents:
22124
diff
changeset
|
477 With arg, activate Quail input method if and only if arg is positive. |
19432
4492653b04e8
(quail-exit-from-minibuffer): Call
Kenichi Handa <handa@m17n.org>
parents:
19404
diff
changeset
|
478 |
22765
7cf2c3800e8f
(quail-mode): This variable deleted.
Kenichi Handa <handa@m17n.org>
parents:
22124
diff
changeset
|
479 While this input method is active, the variable |
7cf2c3800e8f
(quail-mode): This variable deleted.
Kenichi Handa <handa@m17n.org>
parents:
22124
diff
changeset
|
480 `input-method-function' is bound to the function `quail-input-method'." |
7cf2c3800e8f
(quail-mode): This variable deleted.
Kenichi Handa <handa@m17n.org>
parents:
22124
diff
changeset
|
481 (if (and arg |
7cf2c3800e8f
(quail-mode): This variable deleted.
Kenichi Handa <handa@m17n.org>
parents:
22124
diff
changeset
|
482 (< (prefix-numeric-value arg) 0)) |
7cf2c3800e8f
(quail-mode): This variable deleted.
Kenichi Handa <handa@m17n.org>
parents:
22124
diff
changeset
|
483 ;; Let's inactivate Quail input method. |
7cf2c3800e8f
(quail-mode): This variable deleted.
Kenichi Handa <handa@m17n.org>
parents:
22124
diff
changeset
|
484 (unwind-protect |
7cf2c3800e8f
(quail-mode): This variable deleted.
Kenichi Handa <handa@m17n.org>
parents:
22124
diff
changeset
|
485 (progn |
7cf2c3800e8f
(quail-mode): This variable deleted.
Kenichi Handa <handa@m17n.org>
parents:
22124
diff
changeset
|
486 (quail-hide-guidance-buf) |
7cf2c3800e8f
(quail-mode): This variable deleted.
Kenichi Handa <handa@m17n.org>
parents:
22124
diff
changeset
|
487 (quail-delete-overlays) |
7cf2c3800e8f
(quail-mode): This variable deleted.
Kenichi Handa <handa@m17n.org>
parents:
22124
diff
changeset
|
488 (setq describe-current-input-method-function nil) |
7cf2c3800e8f
(quail-mode): This variable deleted.
Kenichi Handa <handa@m17n.org>
parents:
22124
diff
changeset
|
489 (run-hooks 'quail-inactivate-hook)) |
7cf2c3800e8f
(quail-mode): This variable deleted.
Kenichi Handa <handa@m17n.org>
parents:
22124
diff
changeset
|
490 (kill-local-variable 'input-method-function)) |
7cf2c3800e8f
(quail-mode): This variable deleted.
Kenichi Handa <handa@m17n.org>
parents:
22124
diff
changeset
|
491 ;; Let's active Quail input method. |
17052 | 492 (if (null quail-current-package) |
493 ;; Quail package is not yet selected. Select one now. | |
494 (let (name) | |
495 (if quail-package-alist | |
496 (setq name (car (car quail-package-alist))) | |
497 (error "No Quail package loaded")) | |
498 (quail-select-package name))) | |
19404
8901359ae445
(quail-inactivate): Turn Quail mode off
Kenichi Handa <handa@m17n.org>
parents:
19391
diff
changeset
|
499 (setq inactivate-current-input-method-function 'quail-inactivate) |
17052 | 500 (setq describe-current-input-method-function 'quail-help) |
501 (quail-delete-overlays) | |
502 (quail-show-guidance-buf) | |
19432
4492653b04e8
(quail-exit-from-minibuffer): Call
Kenichi Handa <handa@m17n.org>
parents:
19404
diff
changeset
|
503 ;; 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
|
504 ;; before exiting. |
17052 | 505 (if (eq (selected-window) (minibuffer-window)) |
506 (add-hook 'minibuffer-exit-hook 'quail-exit-from-minibuffer)) | |
19432
4492653b04e8
(quail-exit-from-minibuffer): Call
Kenichi Handa <handa@m17n.org>
parents:
19404
diff
changeset
|
507 (make-local-hook 'kill-buffer-hook) |
4492653b04e8
(quail-exit-from-minibuffer): Call
Kenichi Handa <handa@m17n.org>
parents:
19404
diff
changeset
|
508 (add-hook 'kill-buffer-hook 'quail-kill-guidance-buf nil t) |
22765
7cf2c3800e8f
(quail-mode): This variable deleted.
Kenichi Handa <handa@m17n.org>
parents:
22124
diff
changeset
|
509 (run-hooks 'quail-activate-hook) |
7cf2c3800e8f
(quail-mode): This variable deleted.
Kenichi Handa <handa@m17n.org>
parents:
22124
diff
changeset
|
510 (make-local-variable 'input-method-function) |
7cf2c3800e8f
(quail-mode): This variable deleted.
Kenichi Handa <handa@m17n.org>
parents:
22124
diff
changeset
|
511 (setq input-method-function 'quail-input-method))) |
17052 | 512 |
513 (defun quail-exit-from-minibuffer () | |
19432
4492653b04e8
(quail-exit-from-minibuffer): Call
Kenichi Handa <handa@m17n.org>
parents:
19404
diff
changeset
|
514 (inactivate-input-method) |
17052 | 515 (if (<= (minibuffer-depth) 1) |
516 (remove-hook 'minibuffer-exit-hook 'quail-exit-from-minibuffer))) | |
517 | |
518 ;; Keyboard layout translation handlers. | |
519 | |
520 ;; Some Quail packages provide localized keyboard simulation which | |
521 ;; requires a particular keyboard layout. In this case, what we need | |
522 ;; is locations of keys the user entered, not character codes | |
523 ;; generated by those keys. However, for the moment, there's no | |
524 ;; common way to get such information. So, we ask a user to give | |
525 ;; information of his own keyboard layout, then translate it to the | |
526 ;; standard layout which we defined so that all Quail packages depend | |
527 ;; just on it. | |
528 | |
529 (defconst quail-keyboard-layout-standard | |
530 "\ | |
17174
9c1191812679
(quail-translation-keymap): Add entry for escape key.
Kenichi Handa <handa@m17n.org>
parents:
17095
diff
changeset
|
531 \ |
17052 | 532 1!2@3#4$5%6^7&8*9(0)-_=+`~ \ |
533 qQwWeErRtTyYuUiIoOpP[{]} \ | |
534 aAsSdDfFgGhHjJkKlL;:'\"\\| \ | |
17174
9c1191812679
(quail-translation-keymap): Add entry for escape key.
Kenichi Handa <handa@m17n.org>
parents:
17095
diff
changeset
|
535 zZxXcCvVbBnNmM,<.>/? \ |
9c1191812679
(quail-translation-keymap): Add entry for escape key.
Kenichi Handa <handa@m17n.org>
parents:
17095
diff
changeset
|
536 " |
17052 | 537 "Standard keyboard layout of printable characters Quail assumes. |
538 See the documentation of `quail-keyboard-layout' for this format. | |
539 This layout is almost the same as that of VT100, | |
540 but the location of key \\ (backslash) is just right of key ' (single-quote), | |
541 not right of RETURN key.") | |
542 | |
543 (defvar quail-keyboard-layout quail-keyboard-layout-standard | |
544 "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
|
545 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
|
546 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
|
547 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
|
548 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
|
549 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
|
550 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
|
551 the sixth row is below the `z' - `/' row. |
17052 | 552 Nth (N is even) and (N+1)th characters in the string are non-shifted |
553 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
|
554 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
|
555 The command `quail-set-keyboard-layout' usually sets this variable.") |
17052 | 556 |
17174
9c1191812679
(quail-translation-keymap): Add entry for escape key.
Kenichi Handa <handa@m17n.org>
parents:
17095
diff
changeset
|
557 (defconst quail-keyboard-layout-len 180) |
17052 | 558 |
559 ;; Here we provide several examples of famous keyboard layouts. | |
560 | |
561 (defvar quail-keyboard-layout-alist | |
562 (list | |
563 '("sun-type3" . "\ | |
17174
9c1191812679
(quail-translation-keymap): Add entry for escape key.
Kenichi Handa <handa@m17n.org>
parents:
17095
diff
changeset
|
564 \ |
17052 | 565 1!2@3#4$5%6^7&8*9(0)-_=+\\|`~\ |
566 qQwWeErRtTyYuUiIoOpP[{]} \ | |
567 aAsSdDfFgGhHjJkKlL;:'\" \ | |
17174
9c1191812679
(quail-translation-keymap): Add entry for escape key.
Kenichi Handa <handa@m17n.org>
parents:
17095
diff
changeset
|
568 zZxXcCvVbBnNmM,<.>/? \ |
9c1191812679
(quail-translation-keymap): Add entry for escape key.
Kenichi Handa <handa@m17n.org>
parents:
17095
diff
changeset
|
569 ") |
19675
32c3f7d9ef10
(quail-keyboard-layout-alist): Add an
Kenichi Handa <handa@m17n.org>
parents:
19655
diff
changeset
|
570 '("atari-german" . "\ |
32c3f7d9ef10
(quail-keyboard-layout-alist): Add an
Kenichi Handa <handa@m17n.org>
parents:
19655
diff
changeset
|
571 \ |
32c3f7d9ef10
(quail-keyboard-layout-alist): Add an
Kenichi Handa <handa@m17n.org>
parents:
19655
diff
changeset
|
572 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
|
573 qQwWeErRtTzZuUiIoOpP\374\334+* \ |
32c3f7d9ef10
(quail-keyboard-layout-alist): Add an
Kenichi Handa <handa@m17n.org>
parents:
19655
diff
changeset
|
574 aAsSdDfFgGhHjJkKlL\366\326\344\304~| \ |
32c3f7d9ef10
(quail-keyboard-layout-alist): Add an
Kenichi Handa <handa@m17n.org>
parents:
19655
diff
changeset
|
575 <>yYxXcCvVbBnNmM,;.:-_ \ |
32c3f7d9ef10
(quail-keyboard-layout-alist): Add an
Kenichi Handa <handa@m17n.org>
parents:
19655
diff
changeset
|
576 ") |
29073
b46c4dc8c51a
(quail-simple-translation-keymap): Map
Kenichi Handa <handa@m17n.org>
parents:
28213
diff
changeset
|
577 |
b46c4dc8c51a
(quail-simple-translation-keymap): Map
Kenichi Handa <handa@m17n.org>
parents:
28213
diff
changeset
|
578 '("pc102-de" . "\ |
b46c4dc8c51a
(quail-simple-translation-keymap): Map
Kenichi Handa <handa@m17n.org>
parents:
28213
diff
changeset
|
579 \ |
b46c4dc8c51a
(quail-simple-translation-keymap): Map
Kenichi Handa <handa@m17n.org>
parents:
28213
diff
changeset
|
580 ^\2601!2\"3\2474$5%6&7/8(9)0=\337?\264`#' \ |
b46c4dc8c51a
(quail-simple-translation-keymap): Map
Kenichi Handa <handa@m17n.org>
parents:
28213
diff
changeset
|
581 qQwWeErRtTzZuUiIoOpP\374\334+* \ |
b46c4dc8c51a
(quail-simple-translation-keymap): Map
Kenichi Handa <handa@m17n.org>
parents:
28213
diff
changeset
|
582 aAsSdDfFgGhHjJkKlL\366\326\344\304 \ |
b46c4dc8c51a
(quail-simple-translation-keymap): Map
Kenichi Handa <handa@m17n.org>
parents:
28213
diff
changeset
|
583 <>yYxXcCvVbBnNmM,;.:-_ \ |
b46c4dc8c51a
(quail-simple-translation-keymap): Map
Kenichi Handa <handa@m17n.org>
parents:
28213
diff
changeset
|
584 ") |
b46c4dc8c51a
(quail-simple-translation-keymap): Map
Kenichi Handa <handa@m17n.org>
parents:
28213
diff
changeset
|
585 |
17052 | 586 (cons "standard" quail-keyboard-layout-standard)) |
587 "Alist of keyboard names and corresponding layout strings. | |
588 See the documentation of `quail-keyboard-layout' for the format of | |
589 the layout string.") | |
590 | |
19949
ad6d3d0b2cb4
(quail-set-keyboard-layout): Add autoload cookie.
Richard M. Stallman <rms@gnu.org>
parents:
19944
diff
changeset
|
591 ;;;###autoload |
17052 | 592 (defun quail-set-keyboard-layout (kbd-type) |
593 "Set the current keyboard layout to the same as keyboard KBD-TYPE. | |
594 | |
595 Since some Quail packages depends on a physical layout of keys (not | |
596 characters generated by them), those are created by assuming the | |
597 standard layout defined in `quail-keyboard-layout-standard'. This | |
598 function tells Quail system the layout of your keyboard so that what | |
599 you type is correctly handled." | |
600 (interactive | |
28213
2851f83ea432
(quail-set-keyboard-layout): Typo fixed.
Kenichi Handa <handa@m17n.org>
parents:
26891
diff
changeset
|
601 (let* ((completion-ignore-case t) |
17052 | 602 (type (completing-read "Keyboard type: " |
603 quail-keyboard-layout-alist))) | |
604 (list type))) | |
605 (let ((layout (assoc kbd-type quail-keyboard-layout-alist))) | |
606 (if (null layout) | |
607 ;; Here, we had better ask a user to define his own keyboard | |
608 ;; layout interactively. | |
609 (error "Unknown keyboard type `%s'" kbd-type)) | |
610 (setq quail-keyboard-layout (cdr layout)))) | |
611 | |
612 (defun quail-keyboard-translate (ch) | |
613 "Translate CHAR according to `quail-keyboard-layout' and return the result." | |
614 (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
|
615 ;; All Quail packages are designed based on |
32c3f7d9ef10
(quail-keyboard-layout-alist): Add an
Kenichi Handa <handa@m17n.org>
parents:
19655
diff
changeset
|
616 ;; `quail-keyboard-layout-standard'. |
17052 | 617 ch |
618 (let ((i 0)) | |
619 (while (and (< i quail-keyboard-layout-len) | |
620 (/= ch (aref quail-keyboard-layout i))) | |
621 (setq i (1+ i))) | |
622 (if (= i quail-keyboard-layout-len) | |
19675
32c3f7d9ef10
(quail-keyboard-layout-alist): Add an
Kenichi Handa <handa@m17n.org>
parents:
19655
diff
changeset
|
623 ;; 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
|
624 ;; 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
|
625 ;; 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
|
626 ;; quail-execute-non-quail-command handle it correctly. |
32c3f7d9ef10
(quail-keyboard-layout-alist): Add an
Kenichi Handa <handa@m17n.org>
parents:
19655
diff
changeset
|
627 ch |
32c3f7d9ef10
(quail-keyboard-layout-alist): Add an
Kenichi Handa <handa@m17n.org>
parents:
19655
diff
changeset
|
628 (let ((char (aref quail-keyboard-layout-standard i))) |
32c3f7d9ef10
(quail-keyboard-layout-alist): Add an
Kenichi Handa <handa@m17n.org>
parents:
19655
diff
changeset
|
629 (if (= char ?\ ) |
23176 | 630 ;; A user typed a key at the location not converted by |
19675
32c3f7d9ef10
(quail-keyboard-layout-alist): Add an
Kenichi Handa <handa@m17n.org>
parents:
19655
diff
changeset
|
631 ;; quail-keyboard-layout-standard. Just return CH as |
32c3f7d9ef10
(quail-keyboard-layout-alist): Add an
Kenichi Handa <handa@m17n.org>
parents:
19655
diff
changeset
|
632 ;; well as above. |
32c3f7d9ef10
(quail-keyboard-layout-alist): Add an
Kenichi Handa <handa@m17n.org>
parents:
19655
diff
changeset
|
633 ch |
32c3f7d9ef10
(quail-keyboard-layout-alist): Add an
Kenichi Handa <handa@m17n.org>
parents:
19655
diff
changeset
|
634 char)))))) |
17052 | 635 |
636 ;; Quail map | |
637 | |
638 (defsubst quail-map-p (object) | |
639 "Return t if OBJECT is a Quail map. | |
640 | |
641 A Quail map holds information how a particular key should be translated. | |
642 Its format is (TRANSLATION . ALIST). | |
643 TRANSLATION is either a character, or a cons (INDEX . VECTOR). | |
644 In the latter case, each element of VECTOR is a candidate for the translation, | |
645 and INDEX points the currently selected translation. | |
646 | |
647 ALIST is normally a list of elements that look like (CHAR . DEFN), | |
648 where DEFN is another Quail map for a longer key (CHAR added to the | |
649 current key). It may also be a symbol of a function which returns an | |
650 alist of the above format. | |
651 | |
652 Just after a Quail package is read, TRANSLATION may be a string or a | |
653 vector. Then each element of the string or vector is a candidate for | |
654 the translation. These objects are transformed to cons cells in the | |
655 format \(INDEX . VECTOR), as described above." | |
656 (and (consp object) | |
657 (let ((translation (car object))) | |
18297
5c8e37591da5
(quail-current-data): New variable.
Kenichi Handa <handa@m17n.org>
parents:
18201
diff
changeset
|
658 (or (integerp translation) (null translation) |
17052 | 659 (vectorp translation) (stringp translation) |
18297
5c8e37591da5
(quail-current-data): New variable.
Kenichi Handa <handa@m17n.org>
parents:
18201
diff
changeset
|
660 (symbolp translation) |
5c8e37591da5
(quail-current-data): New variable.
Kenichi Handa <handa@m17n.org>
parents:
18201
diff
changeset
|
661 (and (consp translation) (not (vectorp (cdr translation)))))) |
17052 | 662 (let ((alist (cdr object))) |
18297
5c8e37591da5
(quail-current-data): New variable.
Kenichi Handa <handa@m17n.org>
parents:
18201
diff
changeset
|
663 (or (and (listp alist) (consp (car alist))) |
5c8e37591da5
(quail-current-data): New variable.
Kenichi Handa <handa@m17n.org>
parents:
18201
diff
changeset
|
664 (symbolp alist))))) |
17052 | 665 |
18297
5c8e37591da5
(quail-current-data): New variable.
Kenichi Handa <handa@m17n.org>
parents:
18201
diff
changeset
|
666 ;;;###autoload |
17052 | 667 (defmacro quail-define-rules (&rest rules) |
668 "Define translation rules of the current Quail package. | |
669 Each argument is a list of KEY and TRANSLATION. | |
670 KEY is a string meaning a sequence of keystrokes to be translated. | |
671 TRANSLATION is a character, a string, a vector, a Quail map, or a function. | |
24821
7f6aadd2625b
(quail-define-rules): Fix typo in docstring.
Kenichi Handa <handa@m17n.org>
parents:
24304
diff
changeset
|
672 If it is a character, it is the sole translation of KEY. |
17052 | 673 If it is a string, each character is a candidate for the translation. |
674 If it is a vector, each element (string or character) is a candidate | |
675 for the translation. | |
676 In these cases, a key specific Quail map is generated and assigned to KEY. | |
677 | |
678 If TRANSLATION is a Quail map or a function symbol which returns a Quail map, | |
679 it is used to handle KEY." | |
680 `(quail-install-map | |
681 ',(let ((l rules) | |
682 (map (list nil))) | |
683 (while l | |
21082
ca3bd6ec875d
(quail-defrule-internal): New arg REPLACE.
Richard M. Stallman <rms@gnu.org>
parents:
20728
diff
changeset
|
684 (quail-defrule-internal (car (car l)) (car (cdr (car l))) map t) |
17052 | 685 (setq l (cdr l))) |
686 map))) | |
687 | |
18297
5c8e37591da5
(quail-current-data): New variable.
Kenichi Handa <handa@m17n.org>
parents:
18201
diff
changeset
|
688 ;;;###autoload |
26891
651d521c8f52
(quail-install-map): New optional arg
Kenichi Handa <handa@m17n.org>
parents:
24821
diff
changeset
|
689 (defun quail-install-map (map &optional name) |
17052 | 690 "Install the Quail map MAP in the current Quail package. |
26891
651d521c8f52
(quail-install-map): New optional arg
Kenichi Handa <handa@m17n.org>
parents:
24821
diff
changeset
|
691 |
651d521c8f52
(quail-install-map): New optional arg
Kenichi Handa <handa@m17n.org>
parents:
24821
diff
changeset
|
692 Optional 2nd arg NAME, if non-nil, is a name of Quail package for |
651d521c8f52
(quail-install-map): New optional arg
Kenichi Handa <handa@m17n.org>
parents:
24821
diff
changeset
|
693 which to install MAP. |
651d521c8f52
(quail-install-map): New optional arg
Kenichi Handa <handa@m17n.org>
parents:
24821
diff
changeset
|
694 |
17052 | 695 The installed map can be referred by the function `quail-map'." |
696 (if (null quail-current-package) | |
697 (error "No current Quail package")) | |
698 (if (null (quail-map-p map)) | |
699 (error "Invalid Quail map `%s'" map)) | |
700 (setcar (cdr (cdr quail-current-package)) map)) | |
701 | |
18297
5c8e37591da5
(quail-current-data): New variable.
Kenichi Handa <handa@m17n.org>
parents:
18201
diff
changeset
|
702 ;;;###autoload |
23401
a83ca83c8626
(quail-defrule): New optional arg APPEND.
Kenichi Handa <handa@m17n.org>
parents:
23304
diff
changeset
|
703 (defun quail-defrule (key translation &optional name append) |
17052 | 704 "Add one translation rule, KEY to TRANSLATION, in the current Quail package. |
705 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
|
706 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
|
707 a function, or a cons. |
17052 | 708 It it is a character, it is the sole translation of KEY. |
709 If it is a string, each character is a candidate for the translation. | |
710 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
|
711 for the translation. |
18297
5c8e37591da5
(quail-current-data): New variable.
Kenichi Handa <handa@m17n.org>
parents:
18201
diff
changeset
|
712 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
|
713 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
|
714 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
|
715 the value itself is assigned to `quail-current-data'. |
17052 | 716 In these cases, a key specific Quail map is generated and assigned to KEY. |
717 | |
718 If TRANSLATION is a Quail map or a function symbol which returns a Quail map, | |
719 it is used to handle KEY. | |
23401
a83ca83c8626
(quail-defrule): New optional arg APPEND.
Kenichi Handa <handa@m17n.org>
parents:
23304
diff
changeset
|
720 |
a83ca83c8626
(quail-defrule): New optional arg APPEND.
Kenichi Handa <handa@m17n.org>
parents:
23304
diff
changeset
|
721 Optional 3rd argument NAME, if specified, says which Quail package |
17052 | 722 to define this translation rule in. The default is to define it in the |
23401
a83ca83c8626
(quail-defrule): New optional arg APPEND.
Kenichi Handa <handa@m17n.org>
parents:
23304
diff
changeset
|
723 current Quail package. |
a83ca83c8626
(quail-defrule): New optional arg APPEND.
Kenichi Handa <handa@m17n.org>
parents:
23304
diff
changeset
|
724 |
a83ca83c8626
(quail-defrule): New optional arg APPEND.
Kenichi Handa <handa@m17n.org>
parents:
23304
diff
changeset
|
725 Optional 4th argument APPEND, if non-nil, appends TRANSLATION |
a83ca83c8626
(quail-defrule): New optional arg APPEND.
Kenichi Handa <handa@m17n.org>
parents:
23304
diff
changeset
|
726 to the current translations for KEY instead of replacing them." |
17052 | 727 (if name |
728 (let ((package (quail-package name))) | |
729 (if (null package) | |
730 (error "No Quail package `%s'" name)) | |
731 (setq quail-current-package package))) | |
23401
a83ca83c8626
(quail-defrule): New optional arg APPEND.
Kenichi Handa <handa@m17n.org>
parents:
23304
diff
changeset
|
732 (quail-defrule-internal key translation (quail-map) append)) |
17052 | 733 |
18297
5c8e37591da5
(quail-current-data): New variable.
Kenichi Handa <handa@m17n.org>
parents:
18201
diff
changeset
|
734 ;;;###autoload |
21082
ca3bd6ec875d
(quail-defrule-internal): New arg REPLACE.
Richard M. Stallman <rms@gnu.org>
parents:
20728
diff
changeset
|
735 (defun quail-defrule-internal (key trans map &optional append) |
18556
99e8ae18137f
(quail-guidance-buf): Make it buffer
Kenichi Handa <handa@m17n.org>
parents:
18377
diff
changeset
|
736 "Define KEY as TRANS in a Quail map MAP." |
17052 | 737 (if (null (stringp key)) |
738 "Invalid Quail key `%s'" key) | |
739 (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
|
740 (consp trans) |
17052 | 741 (symbolp trans) |
742 (quail-map-p trans))) | |
743 (error "Invalid Quail translation `%s'" trans)) | |
744 (if (null (quail-map-p map)) | |
745 (error "Invalid Quail map `%s'" map)) | |
746 (let ((len (length key)) | |
747 (idx 0) | |
748 ch entry) | |
18297
5c8e37591da5
(quail-current-data): New variable.
Kenichi Handa <handa@m17n.org>
parents:
18201
diff
changeset
|
749 ;; Make a map for registering TRANS if necessary. |
17052 | 750 (while (< idx len) |
751 (if (null (consp map)) | |
752 ;; We come here, for example, when we try to define a rule | |
753 ;; for "ABC" but a rule for "AB" is already defined as a | |
754 ;; symbol. | |
755 (error "Quail key %s is too long" key)) | |
756 (setq ch (aref key idx) | |
757 entry (assq ch (cdr map))) | |
758 (if (null entry) | |
759 (progn | |
760 (setq entry (cons ch (list nil))) | |
761 (setcdr map (cons entry (cdr map))))) | |
762 (setq map (cdr entry)) | |
763 (setq idx (1+ idx))) | |
764 (if (symbolp trans) | |
765 (if (cdr map) | |
766 ;; We come here, for example, when we try to define a rule | |
767 ;; for "AB" as a symbol but a rule for "ABC" is already | |
768 ;; defined. | |
769 (error "Quail key %s is too short" key) | |
770 (setcdr entry trans)) | |
771 (if (quail-map-p trans) | |
772 (if (not (listp (cdr map))) | |
773 ;; We come here, for example, when we try to define a rule | |
774 ;; for "AB" as a symbol but a rule for "ABC" is already | |
775 ;; defined. | |
776 (error "Quail key %s is too short" key) | |
777 (if (not (listp (cdr trans))) | |
778 (if (cdr map) | |
779 ;; We come here, for example, when we try to | |
780 ;; define a rule for "AB" as a symbol but a rule | |
781 ;; for "ABC" is already defined. | |
782 (error "Quail key %s is too short" key) | |
783 (setcdr entry trans)) | |
784 (setcdr entry (append trans (cdr map))))) | |
23401
a83ca83c8626
(quail-defrule): New optional arg APPEND.
Kenichi Handa <handa@m17n.org>
parents:
23304
diff
changeset
|
785 (if (and (car map) append) |
a83ca83c8626
(quail-defrule): New optional arg APPEND.
Kenichi Handa <handa@m17n.org>
parents:
23304
diff
changeset
|
786 (let ((prev (quail-get-translation (car map) key len))) |
a83ca83c8626
(quail-defrule): New optional arg APPEND.
Kenichi Handa <handa@m17n.org>
parents:
23304
diff
changeset
|
787 (if (integerp prev) |
a83ca83c8626
(quail-defrule): New optional arg APPEND.
Kenichi Handa <handa@m17n.org>
parents:
23304
diff
changeset
|
788 (setq prev (vector prev)) |
a83ca83c8626
(quail-defrule): New optional arg APPEND.
Kenichi Handa <handa@m17n.org>
parents:
23304
diff
changeset
|
789 (setq prev (cdr prev))) |
a83ca83c8626
(quail-defrule): New optional arg APPEND.
Kenichi Handa <handa@m17n.org>
parents:
23304
diff
changeset
|
790 (if (integerp trans) |
a83ca83c8626
(quail-defrule): New optional arg APPEND.
Kenichi Handa <handa@m17n.org>
parents:
23304
diff
changeset
|
791 (setq trans (vector trans)) |
a83ca83c8626
(quail-defrule): New optional arg APPEND.
Kenichi Handa <handa@m17n.org>
parents:
23304
diff
changeset
|
792 (if (stringp trans) |
a83ca83c8626
(quail-defrule): New optional arg APPEND.
Kenichi Handa <handa@m17n.org>
parents:
23304
diff
changeset
|
793 (setq trans (string-to-vector trans)))) |
a83ca83c8626
(quail-defrule): New optional arg APPEND.
Kenichi Handa <handa@m17n.org>
parents:
23304
diff
changeset
|
794 (setq trans |
a83ca83c8626
(quail-defrule): New optional arg APPEND.
Kenichi Handa <handa@m17n.org>
parents:
23304
diff
changeset
|
795 (cons (list 0 0 0 0 nil) |
a83ca83c8626
(quail-defrule): New optional arg APPEND.
Kenichi Handa <handa@m17n.org>
parents:
23304
diff
changeset
|
796 (vconcat prev trans))))) |
a83ca83c8626
(quail-defrule): New optional arg APPEND.
Kenichi Handa <handa@m17n.org>
parents:
23304
diff
changeset
|
797 (setcar map trans))))) |
17052 | 798 |
18297
5c8e37591da5
(quail-current-data): New variable.
Kenichi Handa <handa@m17n.org>
parents:
18201
diff
changeset
|
799 (defun quail-get-translation (def key len) |
5c8e37591da5
(quail-current-data): New variable.
Kenichi Handa <handa@m17n.org>
parents:
18201
diff
changeset
|
800 "Return the translation specified as DEF for KEY of length LEN. |
17052 | 801 The translation is either a character or a cons of the form (INDEX . VECTOR), |
802 where VECTOR is a vector of candidates (character or string) for | |
803 the translation, and INDEX points into VECTOR to specify the currently | |
804 selected translation." | |
18297
5c8e37591da5
(quail-current-data): New variable.
Kenichi Handa <handa@m17n.org>
parents:
18201
diff
changeset
|
805 (if (and def (symbolp def)) |
26891
651d521c8f52
(quail-install-map): New optional arg
Kenichi Handa <handa@m17n.org>
parents:
24821
diff
changeset
|
806 (if (functionp def) |
651d521c8f52
(quail-install-map): New optional arg
Kenichi Handa <handa@m17n.org>
parents:
24821
diff
changeset
|
807 ;; DEF is a symbol of a function which returns valid translation. |
651d521c8f52
(quail-install-map): New optional arg
Kenichi Handa <handa@m17n.org>
parents:
24821
diff
changeset
|
808 (setq def (funcall def key len)) |
651d521c8f52
(quail-install-map): New optional arg
Kenichi Handa <handa@m17n.org>
parents:
24821
diff
changeset
|
809 (setq def nil))) |
18297
5c8e37591da5
(quail-current-data): New variable.
Kenichi Handa <handa@m17n.org>
parents:
18201
diff
changeset
|
810 (if (and (consp def) (not (vectorp (cdr def)))) |
5c8e37591da5
(quail-current-data): New variable.
Kenichi Handa <handa@m17n.org>
parents:
18201
diff
changeset
|
811 (setq def (car def))) |
17052 | 812 |
18297
5c8e37591da5
(quail-current-data): New variable.
Kenichi Handa <handa@m17n.org>
parents:
18201
diff
changeset
|
813 (cond |
5c8e37591da5
(quail-current-data): New variable.
Kenichi Handa <handa@m17n.org>
parents:
18201
diff
changeset
|
814 ((or (integerp def) (consp def)) |
5c8e37591da5
(quail-current-data): New variable.
Kenichi Handa <handa@m17n.org>
parents:
18201
diff
changeset
|
815 def) |
5c8e37591da5
(quail-current-data): New variable.
Kenichi Handa <handa@m17n.org>
parents:
18201
diff
changeset
|
816 |
5c8e37591da5
(quail-current-data): New variable.
Kenichi Handa <handa@m17n.org>
parents:
18201
diff
changeset
|
817 ((null def) |
5c8e37591da5
(quail-current-data): New variable.
Kenichi Handa <handa@m17n.org>
parents:
18201
diff
changeset
|
818 ;; No translation. |
5c8e37591da5
(quail-current-data): New variable.
Kenichi Handa <handa@m17n.org>
parents:
18201
diff
changeset
|
819 nil) |
17052 | 820 |
18297
5c8e37591da5
(quail-current-data): New variable.
Kenichi Handa <handa@m17n.org>
parents:
18201
diff
changeset
|
821 ((stringp def) |
5c8e37591da5
(quail-current-data): New variable.
Kenichi Handa <handa@m17n.org>
parents:
18201
diff
changeset
|
822 ;; 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
|
823 ;; it as (INDICES . VECTOR). |
18297
5c8e37591da5
(quail-current-data): New variable.
Kenichi Handa <handa@m17n.org>
parents:
18201
diff
changeset
|
824 (setq def (string-to-vector def)) |
5c8e37591da5
(quail-current-data): New variable.
Kenichi Handa <handa@m17n.org>
parents:
18201
diff
changeset
|
825 ;; 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
|
826 ;; candidate as the translation. |
5c8e37591da5
(quail-current-data): New variable.
Kenichi Handa <handa@m17n.org>
parents:
18201
diff
changeset
|
827 (if (= (length def) 1) |
5c8e37591da5
(quail-current-data): New variable.
Kenichi Handa <handa@m17n.org>
parents:
18201
diff
changeset
|
828 (aref def 0) |
18556
99e8ae18137f
(quail-guidance-buf): Make it buffer
Kenichi Handa <handa@m17n.org>
parents:
18377
diff
changeset
|
829 (cons (list 0 0 0 0 nil) def))) |
17052 | 830 |
18297
5c8e37591da5
(quail-current-data): New variable.
Kenichi Handa <handa@m17n.org>
parents:
18201
diff
changeset
|
831 ((vectorp def) |
5c8e37591da5
(quail-current-data): New variable.
Kenichi Handa <handa@m17n.org>
parents:
18201
diff
changeset
|
832 ;; 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
|
833 ;; translation. Reform it as (INDICES . VECTOR). |
99e8ae18137f
(quail-guidance-buf): Make it buffer
Kenichi Handa <handa@m17n.org>
parents:
18377
diff
changeset
|
834 (cons (list 0 0 0 0 nil) def)) |
17052 | 835 |
18297
5c8e37591da5
(quail-current-data): New variable.
Kenichi Handa <handa@m17n.org>
parents:
18201
diff
changeset
|
836 (t |
5c8e37591da5
(quail-current-data): New variable.
Kenichi Handa <handa@m17n.org>
parents:
18201
diff
changeset
|
837 (error "Invalid object in Quail map: %s" def)))) |
17052 | 838 |
18556
99e8ae18137f
(quail-guidance-buf): Make it buffer
Kenichi Handa <handa@m17n.org>
parents:
18377
diff
changeset
|
839 (defun quail-lookup-key (key &optional len) |
17052 | 840 "Lookup KEY of length LEN in the current Quail map and return the definition. |
841 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
|
842 (or len |
99e8ae18137f
(quail-guidance-buf): Make it buffer
Kenichi Handa <handa@m17n.org>
parents:
18377
diff
changeset
|
843 (setq len (length key))) |
17052 | 844 (let ((idx 0) |
845 (map (quail-map)) | |
846 (kbd-translate (quail-kbd-translate)) | |
18297
5c8e37591da5
(quail-current-data): New variable.
Kenichi Handa <handa@m17n.org>
parents:
18201
diff
changeset
|
847 slot ch translation def) |
17052 | 848 (while (and map (< idx len)) |
849 (setq ch (if kbd-translate (quail-keyboard-translate (aref key idx)) | |
850 (aref key idx))) | |
851 (setq idx (1+ idx)) | |
852 (if (and (cdr map) (symbolp (cdr map))) | |
853 (setcdr map (funcall (cdr map) key idx))) | |
854 (setq slot (assq ch (cdr map))) | |
855 (if (and (cdr slot) (symbolp (cdr slot))) | |
856 (setcdr slot (funcall (cdr slot) key idx))) | |
857 (setq map (cdr slot))) | |
18297
5c8e37591da5
(quail-current-data): New variable.
Kenichi Handa <handa@m17n.org>
parents:
18201
diff
changeset
|
858 (setq def (car map)) |
18556
99e8ae18137f
(quail-guidance-buf): Make it buffer
Kenichi Handa <handa@m17n.org>
parents:
18377
diff
changeset
|
859 (setq quail-current-translations nil) |
18297
5c8e37591da5
(quail-current-data): New variable.
Kenichi Handa <handa@m17n.org>
parents:
18201
diff
changeset
|
860 (if (and map (setq translation (quail-get-translation def key len))) |
17052 | 861 (progn |
18297
5c8e37591da5
(quail-current-data): New variable.
Kenichi Handa <handa@m17n.org>
parents:
18201
diff
changeset
|
862 (if (and (consp def) (not (vectorp (cdr def)))) |
5c8e37591da5
(quail-current-data): New variable.
Kenichi Handa <handa@m17n.org>
parents:
18201
diff
changeset
|
863 (progn |
5c8e37591da5
(quail-current-data): New variable.
Kenichi Handa <handa@m17n.org>
parents:
18201
diff
changeset
|
864 (if (not (equal (car def) translation)) |
5c8e37591da5
(quail-current-data): New variable.
Kenichi Handa <handa@m17n.org>
parents:
18201
diff
changeset
|
865 ;; We must reflect TRANSLATION to car part of DEF. |
5c8e37591da5
(quail-current-data): New variable.
Kenichi Handa <handa@m17n.org>
parents:
18201
diff
changeset
|
866 (setcar def translation)) |
5c8e37591da5
(quail-current-data): New variable.
Kenichi Handa <handa@m17n.org>
parents:
18201
diff
changeset
|
867 (setq quail-current-data |
5c8e37591da5
(quail-current-data): New variable.
Kenichi Handa <handa@m17n.org>
parents:
18201
diff
changeset
|
868 (if (functionp (cdr def)) |
5c8e37591da5
(quail-current-data): New variable.
Kenichi Handa <handa@m17n.org>
parents:
18201
diff
changeset
|
869 (funcall (cdr def)) |
5c8e37591da5
(quail-current-data): New variable.
Kenichi Handa <handa@m17n.org>
parents:
18201
diff
changeset
|
870 (cdr def)))) |
5c8e37591da5
(quail-current-data): New variable.
Kenichi Handa <handa@m17n.org>
parents:
18201
diff
changeset
|
871 (if (not (equal def translation)) |
5c8e37591da5
(quail-current-data): New variable.
Kenichi Handa <handa@m17n.org>
parents:
18201
diff
changeset
|
872 ;; We must reflect TRANSLATION to car part of MAP. |
5c8e37591da5
(quail-current-data): New variable.
Kenichi Handa <handa@m17n.org>
parents:
18201
diff
changeset
|
873 (setcar map translation))) |
5c8e37591da5
(quail-current-data): New variable.
Kenichi Handa <handa@m17n.org>
parents:
18201
diff
changeset
|
874 (if (and (consp translation) (vectorp (cdr translation))) |
17052 | 875 (progn |
876 (setq quail-current-translations translation) | |
877 (if (quail-forget-last-selection) | |
24238
20d23ea9713b
(quail-lookup-key): If cdr of MAP is a
Kenichi Handa <handa@m17n.org>
parents:
23887
diff
changeset
|
878 (setcar (car quail-current-translations) 0)))))) |
20d23ea9713b
(quail-lookup-key): If cdr of MAP is a
Kenichi Handa <handa@m17n.org>
parents:
23887
diff
changeset
|
879 ;; We may have to reform cdr part of MAP. |
20d23ea9713b
(quail-lookup-key): If cdr of MAP is a
Kenichi Handa <handa@m17n.org>
parents:
23887
diff
changeset
|
880 (if (and (cdr map) (functionp (cdr map))) |
20d23ea9713b
(quail-lookup-key): If cdr of MAP is a
Kenichi Handa <handa@m17n.org>
parents:
23887
diff
changeset
|
881 (setcdr map (funcall (cdr map) key len))) |
17052 | 882 map)) |
883 | |
22765
7cf2c3800e8f
(quail-mode): This variable deleted.
Kenichi Handa <handa@m17n.org>
parents:
22124
diff
changeset
|
884 (put 'quail-error 'error-conditions '(quail-error error)) |
7cf2c3800e8f
(quail-mode): This variable deleted.
Kenichi Handa <handa@m17n.org>
parents:
22124
diff
changeset
|
885 (defun quail-error (&rest args) |
7cf2c3800e8f
(quail-mode): This variable deleted.
Kenichi Handa <handa@m17n.org>
parents:
22124
diff
changeset
|
886 (signal 'quail-error (apply 'format args))) |
17052 | 887 |
22765
7cf2c3800e8f
(quail-mode): This variable deleted.
Kenichi Handa <handa@m17n.org>
parents:
22124
diff
changeset
|
888 (defvar quail-translating nil) |
7cf2c3800e8f
(quail-mode): This variable deleted.
Kenichi Handa <handa@m17n.org>
parents:
22124
diff
changeset
|
889 (defvar quail-converting nil) |
22917
00f3497854c4
(quail-translation-keymap): Declare it as
Kenichi Handa <handa@m17n.org>
parents:
22883
diff
changeset
|
890 (defvar quail-conversion-str nil) |
18201
feea31893155
(quail-prefix-arg): New variable.
Kenichi Handa <handa@m17n.org>
parents:
17764
diff
changeset
|
891 |
22765
7cf2c3800e8f
(quail-mode): This variable deleted.
Kenichi Handa <handa@m17n.org>
parents:
22124
diff
changeset
|
892 (defun quail-input-method (key) |
7cf2c3800e8f
(quail-mode): This variable deleted.
Kenichi Handa <handa@m17n.org>
parents:
22124
diff
changeset
|
893 (if (or buffer-read-only |
22777
1b0761cbc15b
(quail-conversion-keymap): New binding
Kenichi Handa <handa@m17n.org>
parents:
22765
diff
changeset
|
894 overriding-terminal-local-map |
1b0761cbc15b
(quail-conversion-keymap): New binding
Kenichi Handa <handa@m17n.org>
parents:
22765
diff
changeset
|
895 overriding-local-map) |
22765
7cf2c3800e8f
(quail-mode): This variable deleted.
Kenichi Handa <handa@m17n.org>
parents:
22124
diff
changeset
|
896 (list key) |
7cf2c3800e8f
(quail-mode): This variable deleted.
Kenichi Handa <handa@m17n.org>
parents:
22124
diff
changeset
|
897 (quail-setup-overlays (quail-conversion-keymap)) |
22917
00f3497854c4
(quail-translation-keymap): Declare it as
Kenichi Handa <handa@m17n.org>
parents:
22883
diff
changeset
|
898 (let ((modified-p (buffer-modified-p)) |
00f3497854c4
(quail-translation-keymap): Declare it as
Kenichi Handa <handa@m17n.org>
parents:
22883
diff
changeset
|
899 (buffer-undo-list t)) |
00f3497854c4
(quail-translation-keymap): Declare it as
Kenichi Handa <handa@m17n.org>
parents:
22883
diff
changeset
|
900 (or (and quail-guidance-win |
00f3497854c4
(quail-translation-keymap): Declare it as
Kenichi Handa <handa@m17n.org>
parents:
22883
diff
changeset
|
901 (window-live-p quail-guidance-win) |
00f3497854c4
(quail-translation-keymap): Declare it as
Kenichi Handa <handa@m17n.org>
parents:
22883
diff
changeset
|
902 (eq (window-buffer quail-guidance-win) quail-guidance-buf) |
00f3497854c4
(quail-translation-keymap): Declare it as
Kenichi Handa <handa@m17n.org>
parents:
22883
diff
changeset
|
903 (not input-method-use-echo-area)) |
00f3497854c4
(quail-translation-keymap): Declare it as
Kenichi Handa <handa@m17n.org>
parents:
22883
diff
changeset
|
904 (quail-show-guidance-buf)) |
22765
7cf2c3800e8f
(quail-mode): This variable deleted.
Kenichi Handa <handa@m17n.org>
parents:
22124
diff
changeset
|
905 (unwind-protect |
7cf2c3800e8f
(quail-mode): This variable deleted.
Kenichi Handa <handa@m17n.org>
parents:
22124
diff
changeset
|
906 (if (quail-conversion-keymap) |
7cf2c3800e8f
(quail-mode): This variable deleted.
Kenichi Handa <handa@m17n.org>
parents:
22124
diff
changeset
|
907 (quail-start-conversion key) |
7cf2c3800e8f
(quail-mode): This variable deleted.
Kenichi Handa <handa@m17n.org>
parents:
22124
diff
changeset
|
908 (quail-start-translation key)) |
22777
1b0761cbc15b
(quail-conversion-keymap): New binding
Kenichi Handa <handa@m17n.org>
parents:
22765
diff
changeset
|
909 (quail-delete-overlays) |
1b0761cbc15b
(quail-conversion-keymap): New binding
Kenichi Handa <handa@m17n.org>
parents:
22765
diff
changeset
|
910 (if (buffer-live-p quail-guidance-buf) |
1b0761cbc15b
(quail-conversion-keymap): New binding
Kenichi Handa <handa@m17n.org>
parents:
22765
diff
changeset
|
911 (save-excursion |
1b0761cbc15b
(quail-conversion-keymap): New binding
Kenichi Handa <handa@m17n.org>
parents:
22765
diff
changeset
|
912 (set-buffer quail-guidance-buf) |
1b0761cbc15b
(quail-conversion-keymap): New binding
Kenichi Handa <handa@m17n.org>
parents:
22765
diff
changeset
|
913 (erase-buffer))) |
22917
00f3497854c4
(quail-translation-keymap): Declare it as
Kenichi Handa <handa@m17n.org>
parents:
22883
diff
changeset
|
914 (if input-method-use-echo-area |
00f3497854c4
(quail-translation-keymap): Declare it as
Kenichi Handa <handa@m17n.org>
parents:
22883
diff
changeset
|
915 (quail-hide-guidance-buf)) |
22765
7cf2c3800e8f
(quail-mode): This variable deleted.
Kenichi Handa <handa@m17n.org>
parents:
22124
diff
changeset
|
916 (set-buffer-modified-p modified-p) |
22777
1b0761cbc15b
(quail-conversion-keymap): New binding
Kenichi Handa <handa@m17n.org>
parents:
22765
diff
changeset
|
917 ;; Run this hook only when the current input method doesn't require |
1b0761cbc15b
(quail-conversion-keymap): New binding
Kenichi Handa <handa@m17n.org>
parents:
22765
diff
changeset
|
918 ;; conversion. When conversion is required, the conversion function |
1b0761cbc15b
(quail-conversion-keymap): New binding
Kenichi Handa <handa@m17n.org>
parents:
22765
diff
changeset
|
919 ;; should run this hook at a proper timing. |
1b0761cbc15b
(quail-conversion-keymap): New binding
Kenichi Handa <handa@m17n.org>
parents:
22765
diff
changeset
|
920 (unless (quail-conversion-keymap) |
1b0761cbc15b
(quail-conversion-keymap): New binding
Kenichi Handa <handa@m17n.org>
parents:
22765
diff
changeset
|
921 (run-hooks 'input-method-after-insert-chunk-hook)))))) |
22765
7cf2c3800e8f
(quail-mode): This variable deleted.
Kenichi Handa <handa@m17n.org>
parents:
22124
diff
changeset
|
922 |
7cf2c3800e8f
(quail-mode): This variable deleted.
Kenichi Handa <handa@m17n.org>
parents:
22124
diff
changeset
|
923 (defun quail-overlay-region-events (overlay) |
7cf2c3800e8f
(quail-mode): This variable deleted.
Kenichi Handa <handa@m17n.org>
parents:
22124
diff
changeset
|
924 (let ((start (overlay-start overlay)) |
7cf2c3800e8f
(quail-mode): This variable deleted.
Kenichi Handa <handa@m17n.org>
parents:
22124
diff
changeset
|
925 (end (overlay-end overlay))) |
7cf2c3800e8f
(quail-mode): This variable deleted.
Kenichi Handa <handa@m17n.org>
parents:
22124
diff
changeset
|
926 (if (< start end) |
7cf2c3800e8f
(quail-mode): This variable deleted.
Kenichi Handa <handa@m17n.org>
parents:
22124
diff
changeset
|
927 (prog1 |
7cf2c3800e8f
(quail-mode): This variable deleted.
Kenichi Handa <handa@m17n.org>
parents:
22124
diff
changeset
|
928 (string-to-list (buffer-substring start end)) |
7cf2c3800e8f
(quail-mode): This variable deleted.
Kenichi Handa <handa@m17n.org>
parents:
22124
diff
changeset
|
929 (delete-region start end))))) |
7cf2c3800e8f
(quail-mode): This variable deleted.
Kenichi Handa <handa@m17n.org>
parents:
22124
diff
changeset
|
930 |
22917
00f3497854c4
(quail-translation-keymap): Declare it as
Kenichi Handa <handa@m17n.org>
parents:
22883
diff
changeset
|
931 (defsubst quail-delete-region () |
00f3497854c4
(quail-translation-keymap): Declare it as
Kenichi Handa <handa@m17n.org>
parents:
22883
diff
changeset
|
932 "Delete the text in the current translation region of Quail." |
00f3497854c4
(quail-translation-keymap): Declare it as
Kenichi Handa <handa@m17n.org>
parents:
22883
diff
changeset
|
933 (if (overlay-start quail-overlay) |
00f3497854c4
(quail-translation-keymap): Declare it as
Kenichi Handa <handa@m17n.org>
parents:
22883
diff
changeset
|
934 (delete-region (overlay-start quail-overlay) |
00f3497854c4
(quail-translation-keymap): Declare it as
Kenichi Handa <handa@m17n.org>
parents:
22883
diff
changeset
|
935 (overlay-end quail-overlay)))) |
00f3497854c4
(quail-translation-keymap): Declare it as
Kenichi Handa <handa@m17n.org>
parents:
22883
diff
changeset
|
936 |
22765
7cf2c3800e8f
(quail-mode): This variable deleted.
Kenichi Handa <handa@m17n.org>
parents:
22124
diff
changeset
|
937 (defun quail-start-translation (key) |
7cf2c3800e8f
(quail-mode): This variable deleted.
Kenichi Handa <handa@m17n.org>
parents:
22124
diff
changeset
|
938 "Start translation of the typed character KEY by the current Quail package." |
7cf2c3800e8f
(quail-mode): This variable deleted.
Kenichi Handa <handa@m17n.org>
parents:
22124
diff
changeset
|
939 ;; Check the possibility of translating KEY. |
22917
00f3497854c4
(quail-translation-keymap): Declare it as
Kenichi Handa <handa@m17n.org>
parents:
22883
diff
changeset
|
940 ;; If KEY is nil, we can anyway start translation. |
00f3497854c4
(quail-translation-keymap): Declare it as
Kenichi Handa <handa@m17n.org>
parents:
22883
diff
changeset
|
941 (if (or (and (integerp key) |
00f3497854c4
(quail-translation-keymap): Declare it as
Kenichi Handa <handa@m17n.org>
parents:
22883
diff
changeset
|
942 (assq (if (quail-kbd-translate) |
00f3497854c4
(quail-translation-keymap): Declare it as
Kenichi Handa <handa@m17n.org>
parents:
22883
diff
changeset
|
943 (quail-keyboard-translate key) key) |
00f3497854c4
(quail-translation-keymap): Declare it as
Kenichi Handa <handa@m17n.org>
parents:
22883
diff
changeset
|
944 (cdr (quail-map)))) |
00f3497854c4
(quail-translation-keymap): Declare it as
Kenichi Handa <handa@m17n.org>
parents:
22883
diff
changeset
|
945 (null key)) |
23176 | 946 ;; OK, we can start translation. |
22917
00f3497854c4
(quail-translation-keymap): Declare it as
Kenichi Handa <handa@m17n.org>
parents:
22883
diff
changeset
|
947 (let* ((echo-keystrokes 0) |
00f3497854c4
(quail-translation-keymap): Declare it as
Kenichi Handa <handa@m17n.org>
parents:
22883
diff
changeset
|
948 (help-char nil) |
00f3497854c4
(quail-translation-keymap): Declare it as
Kenichi Handa <handa@m17n.org>
parents:
22883
diff
changeset
|
949 (overriding-terminal-local-map (quail-translation-keymap)) |
22765
7cf2c3800e8f
(quail-mode): This variable deleted.
Kenichi Handa <handa@m17n.org>
parents:
22124
diff
changeset
|
950 (generated-events nil) |
29145
79b2b42f9a7b
(quail-start-translation): Don't change
Kenichi Handa <handa@m17n.org>
parents:
29129
diff
changeset
|
951 (input-method-function nil) |
79b2b42f9a7b
(quail-start-translation): Don't change
Kenichi Handa <handa@m17n.org>
parents:
29129
diff
changeset
|
952 (modified-p (buffer-modified-p))) |
22765
7cf2c3800e8f
(quail-mode): This variable deleted.
Kenichi Handa <handa@m17n.org>
parents:
22124
diff
changeset
|
953 (setq quail-current-key "" |
22917
00f3497854c4
(quail-translation-keymap): Declare it as
Kenichi Handa <handa@m17n.org>
parents:
22883
diff
changeset
|
954 quail-current-str "" |
00f3497854c4
(quail-translation-keymap): Declare it as
Kenichi Handa <handa@m17n.org>
parents:
22883
diff
changeset
|
955 quail-translating t) |
00f3497854c4
(quail-translation-keymap): Declare it as
Kenichi Handa <handa@m17n.org>
parents:
22883
diff
changeset
|
956 (if key |
00f3497854c4
(quail-translation-keymap): Declare it as
Kenichi Handa <handa@m17n.org>
parents:
22883
diff
changeset
|
957 (setq unread-command-events (cons key unread-command-events))) |
22765
7cf2c3800e8f
(quail-mode): This variable deleted.
Kenichi Handa <handa@m17n.org>
parents:
22124
diff
changeset
|
958 (while quail-translating |
29145
79b2b42f9a7b
(quail-start-translation): Don't change
Kenichi Handa <handa@m17n.org>
parents:
29129
diff
changeset
|
959 (set-buffer-modified-p modified-p) |
22917
00f3497854c4
(quail-translation-keymap): Declare it as
Kenichi Handa <handa@m17n.org>
parents:
22883
diff
changeset
|
960 (let* ((keyseq (read-key-sequence |
00f3497854c4
(quail-translation-keymap): Declare it as
Kenichi Handa <handa@m17n.org>
parents:
22883
diff
changeset
|
961 (and input-method-use-echo-area |
00f3497854c4
(quail-translation-keymap): Declare it as
Kenichi Handa <handa@m17n.org>
parents:
22883
diff
changeset
|
962 (concat input-method-previous-message |
23599
ab69e7987be0
(quail-start-translation): Handle
Kenichi Handa <handa@m17n.org>
parents:
23401
diff
changeset
|
963 quail-current-str)) |
ab69e7987be0
(quail-start-translation): Handle
Kenichi Handa <handa@m17n.org>
parents:
23401
diff
changeset
|
964 nil nil t)) |
22917
00f3497854c4
(quail-translation-keymap): Declare it as
Kenichi Handa <handa@m17n.org>
parents:
22883
diff
changeset
|
965 (cmd (lookup-key (quail-translation-keymap) keyseq))) |
00f3497854c4
(quail-translation-keymap): Declare it as
Kenichi Handa <handa@m17n.org>
parents:
22883
diff
changeset
|
966 (if (if key |
00f3497854c4
(quail-translation-keymap): Declare it as
Kenichi Handa <handa@m17n.org>
parents:
22883
diff
changeset
|
967 (and (commandp cmd) (not (eq cmd 'quail-other-command))) |
00f3497854c4
(quail-translation-keymap): Declare it as
Kenichi Handa <handa@m17n.org>
parents:
22883
diff
changeset
|
968 (eq cmd 'quail-self-insert-command)) |
22765
7cf2c3800e8f
(quail-mode): This variable deleted.
Kenichi Handa <handa@m17n.org>
parents:
22124
diff
changeset
|
969 (progn |
22917
00f3497854c4
(quail-translation-keymap): Declare it as
Kenichi Handa <handa@m17n.org>
parents:
22883
diff
changeset
|
970 (setq key t) |
00f3497854c4
(quail-translation-keymap): Declare it as
Kenichi Handa <handa@m17n.org>
parents:
22883
diff
changeset
|
971 (setq last-command-event (aref keyseq (1- (length keyseq))) |
22777
1b0761cbc15b
(quail-conversion-keymap): New binding
Kenichi Handa <handa@m17n.org>
parents:
22765
diff
changeset
|
972 last-command this-command |
1b0761cbc15b
(quail-conversion-keymap): New binding
Kenichi Handa <handa@m17n.org>
parents:
22765
diff
changeset
|
973 this-command cmd) |
22765
7cf2c3800e8f
(quail-mode): This variable deleted.
Kenichi Handa <handa@m17n.org>
parents:
22124
diff
changeset
|
974 (condition-case err |
7cf2c3800e8f
(quail-mode): This variable deleted.
Kenichi Handa <handa@m17n.org>
parents:
22124
diff
changeset
|
975 (call-interactively cmd) |
7cf2c3800e8f
(quail-mode): This variable deleted.
Kenichi Handa <handa@m17n.org>
parents:
22124
diff
changeset
|
976 (quail-error (message "%s" (cdr err)) (beep)))) |
7cf2c3800e8f
(quail-mode): This variable deleted.
Kenichi Handa <handa@m17n.org>
parents:
22124
diff
changeset
|
977 ;; KEYSEQ is not defined in the translation keymap. |
7cf2c3800e8f
(quail-mode): This variable deleted.
Kenichi Handa <handa@m17n.org>
parents:
22124
diff
changeset
|
978 ;; Let's return the event(s) to the caller. |
26891
651d521c8f52
(quail-install-map): New optional arg
Kenichi Handa <handa@m17n.org>
parents:
24821
diff
changeset
|
979 (setq unread-command-events |
22917
00f3497854c4
(quail-translation-keymap): Declare it as
Kenichi Handa <handa@m17n.org>
parents:
22883
diff
changeset
|
980 (string-to-list (this-single-command-raw-keys))) |
00f3497854c4
(quail-translation-keymap): Declare it as
Kenichi Handa <handa@m17n.org>
parents:
22883
diff
changeset
|
981 (setq quail-translating nil)))) |
00f3497854c4
(quail-translation-keymap): Declare it as
Kenichi Handa <handa@m17n.org>
parents:
22883
diff
changeset
|
982 (quail-delete-region) |
00f3497854c4
(quail-translation-keymap): Declare it as
Kenichi Handa <handa@m17n.org>
parents:
22883
diff
changeset
|
983 (if (and quail-current-str (> (length quail-current-str) 0)) |
26891
651d521c8f52
(quail-install-map): New optional arg
Kenichi Handa <handa@m17n.org>
parents:
24821
diff
changeset
|
984 (let* ((len (length quail-current-str)) |
651d521c8f52
(quail-install-map): New optional arg
Kenichi Handa <handa@m17n.org>
parents:
24821
diff
changeset
|
985 (idx 0) |
651d521c8f52
(quail-install-map): New optional arg
Kenichi Handa <handa@m17n.org>
parents:
24821
diff
changeset
|
986 (val (find-composition 0 len quail-current-str)) |
651d521c8f52
(quail-install-map): New optional arg
Kenichi Handa <handa@m17n.org>
parents:
24821
diff
changeset
|
987 char) |
651d521c8f52
(quail-install-map): New optional arg
Kenichi Handa <handa@m17n.org>
parents:
24821
diff
changeset
|
988 ;; Push characters in quail-current-str one by one to |
651d521c8f52
(quail-install-map): New optional arg
Kenichi Handa <handa@m17n.org>
parents:
24821
diff
changeset
|
989 ;; generated-events while interleaving it with a special |
651d521c8f52
(quail-install-map): New optional arg
Kenichi Handa <handa@m17n.org>
parents:
24821
diff
changeset
|
990 ;; event (compose-last-chars LEN) at each composition |
651d521c8f52
(quail-install-map): New optional arg
Kenichi Handa <handa@m17n.org>
parents:
24821
diff
changeset
|
991 ;; end. |
651d521c8f52
(quail-install-map): New optional arg
Kenichi Handa <handa@m17n.org>
parents:
24821
diff
changeset
|
992 (while (<= idx len) |
651d521c8f52
(quail-install-map): New optional arg
Kenichi Handa <handa@m17n.org>
parents:
24821
diff
changeset
|
993 (when (and val (= idx (nth 1 val))) |
651d521c8f52
(quail-install-map): New optional arg
Kenichi Handa <handa@m17n.org>
parents:
24821
diff
changeset
|
994 (setq generated-events |
651d521c8f52
(quail-install-map): New optional arg
Kenichi Handa <handa@m17n.org>
parents:
24821
diff
changeset
|
995 (cons (list 'compose-last-chars (- idx (car val))) |
651d521c8f52
(quail-install-map): New optional arg
Kenichi Handa <handa@m17n.org>
parents:
24821
diff
changeset
|
996 generated-events)) |
651d521c8f52
(quail-install-map): New optional arg
Kenichi Handa <handa@m17n.org>
parents:
24821
diff
changeset
|
997 (setq val (find-composition idx len quail-current-str))) |
651d521c8f52
(quail-install-map): New optional arg
Kenichi Handa <handa@m17n.org>
parents:
24821
diff
changeset
|
998 (when (< idx len) |
651d521c8f52
(quail-install-map): New optional arg
Kenichi Handa <handa@m17n.org>
parents:
24821
diff
changeset
|
999 (setq char (aref quail-current-str idx)) |
651d521c8f52
(quail-install-map): New optional arg
Kenichi Handa <handa@m17n.org>
parents:
24821
diff
changeset
|
1000 (or enable-multibyte-characters |
651d521c8f52
(quail-install-map): New optional arg
Kenichi Handa <handa@m17n.org>
parents:
24821
diff
changeset
|
1001 (setq char (multibyte-char-to-unibyte char))) |
651d521c8f52
(quail-install-map): New optional arg
Kenichi Handa <handa@m17n.org>
parents:
24821
diff
changeset
|
1002 (setq generated-events (cons char generated-events))) |
651d521c8f52
(quail-install-map): New optional arg
Kenichi Handa <handa@m17n.org>
parents:
24821
diff
changeset
|
1003 (setq idx (1+ idx))) |
651d521c8f52
(quail-install-map): New optional arg
Kenichi Handa <handa@m17n.org>
parents:
24821
diff
changeset
|
1004 ;; Reorder generated-events. |
651d521c8f52
(quail-install-map): New optional arg
Kenichi Handa <handa@m17n.org>
parents:
24821
diff
changeset
|
1005 (setq generated-events (nreverse generated-events)))) |
22917
00f3497854c4
(quail-translation-keymap): Declare it as
Kenichi Handa <handa@m17n.org>
parents:
22883
diff
changeset
|
1006 (if (and input-method-exit-on-first-char generated-events) |
00f3497854c4
(quail-translation-keymap): Declare it as
Kenichi Handa <handa@m17n.org>
parents:
22883
diff
changeset
|
1007 (list (car generated-events)) |
00f3497854c4
(quail-translation-keymap): Declare it as
Kenichi Handa <handa@m17n.org>
parents:
22883
diff
changeset
|
1008 generated-events)) |
17052 | 1009 |
22765
7cf2c3800e8f
(quail-mode): This variable deleted.
Kenichi Handa <handa@m17n.org>
parents:
22124
diff
changeset
|
1010 ;; Since KEY doesn't start any translation, just return it. |
7cf2c3800e8f
(quail-mode): This variable deleted.
Kenichi Handa <handa@m17n.org>
parents:
22124
diff
changeset
|
1011 (list key))) |
17052 | 1012 |
22765
7cf2c3800e8f
(quail-mode): This variable deleted.
Kenichi Handa <handa@m17n.org>
parents:
22124
diff
changeset
|
1013 (defun quail-start-conversion (key) |
7cf2c3800e8f
(quail-mode): This variable deleted.
Kenichi Handa <handa@m17n.org>
parents:
22124
diff
changeset
|
1014 "Start conversion of the typed character KEY by the current Quail package." |
7cf2c3800e8f
(quail-mode): This variable deleted.
Kenichi Handa <handa@m17n.org>
parents:
22124
diff
changeset
|
1015 ;; Check the possibility of translating KEY. |
22917
00f3497854c4
(quail-translation-keymap): Declare it as
Kenichi Handa <handa@m17n.org>
parents:
22883
diff
changeset
|
1016 ;; If KEY is nil, we can anyway start translation. |
00f3497854c4
(quail-translation-keymap): Declare it as
Kenichi Handa <handa@m17n.org>
parents:
22883
diff
changeset
|
1017 (if (or (and (integerp key) |
00f3497854c4
(quail-translation-keymap): Declare it as
Kenichi Handa <handa@m17n.org>
parents:
22883
diff
changeset
|
1018 (assq (if (quail-kbd-translate) |
00f3497854c4
(quail-translation-keymap): Declare it as
Kenichi Handa <handa@m17n.org>
parents:
22883
diff
changeset
|
1019 (quail-keyboard-translate key) key) |
00f3497854c4
(quail-translation-keymap): Declare it as
Kenichi Handa <handa@m17n.org>
parents:
22883
diff
changeset
|
1020 (cdr (quail-map)))) |
00f3497854c4
(quail-translation-keymap): Declare it as
Kenichi Handa <handa@m17n.org>
parents:
22883
diff
changeset
|
1021 (null key)) |
22765
7cf2c3800e8f
(quail-mode): This variable deleted.
Kenichi Handa <handa@m17n.org>
parents:
22124
diff
changeset
|
1022 ;; Ok, we can start translation and conversion. |
22917
00f3497854c4
(quail-translation-keymap): Declare it as
Kenichi Handa <handa@m17n.org>
parents:
22883
diff
changeset
|
1023 (let* ((echo-keystrokes 0) |
00f3497854c4
(quail-translation-keymap): Declare it as
Kenichi Handa <handa@m17n.org>
parents:
22883
diff
changeset
|
1024 (help-char nil) |
00f3497854c4
(quail-translation-keymap): Declare it as
Kenichi Handa <handa@m17n.org>
parents:
22883
diff
changeset
|
1025 (overriding-terminal-local-map (quail-conversion-keymap)) |
22765
7cf2c3800e8f
(quail-mode): This variable deleted.
Kenichi Handa <handa@m17n.org>
parents:
22124
diff
changeset
|
1026 (generated-events nil) |
29145
79b2b42f9a7b
(quail-start-translation): Don't change
Kenichi Handa <handa@m17n.org>
parents:
29129
diff
changeset
|
1027 (input-method-function nil) |
79b2b42f9a7b
(quail-start-translation): Don't change
Kenichi Handa <handa@m17n.org>
parents:
29129
diff
changeset
|
1028 (modified-p (buffer-modified-p))) |
22765
7cf2c3800e8f
(quail-mode): This variable deleted.
Kenichi Handa <handa@m17n.org>
parents:
22124
diff
changeset
|
1029 (setq quail-current-key "" |
22917
00f3497854c4
(quail-translation-keymap): Declare it as
Kenichi Handa <handa@m17n.org>
parents:
22883
diff
changeset
|
1030 quail-current-str "" |
00f3497854c4
(quail-translation-keymap): Declare it as
Kenichi Handa <handa@m17n.org>
parents:
22883
diff
changeset
|
1031 quail-translating t |
22765
7cf2c3800e8f
(quail-mode): This variable deleted.
Kenichi Handa <handa@m17n.org>
parents:
22124
diff
changeset
|
1032 quail-converting t |
22917
00f3497854c4
(quail-translation-keymap): Declare it as
Kenichi Handa <handa@m17n.org>
parents:
22883
diff
changeset
|
1033 quail-conversion-str "") |
00f3497854c4
(quail-translation-keymap): Declare it as
Kenichi Handa <handa@m17n.org>
parents:
22883
diff
changeset
|
1034 (if key |
00f3497854c4
(quail-translation-keymap): Declare it as
Kenichi Handa <handa@m17n.org>
parents:
22883
diff
changeset
|
1035 (setq unread-command-events (cons key unread-command-events))) |
22765
7cf2c3800e8f
(quail-mode): This variable deleted.
Kenichi Handa <handa@m17n.org>
parents:
22124
diff
changeset
|
1036 (while quail-converting |
29145
79b2b42f9a7b
(quail-start-translation): Don't change
Kenichi Handa <handa@m17n.org>
parents:
29129
diff
changeset
|
1037 (set-buffer-modified-p modified-p) |
22765
7cf2c3800e8f
(quail-mode): This variable deleted.
Kenichi Handa <handa@m17n.org>
parents:
22124
diff
changeset
|
1038 (or quail-translating |
7cf2c3800e8f
(quail-mode): This variable deleted.
Kenichi Handa <handa@m17n.org>
parents:
22124
diff
changeset
|
1039 (progn |
7cf2c3800e8f
(quail-mode): This variable deleted.
Kenichi Handa <handa@m17n.org>
parents:
22124
diff
changeset
|
1040 (setq quail-current-key "" |
22917
00f3497854c4
(quail-translation-keymap): Declare it as
Kenichi Handa <handa@m17n.org>
parents:
22883
diff
changeset
|
1041 quail-current-str "" |
22765
7cf2c3800e8f
(quail-mode): This variable deleted.
Kenichi Handa <handa@m17n.org>
parents:
22124
diff
changeset
|
1042 quail-translating t) |
7cf2c3800e8f
(quail-mode): This variable deleted.
Kenichi Handa <handa@m17n.org>
parents:
22124
diff
changeset
|
1043 (quail-setup-overlays nil))) |
22917
00f3497854c4
(quail-translation-keymap): Declare it as
Kenichi Handa <handa@m17n.org>
parents:
22883
diff
changeset
|
1044 (let* ((keyseq (read-key-sequence |
00f3497854c4
(quail-translation-keymap): Declare it as
Kenichi Handa <handa@m17n.org>
parents:
22883
diff
changeset
|
1045 (and input-method-use-echo-area |
00f3497854c4
(quail-translation-keymap): Declare it as
Kenichi Handa <handa@m17n.org>
parents:
22883
diff
changeset
|
1046 (concat input-method-previous-message |
00f3497854c4
(quail-translation-keymap): Declare it as
Kenichi Handa <handa@m17n.org>
parents:
22883
diff
changeset
|
1047 quail-conversion-str |
23599
ab69e7987be0
(quail-start-translation): Handle
Kenichi Handa <handa@m17n.org>
parents:
23401
diff
changeset
|
1048 quail-current-str)) |
ab69e7987be0
(quail-start-translation): Handle
Kenichi Handa <handa@m17n.org>
parents:
23401
diff
changeset
|
1049 nil nil t)) |
22917
00f3497854c4
(quail-translation-keymap): Declare it as
Kenichi Handa <handa@m17n.org>
parents:
22883
diff
changeset
|
1050 (cmd (lookup-key (quail-conversion-keymap) keyseq))) |
00f3497854c4
(quail-translation-keymap): Declare it as
Kenichi Handa <handa@m17n.org>
parents:
22883
diff
changeset
|
1051 (if (if key (commandp cmd) (eq cmd 'quail-self-insert-command)) |
22765
7cf2c3800e8f
(quail-mode): This variable deleted.
Kenichi Handa <handa@m17n.org>
parents:
22124
diff
changeset
|
1052 (progn |
22917
00f3497854c4
(quail-translation-keymap): Declare it as
Kenichi Handa <handa@m17n.org>
parents:
22883
diff
changeset
|
1053 (setq key t) |
00f3497854c4
(quail-translation-keymap): Declare it as
Kenichi Handa <handa@m17n.org>
parents:
22883
diff
changeset
|
1054 (setq last-command-event (aref keyseq (1- (length keyseq))) |
22777
1b0761cbc15b
(quail-conversion-keymap): New binding
Kenichi Handa <handa@m17n.org>
parents:
22765
diff
changeset
|
1055 last-command this-command |
1b0761cbc15b
(quail-conversion-keymap): New binding
Kenichi Handa <handa@m17n.org>
parents:
22765
diff
changeset
|
1056 this-command cmd) |
22765
7cf2c3800e8f
(quail-mode): This variable deleted.
Kenichi Handa <handa@m17n.org>
parents:
22124
diff
changeset
|
1057 (condition-case err |
7cf2c3800e8f
(quail-mode): This variable deleted.
Kenichi Handa <handa@m17n.org>
parents:
22124
diff
changeset
|
1058 (call-interactively cmd) |
22917
00f3497854c4
(quail-translation-keymap): Declare it as
Kenichi Handa <handa@m17n.org>
parents:
22883
diff
changeset
|
1059 (quail-error (message "%s" (cdr err)) (beep))) |
00f3497854c4
(quail-translation-keymap): Declare it as
Kenichi Handa <handa@m17n.org>
parents:
22883
diff
changeset
|
1060 (or quail-translating |
00f3497854c4
(quail-translation-keymap): Declare it as
Kenichi Handa <handa@m17n.org>
parents:
22883
diff
changeset
|
1061 (progn |
00f3497854c4
(quail-translation-keymap): Declare it as
Kenichi Handa <handa@m17n.org>
parents:
22883
diff
changeset
|
1062 (if quail-current-str |
00f3497854c4
(quail-translation-keymap): Declare it as
Kenichi Handa <handa@m17n.org>
parents:
22883
diff
changeset
|
1063 (setq quail-conversion-str |
00f3497854c4
(quail-translation-keymap): Declare it as
Kenichi Handa <handa@m17n.org>
parents:
22883
diff
changeset
|
1064 (concat quail-conversion-str |
00f3497854c4
(quail-translation-keymap): Declare it as
Kenichi Handa <handa@m17n.org>
parents:
22883
diff
changeset
|
1065 (if (stringp quail-current-str) |
00f3497854c4
(quail-translation-keymap): Declare it as
Kenichi Handa <handa@m17n.org>
parents:
22883
diff
changeset
|
1066 quail-current-str |
00f3497854c4
(quail-translation-keymap): Declare it as
Kenichi Handa <handa@m17n.org>
parents:
22883
diff
changeset
|
1067 (char-to-string quail-current-str))))) |
29326
44c929164604
(quail-start-conversion): Don't include
Kenichi Handa <handa@m17n.org>
parents:
29145
diff
changeset
|
1068 (if (or input-method-exit-on-first-char |
44c929164604
(quail-start-conversion): Don't include
Kenichi Handa <handa@m17n.org>
parents:
29145
diff
changeset
|
1069 (= (length quail-conversion-str) 0)) |
22917
00f3497854c4
(quail-translation-keymap): Declare it as
Kenichi Handa <handa@m17n.org>
parents:
22883
diff
changeset
|
1070 (setq quail-converting nil))))) |
22765
7cf2c3800e8f
(quail-mode): This variable deleted.
Kenichi Handa <handa@m17n.org>
parents:
22124
diff
changeset
|
1071 ;; KEYSEQ is not defined in the conversion keymap. |
7cf2c3800e8f
(quail-mode): This variable deleted.
Kenichi Handa <handa@m17n.org>
parents:
22124
diff
changeset
|
1072 ;; Let's return the event(s) to the caller. |
29326
44c929164604
(quail-start-conversion): Don't include
Kenichi Handa <handa@m17n.org>
parents:
29145
diff
changeset
|
1073 (setq unread-command-events |
22917
00f3497854c4
(quail-translation-keymap): Declare it as
Kenichi Handa <handa@m17n.org>
parents:
22883
diff
changeset
|
1074 (string-to-list (this-single-command-raw-keys))) |
00f3497854c4
(quail-translation-keymap): Declare it as
Kenichi Handa <handa@m17n.org>
parents:
22883
diff
changeset
|
1075 (setq quail-converting nil)))) |
22793
c3ab1de66dfc
(quail-simple-translation-keymap): Typo
Kenichi Handa <handa@m17n.org>
parents:
22777
diff
changeset
|
1076 (if (overlay-start quail-conv-overlay) |
22917
00f3497854c4
(quail-translation-keymap): Declare it as
Kenichi Handa <handa@m17n.org>
parents:
22883
diff
changeset
|
1077 (delete-region (overlay-start quail-conv-overlay) |
00f3497854c4
(quail-translation-keymap): Declare it as
Kenichi Handa <handa@m17n.org>
parents:
22883
diff
changeset
|
1078 (overlay-end quail-conv-overlay))) |
00f3497854c4
(quail-translation-keymap): Declare it as
Kenichi Handa <handa@m17n.org>
parents:
22883
diff
changeset
|
1079 (if (> (length quail-conversion-str) 0) |
22793
c3ab1de66dfc
(quail-simple-translation-keymap): Typo
Kenichi Handa <handa@m17n.org>
parents:
22777
diff
changeset
|
1080 (setq generated-events |
29326
44c929164604
(quail-start-conversion): Don't include
Kenichi Handa <handa@m17n.org>
parents:
29145
diff
changeset
|
1081 (string-to-list |
44c929164604
(quail-start-conversion): Don't include
Kenichi Handa <handa@m17n.org>
parents:
29145
diff
changeset
|
1082 (if enable-multibyte-characters |
44c929164604
(quail-start-conversion): Don't include
Kenichi Handa <handa@m17n.org>
parents:
29145
diff
changeset
|
1083 quail-conversion-str |
44c929164604
(quail-start-conversion): Don't include
Kenichi Handa <handa@m17n.org>
parents:
29145
diff
changeset
|
1084 (string-make-unibyte quail-conversion-str))))) |
22917
00f3497854c4
(quail-translation-keymap): Declare it as
Kenichi Handa <handa@m17n.org>
parents:
22883
diff
changeset
|
1085 (if (and input-method-exit-on-first-char generated-events) |
00f3497854c4
(quail-translation-keymap): Declare it as
Kenichi Handa <handa@m17n.org>
parents:
22883
diff
changeset
|
1086 (list (car generated-events)) |
00f3497854c4
(quail-translation-keymap): Declare it as
Kenichi Handa <handa@m17n.org>
parents:
22883
diff
changeset
|
1087 generated-events)) |
22765
7cf2c3800e8f
(quail-mode): This variable deleted.
Kenichi Handa <handa@m17n.org>
parents:
22124
diff
changeset
|
1088 |
7cf2c3800e8f
(quail-mode): This variable deleted.
Kenichi Handa <handa@m17n.org>
parents:
22124
diff
changeset
|
1089 ;; Since KEY doesn't start any translation, just return it. |
7cf2c3800e8f
(quail-mode): This variable deleted.
Kenichi Handa <handa@m17n.org>
parents:
22124
diff
changeset
|
1090 (list key))) |
17052 | 1091 |
1092 (defun quail-terminate-translation () | |
19519
1c0ecc266e38
(quail-terminate-translation): Doc-string
Kenichi Handa <handa@m17n.org>
parents:
19453
diff
changeset
|
1093 "Terminate the translation of the current key." |
22765
7cf2c3800e8f
(quail-mode): This variable deleted.
Kenichi Handa <handa@m17n.org>
parents:
22124
diff
changeset
|
1094 (setq quail-translating nil) |
17052 | 1095 (if (buffer-live-p quail-guidance-buf) |
1096 (save-excursion | |
1097 (set-buffer quail-guidance-buf) | |
22765
7cf2c3800e8f
(quail-mode): This variable deleted.
Kenichi Handa <handa@m17n.org>
parents:
22124
diff
changeset
|
1098 (erase-buffer)))) |
17052 | 1099 |
1100 (defun quail-select-current () | |
1101 "Select the current text shown in Quail translation region." | |
1102 (interactive) | |
1103 (quail-terminate-translation)) | |
1104 | |
1105 ;; Update the current translation status according to CONTROL-FLAG. | |
1106 ;; If CONTROL-FLAG is integer value, it is the number of keys in the | |
1107 ;; head quail-current-key which can be translated. The remaining keys | |
22917
00f3497854c4
(quail-translation-keymap): Declare it as
Kenichi Handa <handa@m17n.org>
parents:
22883
diff
changeset
|
1108 ;; are put back to unread-command-events to be handled again. If |
00f3497854c4
(quail-translation-keymap): Declare it as
Kenichi Handa <handa@m17n.org>
parents:
22883
diff
changeset
|
1109 ;; CONTROL-FLAG is t, terminate the translation for the whole keys in |
00f3497854c4
(quail-translation-keymap): Declare it as
Kenichi Handa <handa@m17n.org>
parents:
22883
diff
changeset
|
1110 ;; quail-current-key. If CONTROL-FLAG is nil, proceed the translation |
00f3497854c4
(quail-translation-keymap): Declare it as
Kenichi Handa <handa@m17n.org>
parents:
22883
diff
changeset
|
1111 ;; with more keys. |
17052 | 1112 |
1113 (defun quail-update-translation (control-flag) | |
1114 (let ((func (quail-update-translation-function))) | |
1115 (if func | |
22917
00f3497854c4
(quail-translation-keymap): Declare it as
Kenichi Handa <handa@m17n.org>
parents:
22883
diff
changeset
|
1116 (setq control-flag (funcall func control-flag)) |
17052 | 1117 (if (numberp control-flag) |
1118 (let ((len (length quail-current-key))) | |
22917
00f3497854c4
(quail-translation-keymap): Declare it as
Kenichi Handa <handa@m17n.org>
parents:
22883
diff
changeset
|
1119 (if (= len 1) |
00f3497854c4
(quail-translation-keymap): Declare it as
Kenichi Handa <handa@m17n.org>
parents:
22883
diff
changeset
|
1120 (setq control-flag t |
00f3497854c4
(quail-translation-keymap): Declare it as
Kenichi Handa <handa@m17n.org>
parents:
22883
diff
changeset
|
1121 quail-current-str quail-current-key) |
23304
3a7a029df593
(quail-update-guidance): Check for the
Kenichi Handa <handa@m17n.org>
parents:
23176
diff
changeset
|
1122 (if input-method-exit-on-first-char |
3a7a029df593
(quail-update-guidance): Check for the
Kenichi Handa <handa@m17n.org>
parents:
23176
diff
changeset
|
1123 (setq len control-flag) |
3a7a029df593
(quail-update-guidance): Check for the
Kenichi Handa <handa@m17n.org>
parents:
23176
diff
changeset
|
1124 (while (> len control-flag) |
3a7a029df593
(quail-update-guidance): Check for the
Kenichi Handa <handa@m17n.org>
parents:
23176
diff
changeset
|
1125 (setq len (1- len)) |
3a7a029df593
(quail-update-guidance): Check for the
Kenichi Handa <handa@m17n.org>
parents:
23176
diff
changeset
|
1126 (setq unread-command-events |
3a7a029df593
(quail-update-guidance): Check for the
Kenichi Handa <handa@m17n.org>
parents:
23176
diff
changeset
|
1127 (cons (aref quail-current-key len) |
3a7a029df593
(quail-update-guidance): Check for the
Kenichi Handa <handa@m17n.org>
parents:
23176
diff
changeset
|
1128 unread-command-events)))) |
22917
00f3497854c4
(quail-translation-keymap): Declare it as
Kenichi Handa <handa@m17n.org>
parents:
22883
diff
changeset
|
1129 (if quail-current-str |
00f3497854c4
(quail-translation-keymap): Declare it as
Kenichi Handa <handa@m17n.org>
parents:
22883
diff
changeset
|
1130 (if input-method-exit-on-first-char |
00f3497854c4
(quail-translation-keymap): Declare it as
Kenichi Handa <handa@m17n.org>
parents:
22883
diff
changeset
|
1131 (setq control-flag t)) |
00f3497854c4
(quail-translation-keymap): Declare it as
Kenichi Handa <handa@m17n.org>
parents:
22883
diff
changeset
|
1132 (setq quail-current-str |
22930
72582ab5369d
(quail-update-translation): Delete the
Kenichi Handa <handa@m17n.org>
parents:
22917
diff
changeset
|
1133 (substring quail-current-key 0 len))))) |
22917
00f3497854c4
(quail-translation-keymap): Declare it as
Kenichi Handa <handa@m17n.org>
parents:
22883
diff
changeset
|
1134 (if quail-current-str |
23304
3a7a029df593
(quail-update-guidance): Check for the
Kenichi Handa <handa@m17n.org>
parents:
23176
diff
changeset
|
1135 (if (and input-method-exit-on-first-char |
3a7a029df593
(quail-update-guidance): Check for the
Kenichi Handa <handa@m17n.org>
parents:
23176
diff
changeset
|
1136 (quail-simple)) |
22917
00f3497854c4
(quail-translation-keymap): Declare it as
Kenichi Handa <handa@m17n.org>
parents:
22883
diff
changeset
|
1137 (setq control-flag t)) |
23304
3a7a029df593
(quail-update-guidance): Check for the
Kenichi Handa <handa@m17n.org>
parents:
23176
diff
changeset
|
1138 (setq quail-current-str quail-current-key))))) |
3a7a029df593
(quail-update-guidance): Check for the
Kenichi Handa <handa@m17n.org>
parents:
23176
diff
changeset
|
1139 (or input-method-use-echo-area |
3a7a029df593
(quail-update-guidance): Check for the
Kenichi Handa <handa@m17n.org>
parents:
23176
diff
changeset
|
1140 (progn |
3a7a029df593
(quail-update-guidance): Check for the
Kenichi Handa <handa@m17n.org>
parents:
23176
diff
changeset
|
1141 (quail-delete-region) |
3a7a029df593
(quail-update-guidance): Check for the
Kenichi Handa <handa@m17n.org>
parents:
23176
diff
changeset
|
1142 (insert quail-current-str))) |
3a7a029df593
(quail-update-guidance): Check for the
Kenichi Handa <handa@m17n.org>
parents:
23176
diff
changeset
|
1143 (let (quail-current-str) |
3a7a029df593
(quail-update-guidance): Check for the
Kenichi Handa <handa@m17n.org>
parents:
23176
diff
changeset
|
1144 (quail-update-guidance)) |
22917
00f3497854c4
(quail-translation-keymap): Declare it as
Kenichi Handa <handa@m17n.org>
parents:
22883
diff
changeset
|
1145 (or (stringp quail-current-str) |
00f3497854c4
(quail-translation-keymap): Declare it as
Kenichi Handa <handa@m17n.org>
parents:
22883
diff
changeset
|
1146 (setq quail-current-str (char-to-string quail-current-str))) |
19432
4492653b04e8
(quail-exit-from-minibuffer): Call
Kenichi Handa <handa@m17n.org>
parents:
19404
diff
changeset
|
1147 (if control-flag |
4492653b04e8
(quail-exit-from-minibuffer): Call
Kenichi Handa <handa@m17n.org>
parents:
19404
diff
changeset
|
1148 (quail-terminate-translation))) |
17052 | 1149 |
1150 (defun quail-self-insert-command () | |
1151 "Add the typed character to the key for translation." | |
1152 (interactive "*") | |
1153 (setq quail-current-key | |
1154 (concat quail-current-key (char-to-string last-command-event))) | |
22917
00f3497854c4
(quail-translation-keymap): Declare it as
Kenichi Handa <handa@m17n.org>
parents:
22883
diff
changeset
|
1155 (or (catch 'quail-tag |
00f3497854c4
(quail-translation-keymap): Declare it as
Kenichi Handa <handa@m17n.org>
parents:
22883
diff
changeset
|
1156 (quail-update-translation (quail-translate-key)) |
00f3497854c4
(quail-translation-keymap): Declare it as
Kenichi Handa <handa@m17n.org>
parents:
22883
diff
changeset
|
1157 t) |
00f3497854c4
(quail-translation-keymap): Declare it as
Kenichi Handa <handa@m17n.org>
parents:
22883
diff
changeset
|
1158 ;; If someone throws for `quail-tag' by value nil, we exit from |
00f3497854c4
(quail-translation-keymap): Declare it as
Kenichi Handa <handa@m17n.org>
parents:
22883
diff
changeset
|
1159 ;; translation mode. |
00f3497854c4
(quail-translation-keymap): Declare it as
Kenichi Handa <handa@m17n.org>
parents:
22883
diff
changeset
|
1160 (setq quail-translating nil))) |
17052 | 1161 |
18556
99e8ae18137f
(quail-guidance-buf): Make it buffer
Kenichi Handa <handa@m17n.org>
parents:
18377
diff
changeset
|
1162 ;; 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
|
1163 (defun quail-map-definition (map) |
99e8ae18137f
(quail-guidance-buf): Make it buffer
Kenichi Handa <handa@m17n.org>
parents:
18377
diff
changeset
|
1164 (let ((def (car map))) |
99e8ae18137f
(quail-guidance-buf): Make it buffer
Kenichi Handa <handa@m17n.org>
parents:
18377
diff
changeset
|
1165 (if (and (consp def) (not (vectorp (cdr def)))) |
99e8ae18137f
(quail-guidance-buf): Make it buffer
Kenichi Handa <handa@m17n.org>
parents:
18377
diff
changeset
|
1166 (setq def (car def))) |
26891
651d521c8f52
(quail-install-map): New optional arg
Kenichi Handa <handa@m17n.org>
parents:
24821
diff
changeset
|
1167 (if (eq def t) |
651d521c8f52
(quail-install-map): New optional arg
Kenichi Handa <handa@m17n.org>
parents:
24821
diff
changeset
|
1168 (setq def nil)) |
18556
99e8ae18137f
(quail-guidance-buf): Make it buffer
Kenichi Handa <handa@m17n.org>
parents:
18377
diff
changeset
|
1169 def)) |
99e8ae18137f
(quail-guidance-buf): Make it buffer
Kenichi Handa <handa@m17n.org>
parents:
18377
diff
changeset
|
1170 |
99e8ae18137f
(quail-guidance-buf): Make it buffer
Kenichi Handa <handa@m17n.org>
parents:
18377
diff
changeset
|
1171 ;; 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
|
1172 ;; 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
|
1173 ;; the sequence. |
99e8ae18137f
(quail-guidance-buf): Make it buffer
Kenichi Handa <handa@m17n.org>
parents:
18377
diff
changeset
|
1174 (defun quail-get-current-str (len def) |
99e8ae18137f
(quail-guidance-buf): Make it buffer
Kenichi Handa <handa@m17n.org>
parents:
18377
diff
changeset
|
1175 (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
|
1176 def |
99e8ae18137f
(quail-guidance-buf): Make it buffer
Kenichi Handa <handa@m17n.org>
parents:
18377
diff
changeset
|
1177 (and (> len 1) |
99e8ae18137f
(quail-guidance-buf): Make it buffer
Kenichi Handa <handa@m17n.org>
parents:
18377
diff
changeset
|
1178 (let ((str (quail-get-current-str |
99e8ae18137f
(quail-guidance-buf): Make it buffer
Kenichi Handa <handa@m17n.org>
parents:
18377
diff
changeset
|
1179 (1- len) |
99e8ae18137f
(quail-guidance-buf): Make it buffer
Kenichi Handa <handa@m17n.org>
parents:
18377
diff
changeset
|
1180 (quail-map-definition (quail-lookup-key |
99e8ae18137f
(quail-guidance-buf): Make it buffer
Kenichi Handa <handa@m17n.org>
parents:
18377
diff
changeset
|
1181 quail-current-key (1- len)))))) |
99e8ae18137f
(quail-guidance-buf): Make it buffer
Kenichi Handa <handa@m17n.org>
parents:
18377
diff
changeset
|
1182 (if str |
99e8ae18137f
(quail-guidance-buf): Make it buffer
Kenichi Handa <handa@m17n.org>
parents:
18377
diff
changeset
|
1183 (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
|
1184 (substring quail-current-key (1- len) len))))))) |
99e8ae18137f
(quail-guidance-buf): Make it buffer
Kenichi Handa <handa@m17n.org>
parents:
18377
diff
changeset
|
1185 |
99e8ae18137f
(quail-guidance-buf): Make it buffer
Kenichi Handa <handa@m17n.org>
parents:
18377
diff
changeset
|
1186 (defvar quail-guidance-translations-starting-column 20) |
99e8ae18137f
(quail-guidance-buf): Make it buffer
Kenichi Handa <handa@m17n.org>
parents:
18377
diff
changeset
|
1187 |
99e8ae18137f
(quail-guidance-buf): Make it buffer
Kenichi Handa <handa@m17n.org>
parents:
18377
diff
changeset
|
1188 ;; 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
|
1189 ;; current translation. |
99e8ae18137f
(quail-guidance-buf): Make it buffer
Kenichi Handa <handa@m17n.org>
parents:
18377
diff
changeset
|
1190 (defun quail-update-current-translations (&optional relative-index) |
99e8ae18137f
(quail-guidance-buf): Make it buffer
Kenichi Handa <handa@m17n.org>
parents:
18377
diff
changeset
|
1191 (let* ((indices (car quail-current-translations)) |
99e8ae18137f
(quail-guidance-buf): Make it buffer
Kenichi Handa <handa@m17n.org>
parents:
18377
diff
changeset
|
1192 (cur (car indices)) |
99e8ae18137f
(quail-guidance-buf): Make it buffer
Kenichi Handa <handa@m17n.org>
parents:
18377
diff
changeset
|
1193 (start (nth 1 indices)) |
99e8ae18137f
(quail-guidance-buf): Make it buffer
Kenichi Handa <handa@m17n.org>
parents:
18377
diff
changeset
|
1194 (end (nth 2 indices))) |
99e8ae18137f
(quail-guidance-buf): Make it buffer
Kenichi Handa <handa@m17n.org>
parents:
18377
diff
changeset
|
1195 ;; Validate the index number of current translation. |
99e8ae18137f
(quail-guidance-buf): Make it buffer
Kenichi Handa <handa@m17n.org>
parents:
18377
diff
changeset
|
1196 (if (< cur 0) |
99e8ae18137f
(quail-guidance-buf): Make it buffer
Kenichi Handa <handa@m17n.org>
parents:
18377
diff
changeset
|
1197 (setcar indices (setq cur 0)) |
99e8ae18137f
(quail-guidance-buf): Make it buffer
Kenichi Handa <handa@m17n.org>
parents:
18377
diff
changeset
|
1198 (if (>= cur (length (cdr quail-current-translations))) |
99e8ae18137f
(quail-guidance-buf): Make it buffer
Kenichi Handa <handa@m17n.org>
parents:
18377
diff
changeset
|
1199 (setcar indices |
99e8ae18137f
(quail-guidance-buf): Make it buffer
Kenichi Handa <handa@m17n.org>
parents:
18377
diff
changeset
|
1200 (setq cur (1- (length (cdr quail-current-translations))))))) |
99e8ae18137f
(quail-guidance-buf): Make it buffer
Kenichi Handa <handa@m17n.org>
parents:
18377
diff
changeset
|
1201 |
99e8ae18137f
(quail-guidance-buf): Make it buffer
Kenichi Handa <handa@m17n.org>
parents:
18377
diff
changeset
|
1202 (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
|
1203 (< cur start) ; We moved to the previous block. |
99e8ae18137f
(quail-guidance-buf): Make it buffer
Kenichi Handa <handa@m17n.org>
parents:
18377
diff
changeset
|
1204 (>= cur end)) ; We moved to the next block. |
99e8ae18137f
(quail-guidance-buf): Make it buffer
Kenichi Handa <handa@m17n.org>
parents:
18377
diff
changeset
|
1205 (let ((len (length (cdr quail-current-translations))) |
99e8ae18137f
(quail-guidance-buf): Make it buffer
Kenichi Handa <handa@m17n.org>
parents:
18377
diff
changeset
|
1206 (maxcol (- (window-width quail-guidance-win) |
99e8ae18137f
(quail-guidance-buf): Make it buffer
Kenichi Handa <handa@m17n.org>
parents:
18377
diff
changeset
|
1207 quail-guidance-translations-starting-column)) |
99e8ae18137f
(quail-guidance-buf): Make it buffer
Kenichi Handa <handa@m17n.org>
parents:
18377
diff
changeset
|
1208 (block (nth 3 indices)) |
99e8ae18137f
(quail-guidance-buf): Make it buffer
Kenichi Handa <handa@m17n.org>
parents:
18377
diff
changeset
|
1209 col idx width trans num-items blocks) |
99e8ae18137f
(quail-guidance-buf): Make it buffer
Kenichi Handa <handa@m17n.org>
parents:
18377
diff
changeset
|
1210 (if (< cur start) |
99e8ae18137f
(quail-guidance-buf): Make it buffer
Kenichi Handa <handa@m17n.org>
parents:
18377
diff
changeset
|
1211 ;; We must calculate from the head. |
99e8ae18137f
(quail-guidance-buf): Make it buffer
Kenichi Handa <handa@m17n.org>
parents:
18377
diff
changeset
|
1212 (setq start 0 block 0) |
99e8ae18137f
(quail-guidance-buf): Make it buffer
Kenichi Handa <handa@m17n.org>
parents:
18377
diff
changeset
|
1213 (if end ; i.e. (>= cur end) |
99e8ae18137f
(quail-guidance-buf): Make it buffer
Kenichi Handa <handa@m17n.org>
parents:
18377
diff
changeset
|
1214 (setq start end))) |
99e8ae18137f
(quail-guidance-buf): Make it buffer
Kenichi Handa <handa@m17n.org>
parents:
18377
diff
changeset
|
1215 (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
|
1216 ;; 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
|
1217 (while (and (< idx len) (>= cur end)) |
99e8ae18137f
(quail-guidance-buf): Make it buffer
Kenichi Handa <handa@m17n.org>
parents:
18377
diff
changeset
|
1218 (if (= num-items 0) |
99e8ae18137f
(quail-guidance-buf): Make it buffer
Kenichi Handa <handa@m17n.org>
parents:
18377
diff
changeset
|
1219 (setq start idx col 0 block (1+ block))) |
99e8ae18137f
(quail-guidance-buf): Make it buffer
Kenichi Handa <handa@m17n.org>
parents:
18377
diff
changeset
|
1220 (setq trans (aref (cdr quail-current-translations) idx)) |
99e8ae18137f
(quail-guidance-buf): Make it buffer
Kenichi Handa <handa@m17n.org>
parents:
18377
diff
changeset
|
1221 (setq width (if (integerp trans) (char-width trans) |
99e8ae18137f
(quail-guidance-buf): Make it buffer
Kenichi Handa <handa@m17n.org>
parents:
18377
diff
changeset
|
1222 (string-width trans))) |
99e8ae18137f
(quail-guidance-buf): Make it buffer
Kenichi Handa <handa@m17n.org>
parents:
18377
diff
changeset
|
1223 (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
|
1224 (if (and (> num-items 0) |
99e8ae18137f
(quail-guidance-buf): Make it buffer
Kenichi Handa <handa@m17n.org>
parents:
18377
diff
changeset
|
1225 (or (>= col maxcol) (> num-items 10))) |
99e8ae18137f
(quail-guidance-buf): Make it buffer
Kenichi Handa <handa@m17n.org>
parents:
18377
diff
changeset
|
1226 (setq end idx num-items 0) |
99e8ae18137f
(quail-guidance-buf): Make it buffer
Kenichi Handa <handa@m17n.org>
parents:
18377
diff
changeset
|
1227 (setq idx (1+ idx)))) |
99e8ae18137f
(quail-guidance-buf): Make it buffer
Kenichi Handa <handa@m17n.org>
parents:
18377
diff
changeset
|
1228 (setcar (nthcdr 3 indices) block) |
99e8ae18137f
(quail-guidance-buf): Make it buffer
Kenichi Handa <handa@m17n.org>
parents:
18377
diff
changeset
|
1229 (if (>= idx len) |
99e8ae18137f
(quail-guidance-buf): Make it buffer
Kenichi Handa <handa@m17n.org>
parents:
18377
diff
changeset
|
1230 (progn |
99e8ae18137f
(quail-guidance-buf): Make it buffer
Kenichi Handa <handa@m17n.org>
parents:
18377
diff
changeset
|
1231 ;; We hit the tail before reaching MAXCOL. |
99e8ae18137f
(quail-guidance-buf): Make it buffer
Kenichi Handa <handa@m17n.org>
parents:
18377
diff
changeset
|
1232 (setq end idx) |
99e8ae18137f
(quail-guidance-buf): Make it buffer
Kenichi Handa <handa@m17n.org>
parents:
18377
diff
changeset
|
1233 (setcar (nthcdr 4 indices) block))) |
99e8ae18137f
(quail-guidance-buf): Make it buffer
Kenichi Handa <handa@m17n.org>
parents:
18377
diff
changeset
|
1234 (setcar (cdr indices) start) |
99e8ae18137f
(quail-guidance-buf): Make it buffer
Kenichi Handa <handa@m17n.org>
parents:
18377
diff
changeset
|
1235 (setcar (nthcdr 2 indices) end))) |
99e8ae18137f
(quail-guidance-buf): Make it buffer
Kenichi Handa <handa@m17n.org>
parents:
18377
diff
changeset
|
1236 (if relative-index |
99e8ae18137f
(quail-guidance-buf): Make it buffer
Kenichi Handa <handa@m17n.org>
parents:
18377
diff
changeset
|
1237 (if (>= (+ start relative-index) end) |
99e8ae18137f
(quail-guidance-buf): Make it buffer
Kenichi Handa <handa@m17n.org>
parents:
18377
diff
changeset
|
1238 (setcar indices end) |
99e8ae18137f
(quail-guidance-buf): Make it buffer
Kenichi Handa <handa@m17n.org>
parents:
18377
diff
changeset
|
1239 (setcar indices (+ start relative-index)))) |
99e8ae18137f
(quail-guidance-buf): Make it buffer
Kenichi Handa <handa@m17n.org>
parents:
18377
diff
changeset
|
1240 (setq quail-current-str |
22917
00f3497854c4
(quail-translation-keymap): Declare it as
Kenichi Handa <handa@m17n.org>
parents:
22883
diff
changeset
|
1241 (aref (cdr quail-current-translations) (car indices))) |
00f3497854c4
(quail-translation-keymap): Declare it as
Kenichi Handa <handa@m17n.org>
parents:
22883
diff
changeset
|
1242 (or (stringp quail-current-str) |
00f3497854c4
(quail-translation-keymap): Declare it as
Kenichi Handa <handa@m17n.org>
parents:
22883
diff
changeset
|
1243 (setq quail-current-str (char-to-string quail-current-str))))) |
18556
99e8ae18137f
(quail-guidance-buf): Make it buffer
Kenichi Handa <handa@m17n.org>
parents:
18377
diff
changeset
|
1244 |
17052 | 1245 (defun quail-translate-key () |
1246 "Translate the current key sequence according to the current Quail map. | |
1247 Return t if we can terminate the translation. | |
1248 Return nil if the current key sequence may be followed by more keys. | |
1249 Return number if we can't find any translation for the current key | |
1250 sequence. The number is the count of valid keys in the current | |
1251 sequence counting from the head." | |
1252 (let* ((len (length quail-current-key)) | |
1253 (map (quail-lookup-key quail-current-key len)) | |
1254 def ch) | |
1255 (if map | |
18556
99e8ae18137f
(quail-guidance-buf): Make it buffer
Kenichi Handa <handa@m17n.org>
parents:
18377
diff
changeset
|
1256 (let ((def (quail-map-definition map))) |
99e8ae18137f
(quail-guidance-buf): Make it buffer
Kenichi Handa <handa@m17n.org>
parents:
18377
diff
changeset
|
1257 (setq quail-current-str (quail-get-current-str len def)) |
17052 | 1258 ;; Return t only if we can terminate the current translation. |
1259 (and | |
1260 ;; No alternative translations. | |
1261 (or (null (consp def)) (= (length (cdr def)) 1)) | |
1262 ;; No translation for the longer key. | |
1263 (null (cdr map)) | |
1264 ;; No shorter breaking point. | |
1265 (or (null (quail-maximum-shortest)) | |
1266 (< len 3) | |
1267 (null (quail-lookup-key quail-current-key (1- len))) | |
1268 (null (quail-lookup-key | |
1269 (substring quail-current-key -2 -1) 1))))) | |
1270 | |
1271 ;; There's no translation for the current key sequence. Before | |
1272 ;; giving up, we must check two possibilities. | |
1273 (cond ((and | |
1274 (quail-maximum-shortest) | |
1275 (>= len 4) | |
18556
99e8ae18137f
(quail-guidance-buf): Make it buffer
Kenichi Handa <handa@m17n.org>
parents:
18377
diff
changeset
|
1276 (setq def (quail-map-definition |
99e8ae18137f
(quail-guidance-buf): Make it buffer
Kenichi Handa <handa@m17n.org>
parents:
18377
diff
changeset
|
1277 (quail-lookup-key quail-current-key (- len 2)))) |
17052 | 1278 (quail-lookup-key (substring quail-current-key -2) 2)) |
1279 ;; Now the sequence is "...ABCD", which can be split into | |
1280 ;; "...AB" and "CD..." to get valid translation. | |
1281 ;; At first, get translation of "...AB". | |
18556
99e8ae18137f
(quail-guidance-buf): Make it buffer
Kenichi Handa <handa@m17n.org>
parents:
18377
diff
changeset
|
1282 (setq quail-current-str (quail-get-current-str (- len 2) def)) |
17052 | 1283 ;; Then, return the length of "...AB". |
1284 (- len 2)) | |
1285 | |
18797
e9aa787f0154
(quail-translate-key): Fix previous change.
Kenichi Handa <handa@m17n.org>
parents:
18642
diff
changeset
|
1286 ((and (> len 0) |
e9aa787f0154
(quail-translate-key): Fix previous change.
Kenichi Handa <handa@m17n.org>
parents:
18642
diff
changeset
|
1287 (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
|
1288 quail-current-translations |
17052 | 1289 (not (quail-deterministic)) |
1290 (setq ch (aref quail-current-key (1- len))) | |
1291 (>= ch ?0) (<= ch ?9)) | |
1292 ;; A numeric key is entered to select a desirable translation. | |
1293 (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
|
1294 ;; 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
|
1295 (setq ch (if (= ch ?0) 9 (- ch ?1))) |
99e8ae18137f
(quail-guidance-buf): Make it buffer
Kenichi Handa <handa@m17n.org>
parents:
18377
diff
changeset
|
1296 (quail-update-current-translations ch) |
17052 | 1297 ;; And, we can terminate the current translation. |
1298 t) | |
1299 | |
1300 (t | |
1301 ;; No way to handle the last character in this context. | |
1302 (1- len)))))) | |
1303 | |
1304 (defun quail-next-translation () | |
1305 "Select next translation in the current batch of candidates." | |
1306 (interactive) | |
1307 (if quail-current-translations | |
18556
99e8ae18137f
(quail-guidance-buf): Make it buffer
Kenichi Handa <handa@m17n.org>
parents:
18377
diff
changeset
|
1308 (let ((indices (car quail-current-translations))) |
99e8ae18137f
(quail-guidance-buf): Make it buffer
Kenichi Handa <handa@m17n.org>
parents:
18377
diff
changeset
|
1309 (if (= (1+ (car indices)) (length (cdr quail-current-translations))) |
19084
9f4b95f30c4f
(quail-next-translation): Call
Kenichi Handa <handa@m17n.org>
parents:
18983
diff
changeset
|
1310 ;; We are already at the tail. |
18556
99e8ae18137f
(quail-guidance-buf): Make it buffer
Kenichi Handa <handa@m17n.org>
parents:
18377
diff
changeset
|
1311 (beep) |
99e8ae18137f
(quail-guidance-buf): Make it buffer
Kenichi Handa <handa@m17n.org>
parents:
18377
diff
changeset
|
1312 (setcar indices (1+ (car indices))) |
99e8ae18137f
(quail-guidance-buf): Make it buffer
Kenichi Handa <handa@m17n.org>
parents:
18377
diff
changeset
|
1313 (quail-update-current-translations) |
99e8ae18137f
(quail-guidance-buf): Make it buffer
Kenichi Handa <handa@m17n.org>
parents:
18377
diff
changeset
|
1314 (quail-update-translation nil))) |
22765
7cf2c3800e8f
(quail-mode): This variable deleted.
Kenichi Handa <handa@m17n.org>
parents:
22124
diff
changeset
|
1315 (setq unread-command-events |
7cf2c3800e8f
(quail-mode): This variable deleted.
Kenichi Handa <handa@m17n.org>
parents:
22124
diff
changeset
|
1316 (cons last-command-event unread-command-events)) |
7cf2c3800e8f
(quail-mode): This variable deleted.
Kenichi Handa <handa@m17n.org>
parents:
22124
diff
changeset
|
1317 (quail-terminate-translation))) |
17052 | 1318 |
1319 (defun quail-prev-translation () | |
1320 "Select previous translation in the current batch of candidates." | |
1321 (interactive) | |
1322 (if quail-current-translations | |
18556
99e8ae18137f
(quail-guidance-buf): Make it buffer
Kenichi Handa <handa@m17n.org>
parents:
18377
diff
changeset
|
1323 (let ((indices (car quail-current-translations))) |
99e8ae18137f
(quail-guidance-buf): Make it buffer
Kenichi Handa <handa@m17n.org>
parents:
18377
diff
changeset
|
1324 (if (= (car indices) 0) |
99e8ae18137f
(quail-guidance-buf): Make it buffer
Kenichi Handa <handa@m17n.org>
parents:
18377
diff
changeset
|
1325 ;; We are already at the head. |
99e8ae18137f
(quail-guidance-buf): Make it buffer
Kenichi Handa <handa@m17n.org>
parents:
18377
diff
changeset
|
1326 (beep) |
99e8ae18137f
(quail-guidance-buf): Make it buffer
Kenichi Handa <handa@m17n.org>
parents:
18377
diff
changeset
|
1327 (setcar indices (1- (car indices))) |
99e8ae18137f
(quail-guidance-buf): Make it buffer
Kenichi Handa <handa@m17n.org>
parents:
18377
diff
changeset
|
1328 (quail-update-current-translations) |
99e8ae18137f
(quail-guidance-buf): Make it buffer
Kenichi Handa <handa@m17n.org>
parents:
18377
diff
changeset
|
1329 (quail-update-translation nil))) |
22765
7cf2c3800e8f
(quail-mode): This variable deleted.
Kenichi Handa <handa@m17n.org>
parents:
22124
diff
changeset
|
1330 (setq unread-command-events |
7cf2c3800e8f
(quail-mode): This variable deleted.
Kenichi Handa <handa@m17n.org>
parents:
22124
diff
changeset
|
1331 (cons last-command-event unread-command-events)) |
7cf2c3800e8f
(quail-mode): This variable deleted.
Kenichi Handa <handa@m17n.org>
parents:
22124
diff
changeset
|
1332 (quail-terminate-translation))) |
17052 | 1333 |
1334 (defun quail-next-translation-block () | |
18556
99e8ae18137f
(quail-guidance-buf): Make it buffer
Kenichi Handa <handa@m17n.org>
parents:
18377
diff
changeset
|
1335 "Select from the next block of translations." |
17052 | 1336 (interactive) |
1337 (if quail-current-translations | |
18556
99e8ae18137f
(quail-guidance-buf): Make it buffer
Kenichi Handa <handa@m17n.org>
parents:
18377
diff
changeset
|
1338 (let* ((indices (car quail-current-translations)) |
99e8ae18137f
(quail-guidance-buf): Make it buffer
Kenichi Handa <handa@m17n.org>
parents:
18377
diff
changeset
|
1339 (offset (- (car indices) (nth 1 indices)))) |
99e8ae18137f
(quail-guidance-buf): Make it buffer
Kenichi Handa <handa@m17n.org>
parents:
18377
diff
changeset
|
1340 (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
|
1341 ;; We are already at the last block. |
99e8ae18137f
(quail-guidance-buf): Make it buffer
Kenichi Handa <handa@m17n.org>
parents:
18377
diff
changeset
|
1342 (beep) |
99e8ae18137f
(quail-guidance-buf): Make it buffer
Kenichi Handa <handa@m17n.org>
parents:
18377
diff
changeset
|
1343 (setcar indices (+ (nth 2 indices) offset)) |
99e8ae18137f
(quail-guidance-buf): Make it buffer
Kenichi Handa <handa@m17n.org>
parents:
18377
diff
changeset
|
1344 (quail-update-current-translations) |
99e8ae18137f
(quail-guidance-buf): Make it buffer
Kenichi Handa <handa@m17n.org>
parents:
18377
diff
changeset
|
1345 (quail-update-translation nil))) |
22765
7cf2c3800e8f
(quail-mode): This variable deleted.
Kenichi Handa <handa@m17n.org>
parents:
22124
diff
changeset
|
1346 (setq unread-command-events |
22917
00f3497854c4
(quail-translation-keymap): Declare it as
Kenichi Handa <handa@m17n.org>
parents:
22883
diff
changeset
|
1347 (cons last-command-event unread-command-events)) |
22765
7cf2c3800e8f
(quail-mode): This variable deleted.
Kenichi Handa <handa@m17n.org>
parents:
22124
diff
changeset
|
1348 (quail-terminate-translation))) |
17052 | 1349 |
1350 (defun quail-prev-translation-block () | |
1351 "Select the previous batch of 10 translation candidates." | |
1352 (interactive) | |
18556
99e8ae18137f
(quail-guidance-buf): Make it buffer
Kenichi Handa <handa@m17n.org>
parents:
18377
diff
changeset
|
1353 (if quail-current-translations |
99e8ae18137f
(quail-guidance-buf): Make it buffer
Kenichi Handa <handa@m17n.org>
parents:
18377
diff
changeset
|
1354 (let* ((indices (car quail-current-translations)) |
99e8ae18137f
(quail-guidance-buf): Make it buffer
Kenichi Handa <handa@m17n.org>
parents:
18377
diff
changeset
|
1355 (offset (- (car indices) (nth 1 indices)))) |
99e8ae18137f
(quail-guidance-buf): Make it buffer
Kenichi Handa <handa@m17n.org>
parents:
18377
diff
changeset
|
1356 (if (= (nth 1 indices) 0) |
99e8ae18137f
(quail-guidance-buf): Make it buffer
Kenichi Handa <handa@m17n.org>
parents:
18377
diff
changeset
|
1357 ;; We are already at the first block. |
99e8ae18137f
(quail-guidance-buf): Make it buffer
Kenichi Handa <handa@m17n.org>
parents:
18377
diff
changeset
|
1358 (beep) |
99e8ae18137f
(quail-guidance-buf): Make it buffer
Kenichi Handa <handa@m17n.org>
parents:
18377
diff
changeset
|
1359 (setcar indices (1- (nth 1 indices))) |
99e8ae18137f
(quail-guidance-buf): Make it buffer
Kenichi Handa <handa@m17n.org>
parents:
18377
diff
changeset
|
1360 (quail-update-current-translations) |
99e8ae18137f
(quail-guidance-buf): Make it buffer
Kenichi Handa <handa@m17n.org>
parents:
18377
diff
changeset
|
1361 (if (< (+ (nth 1 indices) offset) (nth 2 indices)) |
99e8ae18137f
(quail-guidance-buf): Make it buffer
Kenichi Handa <handa@m17n.org>
parents:
18377
diff
changeset
|
1362 (progn |
99e8ae18137f
(quail-guidance-buf): Make it buffer
Kenichi Handa <handa@m17n.org>
parents:
18377
diff
changeset
|
1363 (setcar indices (+ (nth 1 indices) offset)) |
99e8ae18137f
(quail-guidance-buf): Make it buffer
Kenichi Handa <handa@m17n.org>
parents:
18377
diff
changeset
|
1364 (quail-update-current-translations))) |
99e8ae18137f
(quail-guidance-buf): Make it buffer
Kenichi Handa <handa@m17n.org>
parents:
18377
diff
changeset
|
1365 (quail-update-translation nil))) |
22765
7cf2c3800e8f
(quail-mode): This variable deleted.
Kenichi Handa <handa@m17n.org>
parents:
22124
diff
changeset
|
1366 (setq unread-command-events |
7cf2c3800e8f
(quail-mode): This variable deleted.
Kenichi Handa <handa@m17n.org>
parents:
22124
diff
changeset
|
1367 (cons last-command-event unread-command-events)) |
7cf2c3800e8f
(quail-mode): This variable deleted.
Kenichi Handa <handa@m17n.org>
parents:
22124
diff
changeset
|
1368 (quail-terminate-translation))) |
17052 | 1369 |
1370 (defun quail-abort-translation () | |
1371 "Abort translation and delete the current Quail key sequence." | |
1372 (interactive) | |
1373 (quail-delete-region) | |
22917
00f3497854c4
(quail-translation-keymap): Declare it as
Kenichi Handa <handa@m17n.org>
parents:
22883
diff
changeset
|
1374 (setq quail-current-str nil) |
17052 | 1375 (quail-terminate-translation)) |
1376 | |
1377 (defun quail-delete-last-char () | |
1378 "Delete the last input character from the current Quail key sequence." | |
1379 (interactive) | |
1380 (if (= (length quail-current-key) 1) | |
1381 (quail-abort-translation) | |
1382 (setq quail-current-key (substring quail-current-key 0 -1)) | |
26891
651d521c8f52
(quail-install-map): New optional arg
Kenichi Handa <handa@m17n.org>
parents:
24821
diff
changeset
|
1383 (quail-delete-region) |
17052 | 1384 (quail-update-translation (quail-translate-key)))) |
1385 | |
1386 ;; For conversion mode. | |
1387 | |
23887
3a4d3e2418dc
(quail-point-in-conversion-region): New
Kenichi Handa <handa@m17n.org>
parents:
23629
diff
changeset
|
1388 (defsubst quail-point-in-conversion-region () |
3a4d3e2418dc
(quail-point-in-conversion-region): New
Kenichi Handa <handa@m17n.org>
parents:
23629
diff
changeset
|
1389 "Return non-nil value if the point is in conversion region of Quail mode." |
3a4d3e2418dc
(quail-point-in-conversion-region): New
Kenichi Handa <handa@m17n.org>
parents:
23629
diff
changeset
|
1390 (let (start pos) |
3a4d3e2418dc
(quail-point-in-conversion-region): New
Kenichi Handa <handa@m17n.org>
parents:
23629
diff
changeset
|
1391 (and (setq start (overlay-start quail-conv-overlay)) |
3a4d3e2418dc
(quail-point-in-conversion-region): New
Kenichi Handa <handa@m17n.org>
parents:
23629
diff
changeset
|
1392 (>= (setq pos (point)) start) |
3a4d3e2418dc
(quail-point-in-conversion-region): New
Kenichi Handa <handa@m17n.org>
parents:
23629
diff
changeset
|
1393 (<= pos (overlay-end quail-conv-overlay))))) |
3a4d3e2418dc
(quail-point-in-conversion-region): New
Kenichi Handa <handa@m17n.org>
parents:
23629
diff
changeset
|
1394 |
17052 | 1395 (defun quail-conversion-backward-char () |
1396 (interactive) | |
1397 (if (<= (point) (overlay-start quail-conv-overlay)) | |
22765
7cf2c3800e8f
(quail-mode): This variable deleted.
Kenichi Handa <handa@m17n.org>
parents:
22124
diff
changeset
|
1398 (quail-error "Beginning of conversion region")) |
7cf2c3800e8f
(quail-mode): This variable deleted.
Kenichi Handa <handa@m17n.org>
parents:
22124
diff
changeset
|
1399 (setq quail-translating nil) |
17052 | 1400 (forward-char -1)) |
1401 | |
1402 (defun quail-conversion-forward-char () | |
1403 (interactive) | |
1404 (if (>= (point) (overlay-end quail-conv-overlay)) | |
22765
7cf2c3800e8f
(quail-mode): This variable deleted.
Kenichi Handa <handa@m17n.org>
parents:
22124
diff
changeset
|
1405 (quail-error "End of conversion region")) |
7cf2c3800e8f
(quail-mode): This variable deleted.
Kenichi Handa <handa@m17n.org>
parents:
22124
diff
changeset
|
1406 (setq quail-translating nil) |
17052 | 1407 (forward-char 1)) |
1408 | |
1409 (defun quail-conversion-beginning-of-region () | |
1410 (interactive) | |
22777
1b0761cbc15b
(quail-conversion-keymap): New binding
Kenichi Handa <handa@m17n.org>
parents:
22765
diff
changeset
|
1411 (setq quail-translating nil) |
17052 | 1412 (goto-char (overlay-start quail-conv-overlay))) |
1413 | |
1414 (defun quail-conversion-end-of-region () | |
1415 (interactive) | |
22777
1b0761cbc15b
(quail-conversion-keymap): New binding
Kenichi Handa <handa@m17n.org>
parents:
22765
diff
changeset
|
1416 (setq quail-translating nil) |
17052 | 1417 (goto-char (overlay-end quail-conv-overlay))) |
1418 | |
1419 (defun quail-conversion-delete-char () | |
1420 (interactive) | |
22777
1b0761cbc15b
(quail-conversion-keymap): New binding
Kenichi Handa <handa@m17n.org>
parents:
22765
diff
changeset
|
1421 (setq quail-translating nil) |
17052 | 1422 (if (>= (point) (overlay-end quail-conv-overlay)) |
22765
7cf2c3800e8f
(quail-mode): This variable deleted.
Kenichi Handa <handa@m17n.org>
parents:
22124
diff
changeset
|
1423 (quail-error "End of conversion region")) |
17052 | 1424 (delete-char 1) |
22917
00f3497854c4
(quail-translation-keymap): Declare it as
Kenichi Handa <handa@m17n.org>
parents:
22883
diff
changeset
|
1425 (let ((start (overlay-start quail-conv-overlay)) |
00f3497854c4
(quail-translation-keymap): Declare it as
Kenichi Handa <handa@m17n.org>
parents:
22883
diff
changeset
|
1426 (end (overlay-end quail-conv-overlay))) |
00f3497854c4
(quail-translation-keymap): Declare it as
Kenichi Handa <handa@m17n.org>
parents:
22883
diff
changeset
|
1427 (setq quail-conversion-str (buffer-substring start end)) |
00f3497854c4
(quail-translation-keymap): Declare it as
Kenichi Handa <handa@m17n.org>
parents:
22883
diff
changeset
|
1428 (if (= start end) |
00f3497854c4
(quail-translation-keymap): Declare it as
Kenichi Handa <handa@m17n.org>
parents:
22883
diff
changeset
|
1429 (setq quail-converting nil)))) |
17052 | 1430 |
22777
1b0761cbc15b
(quail-conversion-keymap): New binding
Kenichi Handa <handa@m17n.org>
parents:
22765
diff
changeset
|
1431 (defun quail-conversion-delete-tail () |
1b0761cbc15b
(quail-conversion-keymap): New binding
Kenichi Handa <handa@m17n.org>
parents:
22765
diff
changeset
|
1432 (interactive) |
1b0761cbc15b
(quail-conversion-keymap): New binding
Kenichi Handa <handa@m17n.org>
parents:
22765
diff
changeset
|
1433 (if (>= (point) (overlay-end quail-conv-overlay)) |
1b0761cbc15b
(quail-conversion-keymap): New binding
Kenichi Handa <handa@m17n.org>
parents:
22765
diff
changeset
|
1434 (quail-error "End of conversion region")) |
1b0761cbc15b
(quail-conversion-keymap): New binding
Kenichi Handa <handa@m17n.org>
parents:
22765
diff
changeset
|
1435 (delete-region (point) (overlay-end quail-conv-overlay)) |
22917
00f3497854c4
(quail-translation-keymap): Declare it as
Kenichi Handa <handa@m17n.org>
parents:
22883
diff
changeset
|
1436 (let ((start (overlay-start quail-conv-overlay)) |
00f3497854c4
(quail-translation-keymap): Declare it as
Kenichi Handa <handa@m17n.org>
parents:
22883
diff
changeset
|
1437 (end (overlay-end quail-conv-overlay))) |
00f3497854c4
(quail-translation-keymap): Declare it as
Kenichi Handa <handa@m17n.org>
parents:
22883
diff
changeset
|
1438 (setq quail-conversion-str (buffer-substring start end)) |
00f3497854c4
(quail-translation-keymap): Declare it as
Kenichi Handa <handa@m17n.org>
parents:
22883
diff
changeset
|
1439 (if (= start end) |
00f3497854c4
(quail-translation-keymap): Declare it as
Kenichi Handa <handa@m17n.org>
parents:
22883
diff
changeset
|
1440 (setq quail-converting nil)))) |
22777
1b0761cbc15b
(quail-conversion-keymap): New binding
Kenichi Handa <handa@m17n.org>
parents:
22765
diff
changeset
|
1441 |
17052 | 1442 (defun quail-conversion-backward-delete-char () |
1443 (interactive) | |
23887
3a4d3e2418dc
(quail-point-in-conversion-region): New
Kenichi Handa <handa@m17n.org>
parents:
23629
diff
changeset
|
1444 (if (> (length quail-current-key) 0) |
3a4d3e2418dc
(quail-point-in-conversion-region): New
Kenichi Handa <handa@m17n.org>
parents:
23629
diff
changeset
|
1445 (quail-delete-last-char) |
3a4d3e2418dc
(quail-point-in-conversion-region): New
Kenichi Handa <handa@m17n.org>
parents:
23629
diff
changeset
|
1446 (if (<= (point) (overlay-start quail-conv-overlay)) |
3a4d3e2418dc
(quail-point-in-conversion-region): New
Kenichi Handa <handa@m17n.org>
parents:
23629
diff
changeset
|
1447 (quail-error "Beginning of conversion region")) |
3a4d3e2418dc
(quail-point-in-conversion-region): New
Kenichi Handa <handa@m17n.org>
parents:
23629
diff
changeset
|
1448 (delete-char -1) |
3a4d3e2418dc
(quail-point-in-conversion-region): New
Kenichi Handa <handa@m17n.org>
parents:
23629
diff
changeset
|
1449 (let ((start (overlay-start quail-conv-overlay)) |
3a4d3e2418dc
(quail-point-in-conversion-region): New
Kenichi Handa <handa@m17n.org>
parents:
23629
diff
changeset
|
1450 (end (overlay-end quail-conv-overlay))) |
3a4d3e2418dc
(quail-point-in-conversion-region): New
Kenichi Handa <handa@m17n.org>
parents:
23629
diff
changeset
|
1451 (setq quail-conversion-str (buffer-substring start end)) |
3a4d3e2418dc
(quail-point-in-conversion-region): New
Kenichi Handa <handa@m17n.org>
parents:
23629
diff
changeset
|
1452 (if (= start end) |
3a4d3e2418dc
(quail-point-in-conversion-region): New
Kenichi Handa <handa@m17n.org>
parents:
23629
diff
changeset
|
1453 (setq quail-converting nil))))) |
17052 | 1454 |
1455 (defun quail-do-conversion (func &rest args) | |
1456 "Call FUNC to convert text in the current conversion region of Quail. | |
1457 Remaining args are for FUNC." | |
1458 (delete-overlay quail-overlay) | |
1459 (apply func args)) | |
1460 | |
1461 (defun quail-no-conversion () | |
1462 "Do no conversion of the current conversion region of Quail." | |
1463 (interactive) | |
22777
1b0761cbc15b
(quail-conversion-keymap): New binding
Kenichi Handa <handa@m17n.org>
parents:
22765
diff
changeset
|
1464 (setq quail-converting nil)) |
17052 | 1465 |
1466 ;; Guidance, Completion, and Help buffer handlers. | |
1467 | |
18556
99e8ae18137f
(quail-guidance-buf): Make it buffer
Kenichi Handa <handa@m17n.org>
parents:
18377
diff
changeset
|
1468 ;; 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
|
1469 (defun quail-make-guidance-frame (buf) |
99e8ae18137f
(quail-guidance-buf): Make it buffer
Kenichi Handa <handa@m17n.org>
parents:
18377
diff
changeset
|
1470 (let* ((fparam (frame-parameters)) |
99e8ae18137f
(quail-guidance-buf): Make it buffer
Kenichi Handa <handa@m17n.org>
parents:
18377
diff
changeset
|
1471 (top (cdr (assq 'top fparam))) |
99e8ae18137f
(quail-guidance-buf): Make it buffer
Kenichi Handa <handa@m17n.org>
parents:
18377
diff
changeset
|
1472 (border (cdr (assq 'border-width fparam))) |
99e8ae18137f
(quail-guidance-buf): Make it buffer
Kenichi Handa <handa@m17n.org>
parents:
18377
diff
changeset
|
1473 (internal-border (cdr (assq 'internal-border-width fparam))) |
99e8ae18137f
(quail-guidance-buf): Make it buffer
Kenichi Handa <handa@m17n.org>
parents:
18377
diff
changeset
|
1474 (newtop (- top |
99e8ae18137f
(quail-guidance-buf): Make it buffer
Kenichi Handa <handa@m17n.org>
parents:
18377
diff
changeset
|
1475 (frame-char-height) (* internal-border 2) (* border 2)))) |
99e8ae18137f
(quail-guidance-buf): Make it buffer
Kenichi Handa <handa@m17n.org>
parents:
18377
diff
changeset
|
1476 (if (< newtop 0) |
99e8ae18137f
(quail-guidance-buf): Make it buffer
Kenichi Handa <handa@m17n.org>
parents:
18377
diff
changeset
|
1477 (setq newtop (+ top (frame-pixel-height)))) |
99e8ae18137f
(quail-guidance-buf): Make it buffer
Kenichi Handa <handa@m17n.org>
parents:
18377
diff
changeset
|
1478 (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
|
1479 (minibuffer) (menu-bar-lines . 0)) |
99e8ae18137f
(quail-guidance-buf): Make it buffer
Kenichi Handa <handa@m17n.org>
parents:
18377
diff
changeset
|
1480 (cons (cons 'top newtop) fparam)))) |
99e8ae18137f
(quail-guidance-buf): Make it buffer
Kenichi Handa <handa@m17n.org>
parents:
18377
diff
changeset
|
1481 (win (frame-first-window frame))) |
99e8ae18137f
(quail-guidance-buf): Make it buffer
Kenichi Handa <handa@m17n.org>
parents:
18377
diff
changeset
|
1482 (set-window-buffer win buf) |
19878
a69ae37e6932
(quail-update-translation): Fix previous change.
Richard M. Stallman <rms@gnu.org>
parents:
19849
diff
changeset
|
1483 ;;(set-window-dedicated-p win t) |
a69ae37e6932
(quail-update-translation): Fix previous change.
Richard M. Stallman <rms@gnu.org>
parents:
19849
diff
changeset
|
1484 ))) |
17052 | 1485 |
19432
4492653b04e8
(quail-exit-from-minibuffer): Call
Kenichi Handa <handa@m17n.org>
parents:
19404
diff
changeset
|
1486 ;; Setup Quail completion buffer. |
4492653b04e8
(quail-exit-from-minibuffer): Call
Kenichi Handa <handa@m17n.org>
parents:
19404
diff
changeset
|
1487 (defun quail-setup-completion-buf () |
4492653b04e8
(quail-exit-from-minibuffer): Call
Kenichi Handa <handa@m17n.org>
parents:
19404
diff
changeset
|
1488 (unless (buffer-live-p quail-completion-buf) |
4492653b04e8
(quail-exit-from-minibuffer): Call
Kenichi Handa <handa@m17n.org>
parents:
19404
diff
changeset
|
1489 (setq quail-completion-buf (get-buffer-create "*Quail Completions*")) |
4492653b04e8
(quail-exit-from-minibuffer): Call
Kenichi Handa <handa@m17n.org>
parents:
19404
diff
changeset
|
1490 (save-excursion |
4492653b04e8
(quail-exit-from-minibuffer): Call
Kenichi Handa <handa@m17n.org>
parents:
19404
diff
changeset
|
1491 (set-buffer quail-completion-buf) |
4492653b04e8
(quail-exit-from-minibuffer): Call
Kenichi Handa <handa@m17n.org>
parents:
19404
diff
changeset
|
1492 (setq quail-overlay (make-overlay 1 1)) |
4492653b04e8
(quail-exit-from-minibuffer): Call
Kenichi Handa <handa@m17n.org>
parents:
19404
diff
changeset
|
1493 (overlay-put quail-overlay 'face 'highlight)))) |
4492653b04e8
(quail-exit-from-minibuffer): Call
Kenichi Handa <handa@m17n.org>
parents:
19404
diff
changeset
|
1494 |
19849
1c5164d81426
(quail-simple): New function.
Kenichi Handa <handa@m17n.org>
parents:
19844
diff
changeset
|
1495 ;; Return t iff the current Quail package requires showing guidance |
1c5164d81426
(quail-simple): New function.
Kenichi Handa <handa@m17n.org>
parents:
19844
diff
changeset
|
1496 ;; buffer. |
1c5164d81426
(quail-simple): New function.
Kenichi Handa <handa@m17n.org>
parents:
19844
diff
changeset
|
1497 (defun quail-require-guidance-buf () |
1c5164d81426
(quail-simple): New function.
Kenichi Handa <handa@m17n.org>
parents:
19844
diff
changeset
|
1498 (and input-method-verbose-flag |
20160
b8234ea503cd
(quail-require-guidance-buf): Adjusted
Kenichi Handa <handa@m17n.org>
parents:
19987
diff
changeset
|
1499 (if (eq input-method-verbose-flag 'default) |
b8234ea503cd
(quail-require-guidance-buf): Adjusted
Kenichi Handa <handa@m17n.org>
parents:
19987
diff
changeset
|
1500 (not (and (eq (selected-window) (minibuffer-window)) |
b8234ea503cd
(quail-require-guidance-buf): Adjusted
Kenichi Handa <handa@m17n.org>
parents:
19987
diff
changeset
|
1501 (quail-simple))) |
b8234ea503cd
(quail-require-guidance-buf): Adjusted
Kenichi Handa <handa@m17n.org>
parents:
19987
diff
changeset
|
1502 (if (eq input-method-verbose-flag 'complex-only) |
b8234ea503cd
(quail-require-guidance-buf): Adjusted
Kenichi Handa <handa@m17n.org>
parents:
19987
diff
changeset
|
1503 (not (quail-simple)) |
b8234ea503cd
(quail-require-guidance-buf): Adjusted
Kenichi Handa <handa@m17n.org>
parents:
19987
diff
changeset
|
1504 t)))) |
19849
1c5164d81426
(quail-simple): New function.
Kenichi Handa <handa@m17n.org>
parents:
19844
diff
changeset
|
1505 |
18556
99e8ae18137f
(quail-guidance-buf): Make it buffer
Kenichi Handa <handa@m17n.org>
parents:
18377
diff
changeset
|
1506 (defun quail-show-guidance-buf () |
99e8ae18137f
(quail-guidance-buf): Make it buffer
Kenichi Handa <handa@m17n.org>
parents:
18377
diff
changeset
|
1507 "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
|
1508 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
|
1509 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
|
1510 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
|
1511 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
|
1512 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
|
1513 (when (quail-require-guidance-buf) |
18556
99e8ae18137f
(quail-guidance-buf): Make it buffer
Kenichi Handa <handa@m17n.org>
parents:
18377
diff
changeset
|
1514 ;; At first, setup a guidance buffer. |
99e8ae18137f
(quail-guidance-buf): Make it buffer
Kenichi Handa <handa@m17n.org>
parents:
18377
diff
changeset
|
1515 (or (buffer-live-p quail-guidance-buf) |
99e8ae18137f
(quail-guidance-buf): Make it buffer
Kenichi Handa <handa@m17n.org>
parents:
18377
diff
changeset
|
1516 (setq quail-guidance-buf (generate-new-buffer " *Quail-guidance*"))) |
29129
1fad86b8adfc
(quail-show-guidance-buf): Set
Kenichi Handa <handa@m17n.org>
parents:
29073
diff
changeset
|
1517 (let ((name (quail-name)) |
1fad86b8adfc
(quail-show-guidance-buf): Set
Kenichi Handa <handa@m17n.org>
parents:
29073
diff
changeset
|
1518 (title (quail-title))) |
18556
99e8ae18137f
(quail-guidance-buf): Make it buffer
Kenichi Handa <handa@m17n.org>
parents:
18377
diff
changeset
|
1519 (save-excursion |
99e8ae18137f
(quail-guidance-buf): Make it buffer
Kenichi Handa <handa@m17n.org>
parents:
18377
diff
changeset
|
1520 (set-buffer quail-guidance-buf) |
99e8ae18137f
(quail-guidance-buf): Make it buffer
Kenichi Handa <handa@m17n.org>
parents:
18377
diff
changeset
|
1521 ;; To show the title of Quail package. |
29129
1fad86b8adfc
(quail-show-guidance-buf): Set
Kenichi Handa <handa@m17n.org>
parents:
29073
diff
changeset
|
1522 (setq current-input-method name |
18556
99e8ae18137f
(quail-guidance-buf): Make it buffer
Kenichi Handa <handa@m17n.org>
parents:
18377
diff
changeset
|
1523 current-input-method-title title) |
99e8ae18137f
(quail-guidance-buf): Make it buffer
Kenichi Handa <handa@m17n.org>
parents:
18377
diff
changeset
|
1524 (erase-buffer) |
99e8ae18137f
(quail-guidance-buf): Make it buffer
Kenichi Handa <handa@m17n.org>
parents:
18377
diff
changeset
|
1525 (or (overlayp quail-overlay) |
99e8ae18137f
(quail-guidance-buf): Make it buffer
Kenichi Handa <handa@m17n.org>
parents:
18377
diff
changeset
|
1526 (progn |
99e8ae18137f
(quail-guidance-buf): Make it buffer
Kenichi Handa <handa@m17n.org>
parents:
18377
diff
changeset
|
1527 (setq quail-overlay (make-overlay 1 1)) |
99e8ae18137f
(quail-guidance-buf): Make it buffer
Kenichi Handa <handa@m17n.org>
parents:
18377
diff
changeset
|
1528 (overlay-put quail-overlay 'face 'highlight))) |
99e8ae18137f
(quail-guidance-buf): Make it buffer
Kenichi Handa <handa@m17n.org>
parents:
18377
diff
changeset
|
1529 (delete-overlay quail-overlay) |
99e8ae18137f
(quail-guidance-buf): Make it buffer
Kenichi Handa <handa@m17n.org>
parents:
18377
diff
changeset
|
1530 (set-buffer-modified-p nil))) |
99e8ae18137f
(quail-guidance-buf): Make it buffer
Kenichi Handa <handa@m17n.org>
parents:
18377
diff
changeset
|
1531 (bury-buffer quail-guidance-buf) |
17052 | 1532 |
23599
ab69e7987be0
(quail-start-translation): Handle
Kenichi Handa <handa@m17n.org>
parents:
23401
diff
changeset
|
1533 ;; Assign the buffer " *Minibuf-N*" to all windows which are now |
ab69e7987be0
(quail-start-translation): Handle
Kenichi Handa <handa@m17n.org>
parents:
23401
diff
changeset
|
1534 ;; displaying quail-guidance-buf. |
ab69e7987be0
(quail-start-translation): Handle
Kenichi Handa <handa@m17n.org>
parents:
23401
diff
changeset
|
1535 (let ((win-list (get-buffer-window-list quail-guidance-buf t t))) |
ab69e7987be0
(quail-start-translation): Handle
Kenichi Handa <handa@m17n.org>
parents:
23401
diff
changeset
|
1536 (while win-list |
ab69e7987be0
(quail-start-translation): Handle
Kenichi Handa <handa@m17n.org>
parents:
23401
diff
changeset
|
1537 (set-window-buffer (car win-list) |
ab69e7987be0
(quail-start-translation): Handle
Kenichi Handa <handa@m17n.org>
parents:
23401
diff
changeset
|
1538 (format " *Minibuf-%d*" (minibuffer-depth))) |
ab69e7987be0
(quail-start-translation): Handle
Kenichi Handa <handa@m17n.org>
parents:
23401
diff
changeset
|
1539 (setq win-list (cdr win-list)))) |
ab69e7987be0
(quail-start-translation): Handle
Kenichi Handa <handa@m17n.org>
parents:
23401
diff
changeset
|
1540 |
18556
99e8ae18137f
(quail-guidance-buf): Make it buffer
Kenichi Handa <handa@m17n.org>
parents:
18377
diff
changeset
|
1541 ;; Then, display it in an appropriate window. |
99e8ae18137f
(quail-guidance-buf): Make it buffer
Kenichi Handa <handa@m17n.org>
parents:
18377
diff
changeset
|
1542 (let ((win (minibuffer-window))) |
22917
00f3497854c4
(quail-translation-keymap): Declare it as
Kenichi Handa <handa@m17n.org>
parents:
22883
diff
changeset
|
1543 (if (or (eq (selected-window) win) |
00f3497854c4
(quail-translation-keymap): Declare it as
Kenichi Handa <handa@m17n.org>
parents:
22883
diff
changeset
|
1544 input-method-use-echo-area) |
18556
99e8ae18137f
(quail-guidance-buf): Make it buffer
Kenichi Handa <handa@m17n.org>
parents:
18377
diff
changeset
|
1545 ;; 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
|
1546 (if (eq win (frame-root-window)) |
99e8ae18137f
(quail-guidance-buf): Make it buffer
Kenichi Handa <handa@m17n.org>
parents:
18377
diff
changeset
|
1547 ;; 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
|
1548 ;; window system. |
99e8ae18137f
(quail-guidance-buf): Make it buffer
Kenichi Handa <handa@m17n.org>
parents:
18377
diff
changeset
|
1549 (quail-make-guidance-frame quail-guidance-buf) |
99e8ae18137f
(quail-guidance-buf): Make it buffer
Kenichi Handa <handa@m17n.org>
parents:
18377
diff
changeset
|
1550 ;; 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
|
1551 (let (height) |
29690
a81355bcaaeb
(quail-show-guidance-buf): To find the bottom window (but minibuffer),
Kenichi Handa <handa@m17n.org>
parents:
29326
diff
changeset
|
1552 (setq win (window-at |
a81355bcaaeb
(quail-show-guidance-buf): To find the bottom window (but minibuffer),
Kenichi Handa <handa@m17n.org>
parents:
29326
diff
changeset
|
1553 0 (1- (- (frame-height) (window-height win))))) |
18556
99e8ae18137f
(quail-guidance-buf): Make it buffer
Kenichi Handa <handa@m17n.org>
parents:
18377
diff
changeset
|
1554 (setq height (window-height win)) |
99e8ae18137f
(quail-guidance-buf): Make it buffer
Kenichi Handa <handa@m17n.org>
parents:
18377
diff
changeset
|
1555 ;; 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
|
1556 ;; the lower one. |
99e8ae18137f
(quail-guidance-buf): Make it buffer
Kenichi Handa <handa@m17n.org>
parents:
18377
diff
changeset
|
1557 (if (>= height 4) |
99e8ae18137f
(quail-guidance-buf): Make it buffer
Kenichi Handa <handa@m17n.org>
parents:
18377
diff
changeset
|
1558 (let ((window-min-height 2)) |
99e8ae18137f
(quail-guidance-buf): Make it buffer
Kenichi Handa <handa@m17n.org>
parents:
18377
diff
changeset
|
1559 ;; Here, `split-window' returns a lower window |
99e8ae18137f
(quail-guidance-buf): Make it buffer
Kenichi Handa <handa@m17n.org>
parents:
18377
diff
changeset
|
1560 ;; which is what we wanted. |
99e8ae18137f
(quail-guidance-buf): Make it buffer
Kenichi Handa <handa@m17n.org>
parents:
18377
diff
changeset
|
1561 (setq win (split-window win (- height 2))))) |
99e8ae18137f
(quail-guidance-buf): Make it buffer
Kenichi Handa <handa@m17n.org>
parents:
18377
diff
changeset
|
1562 (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
|
1563 ;;(set-window-dedicated-p win t) |
a69ae37e6932
(quail-update-translation): Fix previous change.
Richard M. Stallman <rms@gnu.org>
parents:
19849
diff
changeset
|
1564 )) |
23629
ab6b58c72a04
(quail-show-guidance-buf): Call
Kenichi Handa <handa@m17n.org>
parents:
23599
diff
changeset
|
1565 (set-window-buffer win quail-guidance-buf) |
ab6b58c72a04
(quail-show-guidance-buf): Call
Kenichi Handa <handa@m17n.org>
parents:
23599
diff
changeset
|
1566 (set-minibuffer-window win)) |
18556
99e8ae18137f
(quail-guidance-buf): Make it buffer
Kenichi Handa <handa@m17n.org>
parents:
18377
diff
changeset
|
1567 (setq quail-guidance-win win))) |
17052 | 1568 |
1569 ;; And, create a buffer for completion. | |
19432
4492653b04e8
(quail-exit-from-minibuffer): Call
Kenichi Handa <handa@m17n.org>
parents:
19404
diff
changeset
|
1570 (quail-setup-completion-buf) |
17052 | 1571 (bury-buffer quail-completion-buf)) |
1572 | |
1573 (defun quail-hide-guidance-buf () | |
1574 "Hide the Quail guidance buffer." | |
18556
99e8ae18137f
(quail-guidance-buf): Make it buffer
Kenichi Handa <handa@m17n.org>
parents:
18377
diff
changeset
|
1575 (if (buffer-live-p quail-guidance-buf) |
99e8ae18137f
(quail-guidance-buf): Make it buffer
Kenichi Handa <handa@m17n.org>
parents:
18377
diff
changeset
|
1576 (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
|
1577 win) |
99e8ae18137f
(quail-guidance-buf): Make it buffer
Kenichi Handa <handa@m17n.org>
parents:
18377
diff
changeset
|
1578 (while win-list |
99e8ae18137f
(quail-guidance-buf): Make it buffer
Kenichi Handa <handa@m17n.org>
parents:
18377
diff
changeset
|
1579 (setq win (car win-list) win-list (cdr win-list)) |
23599
ab69e7987be0
(quail-start-translation): Handle
Kenichi Handa <handa@m17n.org>
parents:
23401
diff
changeset
|
1580 (if (window-minibuffer-p win) |
18556
99e8ae18137f
(quail-guidance-buf): Make it buffer
Kenichi Handa <handa@m17n.org>
parents:
18377
diff
changeset
|
1581 ;; 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
|
1582 ;; Vacate it to the deepest minibuffer. |
99e8ae18137f
(quail-guidance-buf): Make it buffer
Kenichi Handa <handa@m17n.org>
parents:
18377
diff
changeset
|
1583 (set-window-buffer win |
99e8ae18137f
(quail-guidance-buf): Make it buffer
Kenichi Handa <handa@m17n.org>
parents:
18377
diff
changeset
|
1584 (format " *Minibuf-%d*" (minibuffer-depth))) |
99e8ae18137f
(quail-guidance-buf): Make it buffer
Kenichi Handa <handa@m17n.org>
parents:
18377
diff
changeset
|
1585 (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
|
1586 (progn |
99e8ae18137f
(quail-guidance-buf): Make it buffer
Kenichi Handa <handa@m17n.org>
parents:
18377
diff
changeset
|
1587 ;; 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
|
1588 ;;(set-window-dedicated-p win nil) |
99e8ae18137f
(quail-guidance-buf): Make it buffer
Kenichi Handa <handa@m17n.org>
parents:
18377
diff
changeset
|
1589 (delete-frame (window-frame win))) |
19878
a69ae37e6932
(quail-update-translation): Fix previous change.
Richard M. Stallman <rms@gnu.org>
parents:
19849
diff
changeset
|
1590 ;;(set-window-dedicated-p win nil) |
23599
ab69e7987be0
(quail-start-translation): Handle
Kenichi Handa <handa@m17n.org>
parents:
23401
diff
changeset
|
1591 (delete-window win)))) |
ab69e7987be0
(quail-start-translation): Handle
Kenichi Handa <handa@m17n.org>
parents:
23401
diff
changeset
|
1592 (setq quail-guidance-win nil)))) |
17052 | 1593 |
1594 (defun quail-update-guidance () | |
1595 "Update the Quail guidance buffer and completion buffer (if displayed now)." | |
1596 ;; Update guidance buffer. | |
19849
1c5164d81426
(quail-simple): New function.
Kenichi Handa <handa@m17n.org>
parents:
19844
diff
changeset
|
1597 (if (quail-require-guidance-buf) |
17052 | 1598 (let ((guidance (quail-guidance))) |
23599
ab69e7987be0
(quail-start-translation): Handle
Kenichi Handa <handa@m17n.org>
parents:
23401
diff
changeset
|
1599 (or (and (eq (selected-frame) (window-frame (minibuffer-window))) |
ab69e7987be0
(quail-start-translation): Handle
Kenichi Handa <handa@m17n.org>
parents:
23401
diff
changeset
|
1600 (eq (selected-frame) (window-frame quail-guidance-win))) |
ab69e7987be0
(quail-start-translation): Handle
Kenichi Handa <handa@m17n.org>
parents:
23401
diff
changeset
|
1601 (quail-show-guidance-buf)) |
19723
3ada64a43911
(quail-update-guidance): If PROMPTKEY is
Kenichi Handa <handa@m17n.org>
parents:
19675
diff
changeset
|
1602 (cond ((or (eq guidance t) |
23304
3a7a029df593
(quail-update-guidance): Check for the
Kenichi Handa <handa@m17n.org>
parents:
23176
diff
changeset
|
1603 (consp guidance)) |
17052 | 1604 ;; Show the current possible translations. |
1605 (quail-show-translations)) | |
1606 ((null guidance) | |
1607 ;; Show the current input keys. | |
1608 (let ((key quail-current-key)) | |
1609 (save-excursion | |
1610 (set-buffer quail-guidance-buf) | |
1611 (erase-buffer) | |
19723
3ada64a43911
(quail-update-guidance): If PROMPTKEY is
Kenichi Handa <handa@m17n.org>
parents:
19675
diff
changeset
|
1612 (insert key))))))) |
17052 | 1613 |
1614 ;; Update completion buffer if displayed now. We highlight the | |
1615 ;; selected candidate string in *Completion* buffer if any. | |
1616 (let ((win (get-buffer-window quail-completion-buf)) | |
1617 key str pos) | |
1618 (if win | |
1619 (save-excursion | |
1620 (setq str (if (stringp quail-current-str) | |
1621 quail-current-str | |
1622 (if (numberp quail-current-str) | |
1623 (char-to-string quail-current-str))) | |
1624 key quail-current-key) | |
1625 (set-buffer quail-completion-buf) | |
1626 (goto-char (point-min)) | |
1627 (if (null (search-forward (concat " " key ":") nil t)) | |
1628 (delete-overlay quail-overlay) | |
1629 (setq pos (point)) | |
1630 (if (and str (search-forward (concat "." str) nil t)) | |
1631 (move-overlay quail-overlay (1+ (match-beginning 0)) (point)) | |
1632 (move-overlay quail-overlay (match-beginning 0) (point))) | |
1633 ;; Now POS points end of KEY and (point) points end of STR. | |
1634 (if (pos-visible-in-window-p (point) win) | |
1635 ;; STR is already visible. | |
1636 nil | |
1637 ;; We want to make both KEY and STR visible, but if the | |
1638 ;; window is too short, make at least STR visible. | |
1639 (setq pos (progn (point) (goto-char pos))) | |
1640 (beginning-of-line) | |
1641 (set-window-start win (point)) | |
1642 (if (not (pos-visible-in-window-p pos win)) | |
1643 (set-window-start win pos)) | |
1644 )))))) | |
1645 | |
1646 (defun quail-show-translations () | |
1647 "Show the current possible translations." | |
18297
5c8e37591da5
(quail-current-data): New variable.
Kenichi Handa <handa@m17n.org>
parents:
18201
diff
changeset
|
1648 (let* ((key quail-current-key) |
22917
00f3497854c4
(quail-translation-keymap): Declare it as
Kenichi Handa <handa@m17n.org>
parents:
22883
diff
changeset
|
1649 (map (quail-lookup-key quail-current-key)) |
00f3497854c4
(quail-translation-keymap): Declare it as
Kenichi Handa <handa@m17n.org>
parents:
22883
diff
changeset
|
1650 (current-translations quail-current-translations)) |
18556
99e8ae18137f
(quail-guidance-buf): Make it buffer
Kenichi Handa <handa@m17n.org>
parents:
18377
diff
changeset
|
1651 (if quail-current-translations |
99e8ae18137f
(quail-guidance-buf): Make it buffer
Kenichi Handa <handa@m17n.org>
parents:
18377
diff
changeset
|
1652 (quail-update-current-translations)) |
17052 | 1653 (save-excursion |
1654 (set-buffer quail-guidance-buf) | |
1655 (erase-buffer) | |
1656 | |
1657 ;; Show the current key. | |
19723
3ada64a43911
(quail-update-guidance): If PROMPTKEY is
Kenichi Handa <handa@m17n.org>
parents:
19675
diff
changeset
|
1658 (let ((guidance (quail-guidance))) |
3ada64a43911
(quail-update-guidance): If PROMPTKEY is
Kenichi Handa <handa@m17n.org>
parents:
19675
diff
changeset
|
1659 (if (listp guidance) |
3ada64a43911
(quail-update-guidance): If PROMPTKEY is
Kenichi Handa <handa@m17n.org>
parents:
19675
diff
changeset
|
1660 ;; 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
|
1661 ;; actual typed keys. |
3ada64a43911
(quail-update-guidance): If PROMPTKEY is
Kenichi Handa <handa@m17n.org>
parents:
19675
diff
changeset
|
1662 (let ((i 0) |
3ada64a43911
(quail-update-guidance): If PROMPTKEY is
Kenichi Handa <handa@m17n.org>
parents:
19675
diff
changeset
|
1663 (len (length key)) |
3ada64a43911
(quail-update-guidance): If PROMPTKEY is
Kenichi Handa <handa@m17n.org>
parents:
19675
diff
changeset
|
1664 prompt-key) |
3ada64a43911
(quail-update-guidance): If PROMPTKEY is
Kenichi Handa <handa@m17n.org>
parents:
19675
diff
changeset
|
1665 (while (< i len) |
3ada64a43911
(quail-update-guidance): If PROMPTKEY is
Kenichi Handa <handa@m17n.org>
parents:
19675
diff
changeset
|
1666 (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
|
1667 (insert (or prompt-key (aref key i))) |
3ada64a43911
(quail-update-guidance): If PROMPTKEY is
Kenichi Handa <handa@m17n.org>
parents:
19675
diff
changeset
|
1668 (setq i (1+ i)))) |
3ada64a43911
(quail-update-guidance): If PROMPTKEY is
Kenichi Handa <handa@m17n.org>
parents:
19675
diff
changeset
|
1669 (insert key))) |
17052 | 1670 |
18556
99e8ae18137f
(quail-guidance-buf): Make it buffer
Kenichi Handa <handa@m17n.org>
parents:
18377
diff
changeset
|
1671 ;; Show followable keys. |
22917
00f3497854c4
(quail-translation-keymap): Declare it as
Kenichi Handa <handa@m17n.org>
parents:
22883
diff
changeset
|
1672 (if (and (> (length key) 0) (cdr map)) |
21881
1a80d464c77a
(quail-show-translations): Show
Kenichi Handa <handa@m17n.org>
parents:
21659
diff
changeset
|
1673 (let ((keys (mapcar (function (lambda (x) (car x))) |
1a80d464c77a
(quail-show-translations): Show
Kenichi Handa <handa@m17n.org>
parents:
21659
diff
changeset
|
1674 (cdr map)))) |
1a80d464c77a
(quail-show-translations): Show
Kenichi Handa <handa@m17n.org>
parents:
21659
diff
changeset
|
1675 (setq keys (sort keys '<)) |
17052 | 1676 (insert "[") |
21881
1a80d464c77a
(quail-show-translations): Show
Kenichi Handa <handa@m17n.org>
parents:
21659
diff
changeset
|
1677 (while keys |
1a80d464c77a
(quail-show-translations): Show
Kenichi Handa <handa@m17n.org>
parents:
21659
diff
changeset
|
1678 (insert (car keys)) |
1a80d464c77a
(quail-show-translations): Show
Kenichi Handa <handa@m17n.org>
parents:
21659
diff
changeset
|
1679 (setq keys (cdr keys))) |
17052 | 1680 (insert "]"))) |
1681 | |
1682 ;; Show list of translations. | |
26891
651d521c8f52
(quail-install-map): New optional arg
Kenichi Handa <handa@m17n.org>
parents:
24821
diff
changeset
|
1683 (if (and current-translations |
651d521c8f52
(quail-install-map): New optional arg
Kenichi Handa <handa@m17n.org>
parents:
24821
diff
changeset
|
1684 (not (quail-deterministic))) |
22917
00f3497854c4
(quail-translation-keymap): Declare it as
Kenichi Handa <handa@m17n.org>
parents:
22883
diff
changeset
|
1685 (let* ((indices (car current-translations)) |
18556
99e8ae18137f
(quail-guidance-buf): Make it buffer
Kenichi Handa <handa@m17n.org>
parents:
18377
diff
changeset
|
1686 (cur (car indices)) |
99e8ae18137f
(quail-guidance-buf): Make it buffer
Kenichi Handa <handa@m17n.org>
parents:
18377
diff
changeset
|
1687 (start (nth 1 indices)) |
99e8ae18137f
(quail-guidance-buf): Make it buffer
Kenichi Handa <handa@m17n.org>
parents:
18377
diff
changeset
|
1688 (end (nth 2 indices)) |
99e8ae18137f
(quail-guidance-buf): Make it buffer
Kenichi Handa <handa@m17n.org>
parents:
18377
diff
changeset
|
1689 (idx start)) |
99e8ae18137f
(quail-guidance-buf): Make it buffer
Kenichi Handa <handa@m17n.org>
parents:
18377
diff
changeset
|
1690 (indent-to (- quail-guidance-translations-starting-column 7)) |
99e8ae18137f
(quail-guidance-buf): Make it buffer
Kenichi Handa <handa@m17n.org>
parents:
18377
diff
changeset
|
1691 (insert (format "(%02d/"(nth 3 indices)) |
99e8ae18137f
(quail-guidance-buf): Make it buffer
Kenichi Handa <handa@m17n.org>
parents:
18377
diff
changeset
|
1692 (if (nth 4 indices) |
99e8ae18137f
(quail-guidance-buf): Make it buffer
Kenichi Handa <handa@m17n.org>
parents:
18377
diff
changeset
|
1693 (format "%02d)" (nth 4 indices)) |
99e8ae18137f
(quail-guidance-buf): Make it buffer
Kenichi Handa <handa@m17n.org>
parents:
18377
diff
changeset
|
1694 "??)")) |
99e8ae18137f
(quail-guidance-buf): Make it buffer
Kenichi Handa <handa@m17n.org>
parents:
18377
diff
changeset
|
1695 (while (< idx end) |
99e8ae18137f
(quail-guidance-buf): Make it buffer
Kenichi Handa <handa@m17n.org>
parents:
18377
diff
changeset
|
1696 (insert (format " %d." (if (= (- idx start) 9) 0 |
99e8ae18137f
(quail-guidance-buf): Make it buffer
Kenichi Handa <handa@m17n.org>
parents:
18377
diff
changeset
|
1697 (1+ (- idx start))))) |
17052 | 1698 (let ((pos (point))) |
22917
00f3497854c4
(quail-translation-keymap): Declare it as
Kenichi Handa <handa@m17n.org>
parents:
22883
diff
changeset
|
1699 (insert (aref (cdr current-translations) idx)) |
18556
99e8ae18137f
(quail-guidance-buf): Make it buffer
Kenichi Handa <handa@m17n.org>
parents:
18377
diff
changeset
|
1700 (if (= idx cur) |
17052 | 1701 (move-overlay quail-overlay pos (point)))) |
18556
99e8ae18137f
(quail-guidance-buf): Make it buffer
Kenichi Handa <handa@m17n.org>
parents:
18377
diff
changeset
|
1702 (setq idx (1+ idx))))) |
17052 | 1703 ))) |
1704 | |
26891
651d521c8f52
(quail-install-map): New optional arg
Kenichi Handa <handa@m17n.org>
parents:
24821
diff
changeset
|
1705 (defvar quail-completion-max-depth 5 |
651d521c8f52
(quail-install-map): New optional arg
Kenichi Handa <handa@m17n.org>
parents:
24821
diff
changeset
|
1706 "The maximum depth of Quail completion list.") |
651d521c8f52
(quail-install-map): New optional arg
Kenichi Handa <handa@m17n.org>
parents:
24821
diff
changeset
|
1707 |
17052 | 1708 (defun quail-completion () |
1709 "List all completions for the current key. | |
1710 All possible translations of the current key and whole possible longer keys | |
26891
651d521c8f52
(quail-install-map): New optional arg
Kenichi Handa <handa@m17n.org>
parents:
24821
diff
changeset
|
1711 are shown (at most to the depth specified `quail-completion-max-depth')." |
17052 | 1712 (interactive) |
19432
4492653b04e8
(quail-exit-from-minibuffer): Call
Kenichi Handa <handa@m17n.org>
parents:
19404
diff
changeset
|
1713 (quail-setup-completion-buf) |
22124
10b3c1cd7f18
(quail-completion): Consecutive call of
Kenichi Handa <handa@m17n.org>
parents:
21881
diff
changeset
|
1714 (let ((win (get-buffer-window quail-completion-buf 'visible)) |
10b3c1cd7f18
(quail-completion): Consecutive call of
Kenichi Handa <handa@m17n.org>
parents:
21881
diff
changeset
|
1715 (key quail-current-key) |
10b3c1cd7f18
(quail-completion): Consecutive call of
Kenichi Handa <handa@m17n.org>
parents:
21881
diff
changeset
|
1716 (map (quail-lookup-key quail-current-key)) |
10b3c1cd7f18
(quail-completion): Consecutive call of
Kenichi Handa <handa@m17n.org>
parents:
21881
diff
changeset
|
1717 (require-update nil)) |
17052 | 1718 (save-excursion |
1719 (set-buffer quail-completion-buf) | |
22124
10b3c1cd7f18
(quail-completion): Consecutive call of
Kenichi Handa <handa@m17n.org>
parents:
21881
diff
changeset
|
1720 (if (and win |
10b3c1cd7f18
(quail-completion): Consecutive call of
Kenichi Handa <handa@m17n.org>
parents:
21881
diff
changeset
|
1721 (equal key quail-current-key) |
10b3c1cd7f18
(quail-completion): Consecutive call of
Kenichi Handa <handa@m17n.org>
parents:
21881
diff
changeset
|
1722 (eq last-command 'quail-completion)) |
10b3c1cd7f18
(quail-completion): Consecutive call of
Kenichi Handa <handa@m17n.org>
parents:
21881
diff
changeset
|
1723 ;; The window for Quail completion buffer has already been |
10b3c1cd7f18
(quail-completion): Consecutive call of
Kenichi Handa <handa@m17n.org>
parents:
21881
diff
changeset
|
1724 ;; shown. We just scroll it appropriately. |
10b3c1cd7f18
(quail-completion): Consecutive call of
Kenichi Handa <handa@m17n.org>
parents:
21881
diff
changeset
|
1725 (if (pos-visible-in-window-p (point-max) win) |
10b3c1cd7f18
(quail-completion): Consecutive call of
Kenichi Handa <handa@m17n.org>
parents:
21881
diff
changeset
|
1726 (set-window-start win (point-min)) |
10b3c1cd7f18
(quail-completion): Consecutive call of
Kenichi Handa <handa@m17n.org>
parents:
21881
diff
changeset
|
1727 (let ((other-window-scroll-buffer quail-completion-buf)) |
10b3c1cd7f18
(quail-completion): Consecutive call of
Kenichi Handa <handa@m17n.org>
parents:
21881
diff
changeset
|
1728 (scroll-other-window))) |
10b3c1cd7f18
(quail-completion): Consecutive call of
Kenichi Handa <handa@m17n.org>
parents:
21881
diff
changeset
|
1729 (setq quail-current-key key) |
10b3c1cd7f18
(quail-completion): Consecutive call of
Kenichi Handa <handa@m17n.org>
parents:
21881
diff
changeset
|
1730 (erase-buffer) |
10b3c1cd7f18
(quail-completion): Consecutive call of
Kenichi Handa <handa@m17n.org>
parents:
21881
diff
changeset
|
1731 (insert "Possible completion and corresponding translations are:\n") |
10b3c1cd7f18
(quail-completion): Consecutive call of
Kenichi Handa <handa@m17n.org>
parents:
21881
diff
changeset
|
1732 (quail-completion-1 key map 1) |
10b3c1cd7f18
(quail-completion): Consecutive call of
Kenichi Handa <handa@m17n.org>
parents:
21881
diff
changeset
|
1733 (goto-char (point-min)) |
10b3c1cd7f18
(quail-completion): Consecutive call of
Kenichi Handa <handa@m17n.org>
parents:
21881
diff
changeset
|
1734 (display-buffer (current-buffer)) |
10b3c1cd7f18
(quail-completion): Consecutive call of
Kenichi Handa <handa@m17n.org>
parents:
21881
diff
changeset
|
1735 (setq require-update t))) |
10b3c1cd7f18
(quail-completion): Consecutive call of
Kenichi Handa <handa@m17n.org>
parents:
21881
diff
changeset
|
1736 (if require-update |
10b3c1cd7f18
(quail-completion): Consecutive call of
Kenichi Handa <handa@m17n.org>
parents:
21881
diff
changeset
|
1737 (quail-update-guidance))) |
10b3c1cd7f18
(quail-completion): Consecutive call of
Kenichi Handa <handa@m17n.org>
parents:
21881
diff
changeset
|
1738 (setq this-command 'quail-completion)) |
17052 | 1739 |
1740 ;; List all completions of KEY in MAP with indentation INDENT. | |
1741 (defun quail-completion-1 (key map indent) | |
1742 (let ((len (length key))) | |
1743 (indent-to indent) | |
1744 (insert key ":") | |
1745 (if (and (symbolp map) (fboundp map)) | |
1746 (setq map (funcall map key len))) | |
1747 (if (car map) | |
1748 (quail-completion-list-translations map key (+ indent len 1)) | |
1749 (insert " -\n")) | |
1750 (setq indent (+ indent 2)) | |
26891
651d521c8f52
(quail-install-map): New optional arg
Kenichi Handa <handa@m17n.org>
parents:
24821
diff
changeset
|
1751 (if (and (cdr map) (< (/ (1- indent) 2) quail-completion-max-depth)) |
17052 | 1752 (let ((l (cdr map)) |
1753 (newkey (make-string (1+ len) 0)) | |
1754 (i 0)) | |
26891
651d521c8f52
(quail-install-map): New optional arg
Kenichi Handa <handa@m17n.org>
parents:
24821
diff
changeset
|
1755 (if (functionp l) |
651d521c8f52
(quail-install-map): New optional arg
Kenichi Handa <handa@m17n.org>
parents:
24821
diff
changeset
|
1756 (setq l (funcall l))) |
17052 | 1757 ;; Set KEY in the first LEN characters of NEWKEY. |
1758 (while (< i len) | |
1759 (aset newkey i (aref key i)) | |
1760 (setq i (1+ i))) | |
1761 (while l ; L = ((CHAR . DEFN) ....) ; | |
1762 (aset newkey len (car (car l))) | |
1763 (quail-completion-1 newkey (cdr (car l)) indent) | |
1764 (setq l (cdr l))))))) | |
1765 | |
1766 ;; 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
|
1767 ;; indentation INDENT. |
17052 | 1768 (defun quail-completion-list-translations (map key indent) |
20169
d938bdf82445
(quail-translation-keymap): KP_Enter key
Kenichi Handa <handa@m17n.org>
parents:
20160
diff
changeset
|
1769 (let (beg (translations |
18297
5c8e37591da5
(quail-current-data): New variable.
Kenichi Handa <handa@m17n.org>
parents:
18201
diff
changeset
|
1770 (quail-get-translation (car map) key (length key)))) |
17052 | 1771 (if (integerp translations) |
20169
d938bdf82445
(quail-translation-keymap): KP_Enter key
Kenichi Handa <handa@m17n.org>
parents:
20160
diff
changeset
|
1772 (progn |
d938bdf82445
(quail-translation-keymap): KP_Enter key
Kenichi Handa <handa@m17n.org>
parents:
20160
diff
changeset
|
1773 (insert "(1/1) 1.") |
d938bdf82445
(quail-translation-keymap): KP_Enter key
Kenichi Handa <handa@m17n.org>
parents:
20160
diff
changeset
|
1774 ;; Endow the character `translations' with `mouse-face' text |
d938bdf82445
(quail-translation-keymap): KP_Enter key
Kenichi Handa <handa@m17n.org>
parents:
20160
diff
changeset
|
1775 ;; property to enable `mouse-2' completion. |
d938bdf82445
(quail-translation-keymap): KP_Enter key
Kenichi Handa <handa@m17n.org>
parents:
20160
diff
changeset
|
1776 (setq beg (point)) |
d938bdf82445
(quail-translation-keymap): KP_Enter key
Kenichi Handa <handa@m17n.org>
parents:
20160
diff
changeset
|
1777 (insert translations) |
d938bdf82445
(quail-translation-keymap): KP_Enter key
Kenichi Handa <handa@m17n.org>
parents:
20160
diff
changeset
|
1778 (put-text-property beg (point) 'mouse-face 'highlight) |
d938bdf82445
(quail-translation-keymap): KP_Enter key
Kenichi Handa <handa@m17n.org>
parents:
20160
diff
changeset
|
1779 (insert "\n")) |
17052 | 1780 ;; We need only vector part. |
1781 (setq translations (cdr translations)) | |
1782 ;; Insert every 10 elements with indices in a line. | |
1783 (let ((len (length translations)) | |
1784 (i 0) | |
1785 num) | |
1786 (while (< i len) | |
19944
e274dc2d61f1
(quail-completion-list-translations): Fix
Richard M. Stallman <rms@gnu.org>
parents:
19934
diff
changeset
|
1787 (when (zerop (% i 10)) |
e274dc2d61f1
(quail-completion-list-translations): Fix
Richard M. Stallman <rms@gnu.org>
parents:
19934
diff
changeset
|
1788 (when (>= i 10) |
20169
d938bdf82445
(quail-translation-keymap): KP_Enter key
Kenichi Handa <handa@m17n.org>
parents:
20160
diff
changeset
|
1789 (insert "\n") |
19944
e274dc2d61f1
(quail-completion-list-translations): Fix
Richard M. Stallman <rms@gnu.org>
parents:
19934
diff
changeset
|
1790 (indent-to indent)) |
e274dc2d61f1
(quail-completion-list-translations): Fix
Richard M. Stallman <rms@gnu.org>
parents:
19934
diff
changeset
|
1791 (insert (format "(%d/%d)" (1+ (/ i 10)) (1+ (/ len 10))))) |
17052 | 1792 ;; We show the last digit of FROM while converting |
1793 ;; 0,1,..,9 to 1,2,..,0. | |
19944
e274dc2d61f1
(quail-completion-list-translations): Fix
Richard M. Stallman <rms@gnu.org>
parents:
19934
diff
changeset
|
1794 (insert (format " %d." (% (1+ i) 10))) |
20169
d938bdf82445
(quail-translation-keymap): KP_Enter key
Kenichi Handa <handa@m17n.org>
parents:
20160
diff
changeset
|
1795 (setq beg (point)) |
17052 | 1796 (insert (aref translations i)) |
20169
d938bdf82445
(quail-translation-keymap): KP_Enter key
Kenichi Handa <handa@m17n.org>
parents:
20160
diff
changeset
|
1797 ;; Passing the mouse over a character will highlight. |
d938bdf82445
(quail-translation-keymap): KP_Enter key
Kenichi Handa <handa@m17n.org>
parents:
20160
diff
changeset
|
1798 (put-text-property beg (point) 'mouse-face 'highlight) |
17052 | 1799 (setq i (1+ i))) |
20169
d938bdf82445
(quail-translation-keymap): KP_Enter key
Kenichi Handa <handa@m17n.org>
parents:
20160
diff
changeset
|
1800 (insert "\n"))))) |
d938bdf82445
(quail-translation-keymap): KP_Enter key
Kenichi Handa <handa@m17n.org>
parents:
20160
diff
changeset
|
1801 |
d938bdf82445
(quail-translation-keymap): KP_Enter key
Kenichi Handa <handa@m17n.org>
parents:
20160
diff
changeset
|
1802 ;; Choose a completion in *Quail Completions* buffer with mouse-2. |
d938bdf82445
(quail-translation-keymap): KP_Enter key
Kenichi Handa <handa@m17n.org>
parents:
20160
diff
changeset
|
1803 |
d938bdf82445
(quail-translation-keymap): KP_Enter key
Kenichi Handa <handa@m17n.org>
parents:
20160
diff
changeset
|
1804 (defun quail-mouse-choose-completion (event) |
d938bdf82445
(quail-translation-keymap): KP_Enter key
Kenichi Handa <handa@m17n.org>
parents:
20160
diff
changeset
|
1805 "Click on an alternative in the `*Quail Completions*' buffer to choose it." |
d938bdf82445
(quail-translation-keymap): KP_Enter key
Kenichi Handa <handa@m17n.org>
parents:
20160
diff
changeset
|
1806 (interactive "e") |
d938bdf82445
(quail-translation-keymap): KP_Enter key
Kenichi Handa <handa@m17n.org>
parents:
20160
diff
changeset
|
1807 ;; This function is an exact copy of the mouse.el function |
d938bdf82445
(quail-translation-keymap): KP_Enter key
Kenichi Handa <handa@m17n.org>
parents:
20160
diff
changeset
|
1808 ;; `mouse-choose-completion' except that we: |
d938bdf82445
(quail-translation-keymap): KP_Enter key
Kenichi Handa <handa@m17n.org>
parents:
20160
diff
changeset
|
1809 ;; 1) add two lines from `choose-completion' in simple.el to give |
d938bdf82445
(quail-translation-keymap): KP_Enter key
Kenichi Handa <handa@m17n.org>
parents:
20160
diff
changeset
|
1810 ;; the `mouse-2' click a little more leeway. |
d938bdf82445
(quail-translation-keymap): KP_Enter key
Kenichi Handa <handa@m17n.org>
parents:
20160
diff
changeset
|
1811 ;; 2) don't bury *Quail Completions* buffer so comment a section, and |
d938bdf82445
(quail-translation-keymap): KP_Enter key
Kenichi Handa <handa@m17n.org>
parents:
20160
diff
changeset
|
1812 ;; 3) delete/terminate the current quail selection here. |
d938bdf82445
(quail-translation-keymap): KP_Enter key
Kenichi Handa <handa@m17n.org>
parents:
20160
diff
changeset
|
1813 ;; Give temporary modes such as isearch a chance to turn off. |
d938bdf82445
(quail-translation-keymap): KP_Enter key
Kenichi Handa <handa@m17n.org>
parents:
20160
diff
changeset
|
1814 (run-hooks 'mouse-leave-buffer-hook) |
d938bdf82445
(quail-translation-keymap): KP_Enter key
Kenichi Handa <handa@m17n.org>
parents:
20160
diff
changeset
|
1815 (let ((buffer (window-buffer)) |
d938bdf82445
(quail-translation-keymap): KP_Enter key
Kenichi Handa <handa@m17n.org>
parents:
20160
diff
changeset
|
1816 choice |
d938bdf82445
(quail-translation-keymap): KP_Enter key
Kenichi Handa <handa@m17n.org>
parents:
20160
diff
changeset
|
1817 base-size) |
d938bdf82445
(quail-translation-keymap): KP_Enter key
Kenichi Handa <handa@m17n.org>
parents:
20160
diff
changeset
|
1818 (save-excursion |
d938bdf82445
(quail-translation-keymap): KP_Enter key
Kenichi Handa <handa@m17n.org>
parents:
20160
diff
changeset
|
1819 (set-buffer (window-buffer (posn-window (event-start event)))) |
d938bdf82445
(quail-translation-keymap): KP_Enter key
Kenichi Handa <handa@m17n.org>
parents:
20160
diff
changeset
|
1820 (if completion-reference-buffer |
d938bdf82445
(quail-translation-keymap): KP_Enter key
Kenichi Handa <handa@m17n.org>
parents:
20160
diff
changeset
|
1821 (setq buffer completion-reference-buffer)) |
d938bdf82445
(quail-translation-keymap): KP_Enter key
Kenichi Handa <handa@m17n.org>
parents:
20160
diff
changeset
|
1822 (setq base-size completion-base-size) |
d938bdf82445
(quail-translation-keymap): KP_Enter key
Kenichi Handa <handa@m17n.org>
parents:
20160
diff
changeset
|
1823 (save-excursion |
d938bdf82445
(quail-translation-keymap): KP_Enter key
Kenichi Handa <handa@m17n.org>
parents:
20160
diff
changeset
|
1824 (goto-char (posn-point (event-start event))) |
d938bdf82445
(quail-translation-keymap): KP_Enter key
Kenichi Handa <handa@m17n.org>
parents:
20160
diff
changeset
|
1825 (let (beg end) |
d938bdf82445
(quail-translation-keymap): KP_Enter key
Kenichi Handa <handa@m17n.org>
parents:
20160
diff
changeset
|
1826 (if (and (not (eobp)) (get-text-property (point) 'mouse-face)) |
d938bdf82445
(quail-translation-keymap): KP_Enter key
Kenichi Handa <handa@m17n.org>
parents:
20160
diff
changeset
|
1827 (setq end (point) beg (1+ (point)))) |
d938bdf82445
(quail-translation-keymap): KP_Enter key
Kenichi Handa <handa@m17n.org>
parents:
20160
diff
changeset
|
1828 (if (and (not (bobp)) (get-text-property (1- (point)) 'mouse-face)) |
d938bdf82445
(quail-translation-keymap): KP_Enter key
Kenichi Handa <handa@m17n.org>
parents:
20160
diff
changeset
|
1829 (setq end (1- (point)) beg (point))) |
d938bdf82445
(quail-translation-keymap): KP_Enter key
Kenichi Handa <handa@m17n.org>
parents:
20160
diff
changeset
|
1830 (if (null beg) |
22765
7cf2c3800e8f
(quail-mode): This variable deleted.
Kenichi Handa <handa@m17n.org>
parents:
22124
diff
changeset
|
1831 (quail-error "No completion here")) |
20169
d938bdf82445
(quail-translation-keymap): KP_Enter key
Kenichi Handa <handa@m17n.org>
parents:
20160
diff
changeset
|
1832 (setq beg (previous-single-property-change beg 'mouse-face)) |
d938bdf82445
(quail-translation-keymap): KP_Enter key
Kenichi Handa <handa@m17n.org>
parents:
20160
diff
changeset
|
1833 (setq end (or (next-single-property-change end 'mouse-face) |
d938bdf82445
(quail-translation-keymap): KP_Enter key
Kenichi Handa <handa@m17n.org>
parents:
20160
diff
changeset
|
1834 (point-max))) |
d938bdf82445
(quail-translation-keymap): KP_Enter key
Kenichi Handa <handa@m17n.org>
parents:
20160
diff
changeset
|
1835 (setq choice (buffer-substring beg end))))) |
d938bdf82445
(quail-translation-keymap): KP_Enter key
Kenichi Handa <handa@m17n.org>
parents:
20160
diff
changeset
|
1836 ; (let ((owindow (selected-window))) |
d938bdf82445
(quail-translation-keymap): KP_Enter key
Kenichi Handa <handa@m17n.org>
parents:
20160
diff
changeset
|
1837 ; (select-window (posn-window (event-start event))) |
d938bdf82445
(quail-translation-keymap): KP_Enter key
Kenichi Handa <handa@m17n.org>
parents:
20160
diff
changeset
|
1838 ; (if (and (one-window-p t 'selected-frame) |
d938bdf82445
(quail-translation-keymap): KP_Enter key
Kenichi Handa <handa@m17n.org>
parents:
20160
diff
changeset
|
1839 ; (window-dedicated-p (selected-window))) |
d938bdf82445
(quail-translation-keymap): KP_Enter key
Kenichi Handa <handa@m17n.org>
parents:
20160
diff
changeset
|
1840 ; ;; This is a special buffer's frame |
d938bdf82445
(quail-translation-keymap): KP_Enter key
Kenichi Handa <handa@m17n.org>
parents:
20160
diff
changeset
|
1841 ; (iconify-frame (selected-frame)) |
d938bdf82445
(quail-translation-keymap): KP_Enter key
Kenichi Handa <handa@m17n.org>
parents:
20160
diff
changeset
|
1842 ; (or (window-dedicated-p (selected-window)) |
d938bdf82445
(quail-translation-keymap): KP_Enter key
Kenichi Handa <handa@m17n.org>
parents:
20160
diff
changeset
|
1843 ; (bury-buffer))) |
d938bdf82445
(quail-translation-keymap): KP_Enter key
Kenichi Handa <handa@m17n.org>
parents:
20160
diff
changeset
|
1844 ; (select-window owindow)) |
d938bdf82445
(quail-translation-keymap): KP_Enter key
Kenichi Handa <handa@m17n.org>
parents:
20160
diff
changeset
|
1845 (quail-delete-region) |
d938bdf82445
(quail-translation-keymap): KP_Enter key
Kenichi Handa <handa@m17n.org>
parents:
20160
diff
changeset
|
1846 (quail-choose-completion-string choice buffer base-size) |
d938bdf82445
(quail-translation-keymap): KP_Enter key
Kenichi Handa <handa@m17n.org>
parents:
20160
diff
changeset
|
1847 (quail-terminate-translation))) |
d938bdf82445
(quail-translation-keymap): KP_Enter key
Kenichi Handa <handa@m17n.org>
parents:
20160
diff
changeset
|
1848 |
d938bdf82445
(quail-translation-keymap): KP_Enter key
Kenichi Handa <handa@m17n.org>
parents:
20160
diff
changeset
|
1849 ;; Modify the simple.el function `choose-completion-string', because |
d938bdf82445
(quail-translation-keymap): KP_Enter key
Kenichi Handa <handa@m17n.org>
parents:
20160
diff
changeset
|
1850 ;; the simple.el function `choose-completion-delete-max-match' breaks |
d938bdf82445
(quail-translation-keymap): KP_Enter key
Kenichi Handa <handa@m17n.org>
parents:
20160
diff
changeset
|
1851 ;; on Mule data, since the semantics of `forward-char' have changed. |
d938bdf82445
(quail-translation-keymap): KP_Enter key
Kenichi Handa <handa@m17n.org>
parents:
20160
diff
changeset
|
1852 |
d938bdf82445
(quail-translation-keymap): KP_Enter key
Kenichi Handa <handa@m17n.org>
parents:
20160
diff
changeset
|
1853 (defun quail-choose-completion-string (choice &optional buffer base-size) |
d938bdf82445
(quail-translation-keymap): KP_Enter key
Kenichi Handa <handa@m17n.org>
parents:
20160
diff
changeset
|
1854 (let ((buffer (or buffer completion-reference-buffer))) |
d938bdf82445
(quail-translation-keymap): KP_Enter key
Kenichi Handa <handa@m17n.org>
parents:
20160
diff
changeset
|
1855 ;; If BUFFER is a minibuffer, barf unless it's the currently |
d938bdf82445
(quail-translation-keymap): KP_Enter key
Kenichi Handa <handa@m17n.org>
parents:
20160
diff
changeset
|
1856 ;; active minibuffer. |
d938bdf82445
(quail-translation-keymap): KP_Enter key
Kenichi Handa <handa@m17n.org>
parents:
20160
diff
changeset
|
1857 (if (and (string-match "\\` \\*Minibuf-[0-9]+\\*\\'" (buffer-name buffer)) |
d938bdf82445
(quail-translation-keymap): KP_Enter key
Kenichi Handa <handa@m17n.org>
parents:
20160
diff
changeset
|
1858 (or (not (active-minibuffer-window)) |
d938bdf82445
(quail-translation-keymap): KP_Enter key
Kenichi Handa <handa@m17n.org>
parents:
20160
diff
changeset
|
1859 (not (equal buffer |
d938bdf82445
(quail-translation-keymap): KP_Enter key
Kenichi Handa <handa@m17n.org>
parents:
20160
diff
changeset
|
1860 (window-buffer (active-minibuffer-window)))))) |
22765
7cf2c3800e8f
(quail-mode): This variable deleted.
Kenichi Handa <handa@m17n.org>
parents:
22124
diff
changeset
|
1861 (quail-error "Minibuffer is not active for completion") |
23172
a47eab4fc085
(quail-choose-completion-string): Store
Kenichi Handa <handa@m17n.org>
parents:
23014
diff
changeset
|
1862 ;; Store the completion in `quail-current-str', which will later |
a47eab4fc085
(quail-choose-completion-string): Store
Kenichi Handa <handa@m17n.org>
parents:
23014
diff
changeset
|
1863 ;; be converted to a character event list, then inserted into |
a47eab4fc085
(quail-choose-completion-string): Store
Kenichi Handa <handa@m17n.org>
parents:
23014
diff
changeset
|
1864 ;; the buffer where completion was requested. |
20169
d938bdf82445
(quail-translation-keymap): KP_Enter key
Kenichi Handa <handa@m17n.org>
parents:
20160
diff
changeset
|
1865 (set-buffer buffer) |
d938bdf82445
(quail-translation-keymap): KP_Enter key
Kenichi Handa <handa@m17n.org>
parents:
20160
diff
changeset
|
1866 ; (if base-size |
d938bdf82445
(quail-translation-keymap): KP_Enter key
Kenichi Handa <handa@m17n.org>
parents:
20160
diff
changeset
|
1867 ; (delete-region (+ base-size (point-min)) (point)) |
d938bdf82445
(quail-translation-keymap): KP_Enter key
Kenichi Handa <handa@m17n.org>
parents:
20160
diff
changeset
|
1868 ; (choose-completion-delete-max-match choice)) |
23172
a47eab4fc085
(quail-choose-completion-string): Store
Kenichi Handa <handa@m17n.org>
parents:
23014
diff
changeset
|
1869 (setq quail-current-str choice) |
20169
d938bdf82445
(quail-translation-keymap): KP_Enter key
Kenichi Handa <handa@m17n.org>
parents:
20160
diff
changeset
|
1870 ;; Update point in the window that BUFFER is showing in. |
d938bdf82445
(quail-translation-keymap): KP_Enter key
Kenichi Handa <handa@m17n.org>
parents:
20160
diff
changeset
|
1871 (let ((window (get-buffer-window buffer t))) |
d938bdf82445
(quail-translation-keymap): KP_Enter key
Kenichi Handa <handa@m17n.org>
parents:
20160
diff
changeset
|
1872 (set-window-point window (point))) |
d938bdf82445
(quail-translation-keymap): KP_Enter key
Kenichi Handa <handa@m17n.org>
parents:
20160
diff
changeset
|
1873 ;; If completing for the minibuffer, exit it with this choice. |
d938bdf82445
(quail-translation-keymap): KP_Enter key
Kenichi Handa <handa@m17n.org>
parents:
20160
diff
changeset
|
1874 (and (not completion-no-auto-exit) |
d938bdf82445
(quail-translation-keymap): KP_Enter key
Kenichi Handa <handa@m17n.org>
parents:
20160
diff
changeset
|
1875 (equal buffer (window-buffer (minibuffer-window))) |
d938bdf82445
(quail-translation-keymap): KP_Enter key
Kenichi Handa <handa@m17n.org>
parents:
20160
diff
changeset
|
1876 minibuffer-completion-table |
d938bdf82445
(quail-translation-keymap): KP_Enter key
Kenichi Handa <handa@m17n.org>
parents:
20160
diff
changeset
|
1877 ;; If this is reading a file name, and the file name chosen |
d938bdf82445
(quail-translation-keymap): KP_Enter key
Kenichi Handa <handa@m17n.org>
parents:
20160
diff
changeset
|
1878 ;; is a directory, don't exit the minibuffer. |
d938bdf82445
(quail-translation-keymap): KP_Enter key
Kenichi Handa <handa@m17n.org>
parents:
20160
diff
changeset
|
1879 (if (and (eq minibuffer-completion-table 'read-file-name-internal) |
d938bdf82445
(quail-translation-keymap): KP_Enter key
Kenichi Handa <handa@m17n.org>
parents:
20160
diff
changeset
|
1880 (file-directory-p (buffer-string))) |
d938bdf82445
(quail-translation-keymap): KP_Enter key
Kenichi Handa <handa@m17n.org>
parents:
20160
diff
changeset
|
1881 (select-window (active-minibuffer-window)) |
d938bdf82445
(quail-translation-keymap): KP_Enter key
Kenichi Handa <handa@m17n.org>
parents:
20160
diff
changeset
|
1882 (exit-minibuffer)))))) |
17052 | 1883 |
1884 (defun quail-help () | |
1885 "Show brief description of the current Quail package." | |
1886 (interactive) | |
18349
f468344dd2bd
(quail-help): Use with-output-to-temp-buffer.
Kenichi Handa <handa@m17n.org>
parents:
18297
diff
changeset
|
1887 (let ((package quail-current-package)) |
f468344dd2bd
(quail-help): Use with-output-to-temp-buffer.
Kenichi Handa <handa@m17n.org>
parents:
18297
diff
changeset
|
1888 (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
|
1889 (save-excursion |
f468344dd2bd
(quail-help): Use with-output-to-temp-buffer.
Kenichi Handa <handa@m17n.org>
parents:
18297
diff
changeset
|
1890 (set-buffer standard-output) |
f468344dd2bd
(quail-help): Use with-output-to-temp-buffer.
Kenichi Handa <handa@m17n.org>
parents:
18297
diff
changeset
|
1891 (let ((quail-current-package package)) |
f468344dd2bd
(quail-help): Use with-output-to-temp-buffer.
Kenichi Handa <handa@m17n.org>
parents:
18297
diff
changeset
|
1892 (insert "Quail input method (name:" |
f468344dd2bd
(quail-help): Use with-output-to-temp-buffer.
Kenichi Handa <handa@m17n.org>
parents:
18297
diff
changeset
|
1893 (quail-name) |
f468344dd2bd
(quail-help): Use with-output-to-temp-buffer.
Kenichi Handa <handa@m17n.org>
parents:
18297
diff
changeset
|
1894 ", mode line indicator:[" |
f468344dd2bd
(quail-help): Use with-output-to-temp-buffer.
Kenichi Handa <handa@m17n.org>
parents:
18297
diff
changeset
|
1895 (quail-title) |
f468344dd2bd
(quail-help): Use with-output-to-temp-buffer.
Kenichi Handa <handa@m17n.org>
parents:
18297
diff
changeset
|
1896 "])\n---- Documentation ----\n" |
f468344dd2bd
(quail-help): Use with-output-to-temp-buffer.
Kenichi Handa <handa@m17n.org>
parents:
18297
diff
changeset
|
1897 (quail-docstring)) |
f468344dd2bd
(quail-help): Use with-output-to-temp-buffer.
Kenichi Handa <handa@m17n.org>
parents:
18297
diff
changeset
|
1898 (newline) |
f468344dd2bd
(quail-help): Use with-output-to-temp-buffer.
Kenichi Handa <handa@m17n.org>
parents:
18297
diff
changeset
|
1899 (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
|
1900 (quail-help-insert-keymap-description |
f468344dd2bd
(quail-help): Use with-output-to-temp-buffer.
Kenichi Handa <handa@m17n.org>
parents:
18297
diff
changeset
|
1901 (quail-translation-keymap) |
f468344dd2bd
(quail-help): Use with-output-to-temp-buffer.
Kenichi Handa <handa@m17n.org>
parents:
18297
diff
changeset
|
1902 "--- Key bindings (while translating) --- |
17052 | 1903 key binding |
1904 --- -------\n") | |
18349
f468344dd2bd
(quail-help): Use with-output-to-temp-buffer.
Kenichi Handa <handa@m17n.org>
parents:
18297
diff
changeset
|
1905 (if (quail-conversion-keymap) |
f468344dd2bd
(quail-help): Use with-output-to-temp-buffer.
Kenichi Handa <handa@m17n.org>
parents:
18297
diff
changeset
|
1906 (quail-help-insert-keymap-description |
f468344dd2bd
(quail-help): Use with-output-to-temp-buffer.
Kenichi Handa <handa@m17n.org>
parents:
18297
diff
changeset
|
1907 (quail-conversion-keymap) |
f468344dd2bd
(quail-help): Use with-output-to-temp-buffer.
Kenichi Handa <handa@m17n.org>
parents:
18297
diff
changeset
|
1908 "--- Key bindings (while converting) --- |
17052 | 1909 key binding |
1910 --- -------\n")) | |
18349
f468344dd2bd
(quail-help): Use with-output-to-temp-buffer.
Kenichi Handa <handa@m17n.org>
parents:
18297
diff
changeset
|
1911 (help-mode)))))) |
f468344dd2bd
(quail-help): Use with-output-to-temp-buffer.
Kenichi Handa <handa@m17n.org>
parents:
18297
diff
changeset
|
1912 |
17052 | 1913 (defun quail-help-insert-keymap-description (keymap &optional header) |
1914 (let (from to) | |
1915 (if header | |
1916 (insert header)) | |
1917 (save-excursion | |
1918 (save-window-excursion | |
19404
8901359ae445
(quail-inactivate): Turn Quail mode off
Kenichi Handa <handa@m17n.org>
parents:
19391
diff
changeset
|
1919 (let ((overriding-terminal-local-map keymap)) |
17052 | 1920 (describe-bindings)) |
1921 (set-buffer "*Help*") | |
1922 (goto-char (point-min)) | |
1923 (forward-line 4) | |
1924 (setq from (point)) | |
1925 (search-forward "Global Bindings:" nil 'move) | |
1926 (beginning-of-line) | |
1927 (setq to (point)))) | |
1928 (insert-buffer-substring "*Help*" from to))) | |
1929 | |
1930 (defun quail-show-kbd-layout () | |
1931 "Show keyboard layout with key tops of multilingual characters." | |
1932 (insert "--- Keyboard layout ---\n") | |
24304
cef9cf0a46b4
(quail-show-kbd-layout): Bind blink-matching-paren to nil.
Kenichi Handa <handa@m17n.org>
parents:
24238
diff
changeset
|
1933 (let ((blink-matching-paren nil) |
cef9cf0a46b4
(quail-show-kbd-layout): Bind blink-matching-paren to nil.
Kenichi Handa <handa@m17n.org>
parents:
24238
diff
changeset
|
1934 (i 0) |
cef9cf0a46b4
(quail-show-kbd-layout): Bind blink-matching-paren to nil.
Kenichi Handa <handa@m17n.org>
parents:
24238
diff
changeset
|
1935 ch) |
17052 | 1936 (while (< i quail-keyboard-layout-len) |
1937 (if (= (% i 30) 0) | |
1938 (progn | |
1939 (newline) | |
1940 (indent-to (/ i 30))) | |
1941 (if (= (% i 2) 0) | |
1942 (insert " "))) | |
1943 (setq ch (aref quail-keyboard-layout i)) | |
19675
32c3f7d9ef10
(quail-keyboard-layout-alist): Add an
Kenichi Handa <handa@m17n.org>
parents:
19655
diff
changeset
|
1944 (when (and (quail-kbd-translate) |
32c3f7d9ef10
(quail-keyboard-layout-alist): Add an
Kenichi Handa <handa@m17n.org>
parents:
19655
diff
changeset
|
1945 (/= ch ?\ )) |
32c3f7d9ef10
(quail-keyboard-layout-alist): Add an
Kenichi Handa <handa@m17n.org>
parents:
19655
diff
changeset
|
1946 ;; 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
|
1947 ;; some keyboard layout (which means it requires keyboard |
32c3f7d9ef10
(quail-keyboard-layout-alist): Add an
Kenichi Handa <handa@m17n.org>
parents:
19655
diff
changeset
|
1948 ;; 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
|
1949 ;; keyboard. We must translate that key by |
32c3f7d9ef10
(quail-keyboard-layout-alist): Add an
Kenichi Handa <handa@m17n.org>
parents:
19655
diff
changeset
|
1950 ;; `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
|
1951 ;; 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
|
1952 ;; 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
|
1953 ;; minus value. |
32c3f7d9ef10
(quail-keyboard-layout-alist): Add an
Kenichi Handa <handa@m17n.org>
parents:
19655
diff
changeset
|
1954 (setq ch (aref quail-keyboard-layout-standard i)) |
32c3f7d9ef10
(quail-keyboard-layout-alist): Add an
Kenichi Handa <handa@m17n.org>
parents:
19655
diff
changeset
|
1955 (if (= ch ?\ ) |
32c3f7d9ef10
(quail-keyboard-layout-alist): Add an
Kenichi Handa <handa@m17n.org>
parents:
19655
diff
changeset
|
1956 (setq ch (- (aref quail-keyboard-layout i))))) |
32c3f7d9ef10
(quail-keyboard-layout-alist): Add an
Kenichi Handa <handa@m17n.org>
parents:
19655
diff
changeset
|
1957 (if (< ch 0) |
32c3f7d9ef10
(quail-keyboard-layout-alist): Add an
Kenichi Handa <handa@m17n.org>
parents:
19655
diff
changeset
|
1958 (let ((last-command-event (- ch))) |
32c3f7d9ef10
(quail-keyboard-layout-alist): Add an
Kenichi Handa <handa@m17n.org>
parents:
19655
diff
changeset
|
1959 (self-insert-command 1)) |
32c3f7d9ef10
(quail-keyboard-layout-alist): Add an
Kenichi Handa <handa@m17n.org>
parents:
19655
diff
changeset
|
1960 (if (= ch ?\ ) |
32c3f7d9ef10
(quail-keyboard-layout-alist): Add an
Kenichi Handa <handa@m17n.org>
parents:
19655
diff
changeset
|
1961 (insert ch) |
32c3f7d9ef10
(quail-keyboard-layout-alist): Add an
Kenichi Handa <handa@m17n.org>
parents:
19655
diff
changeset
|
1962 (let* ((map (cdr (assq ch (cdr (quail-map))))) |
32c3f7d9ef10
(quail-keyboard-layout-alist): Add an
Kenichi Handa <handa@m17n.org>
parents:
19655
diff
changeset
|
1963 (translation (and map (quail-get-translation |
32c3f7d9ef10
(quail-keyboard-layout-alist): Add an
Kenichi Handa <handa@m17n.org>
parents:
19655
diff
changeset
|
1964 (car map) (char-to-string ch) 1)))) |
32c3f7d9ef10
(quail-keyboard-layout-alist): Add an
Kenichi Handa <handa@m17n.org>
parents:
19655
diff
changeset
|
1965 (if (integerp translation) |
32c3f7d9ef10
(quail-keyboard-layout-alist): Add an
Kenichi Handa <handa@m17n.org>
parents:
19655
diff
changeset
|
1966 (insert translation) |
32c3f7d9ef10
(quail-keyboard-layout-alist): Add an
Kenichi Handa <handa@m17n.org>
parents:
19655
diff
changeset
|
1967 (if (consp translation) |
20728
a47662abcc23
(quail-show-kbd-layout): Bug fix for the
Kenichi Handa <handa@m17n.org>
parents:
20638
diff
changeset
|
1968 (insert (aref (cdr translation) (car (car translation)))) |
19675
32c3f7d9ef10
(quail-keyboard-layout-alist): Add an
Kenichi Handa <handa@m17n.org>
parents:
19655
diff
changeset
|
1969 (let ((last-command-event ch)) |
32c3f7d9ef10
(quail-keyboard-layout-alist): Add an
Kenichi Handa <handa@m17n.org>
parents:
19655
diff
changeset
|
1970 (self-insert-command 1))))))) |
17052 | 1971 (setq i (1+ i)))) |
1972 (newline)) | |
1973 | |
1974 (defun quail-translation-help () | |
22917
00f3497854c4
(quail-translation-keymap): Declare it as
Kenichi Handa <handa@m17n.org>
parents:
22883
diff
changeset
|
1975 "Show help message while translating in Quail input method." |
17052 | 1976 (interactive) |
22917
00f3497854c4
(quail-translation-keymap): Declare it as
Kenichi Handa <handa@m17n.org>
parents:
22883
diff
changeset
|
1977 (if (not (eq this-command last-command)) |
00f3497854c4
(quail-translation-keymap): Declare it as
Kenichi Handa <handa@m17n.org>
parents:
22883
diff
changeset
|
1978 (let (state-msg keymap) |
00f3497854c4
(quail-translation-keymap): Declare it as
Kenichi Handa <handa@m17n.org>
parents:
22883
diff
changeset
|
1979 (if (and quail-converting (= (length quail-current-key) 0)) |
00f3497854c4
(quail-translation-keymap): Declare it as
Kenichi Handa <handa@m17n.org>
parents:
22883
diff
changeset
|
1980 (setq state-msg |
00f3497854c4
(quail-translation-keymap): Declare it as
Kenichi Handa <handa@m17n.org>
parents:
22883
diff
changeset
|
1981 (format "Converting string %S by input method %S.\n" |
00f3497854c4
(quail-translation-keymap): Declare it as
Kenichi Handa <handa@m17n.org>
parents:
22883
diff
changeset
|
1982 quail-conversion-str (quail-name)) |
00f3497854c4
(quail-translation-keymap): Declare it as
Kenichi Handa <handa@m17n.org>
parents:
22883
diff
changeset
|
1983 keymap (quail-conversion-keymap)) |
00f3497854c4
(quail-translation-keymap): Declare it as
Kenichi Handa <handa@m17n.org>
parents:
22883
diff
changeset
|
1984 (setq state-msg |
00f3497854c4
(quail-translation-keymap): Declare it as
Kenichi Handa <handa@m17n.org>
parents:
22883
diff
changeset
|
1985 (format "Translating key sequence %S by input method %S.\n" |
00f3497854c4
(quail-translation-keymap): Declare it as
Kenichi Handa <handa@m17n.org>
parents:
22883
diff
changeset
|
1986 quail-current-key (quail-name)) |
00f3497854c4
(quail-translation-keymap): Declare it as
Kenichi Handa <handa@m17n.org>
parents:
22883
diff
changeset
|
1987 keymap (quail-translation-keymap))) |
00f3497854c4
(quail-translation-keymap): Declare it as
Kenichi Handa <handa@m17n.org>
parents:
22883
diff
changeset
|
1988 (with-output-to-temp-buffer "*Quail-Help*" |
00f3497854c4
(quail-translation-keymap): Declare it as
Kenichi Handa <handa@m17n.org>
parents:
22883
diff
changeset
|
1989 (save-excursion |
00f3497854c4
(quail-translation-keymap): Declare it as
Kenichi Handa <handa@m17n.org>
parents:
22883
diff
changeset
|
1990 (set-buffer standard-output) |
00f3497854c4
(quail-translation-keymap): Declare it as
Kenichi Handa <handa@m17n.org>
parents:
22883
diff
changeset
|
1991 (insert state-msg) |
00f3497854c4
(quail-translation-keymap): Declare it as
Kenichi Handa <handa@m17n.org>
parents:
22883
diff
changeset
|
1992 (quail-help-insert-keymap-description |
00f3497854c4
(quail-translation-keymap): Declare it as
Kenichi Handa <handa@m17n.org>
parents:
22883
diff
changeset
|
1993 keymap |
00f3497854c4
(quail-translation-keymap): Declare it as
Kenichi Handa <handa@m17n.org>
parents:
22883
diff
changeset
|
1994 "----------------------- |
17052 | 1995 key binding |
22917
00f3497854c4
(quail-translation-keymap): Declare it as
Kenichi Handa <handa@m17n.org>
parents:
22883
diff
changeset
|
1996 --- -------\n") |
00f3497854c4
(quail-translation-keymap): Declare it as
Kenichi Handa <handa@m17n.org>
parents:
22883
diff
changeset
|
1997 (help-mode))))) |
00f3497854c4
(quail-translation-keymap): Declare it as
Kenichi Handa <handa@m17n.org>
parents:
22883
diff
changeset
|
1998 (let (scroll-help) |
00f3497854c4
(quail-translation-keymap): Declare it as
Kenichi Handa <handa@m17n.org>
parents:
22883
diff
changeset
|
1999 (save-selected-window |
00f3497854c4
(quail-translation-keymap): Declare it as
Kenichi Handa <handa@m17n.org>
parents:
22883
diff
changeset
|
2000 (select-window (get-buffer-window "*Quail-Help*")) |
00f3497854c4
(quail-translation-keymap): Declare it as
Kenichi Handa <handa@m17n.org>
parents:
22883
diff
changeset
|
2001 (if (eq this-command last-command) |
00f3497854c4
(quail-translation-keymap): Declare it as
Kenichi Handa <handa@m17n.org>
parents:
22883
diff
changeset
|
2002 (if (< (window-end) (point-max)) |
00f3497854c4
(quail-translation-keymap): Declare it as
Kenichi Handa <handa@m17n.org>
parents:
22883
diff
changeset
|
2003 (scroll-up) |
00f3497854c4
(quail-translation-keymap): Declare it as
Kenichi Handa <handa@m17n.org>
parents:
22883
diff
changeset
|
2004 (if (> (window-start) (point-min)) |
00f3497854c4
(quail-translation-keymap): Declare it as
Kenichi Handa <handa@m17n.org>
parents:
22883
diff
changeset
|
2005 (set-window-start (selected-window) (point-min))))) |
00f3497854c4
(quail-translation-keymap): Declare it as
Kenichi Handa <handa@m17n.org>
parents:
22883
diff
changeset
|
2006 (setq scroll-help |
00f3497854c4
(quail-translation-keymap): Declare it as
Kenichi Handa <handa@m17n.org>
parents:
22883
diff
changeset
|
2007 (if (< (window-end (selected-window) 'up-to-date) (point-max)) |
00f3497854c4
(quail-translation-keymap): Declare it as
Kenichi Handa <handa@m17n.org>
parents:
22883
diff
changeset
|
2008 "Type \\[quail-translation-help] to scroll up the help" |
00f3497854c4
(quail-translation-keymap): Declare it as
Kenichi Handa <handa@m17n.org>
parents:
22883
diff
changeset
|
2009 (if (> (window-start) (point-min)) |
00f3497854c4
(quail-translation-keymap): Declare it as
Kenichi Handa <handa@m17n.org>
parents:
22883
diff
changeset
|
2010 "Type \\[quail-translation-help] to see the head of help")))) |
00f3497854c4
(quail-translation-keymap): Declare it as
Kenichi Handa <handa@m17n.org>
parents:
22883
diff
changeset
|
2011 (if scroll-help |
00f3497854c4
(quail-translation-keymap): Declare it as
Kenichi Handa <handa@m17n.org>
parents:
22883
diff
changeset
|
2012 (progn |
00f3497854c4
(quail-translation-keymap): Declare it as
Kenichi Handa <handa@m17n.org>
parents:
22883
diff
changeset
|
2013 (message "%s" (substitute-command-keys scroll-help)) |
00f3497854c4
(quail-translation-keymap): Declare it as
Kenichi Handa <handa@m17n.org>
parents:
22883
diff
changeset
|
2014 (sit-for 1) |
00f3497854c4
(quail-translation-keymap): Declare it as
Kenichi Handa <handa@m17n.org>
parents:
22883
diff
changeset
|
2015 (message nil) |
00f3497854c4
(quail-translation-keymap): Declare it as
Kenichi Handa <handa@m17n.org>
parents:
22883
diff
changeset
|
2016 (quail-update-guidance) |
00f3497854c4
(quail-translation-keymap): Declare it as
Kenichi Handa <handa@m17n.org>
parents:
22883
diff
changeset
|
2017 )))) |
26891
651d521c8f52
(quail-install-map): New optional arg
Kenichi Handa <handa@m17n.org>
parents:
24821
diff
changeset
|
2018 |
651d521c8f52
(quail-install-map): New optional arg
Kenichi Handa <handa@m17n.org>
parents:
24821
diff
changeset
|
2019 ;; Quail map generator from state transition table. |
651d521c8f52
(quail-install-map): New optional arg
Kenichi Handa <handa@m17n.org>
parents:
24821
diff
changeset
|
2020 |
651d521c8f52
(quail-install-map): New optional arg
Kenichi Handa <handa@m17n.org>
parents:
24821
diff
changeset
|
2021 (defun quail-map-from-table (table) |
651d521c8f52
(quail-install-map): New optional arg
Kenichi Handa <handa@m17n.org>
parents:
24821
diff
changeset
|
2022 "Make quail map from state transition table TABLE. |
651d521c8f52
(quail-install-map): New optional arg
Kenichi Handa <handa@m17n.org>
parents:
24821
diff
changeset
|
2023 |
651d521c8f52
(quail-install-map): New optional arg
Kenichi Handa <handa@m17n.org>
parents:
24821
diff
changeset
|
2024 TABLE is an alist, the form is: |
651d521c8f52
(quail-install-map): New optional arg
Kenichi Handa <handa@m17n.org>
parents:
24821
diff
changeset
|
2025 ((STATE-0 TRANSITION-0-1 TRANSITION-0-2 ...) (STATE-1 ...) ...) |
651d521c8f52
(quail-install-map): New optional arg
Kenichi Handa <handa@m17n.org>
parents:
24821
diff
changeset
|
2026 |
651d521c8f52
(quail-install-map): New optional arg
Kenichi Handa <handa@m17n.org>
parents:
24821
diff
changeset
|
2027 STATE-n are symbols to denote state. STATE-0 is the initial state. |
651d521c8f52
(quail-install-map): New optional arg
Kenichi Handa <handa@m17n.org>
parents:
24821
diff
changeset
|
2028 |
651d521c8f52
(quail-install-map): New optional arg
Kenichi Handa <handa@m17n.org>
parents:
24821
diff
changeset
|
2029 TRANSITION-n-m are transition rules from STATE-n, and have the form |
651d521c8f52
(quail-install-map): New optional arg
Kenichi Handa <handa@m17n.org>
parents:
24821
diff
changeset
|
2030 \(RULES . STATE-x) or RULES, where STATE-x is one of STATE-n above, |
651d521c8f52
(quail-install-map): New optional arg
Kenichi Handa <handa@m17n.org>
parents:
24821
diff
changeset
|
2031 RULES is a symbol whose value is an alist of keys \(string) vs the |
651d521c8f52
(quail-install-map): New optional arg
Kenichi Handa <handa@m17n.org>
parents:
24821
diff
changeset
|
2032 correponding characters or strings. The format of the symbol value of |
651d521c8f52
(quail-install-map): New optional arg
Kenichi Handa <handa@m17n.org>
parents:
24821
diff
changeset
|
2033 RULES is the same as arguments to `quail-define-rules'. |
651d521c8f52
(quail-install-map): New optional arg
Kenichi Handa <handa@m17n.org>
parents:
24821
diff
changeset
|
2034 |
651d521c8f52
(quail-install-map): New optional arg
Kenichi Handa <handa@m17n.org>
parents:
24821
diff
changeset
|
2035 If TRANSITION-n-m has the form (RULES . STATE-x), it means that |
651d521c8f52
(quail-install-map): New optional arg
Kenichi Handa <handa@m17n.org>
parents:
24821
diff
changeset
|
2036 STATE-n transits to STATE-x when keys in RULES are input. Recursive |
651d521c8f52
(quail-install-map): New optional arg
Kenichi Handa <handa@m17n.org>
parents:
24821
diff
changeset
|
2037 transition is allowed, i.e. STATE-x may be STATE-n. |
651d521c8f52
(quail-install-map): New optional arg
Kenichi Handa <handa@m17n.org>
parents:
24821
diff
changeset
|
2038 |
651d521c8f52
(quail-install-map): New optional arg
Kenichi Handa <handa@m17n.org>
parents:
24821
diff
changeset
|
2039 If TRANSITION-n-m has the form RULES, the transition terminates |
651d521c8f52
(quail-install-map): New optional arg
Kenichi Handa <handa@m17n.org>
parents:
24821
diff
changeset
|
2040 when keys in RULES are input. |
651d521c8f52
(quail-install-map): New optional arg
Kenichi Handa <handa@m17n.org>
parents:
24821
diff
changeset
|
2041 |
651d521c8f52
(quail-install-map): New optional arg
Kenichi Handa <handa@m17n.org>
parents:
24821
diff
changeset
|
2042 The generated map can be set for the current Quail package by the |
651d521c8f52
(quail-install-map): New optional arg
Kenichi Handa <handa@m17n.org>
parents:
24821
diff
changeset
|
2043 function `quail-install-map' (which see)." |
651d521c8f52
(quail-install-map): New optional arg
Kenichi Handa <handa@m17n.org>
parents:
24821
diff
changeset
|
2044 (let ((state-alist (mapcar (lambda (x) (list (car x))) table)) |
651d521c8f52
(quail-install-map): New optional arg
Kenichi Handa <handa@m17n.org>
parents:
24821
diff
changeset
|
2045 tail elt) |
651d521c8f52
(quail-install-map): New optional arg
Kenichi Handa <handa@m17n.org>
parents:
24821
diff
changeset
|
2046 ;; STATE-ALIST is an alist of states vs the correponding sub Quail |
651d521c8f52
(quail-install-map): New optional arg
Kenichi Handa <handa@m17n.org>
parents:
24821
diff
changeset
|
2047 ;; map. It is now initialized to ((STATE-0) (STATE-1) ...). |
651d521c8f52
(quail-install-map): New optional arg
Kenichi Handa <handa@m17n.org>
parents:
24821
diff
changeset
|
2048 ;; Set key sequence mapping rules in cdr part of each element. |
651d521c8f52
(quail-install-map): New optional arg
Kenichi Handa <handa@m17n.org>
parents:
24821
diff
changeset
|
2049 (while table |
651d521c8f52
(quail-install-map): New optional arg
Kenichi Handa <handa@m17n.org>
parents:
24821
diff
changeset
|
2050 (quail-map-from-table-1 state-alist (car table)) |
651d521c8f52
(quail-install-map): New optional arg
Kenichi Handa <handa@m17n.org>
parents:
24821
diff
changeset
|
2051 (setq table (cdr table))) |
651d521c8f52
(quail-install-map): New optional arg
Kenichi Handa <handa@m17n.org>
parents:
24821
diff
changeset
|
2052 |
651d521c8f52
(quail-install-map): New optional arg
Kenichi Handa <handa@m17n.org>
parents:
24821
diff
changeset
|
2053 ;; Now STATE-ALIST has the form ((STATE-0 MAPPING-RULES) ...). |
651d521c8f52
(quail-install-map): New optional arg
Kenichi Handa <handa@m17n.org>
parents:
24821
diff
changeset
|
2054 ;; Elements of MAPPING-RULES may have the form (STATE-x). Replace |
651d521c8f52
(quail-install-map): New optional arg
Kenichi Handa <handa@m17n.org>
parents:
24821
diff
changeset
|
2055 ;; them with MAPPING-RULES of STATE-x to make elements of |
651d521c8f52
(quail-install-map): New optional arg
Kenichi Handa <handa@m17n.org>
parents:
24821
diff
changeset
|
2056 ;; STATE-ALIST valid Quail maps. |
651d521c8f52
(quail-install-map): New optional arg
Kenichi Handa <handa@m17n.org>
parents:
24821
diff
changeset
|
2057 (setq tail state-alist) |
651d521c8f52
(quail-install-map): New optional arg
Kenichi Handa <handa@m17n.org>
parents:
24821
diff
changeset
|
2058 (while tail |
651d521c8f52
(quail-install-map): New optional arg
Kenichi Handa <handa@m17n.org>
parents:
24821
diff
changeset
|
2059 (setq elt (car tail) tail (cdr tail)) |
651d521c8f52
(quail-install-map): New optional arg
Kenichi Handa <handa@m17n.org>
parents:
24821
diff
changeset
|
2060 (quail-map-from-table-2 state-alist elt)) |
651d521c8f52
(quail-install-map): New optional arg
Kenichi Handa <handa@m17n.org>
parents:
24821
diff
changeset
|
2061 |
651d521c8f52
(quail-install-map): New optional arg
Kenichi Handa <handa@m17n.org>
parents:
24821
diff
changeset
|
2062 ;; Return the Quail map for the initial state. |
651d521c8f52
(quail-install-map): New optional arg
Kenichi Handa <handa@m17n.org>
parents:
24821
diff
changeset
|
2063 (car state-alist))) |
651d521c8f52
(quail-install-map): New optional arg
Kenichi Handa <handa@m17n.org>
parents:
24821
diff
changeset
|
2064 |
651d521c8f52
(quail-install-map): New optional arg
Kenichi Handa <handa@m17n.org>
parents:
24821
diff
changeset
|
2065 ;; STATE-INFO has the form (STATE TRANSITION ...). Set key sequence |
651d521c8f52
(quail-install-map): New optional arg
Kenichi Handa <handa@m17n.org>
parents:
24821
diff
changeset
|
2066 ;; mapping rules in the element of STATE-ALIST that corresponds to |
651d521c8f52
(quail-install-map): New optional arg
Kenichi Handa <handa@m17n.org>
parents:
24821
diff
changeset
|
2067 ;; STATE according to TRANSITION ... |
651d521c8f52
(quail-install-map): New optional arg
Kenichi Handa <handa@m17n.org>
parents:
24821
diff
changeset
|
2068 (defun quail-map-from-table-1 (state-alist state-info) |
651d521c8f52
(quail-install-map): New optional arg
Kenichi Handa <handa@m17n.org>
parents:
24821
diff
changeset
|
2069 (let* ((state (car state-info)) |
651d521c8f52
(quail-install-map): New optional arg
Kenichi Handa <handa@m17n.org>
parents:
24821
diff
changeset
|
2070 (map (assq state state-alist)) |
651d521c8f52
(quail-install-map): New optional arg
Kenichi Handa <handa@m17n.org>
parents:
24821
diff
changeset
|
2071 (transitions (cdr state-info)) |
651d521c8f52
(quail-install-map): New optional arg
Kenichi Handa <handa@m17n.org>
parents:
24821
diff
changeset
|
2072 elt) |
651d521c8f52
(quail-install-map): New optional arg
Kenichi Handa <handa@m17n.org>
parents:
24821
diff
changeset
|
2073 (while transitions |
651d521c8f52
(quail-install-map): New optional arg
Kenichi Handa <handa@m17n.org>
parents:
24821
diff
changeset
|
2074 (setq elt (car transitions) transitions (cdr transitions)) |
651d521c8f52
(quail-install-map): New optional arg
Kenichi Handa <handa@m17n.org>
parents:
24821
diff
changeset
|
2075 (let (rules dst-state key trans) |
651d521c8f52
(quail-install-map): New optional arg
Kenichi Handa <handa@m17n.org>
parents:
24821
diff
changeset
|
2076 ;; ELT has the form (RULES-SYMBOL . STATE-x) or RULES-SYMBOL. |
651d521c8f52
(quail-install-map): New optional arg
Kenichi Handa <handa@m17n.org>
parents:
24821
diff
changeset
|
2077 ;; STATE-x is one of car parts of STATE-ALIST's elements. |
651d521c8f52
(quail-install-map): New optional arg
Kenichi Handa <handa@m17n.org>
parents:
24821
diff
changeset
|
2078 (if (consp elt) |
651d521c8f52
(quail-install-map): New optional arg
Kenichi Handa <handa@m17n.org>
parents:
24821
diff
changeset
|
2079 (setq rules (symbol-value (car elt)) |
651d521c8f52
(quail-install-map): New optional arg
Kenichi Handa <handa@m17n.org>
parents:
24821
diff
changeset
|
2080 ;; Set (STATE-x) as branches for all keys in RULES. |
651d521c8f52
(quail-install-map): New optional arg
Kenichi Handa <handa@m17n.org>
parents:
24821
diff
changeset
|
2081 ;; It is replaced with actual branches for STATE-x |
651d521c8f52
(quail-install-map): New optional arg
Kenichi Handa <handa@m17n.org>
parents:
24821
diff
changeset
|
2082 ;; later in `quail-map-from-table-2'. |
651d521c8f52
(quail-install-map): New optional arg
Kenichi Handa <handa@m17n.org>
parents:
24821
diff
changeset
|
2083 dst-state (list (cdr elt))) |
651d521c8f52
(quail-install-map): New optional arg
Kenichi Handa <handa@m17n.org>
parents:
24821
diff
changeset
|
2084 (setq rules (symbol-value elt))) |
651d521c8f52
(quail-install-map): New optional arg
Kenichi Handa <handa@m17n.org>
parents:
24821
diff
changeset
|
2085 (while rules |
651d521c8f52
(quail-install-map): New optional arg
Kenichi Handa <handa@m17n.org>
parents:
24821
diff
changeset
|
2086 (setq key (car (car rules)) trans (cdr (car rules)) |
651d521c8f52
(quail-install-map): New optional arg
Kenichi Handa <handa@m17n.org>
parents:
24821
diff
changeset
|
2087 rules (cdr rules)) |
651d521c8f52
(quail-install-map): New optional arg
Kenichi Handa <handa@m17n.org>
parents:
24821
diff
changeset
|
2088 (if (stringp trans) |
651d521c8f52
(quail-install-map): New optional arg
Kenichi Handa <handa@m17n.org>
parents:
24821
diff
changeset
|
2089 (if (= (length trans) 1) |
651d521c8f52
(quail-install-map): New optional arg
Kenichi Handa <handa@m17n.org>
parents:
24821
diff
changeset
|
2090 (setq trans (aref trans 0)) |
651d521c8f52
(quail-install-map): New optional arg
Kenichi Handa <handa@m17n.org>
parents:
24821
diff
changeset
|
2091 (setq trans (string-to-vector trans)))) |
651d521c8f52
(quail-install-map): New optional arg
Kenichi Handa <handa@m17n.org>
parents:
24821
diff
changeset
|
2092 (set-nested-alist key trans map nil dst-state)))))) |
651d521c8f52
(quail-install-map): New optional arg
Kenichi Handa <handa@m17n.org>
parents:
24821
diff
changeset
|
2093 |
651d521c8f52
(quail-install-map): New optional arg
Kenichi Handa <handa@m17n.org>
parents:
24821
diff
changeset
|
2094 ;; ELEMENT is one element of STATE-ALIST. ELEMENT is a nested alist; |
651d521c8f52
(quail-install-map): New optional arg
Kenichi Handa <handa@m17n.org>
parents:
24821
diff
changeset
|
2095 ;; the form is: |
651d521c8f52
(quail-install-map): New optional arg
Kenichi Handa <handa@m17n.org>
parents:
24821
diff
changeset
|
2096 ;; (STATE (CHAR NESTED-ALIST) ...) |
651d521c8f52
(quail-install-map): New optional arg
Kenichi Handa <handa@m17n.org>
parents:
24821
diff
changeset
|
2097 ;; NESTED-ALIST is a nested alist; the form is: |
651d521c8f52
(quail-install-map): New optional arg
Kenichi Handa <handa@m17n.org>
parents:
24821
diff
changeset
|
2098 ;; (TRANS (CHAR NESTED-ALIST) ...) |
651d521c8f52
(quail-install-map): New optional arg
Kenichi Handa <handa@m17n.org>
parents:
24821
diff
changeset
|
2099 ;; or |
651d521c8f52
(quail-install-map): New optional arg
Kenichi Handa <handa@m17n.org>
parents:
24821
diff
changeset
|
2100 ;; (TRANS (CHAR NESTED-ALIST) ... . (STATE-x)) |
651d521c8f52
(quail-install-map): New optional arg
Kenichi Handa <handa@m17n.org>
parents:
24821
diff
changeset
|
2101 ;; Here, the task is to replace all occurrences of (STATE-x) with: |
651d521c8f52
(quail-install-map): New optional arg
Kenichi Handa <handa@m17n.org>
parents:
24821
diff
changeset
|
2102 ;; (cdr (assq STATE-x STATE-ALIST)) |
651d521c8f52
(quail-install-map): New optional arg
Kenichi Handa <handa@m17n.org>
parents:
24821
diff
changeset
|
2103 |
651d521c8f52
(quail-install-map): New optional arg
Kenichi Handa <handa@m17n.org>
parents:
24821
diff
changeset
|
2104 (defun quail-map-from-table-2 (state-alist element) |
651d521c8f52
(quail-install-map): New optional arg
Kenichi Handa <handa@m17n.org>
parents:
24821
diff
changeset
|
2105 (let ((prev element) |
651d521c8f52
(quail-install-map): New optional arg
Kenichi Handa <handa@m17n.org>
parents:
24821
diff
changeset
|
2106 (tail (cdr element)) |
651d521c8f52
(quail-install-map): New optional arg
Kenichi Handa <handa@m17n.org>
parents:
24821
diff
changeset
|
2107 elt) |
651d521c8f52
(quail-install-map): New optional arg
Kenichi Handa <handa@m17n.org>
parents:
24821
diff
changeset
|
2108 (while (cdr tail) |
651d521c8f52
(quail-install-map): New optional arg
Kenichi Handa <handa@m17n.org>
parents:
24821
diff
changeset
|
2109 (setq elt (car tail) prev tail tail (cdr tail)) |
651d521c8f52
(quail-install-map): New optional arg
Kenichi Handa <handa@m17n.org>
parents:
24821
diff
changeset
|
2110 (quail-map-from-table-2 state-alist (cdr elt))) |
651d521c8f52
(quail-install-map): New optional arg
Kenichi Handa <handa@m17n.org>
parents:
24821
diff
changeset
|
2111 (setq elt (car tail)) |
651d521c8f52
(quail-install-map): New optional arg
Kenichi Handa <handa@m17n.org>
parents:
24821
diff
changeset
|
2112 (if (consp elt) |
651d521c8f52
(quail-install-map): New optional arg
Kenichi Handa <handa@m17n.org>
parents:
24821
diff
changeset
|
2113 (quail-map-from-table-2 state-alist (cdr elt)) |
651d521c8f52
(quail-install-map): New optional arg
Kenichi Handa <handa@m17n.org>
parents:
24821
diff
changeset
|
2114 (setcdr prev (cdr (assq elt state-alist)))))) |
651d521c8f52
(quail-install-map): New optional arg
Kenichi Handa <handa@m17n.org>
parents:
24821
diff
changeset
|
2115 |
651d521c8f52
(quail-install-map): New optional arg
Kenichi Handa <handa@m17n.org>
parents:
24821
diff
changeset
|
2116 ;; Concatenate translations for all heading substrings of KEY in the |
651d521c8f52
(quail-install-map): New optional arg
Kenichi Handa <handa@m17n.org>
parents:
24821
diff
changeset
|
2117 ;; current Quail map. Here, `heading substring' means (substring KEY |
651d521c8f52
(quail-install-map): New optional arg
Kenichi Handa <handa@m17n.org>
parents:
24821
diff
changeset
|
2118 ;; 0 LEN), where LEN is 1, 2, ... (length KEY). |
651d521c8f52
(quail-install-map): New optional arg
Kenichi Handa <handa@m17n.org>
parents:
24821
diff
changeset
|
2119 (defun quail-lookup-map-and-concat (key) |
651d521c8f52
(quail-install-map): New optional arg
Kenichi Handa <handa@m17n.org>
parents:
24821
diff
changeset
|
2120 (let* ((len (length key)) |
651d521c8f52
(quail-install-map): New optional arg
Kenichi Handa <handa@m17n.org>
parents:
24821
diff
changeset
|
2121 (translation-list nil) |
651d521c8f52
(quail-install-map): New optional arg
Kenichi Handa <handa@m17n.org>
parents:
24821
diff
changeset
|
2122 map) |
651d521c8f52
(quail-install-map): New optional arg
Kenichi Handa <handa@m17n.org>
parents:
24821
diff
changeset
|
2123 (while (> len 0) |
651d521c8f52
(quail-install-map): New optional arg
Kenichi Handa <handa@m17n.org>
parents:
24821
diff
changeset
|
2124 (setq map (quail-lookup-key key len) |
651d521c8f52
(quail-install-map): New optional arg
Kenichi Handa <handa@m17n.org>
parents:
24821
diff
changeset
|
2125 len (1- len)) |
651d521c8f52
(quail-install-map): New optional arg
Kenichi Handa <handa@m17n.org>
parents:
24821
diff
changeset
|
2126 (if map |
651d521c8f52
(quail-install-map): New optional arg
Kenichi Handa <handa@m17n.org>
parents:
24821
diff
changeset
|
2127 (let* ((def (quail-map-definition map)) |
651d521c8f52
(quail-install-map): New optional arg
Kenichi Handa <handa@m17n.org>
parents:
24821
diff
changeset
|
2128 (trans (if (consp def) (aref (cdr def) (car (car def))) |
651d521c8f52
(quail-install-map): New optional arg
Kenichi Handa <handa@m17n.org>
parents:
24821
diff
changeset
|
2129 def))) |
651d521c8f52
(quail-install-map): New optional arg
Kenichi Handa <handa@m17n.org>
parents:
24821
diff
changeset
|
2130 (if (integerp trans) |
651d521c8f52
(quail-install-map): New optional arg
Kenichi Handa <handa@m17n.org>
parents:
24821
diff
changeset
|
2131 (setq trans (char-to-string trans))) |
651d521c8f52
(quail-install-map): New optional arg
Kenichi Handa <handa@m17n.org>
parents:
24821
diff
changeset
|
2132 (setq translation-list (cons trans translation-list))))) |
651d521c8f52
(quail-install-map): New optional arg
Kenichi Handa <handa@m17n.org>
parents:
24821
diff
changeset
|
2133 (apply 'concat translation-list))) |
17052 | 2134 |
18297
5c8e37591da5
(quail-current-data): New variable.
Kenichi Handa <handa@m17n.org>
parents:
18201
diff
changeset
|
2135 |
5c8e37591da5
(quail-current-data): New variable.
Kenichi Handa <handa@m17n.org>
parents:
18201
diff
changeset
|
2136 (defvar quail-directory-name "quail" |
23176 | 2137 "Name of Quail directory which contains Quail packages. |
18297
5c8e37591da5
(quail-current-data): New variable.
Kenichi Handa <handa@m17n.org>
parents:
18201
diff
changeset
|
2138 This is a sub-directory of LEIM directory.") |
5c8e37591da5
(quail-current-data): New variable.
Kenichi Handa <handa@m17n.org>
parents:
18201
diff
changeset
|
2139 |
5c8e37591da5
(quail-current-data): New variable.
Kenichi Handa <handa@m17n.org>
parents:
18201
diff
changeset
|
2140 ;;;###autoload |
19605
3b700b203cfd
(quail-update-leim-list-file): Make it
Kenichi Handa <handa@m17n.org>
parents:
19519
diff
changeset
|
2141 (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
|
2142 "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
|
2143 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
|
2144 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
|
2145 of the Emacs source tree. |
3b700b203cfd
(quail-update-leim-list-file): Make it
Kenichi Handa <handa@m17n.org>
parents:
19519
diff
changeset
|
2146 |
3b700b203cfd
(quail-update-leim-list-file): Make it
Kenichi Handa <handa@m17n.org>
parents:
19519
diff
changeset
|
2147 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
|
2148 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
|
2149 |
3b700b203cfd
(quail-update-leim-list-file): Make it
Kenichi Handa <handa@m17n.org>
parents:
19519
diff
changeset
|
2150 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
|
2151 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
|
2152 of each directory." |
18297
5c8e37591da5
(quail-current-data): New variable.
Kenichi Handa <handa@m17n.org>
parents:
18201
diff
changeset
|
2153 (interactive "FDirectory of LEIM: ") |
19605
3b700b203cfd
(quail-update-leim-list-file): Make it
Kenichi Handa <handa@m17n.org>
parents:
19519
diff
changeset
|
2154 (setq dirname (expand-file-name dirname)) |
3b700b203cfd
(quail-update-leim-list-file): Make it
Kenichi Handa <handa@m17n.org>
parents:
19519
diff
changeset
|
2155 (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
|
2156 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
|
2157 (if (not (file-writable-p leim-list)) |
3b700b203cfd
(quail-update-leim-list-file): Make it
Kenichi Handa <handa@m17n.org>
parents:
19519
diff
changeset
|
2158 (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
|
2159 (message "Updating %s ..." leim-list) |
3b700b203cfd
(quail-update-leim-list-file): Make it
Kenichi Handa <handa@m17n.org>
parents:
19519
diff
changeset
|
2160 (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
|
2161 |
3b700b203cfd
(quail-update-leim-list-file): Make it
Kenichi Handa <handa@m17n.org>
parents:
19519
diff
changeset
|
2162 ;; At first, clean up the file. |
3b700b203cfd
(quail-update-leim-list-file): Make it
Kenichi Handa <handa@m17n.org>
parents:
19519
diff
changeset
|
2163 (save-excursion |
3b700b203cfd
(quail-update-leim-list-file): Make it
Kenichi Handa <handa@m17n.org>
parents:
19519
diff
changeset
|
2164 (set-buffer list-buf) |
3b700b203cfd
(quail-update-leim-list-file): Make it
Kenichi Handa <handa@m17n.org>
parents:
19519
diff
changeset
|
2165 (goto-char 1) |
18297
5c8e37591da5
(quail-current-data): New variable.
Kenichi Handa <handa@m17n.org>
parents:
18201
diff
changeset
|
2166 |
19605
3b700b203cfd
(quail-update-leim-list-file): Make it
Kenichi Handa <handa@m17n.org>
parents:
19519
diff
changeset
|
2167 ;; Insert the correct header. |
3b700b203cfd
(quail-update-leim-list-file): Make it
Kenichi Handa <handa@m17n.org>
parents:
19519
diff
changeset
|
2168 (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
|
2169 (goto-char (match-end 0)) |
3b700b203cfd
(quail-update-leim-list-file): Make it
Kenichi Handa <handa@m17n.org>
parents:
19519
diff
changeset
|
2170 (insert leim-list-header)) |
3b700b203cfd
(quail-update-leim-list-file): Make it
Kenichi Handa <handa@m17n.org>
parents:
19519
diff
changeset
|
2171 (setq pos (point)) |
3b700b203cfd
(quail-update-leim-list-file): Make it
Kenichi Handa <handa@m17n.org>
parents:
19519
diff
changeset
|
2172 (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
|
2173 nil |
3b700b203cfd
(quail-update-leim-list-file): Make it
Kenichi Handa <handa@m17n.org>
parents:
19519
diff
changeset
|
2174 |
3b700b203cfd
(quail-update-leim-list-file): Make it
Kenichi Handa <handa@m17n.org>
parents:
19519
diff
changeset
|
2175 ;; Remove garbages after the header. |
3b700b203cfd
(quail-update-leim-list-file): Make it
Kenichi Handa <handa@m17n.org>
parents:
19519
diff
changeset
|
2176 (goto-char (match-beginning 0)) |
3b700b203cfd
(quail-update-leim-list-file): Make it
Kenichi Handa <handa@m17n.org>
parents:
19519
diff
changeset
|
2177 (if (< pos (point)) |
3b700b203cfd
(quail-update-leim-list-file): Make it
Kenichi Handa <handa@m17n.org>
parents:
19519
diff
changeset
|
2178 (delete-region pos (point))) |
18297
5c8e37591da5
(quail-current-data): New variable.
Kenichi Handa <handa@m17n.org>
parents:
18201
diff
changeset
|
2179 |
19605
3b700b203cfd
(quail-update-leim-list-file): Make it
Kenichi Handa <handa@m17n.org>
parents:
19519
diff
changeset
|
2180 ;; Remove all entries for Quail. |
3b700b203cfd
(quail-update-leim-list-file): Make it
Kenichi Handa <handa@m17n.org>
parents:
19519
diff
changeset
|
2181 (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
|
2182 (goto-char (match-beginning 0)) |
3b700b203cfd
(quail-update-leim-list-file): Make it
Kenichi Handa <handa@m17n.org>
parents:
19519
diff
changeset
|
2183 (setq pos (point)) |
3b700b203cfd
(quail-update-leim-list-file): Make it
Kenichi Handa <handa@m17n.org>
parents:
19519
diff
changeset
|
2184 (condition-case nil |
3b700b203cfd
(quail-update-leim-list-file): Make it
Kenichi Handa <handa@m17n.org>
parents:
19519
diff
changeset
|
2185 (let ((form (read list-buf))) |
3b700b203cfd
(quail-update-leim-list-file): Make it
Kenichi Handa <handa@m17n.org>
parents:
19519
diff
changeset
|
2186 (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
|
2187 (if (eolp) (forward-line 1)) |
3b700b203cfd
(quail-update-leim-list-file): Make it
Kenichi Handa <handa@m17n.org>
parents:
19519
diff
changeset
|
2188 (delete-region pos (point)))) |
3b700b203cfd
(quail-update-leim-list-file): Make it
Kenichi Handa <handa@m17n.org>
parents:
19519
diff
changeset
|
2189 (error |
3b700b203cfd
(quail-update-leim-list-file): Make it
Kenichi Handa <handa@m17n.org>
parents:
19519
diff
changeset
|
2190 ;; 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
|
2191 ;; this file is broken. |
23014
ddc2fa7883d6
(quail-update-leim-list-file): Fix message syntax.
Richard M. Stallman <rms@gnu.org>
parents:
22984
diff
changeset
|
2192 (message "Garbage in %s deleted" leim-list) |
19605
3b700b203cfd
(quail-update-leim-list-file): Make it
Kenichi Handa <handa@m17n.org>
parents:
19519
diff
changeset
|
2193 (delete-region pos (point-max))))))) |
18297
5c8e37591da5
(quail-current-data): New variable.
Kenichi Handa <handa@m17n.org>
parents:
18201
diff
changeset
|
2194 |
23176 | 2195 ;; Search for `quail' subdirectory under each DIRNAMES. |
19605
3b700b203cfd
(quail-update-leim-list-file): Make it
Kenichi Handa <handa@m17n.org>
parents:
19519
diff
changeset
|
2196 (setq dirnames (cons dirname dirnames)) |
3b700b203cfd
(quail-update-leim-list-file): Make it
Kenichi Handa <handa@m17n.org>
parents:
19519
diff
changeset
|
2197 (let ((l dirnames)) |
3b700b203cfd
(quail-update-leim-list-file): Make it
Kenichi Handa <handa@m17n.org>
parents:
19519
diff
changeset
|
2198 (while l |
3b700b203cfd
(quail-update-leim-list-file): Make it
Kenichi Handa <handa@m17n.org>
parents:
19519
diff
changeset
|
2199 (setcar l (expand-file-name (car l))) |
3b700b203cfd
(quail-update-leim-list-file): Make it
Kenichi Handa <handa@m17n.org>
parents:
19519
diff
changeset
|
2200 (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
|
2201 (if (file-readable-p dirname) |
3b700b203cfd
(quail-update-leim-list-file): Make it
Kenichi Handa <handa@m17n.org>
parents:
19519
diff
changeset
|
2202 (setq quail-dirs (cons dirname quail-dirs)) |
23014
ddc2fa7883d6
(quail-update-leim-list-file): Fix message syntax.
Richard M. Stallman <rms@gnu.org>
parents:
22984
diff
changeset
|
2203 (message "%s doesn't have `%s' subdirectory, just ignored" |
19605
3b700b203cfd
(quail-update-leim-list-file): Make it
Kenichi Handa <handa@m17n.org>
parents:
19519
diff
changeset
|
2204 (car l) quail-directory-name) |
3b700b203cfd
(quail-update-leim-list-file): Make it
Kenichi Handa <handa@m17n.org>
parents:
19519
diff
changeset
|
2205 (setq quail-dirs (cons nil quail-dirs))) |
3b700b203cfd
(quail-update-leim-list-file): Make it
Kenichi Handa <handa@m17n.org>
parents:
19519
diff
changeset
|
2206 (setq l (cdr l))) |
3b700b203cfd
(quail-update-leim-list-file): Make it
Kenichi Handa <handa@m17n.org>
parents:
19519
diff
changeset
|
2207 (setq quail-dirs (nreverse quail-dirs))) |
18297
5c8e37591da5
(quail-current-data): New variable.
Kenichi Handa <handa@m17n.org>
parents:
18201
diff
changeset
|
2208 |
19605
3b700b203cfd
(quail-update-leim-list-file): Make it
Kenichi Handa <handa@m17n.org>
parents:
19519
diff
changeset
|
2209 ;; Insert input method registering forms. |
3b700b203cfd
(quail-update-leim-list-file): Make it
Kenichi Handa <handa@m17n.org>
parents:
19519
diff
changeset
|
2210 (while quail-dirs |
3b700b203cfd
(quail-update-leim-list-file): Make it
Kenichi Handa <handa@m17n.org>
parents:
19519
diff
changeset
|
2211 (setq dirname (car quail-dirs)) |
3b700b203cfd
(quail-update-leim-list-file): Make it
Kenichi Handa <handa@m17n.org>
parents:
19519
diff
changeset
|
2212 (when dirname |
3b700b203cfd
(quail-update-leim-list-file): Make it
Kenichi Handa <handa@m17n.org>
parents:
19519
diff
changeset
|
2213 (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
|
2214 (while pkg-list |
3b700b203cfd
(quail-update-leim-list-file): Make it
Kenichi Handa <handa@m17n.org>
parents:
19519
diff
changeset
|
2215 (message "Checking %s ..." (car pkg-list)) |
3b700b203cfd
(quail-update-leim-list-file): Make it
Kenichi Handa <handa@m17n.org>
parents:
19519
diff
changeset
|
2216 (with-temp-buffer |
3b700b203cfd
(quail-update-leim-list-file): Make it
Kenichi Handa <handa@m17n.org>
parents:
19519
diff
changeset
|
2217 (insert-file-contents (car pkg-list)) |
3b700b203cfd
(quail-update-leim-list-file): Make it
Kenichi Handa <handa@m17n.org>
parents:
19519
diff
changeset
|
2218 (goto-char (point-min)) |
3b700b203cfd
(quail-update-leim-list-file): Make it
Kenichi Handa <handa@m17n.org>
parents:
19519
diff
changeset
|
2219 (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
|
2220 (goto-char (match-beginning 0)) |
3b700b203cfd
(quail-update-leim-list-file): Make it
Kenichi Handa <handa@m17n.org>
parents:
19519
diff
changeset
|
2221 (condition-case nil |
3b700b203cfd
(quail-update-leim-list-file): Make it
Kenichi Handa <handa@m17n.org>
parents:
19519
diff
changeset
|
2222 (let ((form (read (current-buffer)))) |
3b700b203cfd
(quail-update-leim-list-file): Make it
Kenichi Handa <handa@m17n.org>
parents:
19519
diff
changeset
|
2223 (save-excursion |
3b700b203cfd
(quail-update-leim-list-file): Make it
Kenichi Handa <handa@m17n.org>
parents:
19519
diff
changeset
|
2224 (set-buffer list-buf) |
3b700b203cfd
(quail-update-leim-list-file): Make it
Kenichi Handa <handa@m17n.org>
parents:
19519
diff
changeset
|
2225 (insert |
3b700b203cfd
(quail-update-leim-list-file): Make it
Kenichi Handa <handa@m17n.org>
parents:
19519
diff
changeset
|
2226 (format "(register-input-method |
18297
5c8e37591da5
(quail-current-data): New variable.
Kenichi Handa <handa@m17n.org>
parents:
18201
diff
changeset
|
2227 %S %S '%s |
5c8e37591da5
(quail-current-data): New variable.
Kenichi Handa <handa@m17n.org>
parents:
18201
diff
changeset
|
2228 %S %S |
19200
74ec766c0ada
(quail-update-leim-list-file):
Richard M. Stallman <rms@gnu.org>
parents:
19144
diff
changeset
|
2229 %S)\n" |
19605
3b700b203cfd
(quail-update-leim-list-file): Make it
Kenichi Handa <handa@m17n.org>
parents:
19519
diff
changeset
|
2230 (nth 1 form) ; PACKAGE-NAME |
3b700b203cfd
(quail-update-leim-list-file): Make it
Kenichi Handa <handa@m17n.org>
parents:
19519
diff
changeset
|
2231 (nth 2 form) ; LANGUAGE |
3b700b203cfd
(quail-update-leim-list-file): Make it
Kenichi Handa <handa@m17n.org>
parents:
19519
diff
changeset
|
2232 'quail-use-package ; ACTIVATE-FUNC |
3b700b203cfd
(quail-update-leim-list-file): Make it
Kenichi Handa <handa@m17n.org>
parents:
19519
diff
changeset
|
2233 (nth 3 form) ; PACKAGE-TITLE |
3b700b203cfd
(quail-update-leim-list-file): Make it
Kenichi Handa <handa@m17n.org>
parents:
19519
diff
changeset
|
2234 (progn ; PACKAGE-DESCRIPTION (one line) |
3b700b203cfd
(quail-update-leim-list-file): Make it
Kenichi Handa <handa@m17n.org>
parents:
19519
diff
changeset
|
2235 (string-match ".*" (nth 5 form)) |
3b700b203cfd
(quail-update-leim-list-file): Make it
Kenichi Handa <handa@m17n.org>
parents:
19519
diff
changeset
|
2236 (match-string 0 (nth 5 form))) |
3b700b203cfd
(quail-update-leim-list-file): Make it
Kenichi Handa <handa@m17n.org>
parents:
19519
diff
changeset
|
2237 (file-relative-name ; PACKAGE-FILENAME |
3b700b203cfd
(quail-update-leim-list-file): Make it
Kenichi Handa <handa@m17n.org>
parents:
19519
diff
changeset
|
2238 (file-name-sans-extension (car pkg-list)) |
3b700b203cfd
(quail-update-leim-list-file): Make it
Kenichi Handa <handa@m17n.org>
parents:
19519
diff
changeset
|
2239 (car dirnames)))))) |
3b700b203cfd
(quail-update-leim-list-file): Make it
Kenichi Handa <handa@m17n.org>
parents:
19519
diff
changeset
|
2240 (error |
3b700b203cfd
(quail-update-leim-list-file): Make it
Kenichi Handa <handa@m17n.org>
parents:
19519
diff
changeset
|
2241 ;; Ignore the remaining contents of this file. |
3b700b203cfd
(quail-update-leim-list-file): Make it
Kenichi Handa <handa@m17n.org>
parents:
19519
diff
changeset
|
2242 (goto-char (point-max)) |
3b700b203cfd
(quail-update-leim-list-file): Make it
Kenichi Handa <handa@m17n.org>
parents:
19519
diff
changeset
|
2243 (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
|
2244 (setq pkg-list (cdr pkg-list))) |
3b700b203cfd
(quail-update-leim-list-file): Make it
Kenichi Handa <handa@m17n.org>
parents:
19519
diff
changeset
|
2245 (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
|
2246 |
3b700b203cfd
(quail-update-leim-list-file): Make it
Kenichi Handa <handa@m17n.org>
parents:
19519
diff
changeset
|
2247 ;; At last, write out LEIM list file. |
3b700b203cfd
(quail-update-leim-list-file): Make it
Kenichi Handa <handa@m17n.org>
parents:
19519
diff
changeset
|
2248 (save-excursion |
3b700b203cfd
(quail-update-leim-list-file): Make it
Kenichi Handa <handa@m17n.org>
parents:
19519
diff
changeset
|
2249 (set-buffer list-buf) |
3b700b203cfd
(quail-update-leim-list-file): Make it
Kenichi Handa <handa@m17n.org>
parents:
19519
diff
changeset
|
2250 (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
|
2251 (save-buffer 0)) |
3b700b203cfd
(quail-update-leim-list-file): Make it
Kenichi Handa <handa@m17n.org>
parents:
19519
diff
changeset
|
2252 (kill-buffer list-buf) |
3b700b203cfd
(quail-update-leim-list-file): Make it
Kenichi Handa <handa@m17n.org>
parents:
19519
diff
changeset
|
2253 (message "Updating %s ... done" leim-list))) |
17052 | 2254 ;; |
2255 (provide 'quail) | |
2256 | |
2257 ;;; quail.el ends here |