Mercurial > emacs
annotate lisp/international/quail.el @ 34715:fc3693bea815
(direct_output_for_insert): Fix check for mini-window
currently displaying a message.
author | Gerd Moellmann <gerd@gnu.org> |
---|---|
date | Tue, 19 Dec 2000 13:37:19 +0000 |
parents | 1afa708b89ea |
children | 30f56d213a09 |
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 | |
31424 | 46 (defgroup quail nil |
47 "Quail: multilingual input method." | |
48 :group 'leim) | |
17052 | 49 |
50 ;; Buffer local variables | |
51 | |
52 (defvar quail-current-package nil | |
19391
763bc03e7797
(quail-guidance-buf): Now a permanent local.
Richard M. Stallman <rms@gnu.org>
parents:
19327
diff
changeset
|
53 "The current Quail package, which depends on the current input method. |
17052 | 54 See the documentation of `quail-package-alist' for the format.") |
55 (make-variable-buffer-local 'quail-current-package) | |
56 (put 'quail-current-package 'permanent-local t) | |
57 | |
58 ;; Quail uses the following two buffers to assist users. | |
59 ;; A buffer to show available key sequence or translation list. | |
60 (defvar quail-guidance-buf nil) | |
61 ;; A buffer to show completion list of the current key sequence. | |
62 (defvar quail-completion-buf nil) | |
63 | |
18556
99e8ae18137f
(quail-guidance-buf): Make it buffer
Kenichi Handa <handa@m17n.org>
parents:
18377
diff
changeset
|
64 ;; 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
|
65 ;; guidance buffers. |
99e8ae18137f
(quail-guidance-buf): Make it buffer
Kenichi Handa <handa@m17n.org>
parents:
18377
diff
changeset
|
66 (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
|
67 (put 'quail-guidance-buf 'permanent-local t) |
18556
99e8ae18137f
(quail-guidance-buf): Make it buffer
Kenichi Handa <handa@m17n.org>
parents:
18377
diff
changeset
|
68 |
99e8ae18137f
(quail-guidance-buf): Make it buffer
Kenichi Handa <handa@m17n.org>
parents:
18377
diff
changeset
|
69 ;; A main window showing Quail guidance buffer. |
99e8ae18137f
(quail-guidance-buf): Make it buffer
Kenichi Handa <handa@m17n.org>
parents:
18377
diff
changeset
|
70 (defvar quail-guidance-win nil) |
99e8ae18137f
(quail-guidance-buf): Make it buffer
Kenichi Handa <handa@m17n.org>
parents:
18377
diff
changeset
|
71 (make-variable-buffer-local 'quail-guidance-win) |
99e8ae18137f
(quail-guidance-buf): Make it buffer
Kenichi Handa <handa@m17n.org>
parents:
18377
diff
changeset
|
72 |
17052 | 73 (defvar quail-overlay nil |
74 "Overlay which covers the current translation region of Quail.") | |
75 (make-variable-buffer-local 'quail-overlay) | |
76 | |
77 (defvar quail-conv-overlay nil | |
78 "Overlay which covers the text to be converted in Quail mode.") | |
79 (make-variable-buffer-local 'quail-conv-overlay) | |
80 | |
81 (defvar quail-current-key nil | |
82 "Current key for translation in Quail mode.") | |
22765
7cf2c3800e8f
(quail-mode): This variable deleted.
Kenichi Handa <handa@m17n.org>
parents:
22124
diff
changeset
|
83 (make-variable-buffer-local 'quail-current-key) |
17052 | 84 |
85 (defvar quail-current-str nil | |
86 "Currently selected translation of the current key.") | |
22765
7cf2c3800e8f
(quail-mode): This variable deleted.
Kenichi Handa <handa@m17n.org>
parents:
22124
diff
changeset
|
87 (make-variable-buffer-local 'quail-current-str) |
17052 | 88 |
89 (defvar quail-current-translations nil | |
18556
99e8ae18137f
(quail-guidance-buf): Make it buffer
Kenichi Handa <handa@m17n.org>
parents:
18377
diff
changeset
|
90 "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
|
91 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
|
92 CURRENT is an index of the current translation, |
99e8ae18137f
(quail-guidance-buf): Make it buffer
Kenichi Handa <handa@m17n.org>
parents:
18377
diff
changeset
|
93 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
|
94 BLOCK is the current block index, |
99e8ae18137f
(quail-guidance-buf): Make it buffer
Kenichi Handa <handa@m17n.org>
parents:
18377
diff
changeset
|
95 BLOCKS is a number of blocks of translation.") |
22765
7cf2c3800e8f
(quail-mode): This variable deleted.
Kenichi Handa <handa@m17n.org>
parents:
22124
diff
changeset
|
96 (make-variable-buffer-local 'quail-current-translations) |
17052 | 97 |
18297
5c8e37591da5
(quail-current-data): New variable.
Kenichi Handa <handa@m17n.org>
parents:
18201
diff
changeset
|
98 (defvar quail-current-data nil |
5c8e37591da5
(quail-current-data): New variable.
Kenichi Handa <handa@m17n.org>
parents:
18201
diff
changeset
|
99 "Any Lisp object holding information of current translation status. |
5c8e37591da5
(quail-current-data): New variable.
Kenichi Handa <handa@m17n.org>
parents:
18201
diff
changeset
|
100 When a key sequence is mapped to TRANS and TRANS is a cons |
23176 | 101 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
|
102 for translating the longer key sequence, this variable is set |
5c8e37591da5
(quail-current-data): New variable.
Kenichi Handa <handa@m17n.org>
parents:
18201
diff
changeset
|
103 to that Lisp object.") |
18556
99e8ae18137f
(quail-guidance-buf): Make it buffer
Kenichi Handa <handa@m17n.org>
parents:
18377
diff
changeset
|
104 (make-variable-buffer-local 'quail-current-data) |
18297
5c8e37591da5
(quail-current-data): New variable.
Kenichi Handa <handa@m17n.org>
parents:
18201
diff
changeset
|
105 |
17052 | 106 ;; Quail package handlers. |
107 | |
108 (defvar quail-package-alist nil | |
109 "List of Quail packages. | |
110 A Quail package is a list of these elements: | |
111 NAME, TITLE, QUAIL-MAP, GUIDANCE, DOCSTRING, TRANSLATION-KEYS, | |
112 FORGET-LAST-SELECTION, DETERMINISTIC, KBD-TRANSLATE, SHOW-LAYOUT, | |
113 DECODE-MAP, MAXIMUM-SHORTEST, OVERLAY-PLIST, UPDATE-TRANSLATION-FUNCTION, | |
19849
1c5164d81426
(quail-simple): New function.
Kenichi Handa <handa@m17n.org>
parents:
19844
diff
changeset
|
114 CONVERSION-KEYS, SIMPLE. |
17052 | 115 |
116 QUAIL-MAP is a data structure to map key strings to translations. For | |
117 the format, see the documentation of `quail-map-p'. | |
118 | |
119 DECODE-MAP is an alist of translations and corresponding keys. | |
120 | |
121 See the documentation of `quail-define-package' for the other elements.") | |
122 | |
123 ;; Return various slots in the current quail-package. | |
124 | |
125 (defsubst quail-name () | |
126 "Return the name of the current Quail package." | |
127 (nth 0 quail-current-package)) | |
128 (defsubst quail-title () | |
129 "Return the title of the current Quail package." | |
130 (nth 1 quail-current-package)) | |
131 (defsubst quail-map () | |
132 "Return the translation map of the current Quail package." | |
133 (nth 2 quail-current-package)) | |
134 (defsubst quail-guidance () | |
135 "Return an object used for `guidance' feature of the current Quail package. | |
136 See also the documentation of `quail-define-package'." | |
137 (nth 3 quail-current-package)) | |
138 (defsubst quail-docstring () | |
139 "Return the documentation string of the current Quail package." | |
140 (nth 4 quail-current-package)) | |
141 (defsubst quail-translation-keymap () | |
142 "Return translation keymap in the current Quail package. | |
143 Translation keymap is a keymap used while translation region is active." | |
144 (nth 5 quail-current-package)) | |
145 (defsubst quail-forget-last-selection () | |
146 "Return `forget-last-selection' flag of the current Quail package. | |
147 See also the documentation of `quail-define-package'." | |
148 (nth 6 quail-current-package)) | |
149 (defsubst quail-deterministic () | |
150 "Return `deterministic' flag of the current Quail package. | |
151 See also the documentation of `quail-define-package'." | |
152 (nth 7 quail-current-package)) | |
153 (defsubst quail-kbd-translate () | |
154 "Return `kbd-translate' flag of the current Quail package. | |
155 See also the documentation of `quail-define-package'." | |
156 (nth 8 quail-current-package)) | |
157 (defsubst quail-show-layout () | |
158 "Return `show-layout' flag of the current Quail package. | |
159 See also the documentation of `quail-define-package'." | |
160 (nth 9 quail-current-package)) | |
161 (defsubst quail-decode-map () | |
162 "Return decode map of the current Quail package. | |
163 It is an alist of translations and corresponding keys." | |
164 (nth 10 quail-current-package)) | |
165 (defsubst quail-maximum-shortest () | |
166 "Return `maximum-shortest' flag of the current Quail package. | |
167 See also the documentation of `quail-define-package'." | |
168 (nth 11 quail-current-package)) | |
169 (defsubst quail-overlay-plist () | |
170 "Return property list of an overly used in the current Quail package." | |
171 (nth 12 quail-current-package)) | |
172 (defsubst quail-update-translation-function () | |
173 "Return a function for updating translation in the current Quail package." | |
174 (nth 13 quail-current-package)) | |
175 (defsubst quail-conversion-keymap () | |
176 "Return conversion keymap in the current Quail package. | |
177 Conversion keymap is a keymap used while conversion region is active | |
178 but translation region is not active." | |
179 (nth 14 quail-current-package)) | |
19849
1c5164d81426
(quail-simple): New function.
Kenichi Handa <handa@m17n.org>
parents:
19844
diff
changeset
|
180 (defsubst quail-simple () |
1c5164d81426
(quail-simple): New function.
Kenichi Handa <handa@m17n.org>
parents:
19844
diff
changeset
|
181 "Return t if the current Quail package is simple." |
1c5164d81426
(quail-simple): New function.
Kenichi Handa <handa@m17n.org>
parents:
19844
diff
changeset
|
182 (nth 15 quail-current-package)) |
17052 | 183 |
184 (defsubst quail-package (name) | |
185 "Return Quail package named NAME." | |
186 (assoc name quail-package-alist)) | |
187 | |
188 (defun quail-add-package (package) | |
189 "Add Quail package PACKAGE to `quail-package-alist'." | |
190 (let ((pac (quail-package (car package)))) | |
191 (if pac | |
192 (setcdr pac (cdr package)) | |
193 (setq quail-package-alist (cons package quail-package-alist))))) | |
194 | |
195 (defun quail-select-package (name) | |
196 "Select Quail package named NAME as the current Quail package." | |
197 (let ((package (quail-package name))) | |
198 (if (null package) | |
199 (error "No Quail package `%s'" name)) | |
200 (setq quail-current-package package) | |
201 (setq-default quail-current-package package) | |
202 name)) | |
203 | |
204 ;;;###autoload | |
205 (defun quail-use-package (package-name &rest libraries) | |
206 "Start using Quail package PACKAGE-NAME. | |
207 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
|
208 (let ((package (quail-package package-name))) |
5c8e37591da5
(quail-current-data): New variable.
Kenichi Handa <handa@m17n.org>
parents:
18201
diff
changeset
|
209 (if (null package) |
5c8e37591da5
(quail-current-data): New variable.
Kenichi Handa <handa@m17n.org>
parents:
18201
diff
changeset
|
210 ;; Perhaps we have not yet loaded necessary libraries. |
5c8e37591da5
(quail-current-data): New variable.
Kenichi Handa <handa@m17n.org>
parents:
18201
diff
changeset
|
211 (while libraries |
5c8e37591da5
(quail-current-data): New variable.
Kenichi Handa <handa@m17n.org>
parents:
18201
diff
changeset
|
212 (if (not (load (car libraries) t)) |
5c8e37591da5
(quail-current-data): New variable.
Kenichi Handa <handa@m17n.org>
parents:
18201
diff
changeset
|
213 (progn |
5c8e37591da5
(quail-current-data): New variable.
Kenichi Handa <handa@m17n.org>
parents:
18201
diff
changeset
|
214 (with-output-to-temp-buffer "*Help*" |
5c8e37591da5
(quail-current-data): New variable.
Kenichi Handa <handa@m17n.org>
parents:
18201
diff
changeset
|
215 (princ "Quail package \"") |
5c8e37591da5
(quail-current-data): New variable.
Kenichi Handa <handa@m17n.org>
parents:
18201
diff
changeset
|
216 (princ package-name) |
5c8e37591da5
(quail-current-data): New variable.
Kenichi Handa <handa@m17n.org>
parents:
18201
diff
changeset
|
217 (princ "\" can't be activated\n because library \"") |
5c8e37591da5
(quail-current-data): New variable.
Kenichi Handa <handa@m17n.org>
parents:
18201
diff
changeset
|
218 (princ (car libraries)) |
5c8e37591da5
(quail-current-data): New variable.
Kenichi Handa <handa@m17n.org>
parents:
18201
diff
changeset
|
219 (princ "\" is not in `load-path'. |
17052 | 220 |
221 The most common case is that you have not yet installed appropriate | |
222 libraries in LEIM (Libraries of Emacs Input Method) which is | |
223 distributed separately from Emacs. | |
224 | |
225 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
|
226 (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
|
227 (setq libraries (cdr libraries)))))) |
17052 | 228 (quail-select-package package-name) |
229 (setq current-input-method-title (quail-title)) | |
31217
8e8fa4dbc0bc
(quail-use-package): Hide "... loaded" message.
Kenichi Handa <handa@m17n.org>
parents:
30656
diff
changeset
|
230 (quail-activate) |
8e8fa4dbc0bc
(quail-use-package): Hide "... loaded" message.
Kenichi Handa <handa@m17n.org>
parents:
30656
diff
changeset
|
231 ;; Hide all '... loaded' message. |
8e8fa4dbc0bc
(quail-use-package): Hide "... loaded" message.
Kenichi Handa <handa@m17n.org>
parents:
30656
diff
changeset
|
232 (message nil)) |
17052 | 233 |
22917
00f3497854c4
(quail-translation-keymap): Declare it as
Kenichi Handa <handa@m17n.org>
parents:
22883
diff
changeset
|
234 (defvar quail-translation-keymap |
17052 | 235 (let ((map (make-keymap)) |
22917
00f3497854c4
(quail-translation-keymap): Declare it as
Kenichi Handa <handa@m17n.org>
parents:
22883
diff
changeset
|
236 (i 0)) |
00f3497854c4
(quail-translation-keymap): Declare it as
Kenichi Handa <handa@m17n.org>
parents:
22883
diff
changeset
|
237 (while (< i ?\ ) |
00f3497854c4
(quail-translation-keymap): Declare it as
Kenichi Handa <handa@m17n.org>
parents:
22883
diff
changeset
|
238 (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
|
239 (setq i (1+ i))) |
17052 | 240 (while (< i 127) |
241 (define-key map (char-to-string i) 'quail-self-insert-command) | |
242 (setq i (1+ i))) | |
19647
9b9af28bee8d
(quail-translation-keymap): Do not bind
Kenichi Handa <handa@m17n.org>
parents:
19619
diff
changeset
|
243 (setq i 128) |
19655
47d11f4bbc6c
(quail-translation-keymap): Fix previous
Kenichi Handa <handa@m17n.org>
parents:
19647
diff
changeset
|
244 (while (< i 256) |
19647
9b9af28bee8d
(quail-translation-keymap): Do not bind
Kenichi Handa <handa@m17n.org>
parents:
19619
diff
changeset
|
245 (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
|
246 (setq i (1+ i))) |
17052 | 247 (define-key map "\177" 'quail-delete-last-char) |
248 (define-key map "\C-f" 'quail-next-translation) | |
249 (define-key map "\C-b" 'quail-prev-translation) | |
250 (define-key map "\C-n" 'quail-next-translation-block) | |
251 (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
|
252 (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
|
253 (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
|
254 (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
|
255 (define-key map [up] 'quail-prev-translation-block) |
17052 | 256 (define-key map "\C-i" 'quail-completion) |
257 (define-key map "\C-@" 'quail-select-current) | |
20169
d938bdf82445
(quail-translation-keymap): KP_Enter key
Kenichi Handa <handa@m17n.org>
parents:
20160
diff
changeset
|
258 ;; 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
|
259 ;; 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
|
260 ;; any completion visible in the *Quail Completions* buffer. |
d938bdf82445
(quail-translation-keymap): KP_Enter key
Kenichi Handa <handa@m17n.org>
parents:
20160
diff
changeset
|
261 (define-key map [kp-enter] 'quail-select-current) |
d938bdf82445
(quail-translation-keymap): KP_Enter key
Kenichi Handa <handa@m17n.org>
parents:
20160
diff
changeset
|
262 (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
|
263 (define-key map [down-mouse-2] nil) |
17052 | 264 (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
|
265 (define-key map [?\C- ] 'quail-select-current) |
17052 | 266 (define-key map [tab] 'quail-completion) |
267 (define-key map [delete] 'quail-delete-last-char) | |
268 (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
|
269 map) |
19619
b033d0b34c71
(quail-define-package): New arg SIMPLE.
Richard M. Stallman <rms@gnu.org>
parents:
19605
diff
changeset
|
270 "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
|
271 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
|
272 most use `quail-simple-translation-keymap' instead. |
b033d0b34c71
(quail-define-package): New arg SIMPLE.
Richard M. Stallman <rms@gnu.org>
parents:
19605
diff
changeset
|
273 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
|
274 |
31546
09bc2badb9e6
(quail-translation-docstring): New variable.
Kenichi Handa <handa@m17n.org>
parents:
31453
diff
changeset
|
275 (defvar quail-translation-docstring |
09bc2badb9e6
(quail-translation-docstring): New variable.
Kenichi Handa <handa@m17n.org>
parents:
31453
diff
changeset
|
276 "When you type keys, the echo area shows the possible characters |
09bc2badb9e6
(quail-translation-docstring): New variable.
Kenichi Handa <handa@m17n.org>
parents:
31453
diff
changeset
|
277 which correspond to that key sequence, each preceded by a digit. You |
09bc2badb9e6
(quail-translation-docstring): New variable.
Kenichi Handa <handa@m17n.org>
parents:
31453
diff
changeset
|
278 can select one of the characters shown by typing the corresponding |
09bc2badb9e6
(quail-translation-docstring): New variable.
Kenichi Handa <handa@m17n.org>
parents:
31453
diff
changeset
|
279 digit. Alternatively, you can use C-f and C-b to move through the |
09bc2badb9e6
(quail-translation-docstring): New variable.
Kenichi Handa <handa@m17n.org>
parents:
31453
diff
changeset
|
280 line to select the character you want, then type a letter to begin |
09bc2badb9e6
(quail-translation-docstring): New variable.
Kenichi Handa <handa@m17n.org>
parents:
31453
diff
changeset
|
281 entering another Chinese character or type a space or punctuation |
09bc2badb9e6
(quail-translation-docstring): New variable.
Kenichi Handa <handa@m17n.org>
parents:
31453
diff
changeset
|
282 character. |
09bc2badb9e6
(quail-translation-docstring): New variable.
Kenichi Handa <handa@m17n.org>
parents:
31453
diff
changeset
|
283 |
09bc2badb9e6
(quail-translation-docstring): New variable.
Kenichi Handa <handa@m17n.org>
parents:
31453
diff
changeset
|
284 If there are more than ten possible characters for the given spelling, |
09bc2badb9e6
(quail-translation-docstring): New variable.
Kenichi Handa <handa@m17n.org>
parents:
31453
diff
changeset
|
285 the echo area shows ten characters at a time; you can use C-n to move |
09bc2badb9e6
(quail-translation-docstring): New variable.
Kenichi Handa <handa@m17n.org>
parents:
31453
diff
changeset
|
286 to the next group of ten, and C-p to move back to the previous group |
09bc2badb9e6
(quail-translation-docstring): New variable.
Kenichi Handa <handa@m17n.org>
parents:
31453
diff
changeset
|
287 of ten.") |
09bc2badb9e6
(quail-translation-docstring): New variable.
Kenichi Handa <handa@m17n.org>
parents:
31453
diff
changeset
|
288 |
09bc2badb9e6
(quail-translation-docstring): New variable.
Kenichi Handa <handa@m17n.org>
parents:
31453
diff
changeset
|
289 ;; Categorize each Quail commands to make the output of quail-help |
09bc2badb9e6
(quail-translation-docstring): New variable.
Kenichi Handa <handa@m17n.org>
parents:
31453
diff
changeset
|
290 ;; concise. This is done by putting `quail-help' property. The value |
09bc2badb9e6
(quail-translation-docstring): New variable.
Kenichi Handa <handa@m17n.org>
parents:
31453
diff
changeset
|
291 ;; is: |
09bc2badb9e6
(quail-translation-docstring): New variable.
Kenichi Handa <handa@m17n.org>
parents:
31453
diff
changeset
|
292 ;; hide -- never show this command |
09bc2badb9e6
(quail-translation-docstring): New variable.
Kenichi Handa <handa@m17n.org>
parents:
31453
diff
changeset
|
293 ;; non-deterministic -- show only for non-deterministic input method |
09bc2badb9e6
(quail-translation-docstring): New variable.
Kenichi Handa <handa@m17n.org>
parents:
31453
diff
changeset
|
294 (let ((l '((quail-other-command . hide) |
09bc2badb9e6
(quail-translation-docstring): New variable.
Kenichi Handa <handa@m17n.org>
parents:
31453
diff
changeset
|
295 (quail-self-insert-command . hide) |
09bc2badb9e6
(quail-translation-docstring): New variable.
Kenichi Handa <handa@m17n.org>
parents:
31453
diff
changeset
|
296 (quail-delete-last-char . hide) |
09bc2badb9e6
(quail-translation-docstring): New variable.
Kenichi Handa <handa@m17n.org>
parents:
31453
diff
changeset
|
297 (quail-next-translation . non-deterministic) |
09bc2badb9e6
(quail-translation-docstring): New variable.
Kenichi Handa <handa@m17n.org>
parents:
31453
diff
changeset
|
298 (quail-prev-translation . non-deterministic) |
09bc2badb9e6
(quail-translation-docstring): New variable.
Kenichi Handa <handa@m17n.org>
parents:
31453
diff
changeset
|
299 (quail-next-translation-block . non-deterministic) |
09bc2badb9e6
(quail-translation-docstring): New variable.
Kenichi Handa <handa@m17n.org>
parents:
31453
diff
changeset
|
300 (quail-prev-translation-block . non-deterministic)))) |
31424 | 301 (while l |
31546
09bc2badb9e6
(quail-translation-docstring): New variable.
Kenichi Handa <handa@m17n.org>
parents:
31453
diff
changeset
|
302 (put (car (car l)) 'quail-help (cdr (car l))) |
31424 | 303 (setq l (cdr l)))) |
304 | |
22917
00f3497854c4
(quail-translation-keymap): Declare it as
Kenichi Handa <handa@m17n.org>
parents:
22883
diff
changeset
|
305 (defvar quail-simple-translation-keymap |
19619
b033d0b34c71
(quail-define-package): New arg SIMPLE.
Richard M. Stallman <rms@gnu.org>
parents:
19605
diff
changeset
|
306 (let ((map (make-keymap)) |
22917
00f3497854c4
(quail-translation-keymap): Declare it as
Kenichi Handa <handa@m17n.org>
parents:
22883
diff
changeset
|
307 (i 0)) |
00f3497854c4
(quail-translation-keymap): Declare it as
Kenichi Handa <handa@m17n.org>
parents:
22883
diff
changeset
|
308 (while (< i ?\ ) |
00f3497854c4
(quail-translation-keymap): Declare it as
Kenichi Handa <handa@m17n.org>
parents:
22883
diff
changeset
|
309 (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
|
310 (setq i (1+ i))) |
19619
b033d0b34c71
(quail-define-package): New arg SIMPLE.
Richard M. Stallman <rms@gnu.org>
parents:
19605
diff
changeset
|
311 (while (< i 127) |
b033d0b34c71
(quail-define-package): New arg SIMPLE.
Richard M. Stallman <rms@gnu.org>
parents:
19605
diff
changeset
|
312 (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
|
313 (setq i (1+ i))) |
29073
b46c4dc8c51a
(quail-simple-translation-keymap): Map
Kenichi Handa <handa@m17n.org>
parents:
28213
diff
changeset
|
314 (setq i 128) |
b46c4dc8c51a
(quail-simple-translation-keymap): Map
Kenichi Handa <handa@m17n.org>
parents:
28213
diff
changeset
|
315 (while (< i 256) |
b46c4dc8c51a
(quail-simple-translation-keymap): Map
Kenichi Handa <handa@m17n.org>
parents:
28213
diff
changeset
|
316 (define-key map (vector i) 'quail-self-insert-command) |
b46c4dc8c51a
(quail-simple-translation-keymap): Map
Kenichi Handa <handa@m17n.org>
parents:
28213
diff
changeset
|
317 (setq i (1+ i))) |
19619
b033d0b34c71
(quail-define-package): New arg SIMPLE.
Richard M. Stallman <rms@gnu.org>
parents:
19605
diff
changeset
|
318 (define-key map "\177" 'quail-delete-last-char) |
19951
820fc18dd520
(quail-simple-translation-keymap):
Richard M. Stallman <rms@gnu.org>
parents:
19949
diff
changeset
|
319 (define-key map [delete] 'quail-delete-last-char) |
820fc18dd520
(quail-simple-translation-keymap):
Richard M. Stallman <rms@gnu.org>
parents:
19949
diff
changeset
|
320 (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
|
321 ;;(let ((meta-map (make-sparse-keymap))) |
00f3497854c4
(quail-translation-keymap): Declare it as
Kenichi Handa <handa@m17n.org>
parents:
22883
diff
changeset
|
322 ;;(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
|
323 ;;(define-key map [escape] meta-map)) |
19878
a69ae37e6932
(quail-update-translation): Fix previous change.
Richard M. Stallman <rms@gnu.org>
parents:
19849
diff
changeset
|
324 map) |
19619
b033d0b34c71
(quail-define-package): New arg SIMPLE.
Richard M. Stallman <rms@gnu.org>
parents:
19605
diff
changeset
|
325 "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
|
326 A few especially complex input methods use `quail-translation-keymap' instead. |
17052 | 327 This map is activated while translation region is active.") |
328 | |
22917
00f3497854c4
(quail-translation-keymap): Declare it as
Kenichi Handa <handa@m17n.org>
parents:
22883
diff
changeset
|
329 (defvar quail-conversion-keymap |
17052 | 330 (let ((map (make-keymap)) |
22765
7cf2c3800e8f
(quail-mode): This variable deleted.
Kenichi Handa <handa@m17n.org>
parents:
22124
diff
changeset
|
331 (i ?\ )) |
17052 | 332 (while (< i 127) |
22765
7cf2c3800e8f
(quail-mode): This variable deleted.
Kenichi Handa <handa@m17n.org>
parents:
22124
diff
changeset
|
333 (define-key map (char-to-string i) 'quail-self-insert-command) |
17052 | 334 (setq i (1+ i))) |
19647
9b9af28bee8d
(quail-translation-keymap): Do not bind
Kenichi Handa <handa@m17n.org>
parents:
19619
diff
changeset
|
335 (setq i 128) |
19655
47d11f4bbc6c
(quail-translation-keymap): Fix previous
Kenichi Handa <handa@m17n.org>
parents:
19647
diff
changeset
|
336 (while (< i 256) |
22765
7cf2c3800e8f
(quail-mode): This variable deleted.
Kenichi Handa <handa@m17n.org>
parents:
22124
diff
changeset
|
337 (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
|
338 (setq i (1+ i))) |
17052 | 339 (define-key map "\C-b" 'quail-conversion-backward-char) |
340 (define-key map "\C-f" 'quail-conversion-forward-char) | |
341 (define-key map "\C-a" 'quail-conversion-beginning-of-region) | |
342 (define-key map "\C-e" 'quail-conversion-end-of-region) | |
343 (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
|
344 (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
|
345 (define-key map "\C-h" 'quail-translation-help) |
17052 | 346 (define-key map "\177" 'quail-conversion-backward-delete-char) |
347 (define-key map [delete] 'quail-conversion-backward-delete-char) | |
348 (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
|
349 map) |
17052 | 350 "Keymap used for processing conversion in Quail mode. |
23176 | 351 This map is activated while conversion region is active but translation |
17052 | 352 region is not active.") |
353 | |
31424 | 354 ;; Just a dummy definition. |
355 (defun quail-other-command () | |
356 (interactive) | |
357 ) | |
358 | |
18297
5c8e37591da5
(quail-current-data): New variable.
Kenichi Handa <handa@m17n.org>
parents:
18201
diff
changeset
|
359 ;;;###autoload |
17052 | 360 (defun quail-define-package (name language title |
361 &optional guidance docstring translation-keys | |
362 forget-last-selection deterministic | |
363 kbd-translate show-layout create-decode-map | |
364 maximum-shortest overlay-plist | |
365 update-translation-function | |
19619
b033d0b34c71
(quail-define-package): New arg SIMPLE.
Richard M. Stallman <rms@gnu.org>
parents:
19605
diff
changeset
|
366 conversion-keys simple) |
17052 | 367 "Define NAME as a new Quail package for input LANGUAGE. |
368 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
|
369 Optional arguments are GUIDANCE, DOCSTRING, TRANSLATION-KEYS, |
17052 | 370 FORGET-LAST-SELECTION, DETERMINISTIC, KBD-TRANSLATE, SHOW-LAYOUT, |
371 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
|
372 UPDATE-TRANSLATION-FUNCTION, CONVERSION-KEYS and SIMPLE. |
17052 | 373 |
374 GUIDANCE specifies how a guidance string is shown in echo area. | |
375 If it is t, list of all possible translations for the current key is shown | |
376 with the currently selected translation being highlighted. | |
377 If it is an alist, the element has the form (CHAR . STRING). Each character | |
378 in the current key is searched in the list and the corresponding string is | |
379 shown. | |
380 If it is nil, the current key is shown. | |
381 | |
31546
09bc2badb9e6
(quail-translation-docstring): New variable.
Kenichi Handa <handa@m17n.org>
parents:
31453
diff
changeset
|
382 DOCSTRING is the documentation string of this package. The command |
09bc2badb9e6
(quail-translation-docstring): New variable.
Kenichi Handa <handa@m17n.org>
parents:
31453
diff
changeset
|
383 `describe-input-method' shows this string while replacing the form |
31549
84fcbc8496b7
(quail-define-package): Docstring modified.
Kenichi Handa <handa@m17n.org>
parents:
31546
diff
changeset
|
384 \\=\\<VAR> in the string by the value of VAR. That value should be a |
84fcbc8496b7
(quail-define-package): Docstring modified.
Kenichi Handa <handa@m17n.org>
parents:
31546
diff
changeset
|
385 string. For instance, the form \\=\\<quail-translation-docstring> is |
31546
09bc2badb9e6
(quail-translation-docstring): New variable.
Kenichi Handa <handa@m17n.org>
parents:
31453
diff
changeset
|
386 replaced by a description about how to select a translation from a |
09bc2badb9e6
(quail-translation-docstring): New variable.
Kenichi Handa <handa@m17n.org>
parents:
31453
diff
changeset
|
387 list of candidates. |
17052 | 388 |
389 TRANSLATION-KEYS specifies additional key bindings used while translation | |
390 region is active. It is an alist of single key character vs. corresponding | |
391 command to be called. | |
392 | |
393 FORGET-LAST-SELECTION non-nil means a selected translation is not kept | |
394 for the future to translate the same key. If this flag is nil, a | |
395 translation selected for a key is remembered so that it can be the | |
396 first candidate when the same key is entered later. | |
397 | |
398 DETERMINISTIC non-nil means the first candidate of translation is | |
399 selected automatically without allowing users to select another | |
400 translation for a key. In this case, unselected translations are of | |
401 no use for an interactive use of Quail but can be used by some other | |
402 programs. If this flag is non-nil, FORGET-LAST-SELECTION is also set | |
403 to t. | |
404 | |
405 KBD-TRANSLATE non-nil means input characters are translated from a | |
406 user's keyboard layout to the standard keyboard layout. See the | |
407 documentation of `quail-keyboard-layout' and | |
408 `quail-keyboard-layout-standard' for more detail. | |
409 | |
410 SHOW-LAYOUT non-nil means the `quail-help' command should show | |
411 the user's keyboard layout visually with translated characters. | |
412 If KBD-TRANSLATE is set, it is desirable to set also this flag unless | |
413 this package defines no translations for single character keys. | |
414 | |
415 CREATE-DECODE-MAP non-nil means decode map is also created. A decode | |
416 map is an alist of translations and corresponding original keys. | |
417 Although this map is not used by Quail itself, it can be used by some | |
418 other programs. For instance, Vietnamese supporting needs this map to | |
419 convert Vietnamese text to VIQR format which uses only ASCII | |
420 characters to represent Vietnamese characters. | |
421 | |
422 MAXIMUM-SHORTEST non-nil means break key sequence to get maximum | |
423 length of the shortest sequence. When we don't have a translation of | |
424 key \"..ABCD\" but have translations of \"..AB\" and \"CD..\", break | |
425 the key at \"..AB\" and start translation of \"CD..\". Hangul | |
426 packages, for instance, use this facility. If this flag is nil, we | |
427 break the key just at \"..ABC\" and start translation of \"D..\". | |
428 | |
429 OVERLAY-PLIST if non-nil is a property list put on an overlay which | |
430 covers Quail translation region. | |
431 | |
432 UPDATE-TRANSLATION-FUNCTION if non-nil is a function to call to update | |
23176 | 433 the current translation region according to a new translation data. By |
434 default, a translated text or a user's key sequence (if no translation | |
17052 | 435 for it) is inserted. |
436 | |
437 CONVERSION-KEYS specifies additional key bindings used while | |
438 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
|
439 vs. corresponding command to be called. |
b033d0b34c71
(quail-define-package): New arg SIMPLE.
Richard M. Stallman <rms@gnu.org>
parents:
19605
diff
changeset
|
440 |
b033d0b34c71
(quail-define-package): New arg SIMPLE.
Richard M. Stallman <rms@gnu.org>
parents:
19605
diff
changeset
|
441 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
|
442 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
|
443 non-Quail commands." |
17052 | 444 (let (translation-keymap conversion-keymap) |
445 (if deterministic (setq forget-last-selection t)) | |
446 (if translation-keys | |
19404
8901359ae445
(quail-inactivate): Turn Quail mode off
Kenichi Handa <handa@m17n.org>
parents:
19391
diff
changeset
|
447 (progn |
19619
b033d0b34c71
(quail-define-package): New arg SIMPLE.
Richard M. Stallman <rms@gnu.org>
parents:
19605
diff
changeset
|
448 (setq translation-keymap (copy-keymap |
b033d0b34c71
(quail-define-package): New arg SIMPLE.
Richard M. Stallman <rms@gnu.org>
parents:
19605
diff
changeset
|
449 (if simple quail-simple-translation-keymap |
b033d0b34c71
(quail-define-package): New arg SIMPLE.
Richard M. Stallman <rms@gnu.org>
parents:
19605
diff
changeset
|
450 quail-translation-keymap))) |
19404
8901359ae445
(quail-inactivate): Turn Quail mode off
Kenichi Handa <handa@m17n.org>
parents:
19391
diff
changeset
|
451 (while translation-keys |
8901359ae445
(quail-inactivate): Turn Quail mode off
Kenichi Handa <handa@m17n.org>
parents:
19391
diff
changeset
|
452 (define-key translation-keymap |
8901359ae445
(quail-inactivate): Turn Quail mode off
Kenichi Handa <handa@m17n.org>
parents:
19391
diff
changeset
|
453 (car (car translation-keys)) (cdr (car translation-keys))) |
8901359ae445
(quail-inactivate): Turn Quail mode off
Kenichi Handa <handa@m17n.org>
parents:
19391
diff
changeset
|
454 (setq translation-keys (cdr translation-keys)))) |
19619
b033d0b34c71
(quail-define-package): New arg SIMPLE.
Richard M. Stallman <rms@gnu.org>
parents:
19605
diff
changeset
|
455 (setq translation-keymap |
b033d0b34c71
(quail-define-package): New arg SIMPLE.
Richard M. Stallman <rms@gnu.org>
parents:
19605
diff
changeset
|
456 (if simple quail-simple-translation-keymap |
b033d0b34c71
(quail-define-package): New arg SIMPLE.
Richard M. Stallman <rms@gnu.org>
parents:
19605
diff
changeset
|
457 quail-translation-keymap))) |
19404
8901359ae445
(quail-inactivate): Turn Quail mode off
Kenichi Handa <handa@m17n.org>
parents:
19391
diff
changeset
|
458 (when conversion-keys |
8901359ae445
(quail-inactivate): Turn Quail mode off
Kenichi Handa <handa@m17n.org>
parents:
19391
diff
changeset
|
459 (setq conversion-keymap (copy-keymap quail-conversion-keymap)) |
8901359ae445
(quail-inactivate): Turn Quail mode off
Kenichi Handa <handa@m17n.org>
parents:
19391
diff
changeset
|
460 (while conversion-keys |
8901359ae445
(quail-inactivate): Turn Quail mode off
Kenichi Handa <handa@m17n.org>
parents:
19391
diff
changeset
|
461 (define-key conversion-keymap |
8901359ae445
(quail-inactivate): Turn Quail mode off
Kenichi Handa <handa@m17n.org>
parents:
19391
diff
changeset
|
462 (car (car conversion-keys)) (cdr (car conversion-keys))) |
8901359ae445
(quail-inactivate): Turn Quail mode off
Kenichi Handa <handa@m17n.org>
parents:
19391
diff
changeset
|
463 (setq conversion-keys (cdr conversion-keys)))) |
17052 | 464 (quail-add-package |
465 (list name title (list nil) guidance (or docstring "") | |
466 translation-keymap | |
467 forget-last-selection deterministic kbd-translate show-layout | |
468 (if create-decode-map (list 'decode-map) nil) | |
469 maximum-shortest overlay-plist update-translation-function | |
19849
1c5164d81426
(quail-simple): New function.
Kenichi Handa <handa@m17n.org>
parents:
19844
diff
changeset
|
470 conversion-keymap simple)) |
18556
99e8ae18137f
(quail-guidance-buf): Make it buffer
Kenichi Handa <handa@m17n.org>
parents:
18377
diff
changeset
|
471 |
99e8ae18137f
(quail-guidance-buf): Make it buffer
Kenichi Handa <handa@m17n.org>
parents:
18377
diff
changeset
|
472 ;; Update input-method-alist. |
99e8ae18137f
(quail-guidance-buf): Make it buffer
Kenichi Handa <handa@m17n.org>
parents:
18377
diff
changeset
|
473 (let ((slot (assoc name input-method-alist)) |
99e8ae18137f
(quail-guidance-buf): Make it buffer
Kenichi Handa <handa@m17n.org>
parents:
18377
diff
changeset
|
474 (val (list language 'quail-use-package title docstring))) |
99e8ae18137f
(quail-guidance-buf): Make it buffer
Kenichi Handa <handa@m17n.org>
parents:
18377
diff
changeset
|
475 (if slot (setcdr slot val) |
99e8ae18137f
(quail-guidance-buf): Make it buffer
Kenichi Handa <handa@m17n.org>
parents:
18377
diff
changeset
|
476 (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
|
477 |
17052 | 478 (quail-select-package name)) |
479 | |
480 ;; Quail minor mode handlers. | |
481 | |
482 ;; Setup overlays used in Quail mode. | |
19404
8901359ae445
(quail-inactivate): Turn Quail mode off
Kenichi Handa <handa@m17n.org>
parents:
19391
diff
changeset
|
483 (defun quail-setup-overlays (conversion-mode) |
17052 | 484 (let ((pos (point))) |
485 (if (overlayp quail-overlay) | |
486 (move-overlay quail-overlay pos pos) | |
487 (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
|
488 (if input-method-highlight-flag |
8901359ae445
(quail-inactivate): Turn Quail mode off
Kenichi Handa <handa@m17n.org>
parents:
19391
diff
changeset
|
489 (overlay-put quail-overlay 'face 'underline)) |
17052 | 490 (let ((l (quail-overlay-plist))) |
491 (while l | |
492 (overlay-put quail-overlay (car l) (car (cdr l))) | |
493 (setq l (cdr (cdr l)))))) | |
19404
8901359ae445
(quail-inactivate): Turn Quail mode off
Kenichi Handa <handa@m17n.org>
parents:
19391
diff
changeset
|
494 (if conversion-mode |
8901359ae445
(quail-inactivate): Turn Quail mode off
Kenichi Handa <handa@m17n.org>
parents:
19391
diff
changeset
|
495 (if (overlayp quail-conv-overlay) |
8901359ae445
(quail-inactivate): Turn Quail mode off
Kenichi Handa <handa@m17n.org>
parents:
19391
diff
changeset
|
496 (if (not (overlay-start quail-conv-overlay)) |
8901359ae445
(quail-inactivate): Turn Quail mode off
Kenichi Handa <handa@m17n.org>
parents:
19391
diff
changeset
|
497 (move-overlay quail-conv-overlay pos pos)) |
8901359ae445
(quail-inactivate): Turn Quail mode off
Kenichi Handa <handa@m17n.org>
parents:
19391
diff
changeset
|
498 (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
|
499 (if input-method-highlight-flag |
8901359ae445
(quail-inactivate): Turn Quail mode off
Kenichi Handa <handa@m17n.org>
parents:
19391
diff
changeset
|
500 (overlay-put quail-conv-overlay 'face 'underline)))))) |
17052 | 501 |
502 ;; Delete overlays used in Quail mode. | |
503 (defun quail-delete-overlays () | |
22765
7cf2c3800e8f
(quail-mode): This variable deleted.
Kenichi Handa <handa@m17n.org>
parents:
22124
diff
changeset
|
504 (if (and (overlayp quail-overlay) (overlay-start quail-overlay)) |
17052 | 505 (delete-overlay quail-overlay)) |
22765
7cf2c3800e8f
(quail-mode): This variable deleted.
Kenichi Handa <handa@m17n.org>
parents:
22124
diff
changeset
|
506 (if (and (overlayp quail-conv-overlay) (overlay-start quail-conv-overlay)) |
17052 | 507 (delete-overlay quail-conv-overlay))) |
508 | |
19432
4492653b04e8
(quail-exit-from-minibuffer): Call
Kenichi Handa <handa@m17n.org>
parents:
19404
diff
changeset
|
509 ;; Kill Quail guidance buffer. Set in kill-buffer-hook. |
4492653b04e8
(quail-exit-from-minibuffer): Call
Kenichi Handa <handa@m17n.org>
parents:
19404
diff
changeset
|
510 (defun quail-kill-guidance-buf () |
4492653b04e8
(quail-exit-from-minibuffer): Call
Kenichi Handa <handa@m17n.org>
parents:
19404
diff
changeset
|
511 (if (buffer-live-p quail-guidance-buf) |
4492653b04e8
(quail-exit-from-minibuffer): Call
Kenichi Handa <handa@m17n.org>
parents:
19404
diff
changeset
|
512 (kill-buffer quail-guidance-buf))) |
4492653b04e8
(quail-exit-from-minibuffer): Call
Kenichi Handa <handa@m17n.org>
parents:
19404
diff
changeset
|
513 |
22765
7cf2c3800e8f
(quail-mode): This variable deleted.
Kenichi Handa <handa@m17n.org>
parents:
22124
diff
changeset
|
514 (defun quail-inactivate () |
7cf2c3800e8f
(quail-mode): This variable deleted.
Kenichi Handa <handa@m17n.org>
parents:
22124
diff
changeset
|
515 "Inactivate Quail input method." |
7cf2c3800e8f
(quail-mode): This variable deleted.
Kenichi Handa <handa@m17n.org>
parents:
22124
diff
changeset
|
516 (interactive) |
7cf2c3800e8f
(quail-mode): This variable deleted.
Kenichi Handa <handa@m17n.org>
parents:
22124
diff
changeset
|
517 (quail-activate -1)) |
7cf2c3800e8f
(quail-mode): This variable deleted.
Kenichi Handa <handa@m17n.org>
parents:
22124
diff
changeset
|
518 |
7cf2c3800e8f
(quail-mode): This variable deleted.
Kenichi Handa <handa@m17n.org>
parents:
22124
diff
changeset
|
519 (defun quail-activate (&optional arg) |
7cf2c3800e8f
(quail-mode): This variable deleted.
Kenichi Handa <handa@m17n.org>
parents:
22124
diff
changeset
|
520 "Activate Quail input method. |
7cf2c3800e8f
(quail-mode): This variable deleted.
Kenichi Handa <handa@m17n.org>
parents:
22124
diff
changeset
|
521 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
|
522 |
22765
7cf2c3800e8f
(quail-mode): This variable deleted.
Kenichi Handa <handa@m17n.org>
parents:
22124
diff
changeset
|
523 While this input method is active, the variable |
7cf2c3800e8f
(quail-mode): This variable deleted.
Kenichi Handa <handa@m17n.org>
parents:
22124
diff
changeset
|
524 `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
|
525 (if (and arg |
7cf2c3800e8f
(quail-mode): This variable deleted.
Kenichi Handa <handa@m17n.org>
parents:
22124
diff
changeset
|
526 (< (prefix-numeric-value arg) 0)) |
7cf2c3800e8f
(quail-mode): This variable deleted.
Kenichi Handa <handa@m17n.org>
parents:
22124
diff
changeset
|
527 ;; Let's inactivate Quail input method. |
7cf2c3800e8f
(quail-mode): This variable deleted.
Kenichi Handa <handa@m17n.org>
parents:
22124
diff
changeset
|
528 (unwind-protect |
7cf2c3800e8f
(quail-mode): This variable deleted.
Kenichi Handa <handa@m17n.org>
parents:
22124
diff
changeset
|
529 (progn |
7cf2c3800e8f
(quail-mode): This variable deleted.
Kenichi Handa <handa@m17n.org>
parents:
22124
diff
changeset
|
530 (quail-hide-guidance-buf) |
7cf2c3800e8f
(quail-mode): This variable deleted.
Kenichi Handa <handa@m17n.org>
parents:
22124
diff
changeset
|
531 (quail-delete-overlays) |
7cf2c3800e8f
(quail-mode): This variable deleted.
Kenichi Handa <handa@m17n.org>
parents:
22124
diff
changeset
|
532 (setq describe-current-input-method-function nil) |
7cf2c3800e8f
(quail-mode): This variable deleted.
Kenichi Handa <handa@m17n.org>
parents:
22124
diff
changeset
|
533 (run-hooks 'quail-inactivate-hook)) |
7cf2c3800e8f
(quail-mode): This variable deleted.
Kenichi Handa <handa@m17n.org>
parents:
22124
diff
changeset
|
534 (kill-local-variable 'input-method-function)) |
33476
51bec48940dd
(quail-show-guidance-buf): Call fit-window-to-buffer to assure the
Kenichi Handa <handa@m17n.org>
parents:
32958
diff
changeset
|
535 ;; Let's activate Quail input method. |
17052 | 536 (if (null quail-current-package) |
537 ;; Quail package is not yet selected. Select one now. | |
538 (let (name) | |
539 (if quail-package-alist | |
540 (setq name (car (car quail-package-alist))) | |
541 (error "No Quail package loaded")) | |
542 (quail-select-package name))) | |
19404
8901359ae445
(quail-inactivate): Turn Quail mode off
Kenichi Handa <handa@m17n.org>
parents:
19391
diff
changeset
|
543 (setq inactivate-current-input-method-function 'quail-inactivate) |
17052 | 544 (setq describe-current-input-method-function 'quail-help) |
545 (quail-delete-overlays) | |
546 (quail-show-guidance-buf) | |
19432
4492653b04e8
(quail-exit-from-minibuffer): Call
Kenichi Handa <handa@m17n.org>
parents:
19404
diff
changeset
|
547 ;; 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
|
548 ;; before exiting. |
17052 | 549 (if (eq (selected-window) (minibuffer-window)) |
550 (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
|
551 (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
|
552 (run-hooks 'quail-activate-hook) |
7cf2c3800e8f
(quail-mode): This variable deleted.
Kenichi Handa <handa@m17n.org>
parents:
22124
diff
changeset
|
553 (make-local-variable 'input-method-function) |
7cf2c3800e8f
(quail-mode): This variable deleted.
Kenichi Handa <handa@m17n.org>
parents:
22124
diff
changeset
|
554 (setq input-method-function 'quail-input-method))) |
17052 | 555 |
556 (defun quail-exit-from-minibuffer () | |
19432
4492653b04e8
(quail-exit-from-minibuffer): Call
Kenichi Handa <handa@m17n.org>
parents:
19404
diff
changeset
|
557 (inactivate-input-method) |
17052 | 558 (if (<= (minibuffer-depth) 1) |
559 (remove-hook 'minibuffer-exit-hook 'quail-exit-from-minibuffer))) | |
560 | |
561 ;; Keyboard layout translation handlers. | |
562 | |
563 ;; Some Quail packages provide localized keyboard simulation which | |
564 ;; requires a particular keyboard layout. In this case, what we need | |
565 ;; is locations of keys the user entered, not character codes | |
566 ;; generated by those keys. However, for the moment, there's no | |
567 ;; common way to get such information. So, we ask a user to give | |
568 ;; information of his own keyboard layout, then translate it to the | |
569 ;; standard layout which we defined so that all Quail packages depend | |
570 ;; just on it. | |
571 | |
572 (defconst quail-keyboard-layout-standard | |
573 "\ | |
17174
9c1191812679
(quail-translation-keymap): Add entry for escape key.
Kenichi Handa <handa@m17n.org>
parents:
17095
diff
changeset
|
574 \ |
17052 | 575 1!2@3#4$5%6^7&8*9(0)-_=+`~ \ |
576 qQwWeErRtTyYuUiIoOpP[{]} \ | |
577 aAsSdDfFgGhHjJkKlL;:'\"\\| \ | |
17174
9c1191812679
(quail-translation-keymap): Add entry for escape key.
Kenichi Handa <handa@m17n.org>
parents:
17095
diff
changeset
|
578 zZxXcCvVbBnNmM,<.>/? \ |
9c1191812679
(quail-translation-keymap): Add entry for escape key.
Kenichi Handa <handa@m17n.org>
parents:
17095
diff
changeset
|
579 " |
17052 | 580 "Standard keyboard layout of printable characters Quail assumes. |
581 See the documentation of `quail-keyboard-layout' for this format. | |
582 This layout is almost the same as that of VT100, | |
583 but the location of key \\ (backslash) is just right of key ' (single-quote), | |
584 not right of RETURN key.") | |
585 | |
586 (defvar quail-keyboard-layout quail-keyboard-layout-standard | |
587 "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
|
588 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
|
589 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
|
590 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
|
591 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
|
592 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
|
593 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
|
594 the sixth row is below the `z' - `/' row. |
17052 | 595 Nth (N is even) and (N+1)th characters in the string are non-shifted |
596 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
|
597 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
|
598 The command `quail-set-keyboard-layout' usually sets this variable.") |
17052 | 599 |
17174
9c1191812679
(quail-translation-keymap): Add entry for escape key.
Kenichi Handa <handa@m17n.org>
parents:
17095
diff
changeset
|
600 (defconst quail-keyboard-layout-len 180) |
17052 | 601 |
602 ;; Here we provide several examples of famous keyboard layouts. | |
603 | |
604 (defvar quail-keyboard-layout-alist | |
605 (list | |
31424 | 606 (cons "standard" quail-keyboard-layout-standard) |
17052 | 607 '("sun-type3" . "\ |
17174
9c1191812679
(quail-translation-keymap): Add entry for escape key.
Kenichi Handa <handa@m17n.org>
parents:
17095
diff
changeset
|
608 \ |
17052 | 609 1!2@3#4$5%6^7&8*9(0)-_=+\\|`~\ |
610 qQwWeErRtTyYuUiIoOpP[{]} \ | |
611 aAsSdDfFgGhHjJkKlL;:'\" \ | |
17174
9c1191812679
(quail-translation-keymap): Add entry for escape key.
Kenichi Handa <handa@m17n.org>
parents:
17095
diff
changeset
|
612 zZxXcCvVbBnNmM,<.>/? \ |
9c1191812679
(quail-translation-keymap): Add entry for escape key.
Kenichi Handa <handa@m17n.org>
parents:
17095
diff
changeset
|
613 ") |
19675
32c3f7d9ef10
(quail-keyboard-layout-alist): Add an
Kenichi Handa <handa@m17n.org>
parents:
19655
diff
changeset
|
614 '("atari-german" . "\ |
32c3f7d9ef10
(quail-keyboard-layout-alist): Add an
Kenichi Handa <handa@m17n.org>
parents:
19655
diff
changeset
|
615 \ |
32c3f7d9ef10
(quail-keyboard-layout-alist): Add an
Kenichi Handa <handa@m17n.org>
parents:
19655
diff
changeset
|
616 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
|
617 qQwWeErRtTzZuUiIoOpP\374\334+* \ |
32c3f7d9ef10
(quail-keyboard-layout-alist): Add an
Kenichi Handa <handa@m17n.org>
parents:
19655
diff
changeset
|
618 aAsSdDfFgGhHjJkKlL\366\326\344\304~| \ |
32c3f7d9ef10
(quail-keyboard-layout-alist): Add an
Kenichi Handa <handa@m17n.org>
parents:
19655
diff
changeset
|
619 <>yYxXcCvVbBnNmM,;.:-_ \ |
32c3f7d9ef10
(quail-keyboard-layout-alist): Add an
Kenichi Handa <handa@m17n.org>
parents:
19655
diff
changeset
|
620 ") |
29073
b46c4dc8c51a
(quail-simple-translation-keymap): Map
Kenichi Handa <handa@m17n.org>
parents:
28213
diff
changeset
|
621 |
b46c4dc8c51a
(quail-simple-translation-keymap): Map
Kenichi Handa <handa@m17n.org>
parents:
28213
diff
changeset
|
622 '("pc102-de" . "\ |
b46c4dc8c51a
(quail-simple-translation-keymap): Map
Kenichi Handa <handa@m17n.org>
parents:
28213
diff
changeset
|
623 \ |
b46c4dc8c51a
(quail-simple-translation-keymap): Map
Kenichi Handa <handa@m17n.org>
parents:
28213
diff
changeset
|
624 ^\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
|
625 qQwWeErRtTzZuUiIoOpP\374\334+* \ |
b46c4dc8c51a
(quail-simple-translation-keymap): Map
Kenichi Handa <handa@m17n.org>
parents:
28213
diff
changeset
|
626 aAsSdDfFgGhHjJkKlL\366\326\344\304 \ |
b46c4dc8c51a
(quail-simple-translation-keymap): Map
Kenichi Handa <handa@m17n.org>
parents:
28213
diff
changeset
|
627 <>yYxXcCvVbBnNmM,;.:-_ \ |
b46c4dc8c51a
(quail-simple-translation-keymap): Map
Kenichi Handa <handa@m17n.org>
parents:
28213
diff
changeset
|
628 ") |
b46c4dc8c51a
(quail-simple-translation-keymap): Map
Kenichi Handa <handa@m17n.org>
parents:
28213
diff
changeset
|
629 |
31424 | 630 '("jp106" . "\ |
631 \ | |
632 1!2\"3#4$5%6&7'8(9)0~-=^~\\| \ | |
633 qQwWeErRtTyYuUiIoOpP@`[{ \ | |
634 aAsSdDfFgGhHjJkKlL;+:*]} \ | |
635 zZxXcCvVbBnNmM,<.>/?\\_ \ | |
636 ") | |
637 ) | |
17052 | 638 "Alist of keyboard names and corresponding layout strings. |
639 See the documentation of `quail-keyboard-layout' for the format of | |
31424 | 640 the layout string.") |
641 | |
642 ;; A non-standard keyboard layout may miss some key locations of the | |
643 ;; standard layout while having additional key locations not in the | |
644 ;; standard layout. This alist maps those additional key locations to | |
645 ;; the missing locations. The value is updated automatically by | |
646 ;; quail-set-keyboard-layout. | |
647 (defvar quail-keyboard-layout-substitution nil) | |
648 | |
649 (defun quail-update-keyboard-layout (kbd-type) | |
650 (let ((layout (assoc kbd-type quail-keyboard-layout-alist))) | |
651 (if (null layout) | |
652 ;; Here, we had better ask a user to define his own keyboard | |
653 ;; layout interactively. | |
654 (error "Unknown keyboard type `%s'" kbd-type)) | |
655 (setq quail-keyboard-layout (cdr layout)) | |
656 (let ((i quail-keyboard-layout-len) | |
657 subst-list missing-list) | |
658 ;; Sum up additional key locations not in the standard layout in | |
659 ;; subst-list, and missing key locations in missing-list. | |
660 (while (> i 0) | |
661 (setq i (1- i)) | |
662 (if (= (aref quail-keyboard-layout i) ? ) | |
663 (if (/= (aref quail-keyboard-layout-standard i) ? ) | |
664 (setq missing-list (cons i missing-list))) | |
665 (if (= (aref quail-keyboard-layout-standard i) ? ) | |
666 (setq subst-list (cons (cons i nil) subst-list))))) | |
667 (setq quail-keyboard-layout-substitution subst-list) | |
668 ;; If there are additional key locations, map them to missing | |
669 ;; key locations. | |
670 (while missing-list | |
671 (while (and subst-list (cdr (car subst-list))) | |
672 (setq subst-list (cdr subst-list))) | |
673 (if subst-list | |
674 (setcdr (car subst-list) (car missing-list))) | |
675 (setq missing-list (cdr missing-list)))))) | |
676 | |
677 (defcustom quail-keyboard-layout-type "standard" | |
678 "Type of keyboard layout used in Quail base input method. | |
679 Available types are listed in the variable `quail-keyboard-layout-alist'." | |
680 :group 'quail | |
681 :type 'string | |
682 :set #'(lambda (symbol value) | |
683 (quail-update-keyboard-layout value) | |
684 (set symbol value))) | |
17052 | 685 |
19949
ad6d3d0b2cb4
(quail-set-keyboard-layout): Add autoload cookie.
Richard M. Stallman <rms@gnu.org>
parents:
19944
diff
changeset
|
686 ;;;###autoload |
17052 | 687 (defun quail-set-keyboard-layout (kbd-type) |
688 "Set the current keyboard layout to the same as keyboard KBD-TYPE. | |
689 | |
690 Since some Quail packages depends on a physical layout of keys (not | |
691 characters generated by them), those are created by assuming the | |
692 standard layout defined in `quail-keyboard-layout-standard'. This | |
693 function tells Quail system the layout of your keyboard so that what | |
694 you type is correctly handled." | |
695 (interactive | |
28213
2851f83ea432
(quail-set-keyboard-layout): Typo fixed.
Kenichi Handa <handa@m17n.org>
parents:
26891
diff
changeset
|
696 (let* ((completion-ignore-case t) |
17052 | 697 (type (completing-read "Keyboard type: " |
698 quail-keyboard-layout-alist))) | |
699 (list type))) | |
31424 | 700 (quail-update-keyboard-layout kbd-type) |
701 (setq quail-keyboard-layout-type kbd-type)) | |
17052 | 702 |
31424 | 703 (defun quail-keyboard-translate (char) |
704 "Translate CHAR to the one in the standard keyboard layout." | |
17052 | 705 (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
|
706 ;; All Quail packages are designed based on |
32c3f7d9ef10
(quail-keyboard-layout-alist): Add an
Kenichi Handa <handa@m17n.org>
parents:
19655
diff
changeset
|
707 ;; `quail-keyboard-layout-standard'. |
31424 | 708 char |
17052 | 709 (let ((i 0)) |
31424 | 710 ;; Find the key location on the current keyboard layout. |
17052 | 711 (while (and (< i quail-keyboard-layout-len) |
31424 | 712 (/= char (aref quail-keyboard-layout i))) |
17052 | 713 (setq i (1+ i))) |
714 (if (= i quail-keyboard-layout-len) | |
31424 | 715 ;; CHAR is not in quail-keyboard-layout, which means that a |
19675
32c3f7d9ef10
(quail-keyboard-layout-alist): Add an
Kenichi Handa <handa@m17n.org>
parents:
19655
diff
changeset
|
716 ;; user typed a key which generated a character code to be |
31424 | 717 ;; handled out of Quail. Just return CHAR and make |
19675
32c3f7d9ef10
(quail-keyboard-layout-alist): Add an
Kenichi Handa <handa@m17n.org>
parents:
19655
diff
changeset
|
718 ;; quail-execute-non-quail-command handle it correctly. |
31424 | 719 char |
720 (let ((ch (aref quail-keyboard-layout-standard i))) | |
721 (if (= ch ?\ ) | |
722 ;; This location not available in the standard keyboard | |
723 ;; layout. Check if the location is used to substitute | |
724 ;; for the other location of the standard layout. | |
725 (if (setq i (cdr (assq i quail-keyboard-layout-substitution))) | |
726 (aref quail-keyboard-layout-standard i) | |
727 ;; Just return CHAR as well as above. | |
728 char) | |
729 ch)))))) | |
730 | |
31828
c6cdd9deac21
(quail-help): The output message is improved.
Kenichi Handa <handa@m17n.org>
parents:
31584
diff
changeset
|
731 (defun quail-keyseq-translate (keyseq) |
c6cdd9deac21
(quail-help): The output message is improved.
Kenichi Handa <handa@m17n.org>
parents:
31584
diff
changeset
|
732 (apply 'string |
c6cdd9deac21
(quail-help): The output message is improved.
Kenichi Handa <handa@m17n.org>
parents:
31584
diff
changeset
|
733 (mapcar (function (lambda (x) (quail-keyboard-translate x))) |
c6cdd9deac21
(quail-help): The output message is improved.
Kenichi Handa <handa@m17n.org>
parents:
31584
diff
changeset
|
734 keyseq))) |
c6cdd9deac21
(quail-help): The output message is improved.
Kenichi Handa <handa@m17n.org>
parents:
31584
diff
changeset
|
735 |
31424 | 736 ;; Insert the visual keyboard layout table according to KBD-LAYOUT. |
737 ;; The format of KBD-LAYOUT is the same as `quail-keyboard-layout'. | |
738 (defun quail-insert-kbd-layout (kbd-layout) | |
739 (let (done-list layout i ch) | |
740 ;; At first, convert KBD-LAYOUT to the same size vector that | |
741 ;; contains translated character or string. | |
742 (setq layout (string-to-vector kbd-layout) | |
743 i 0) | |
744 (while (< i quail-keyboard-layout-len) | |
745 (setq ch (aref kbd-layout i)) | |
746 (if (quail-kbd-translate) | |
747 (setq ch (quail-keyboard-translate ch))) | |
748 (let* ((map (cdr (assq ch (cdr (quail-map))))) | |
749 (translation (and map (quail-get-translation | |
750 (car map) (char-to-string ch) 1)))) | |
751 (if translation | |
752 (progn | |
753 (if (consp translation) | |
754 (setq translation (aref (cdr translation) 0))) | |
755 (setq done-list (cons translation done-list))) | |
756 (setq translation ch)) | |
757 (aset layout i translation)) | |
758 (setq i (1+ i))) | |
759 | |
760 (let ((pos (point)) | |
761 (bar "|") | |
762 lower upper row) | |
763 ;; Make table without horizontal lines. Each column for a key | |
764 ;; has the form "| LU |" where L is for lower key and and U is | |
765 ;; for a upper key. If width of L (U) is greater than 1, | |
766 ;; preceding (following) space is not inserted. | |
767 (put-text-property 0 1 'face 'bold bar) | |
768 (setq i 0) | |
769 (while (< i quail-keyboard-layout-len) | |
770 (when (= (% i 30) 0) | |
771 (setq row (/ i 30)) | |
772 (if (> row 1) | |
773 (insert-char 32 (+ row (/ (- row 2) 2))))) | |
774 (setq lower (aref layout i) | |
775 upper (aref layout (1+ i))) | |
776 (if (and (integerp lower) (>= lower 128) (< lower 256)) | |
777 (setq lower (unibyte-char-to-multibyte lower))) | |
778 (if (and (integerp upper) (>= upper 128) (< upper 256)) | |
779 (setq upper (unibyte-char-to-multibyte upper))) | |
780 (insert bar) | |
781 (if (= (if (stringp lower) (string-width lower) (char-width lower)) 1) | |
782 (insert " ")) | |
783 (insert lower upper) | |
784 (if (= (if (stringp upper) (string-width upper) (char-width upper)) 1) | |
785 (insert " ")) | |
786 (setq i (+ i 2)) | |
787 (if (= (% i 30) 0) | |
788 (insert bar "\n"))) | |
789 ;; Insert horizontal lines while deleting blank key columns at the | |
790 ;; beginning and end of each line. | |
791 (save-restriction | |
792 (narrow-to-region pos (point)) | |
793 (goto-char pos) | |
794 ;;(while (looking-at "[| ]*$") | |
795 ;;(forward-line 1) | |
796 ;;(delete-region pos (point))) | |
797 (let ((from1 100) (to1 0) from2 to2) | |
798 (while (not (eobp)) | |
799 (if (looking-at "[| ]*$") | |
800 ;; The entire row is blank. | |
801 (delete-region (point) (match-end 0)) | |
802 ;; Delete blank key columns at the head. | |
803 (if (looking-at " *\\(| \\)+") | |
804 (subst-char-in-region (point) (match-end 0) ?| ? )) | |
805 ;; Delete blank key columns at the tail. | |
806 (if (re-search-forward "\\( |\\)+$" (line-end-position) t) | |
807 (delete-region (match-beginning 0) (point))) | |
808 (beginning-of-line)) | |
809 ;; Calculate the start and end columns of a horizontal line. | |
810 (if (eolp) | |
811 (setq from2 from1 to2 to1) | |
812 (skip-chars-forward " ") | |
813 (setq from2 (current-column)) | |
814 (end-of-line) | |
815 (setq to2 (current-column)) | |
816 (if (< from2 from1) | |
817 (setq from1 from2)) | |
818 (if (> to2 to1) | |
819 (setq to1 to2)) | |
820 (beginning-of-line)) | |
821 ;; If the previous or the current line has at least one key | |
822 ;; column, insert a horizontal line. | |
823 (when (> to1 0) | |
824 (insert-char 32 from1) | |
825 (setq pos (point)) | |
826 (insert "+") | |
827 (insert-char ?- (- (- to1 from1) 2)) | |
828 (insert "+") | |
829 (put-text-property pos (point) 'face 'bold) | |
830 (insert "\n")) | |
831 (setq from1 from2 to1 to2) | |
832 (forward-line 1))) | |
833 ;; Insert "space bar" box. | |
834 (forward-line -1) | |
835 (setq pos (point)) | |
836 (insert | |
837 " +-----------------------------+ | |
838 | space bar | | |
839 +-----------------------------+ | |
840 ") | |
841 (put-text-property pos (point) 'face 'bold) | |
842 (insert ?\n))) | |
843 | |
844 done-list)) | |
845 | |
846 ;;;###autoload | |
847 (defun quail-show-keyboard-layout (&optional keyboard-type) | |
31546
09bc2badb9e6
(quail-translation-docstring): New variable.
Kenichi Handa <handa@m17n.org>
parents:
31453
diff
changeset
|
848 "Show the physical layout of the keyboard type KEYBOARD-TYPE. |
09bc2badb9e6
(quail-translation-docstring): New variable.
Kenichi Handa <handa@m17n.org>
parents:
31453
diff
changeset
|
849 |
09bc2badb9e6
(quail-translation-docstring): New variable.
Kenichi Handa <handa@m17n.org>
parents:
31453
diff
changeset
|
850 The variable `quail-keyboard-layout-type' holds the currently selected |
09bc2badb9e6
(quail-translation-docstring): New variable.
Kenichi Handa <handa@m17n.org>
parents:
31453
diff
changeset
|
851 keyboard type." |
31424 | 852 (interactive |
853 (list (completing-read "Keyboard type (default, current choise): " | |
854 quail-keyboard-layout-alist | |
855 nil t))) | |
856 (or (and keyboard-type (> (length keyboard-type) 0)) | |
857 (setq keyboard-type quail-keyboard-layout-type)) | |
858 (let ((layout (assoc keyboard-type quail-keyboard-layout-alist))) | |
859 (or layout | |
860 (error "Unknown keyboard type: %s" keyboard-type)) | |
861 (with-output-to-temp-buffer "*Help*" | |
862 (save-excursion | |
863 (set-buffer standard-output) | |
864 (insert "Keyboard layout (keyboard type: " | |
865 keyboard-type | |
866 ")\n") | |
867 (quail-insert-kbd-layout (cdr layout)))))) | |
17052 | 868 |
869 ;; Quail map | |
870 | |
871 (defsubst quail-map-p (object) | |
872 "Return t if OBJECT is a Quail map. | |
873 | |
874 A Quail map holds information how a particular key should be translated. | |
875 Its format is (TRANSLATION . ALIST). | |
876 TRANSLATION is either a character, or a cons (INDEX . VECTOR). | |
877 In the latter case, each element of VECTOR is a candidate for the translation, | |
878 and INDEX points the currently selected translation. | |
879 | |
880 ALIST is normally a list of elements that look like (CHAR . DEFN), | |
881 where DEFN is another Quail map for a longer key (CHAR added to the | |
882 current key). It may also be a symbol of a function which returns an | |
883 alist of the above format. | |
884 | |
885 Just after a Quail package is read, TRANSLATION may be a string or a | |
886 vector. Then each element of the string or vector is a candidate for | |
887 the translation. These objects are transformed to cons cells in the | |
888 format \(INDEX . VECTOR), as described above." | |
889 (and (consp object) | |
890 (let ((translation (car object))) | |
18297
5c8e37591da5
(quail-current-data): New variable.
Kenichi Handa <handa@m17n.org>
parents:
18201
diff
changeset
|
891 (or (integerp translation) (null translation) |
17052 | 892 (vectorp translation) (stringp translation) |
18297
5c8e37591da5
(quail-current-data): New variable.
Kenichi Handa <handa@m17n.org>
parents:
18201
diff
changeset
|
893 (symbolp translation) |
5c8e37591da5
(quail-current-data): New variable.
Kenichi Handa <handa@m17n.org>
parents:
18201
diff
changeset
|
894 (and (consp translation) (not (vectorp (cdr translation)))))) |
17052 | 895 (let ((alist (cdr object))) |
18297
5c8e37591da5
(quail-current-data): New variable.
Kenichi Handa <handa@m17n.org>
parents:
18201
diff
changeset
|
896 (or (and (listp alist) (consp (car alist))) |
5c8e37591da5
(quail-current-data): New variable.
Kenichi Handa <handa@m17n.org>
parents:
18201
diff
changeset
|
897 (symbolp alist))))) |
17052 | 898 |
18297
5c8e37591da5
(quail-current-data): New variable.
Kenichi Handa <handa@m17n.org>
parents:
18201
diff
changeset
|
899 ;;;###autoload |
17052 | 900 (defmacro quail-define-rules (&rest rules) |
901 "Define translation rules of the current Quail package. | |
902 Each argument is a list of KEY and TRANSLATION. | |
903 KEY is a string meaning a sequence of keystrokes to be translated. | |
904 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
|
905 If it is a character, it is the sole translation of KEY. |
17052 | 906 If it is a string, each character is a candidate for the translation. |
907 If it is a vector, each element (string or character) is a candidate | |
908 for the translation. | |
909 In these cases, a key specific Quail map is generated and assigned to KEY. | |
910 | |
911 If TRANSLATION is a Quail map or a function symbol which returns a Quail map, | |
30656
321084a896d1
(quail-define-rules): Handle Quail decode
Kenichi Handa <handa@m17n.org>
parents:
29690
diff
changeset
|
912 it is used to handle KEY. |
321084a896d1
(quail-define-rules): Handle Quail decode
Kenichi Handa <handa@m17n.org>
parents:
29690
diff
changeset
|
913 |
321084a896d1
(quail-define-rules): Handle Quail decode
Kenichi Handa <handa@m17n.org>
parents:
29690
diff
changeset
|
914 The first argument may be an alist of annotations for the following |
321084a896d1
(quail-define-rules): Handle Quail decode
Kenichi Handa <handa@m17n.org>
parents:
29690
diff
changeset
|
915 rules. Each element has the form (ANNOTATION . VALUE), where |
321084a896d1
(quail-define-rules): Handle Quail decode
Kenichi Handa <handa@m17n.org>
parents:
29690
diff
changeset
|
916 ANNOTATION is a symbol indicating the annotation type. Currently |
321084a896d1
(quail-define-rules): Handle Quail decode
Kenichi Handa <handa@m17n.org>
parents:
29690
diff
changeset
|
917 the following annotation types are supported. |
321084a896d1
(quail-define-rules): Handle Quail decode
Kenichi Handa <handa@m17n.org>
parents:
29690
diff
changeset
|
918 |
321084a896d1
(quail-define-rules): Handle Quail decode
Kenichi Handa <handa@m17n.org>
parents:
29690
diff
changeset
|
919 append -- the value non-nil means that the following rules should |
321084a896d1
(quail-define-rules): Handle Quail decode
Kenichi Handa <handa@m17n.org>
parents:
29690
diff
changeset
|
920 be appended to the rules of the current Quail package. |
321084a896d1
(quail-define-rules): Handle Quail decode
Kenichi Handa <handa@m17n.org>
parents:
29690
diff
changeset
|
921 |
321084a896d1
(quail-define-rules): Handle Quail decode
Kenichi Handa <handa@m17n.org>
parents:
29690
diff
changeset
|
922 face -- the value is a face to use for displaying TRANSLATIONs in |
321084a896d1
(quail-define-rules): Handle Quail decode
Kenichi Handa <handa@m17n.org>
parents:
29690
diff
changeset
|
923 candidate list. |
321084a896d1
(quail-define-rules): Handle Quail decode
Kenichi Handa <handa@m17n.org>
parents:
29690
diff
changeset
|
924 |
321084a896d1
(quail-define-rules): Handle Quail decode
Kenichi Handa <handa@m17n.org>
parents:
29690
diff
changeset
|
925 advice -- the value is a function to call after one of RULES is |
321084a896d1
(quail-define-rules): Handle Quail decode
Kenichi Handa <handa@m17n.org>
parents:
29690
diff
changeset
|
926 selected. The function is called with one argument, the |
321084a896d1
(quail-define-rules): Handle Quail decode
Kenichi Handa <handa@m17n.org>
parents:
29690
diff
changeset
|
927 selected TRANSLATION string, after the TRANSLATION is |
321084a896d1
(quail-define-rules): Handle Quail decode
Kenichi Handa <handa@m17n.org>
parents:
29690
diff
changeset
|
928 inserted. |
321084a896d1
(quail-define-rules): Handle Quail decode
Kenichi Handa <handa@m17n.org>
parents:
29690
diff
changeset
|
929 |
321084a896d1
(quail-define-rules): Handle Quail decode
Kenichi Handa <handa@m17n.org>
parents:
29690
diff
changeset
|
930 no-decode-map --- the value non-nil means that decoding map is not |
321084a896d1
(quail-define-rules): Handle Quail decode
Kenichi Handa <handa@m17n.org>
parents:
29690
diff
changeset
|
931 generated for the following translations." |
321084a896d1
(quail-define-rules): Handle Quail decode
Kenichi Handa <handa@m17n.org>
parents:
29690
diff
changeset
|
932 (let ((l rules) |
321084a896d1
(quail-define-rules): Handle Quail decode
Kenichi Handa <handa@m17n.org>
parents:
29690
diff
changeset
|
933 append no-decode-map props) |
321084a896d1
(quail-define-rules): Handle Quail decode
Kenichi Handa <handa@m17n.org>
parents:
29690
diff
changeset
|
934 ;; If the first argument is an alist of annotations, handle them. |
321084a896d1
(quail-define-rules): Handle Quail decode
Kenichi Handa <handa@m17n.org>
parents:
29690
diff
changeset
|
935 (if (consp (car (car l))) |
321084a896d1
(quail-define-rules): Handle Quail decode
Kenichi Handa <handa@m17n.org>
parents:
29690
diff
changeset
|
936 (let ((annotations (car l))) |
321084a896d1
(quail-define-rules): Handle Quail decode
Kenichi Handa <handa@m17n.org>
parents:
29690
diff
changeset
|
937 (setq append (assq 'append annotations)) |
321084a896d1
(quail-define-rules): Handle Quail decode
Kenichi Handa <handa@m17n.org>
parents:
29690
diff
changeset
|
938 (if append |
321084a896d1
(quail-define-rules): Handle Quail decode
Kenichi Handa <handa@m17n.org>
parents:
29690
diff
changeset
|
939 (setq annotations (delete append annotations) |
321084a896d1
(quail-define-rules): Handle Quail decode
Kenichi Handa <handa@m17n.org>
parents:
29690
diff
changeset
|
940 append (cdr append))) |
321084a896d1
(quail-define-rules): Handle Quail decode
Kenichi Handa <handa@m17n.org>
parents:
29690
diff
changeset
|
941 (setq no-decode-map (assq 'no-decode-map annotations)) |
321084a896d1
(quail-define-rules): Handle Quail decode
Kenichi Handa <handa@m17n.org>
parents:
29690
diff
changeset
|
942 (if no-decode-map |
321084a896d1
(quail-define-rules): Handle Quail decode
Kenichi Handa <handa@m17n.org>
parents:
29690
diff
changeset
|
943 (setq annotations (delete no-decode-map annotations) |
321084a896d1
(quail-define-rules): Handle Quail decode
Kenichi Handa <handa@m17n.org>
parents:
29690
diff
changeset
|
944 no-decode-map (cdr no-decode-map))) |
321084a896d1
(quail-define-rules): Handle Quail decode
Kenichi Handa <handa@m17n.org>
parents:
29690
diff
changeset
|
945 ;; Convert the remaining annoations to property list PROPS. |
321084a896d1
(quail-define-rules): Handle Quail decode
Kenichi Handa <handa@m17n.org>
parents:
29690
diff
changeset
|
946 (while annotations |
321084a896d1
(quail-define-rules): Handle Quail decode
Kenichi Handa <handa@m17n.org>
parents:
29690
diff
changeset
|
947 (setq props |
321084a896d1
(quail-define-rules): Handle Quail decode
Kenichi Handa <handa@m17n.org>
parents:
29690
diff
changeset
|
948 (cons (car (car annotations)) |
321084a896d1
(quail-define-rules): Handle Quail decode
Kenichi Handa <handa@m17n.org>
parents:
29690
diff
changeset
|
949 (cons (cdr (car annotations)) |
321084a896d1
(quail-define-rules): Handle Quail decode
Kenichi Handa <handa@m17n.org>
parents:
29690
diff
changeset
|
950 props)) |
321084a896d1
(quail-define-rules): Handle Quail decode
Kenichi Handa <handa@m17n.org>
parents:
29690
diff
changeset
|
951 annotations (cdr annotations))) |
321084a896d1
(quail-define-rules): Handle Quail decode
Kenichi Handa <handa@m17n.org>
parents:
29690
diff
changeset
|
952 (setq l (cdr l)))) |
321084a896d1
(quail-define-rules): Handle Quail decode
Kenichi Handa <handa@m17n.org>
parents:
29690
diff
changeset
|
953 ;; Process the remaining arguments one by one. |
321084a896d1
(quail-define-rules): Handle Quail decode
Kenichi Handa <handa@m17n.org>
parents:
29690
diff
changeset
|
954 (if append |
321084a896d1
(quail-define-rules): Handle Quail decode
Kenichi Handa <handa@m17n.org>
parents:
29690
diff
changeset
|
955 ;; There's no way to add new rules at compiling time. |
321084a896d1
(quail-define-rules): Handle Quail decode
Kenichi Handa <handa@m17n.org>
parents:
29690
diff
changeset
|
956 `(let ((tail ',l) |
321084a896d1
(quail-define-rules): Handle Quail decode
Kenichi Handa <handa@m17n.org>
parents:
29690
diff
changeset
|
957 (map (quail-map)) |
321084a896d1
(quail-define-rules): Handle Quail decode
Kenichi Handa <handa@m17n.org>
parents:
29690
diff
changeset
|
958 (decode-map (and (quail-decode-map) (not ,no-decode-map))) |
321084a896d1
(quail-define-rules): Handle Quail decode
Kenichi Handa <handa@m17n.org>
parents:
29690
diff
changeset
|
959 (properties ',props) |
321084a896d1
(quail-define-rules): Handle Quail decode
Kenichi Handa <handa@m17n.org>
parents:
29690
diff
changeset
|
960 key trans) |
321084a896d1
(quail-define-rules): Handle Quail decode
Kenichi Handa <handa@m17n.org>
parents:
29690
diff
changeset
|
961 (while tail |
321084a896d1
(quail-define-rules): Handle Quail decode
Kenichi Handa <handa@m17n.org>
parents:
29690
diff
changeset
|
962 (setq key (car (car tail)) trans (car (cdr (car tail))) |
321084a896d1
(quail-define-rules): Handle Quail decode
Kenichi Handa <handa@m17n.org>
parents:
29690
diff
changeset
|
963 tail (cdr tail)) |
321084a896d1
(quail-define-rules): Handle Quail decode
Kenichi Handa <handa@m17n.org>
parents:
29690
diff
changeset
|
964 (quail-defrule-internal key trans map t decode-map properties))) |
321084a896d1
(quail-define-rules): Handle Quail decode
Kenichi Handa <handa@m17n.org>
parents:
29690
diff
changeset
|
965 ;; We can build up quail map and decode map at compiling time. |
321084a896d1
(quail-define-rules): Handle Quail decode
Kenichi Handa <handa@m17n.org>
parents:
29690
diff
changeset
|
966 (let ((map (list nil)) |
321084a896d1
(quail-define-rules): Handle Quail decode
Kenichi Handa <handa@m17n.org>
parents:
29690
diff
changeset
|
967 (decode-map (if (not no-decode-map) (list 'decode-map))) |
321084a896d1
(quail-define-rules): Handle Quail decode
Kenichi Handa <handa@m17n.org>
parents:
29690
diff
changeset
|
968 key trans) |
17052 | 969 (while l |
30656
321084a896d1
(quail-define-rules): Handle Quail decode
Kenichi Handa <handa@m17n.org>
parents:
29690
diff
changeset
|
970 (setq key (car (car l)) trans (car (cdr (car l))) l (cdr l)) |
321084a896d1
(quail-define-rules): Handle Quail decode
Kenichi Handa <handa@m17n.org>
parents:
29690
diff
changeset
|
971 (quail-defrule-internal key trans map t decode-map props)) |
321084a896d1
(quail-define-rules): Handle Quail decode
Kenichi Handa <handa@m17n.org>
parents:
29690
diff
changeset
|
972 `(if (not (quail-decode-map)) |
321084a896d1
(quail-define-rules): Handle Quail decode
Kenichi Handa <handa@m17n.org>
parents:
29690
diff
changeset
|
973 (quail-install-map ',map) |
321084a896d1
(quail-define-rules): Handle Quail decode
Kenichi Handa <handa@m17n.org>
parents:
29690
diff
changeset
|
974 (quail-install-map ',map) |
321084a896d1
(quail-define-rules): Handle Quail decode
Kenichi Handa <handa@m17n.org>
parents:
29690
diff
changeset
|
975 (quail-install-decode-map ',decode-map)))))) |
17052 | 976 |
18297
5c8e37591da5
(quail-current-data): New variable.
Kenichi Handa <handa@m17n.org>
parents:
18201
diff
changeset
|
977 ;;;###autoload |
26891
651d521c8f52
(quail-install-map): New optional arg
Kenichi Handa <handa@m17n.org>
parents:
24821
diff
changeset
|
978 (defun quail-install-map (map &optional name) |
17052 | 979 "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
|
980 |
651d521c8f52
(quail-install-map): New optional arg
Kenichi Handa <handa@m17n.org>
parents:
24821
diff
changeset
|
981 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
|
982 which to install MAP. |
651d521c8f52
(quail-install-map): New optional arg
Kenichi Handa <handa@m17n.org>
parents:
24821
diff
changeset
|
983 |
17052 | 984 The installed map can be referred by the function `quail-map'." |
985 (if (null quail-current-package) | |
986 (error "No current Quail package")) | |
987 (if (null (quail-map-p map)) | |
988 (error "Invalid Quail map `%s'" map)) | |
989 (setcar (cdr (cdr quail-current-package)) map)) | |
990 | |
18297
5c8e37591da5
(quail-current-data): New variable.
Kenichi Handa <handa@m17n.org>
parents:
18201
diff
changeset
|
991 ;;;###autoload |
30656
321084a896d1
(quail-define-rules): Handle Quail decode
Kenichi Handa <handa@m17n.org>
parents:
29690
diff
changeset
|
992 (defun quail-install-decode-map (decode-map &optional name) |
321084a896d1
(quail-define-rules): Handle Quail decode
Kenichi Handa <handa@m17n.org>
parents:
29690
diff
changeset
|
993 "Install the Quail decode map DECODE-MAP in the current Quail package. |
321084a896d1
(quail-define-rules): Handle Quail decode
Kenichi Handa <handa@m17n.org>
parents:
29690
diff
changeset
|
994 |
321084a896d1
(quail-define-rules): Handle Quail decode
Kenichi Handa <handa@m17n.org>
parents:
29690
diff
changeset
|
995 Optional 2nd arg NAME, if non-nil, is a name of Quail package for |
321084a896d1
(quail-define-rules): Handle Quail decode
Kenichi Handa <handa@m17n.org>
parents:
29690
diff
changeset
|
996 which to install MAP. |
321084a896d1
(quail-define-rules): Handle Quail decode
Kenichi Handa <handa@m17n.org>
parents:
29690
diff
changeset
|
997 |
321084a896d1
(quail-define-rules): Handle Quail decode
Kenichi Handa <handa@m17n.org>
parents:
29690
diff
changeset
|
998 The installed decode map can be referred by the function `quail-decode-map'." |
321084a896d1
(quail-define-rules): Handle Quail decode
Kenichi Handa <handa@m17n.org>
parents:
29690
diff
changeset
|
999 (if (null quail-current-package) |
321084a896d1
(quail-define-rules): Handle Quail decode
Kenichi Handa <handa@m17n.org>
parents:
29690
diff
changeset
|
1000 (error "No current Quail package")) |
321084a896d1
(quail-define-rules): Handle Quail decode
Kenichi Handa <handa@m17n.org>
parents:
29690
diff
changeset
|
1001 (if (not (and (consp decode-map) (eq (car decode-map) 'decode-map))) |
321084a896d1
(quail-define-rules): Handle Quail decode
Kenichi Handa <handa@m17n.org>
parents:
29690
diff
changeset
|
1002 (error "Invalid Quail decode map `%s'" decode-map)) |
321084a896d1
(quail-define-rules): Handle Quail decode
Kenichi Handa <handa@m17n.org>
parents:
29690
diff
changeset
|
1003 (setcar (nthcdr 10 quail-current-package) decode-map)) |
321084a896d1
(quail-define-rules): Handle Quail decode
Kenichi Handa <handa@m17n.org>
parents:
29690
diff
changeset
|
1004 |
321084a896d1
(quail-define-rules): Handle Quail decode
Kenichi Handa <handa@m17n.org>
parents:
29690
diff
changeset
|
1005 ;;;###autoload |
23401
a83ca83c8626
(quail-defrule): New optional arg APPEND.
Kenichi Handa <handa@m17n.org>
parents:
23304
diff
changeset
|
1006 (defun quail-defrule (key translation &optional name append) |
17052 | 1007 "Add one translation rule, KEY to TRANSLATION, in the current Quail package. |
1008 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
|
1009 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
|
1010 a function, or a cons. |
17052 | 1011 It it is a character, it is the sole translation of KEY. |
1012 If it is a string, each character is a candidate for the translation. | |
1013 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
|
1014 for the translation. |
18297
5c8e37591da5
(quail-current-data): New variable.
Kenichi Handa <handa@m17n.org>
parents:
18201
diff
changeset
|
1015 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
|
1016 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
|
1017 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
|
1018 the value itself is assigned to `quail-current-data'. |
17052 | 1019 In these cases, a key specific Quail map is generated and assigned to KEY. |
1020 | |
1021 If TRANSLATION is a Quail map or a function symbol which returns a Quail map, | |
1022 it is used to handle KEY. | |
23401
a83ca83c8626
(quail-defrule): New optional arg APPEND.
Kenichi Handa <handa@m17n.org>
parents:
23304
diff
changeset
|
1023 |
a83ca83c8626
(quail-defrule): New optional arg APPEND.
Kenichi Handa <handa@m17n.org>
parents:
23304
diff
changeset
|
1024 Optional 3rd argument NAME, if specified, says which Quail package |
17052 | 1025 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
|
1026 current Quail package. |
a83ca83c8626
(quail-defrule): New optional arg APPEND.
Kenichi Handa <handa@m17n.org>
parents:
23304
diff
changeset
|
1027 |
a83ca83c8626
(quail-defrule): New optional arg APPEND.
Kenichi Handa <handa@m17n.org>
parents:
23304
diff
changeset
|
1028 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
|
1029 to the current translations for KEY instead of replacing them." |
17052 | 1030 (if name |
1031 (let ((package (quail-package name))) | |
1032 (if (null package) | |
1033 (error "No Quail package `%s'" name)) | |
1034 (setq quail-current-package package))) | |
23401
a83ca83c8626
(quail-defrule): New optional arg APPEND.
Kenichi Handa <handa@m17n.org>
parents:
23304
diff
changeset
|
1035 (quail-defrule-internal key translation (quail-map) append)) |
17052 | 1036 |
18297
5c8e37591da5
(quail-current-data): New variable.
Kenichi Handa <handa@m17n.org>
parents:
18201
diff
changeset
|
1037 ;;;###autoload |
30656
321084a896d1
(quail-define-rules): Handle Quail decode
Kenichi Handa <handa@m17n.org>
parents:
29690
diff
changeset
|
1038 (defun quail-defrule-internal (key trans map &optional append decode-map props) |
321084a896d1
(quail-define-rules): Handle Quail decode
Kenichi Handa <handa@m17n.org>
parents:
29690
diff
changeset
|
1039 "Define KEY as TRANS in a Quail map MAP. |
321084a896d1
(quail-define-rules): Handle Quail decode
Kenichi Handa <handa@m17n.org>
parents:
29690
diff
changeset
|
1040 |
321084a896d1
(quail-define-rules): Handle Quail decode
Kenichi Handa <handa@m17n.org>
parents:
29690
diff
changeset
|
1041 If Optional 4th arg APPEND is non-nil, TRANS is appended to the |
321084a896d1
(quail-define-rules): Handle Quail decode
Kenichi Handa <handa@m17n.org>
parents:
29690
diff
changeset
|
1042 current translations for KEY instead of replacing them. |
321084a896d1
(quail-define-rules): Handle Quail decode
Kenichi Handa <handa@m17n.org>
parents:
29690
diff
changeset
|
1043 |
321084a896d1
(quail-define-rules): Handle Quail decode
Kenichi Handa <handa@m17n.org>
parents:
29690
diff
changeset
|
1044 Optional 5th arg DECODE-MAP is a Quail decode map. |
321084a896d1
(quail-define-rules): Handle Quail decode
Kenichi Handa <handa@m17n.org>
parents:
29690
diff
changeset
|
1045 |
321084a896d1
(quail-define-rules): Handle Quail decode
Kenichi Handa <handa@m17n.org>
parents:
29690
diff
changeset
|
1046 Optional 6th arg PROPS is a property list annotating TRANS. See the |
321084a896d1
(quail-define-rules): Handle Quail decode
Kenichi Handa <handa@m17n.org>
parents:
29690
diff
changeset
|
1047 function `quail-define-rules' for the detail." |
17052 | 1048 (if (null (stringp key)) |
1049 "Invalid Quail key `%s'" key) | |
1050 (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
|
1051 (consp trans) |
17052 | 1052 (symbolp trans) |
1053 (quail-map-p trans))) | |
1054 (error "Invalid Quail translation `%s'" trans)) | |
1055 (if (null (quail-map-p map)) | |
1056 (error "Invalid Quail map `%s'" map)) | |
1057 (let ((len (length key)) | |
1058 (idx 0) | |
1059 ch entry) | |
18297
5c8e37591da5
(quail-current-data): New variable.
Kenichi Handa <handa@m17n.org>
parents:
18201
diff
changeset
|
1060 ;; Make a map for registering TRANS if necessary. |
17052 | 1061 (while (< idx len) |
1062 (if (null (consp map)) | |
1063 ;; We come here, for example, when we try to define a rule | |
1064 ;; for "ABC" but a rule for "AB" is already defined as a | |
1065 ;; symbol. | |
1066 (error "Quail key %s is too long" key)) | |
1067 (setq ch (aref key idx) | |
1068 entry (assq ch (cdr map))) | |
1069 (if (null entry) | |
1070 (progn | |
1071 (setq entry (cons ch (list nil))) | |
1072 (setcdr map (cons entry (cdr map))))) | |
1073 (setq map (cdr entry)) | |
1074 (setq idx (1+ idx))) | |
1075 (if (symbolp trans) | |
1076 (if (cdr map) | |
1077 ;; We come here, for example, when we try to define a rule | |
1078 ;; for "AB" as a symbol but a rule for "ABC" is already | |
1079 ;; defined. | |
1080 (error "Quail key %s is too short" key) | |
1081 (setcdr entry trans)) | |
1082 (if (quail-map-p trans) | |
1083 (if (not (listp (cdr map))) | |
1084 ;; We come here, for example, when we try to define a rule | |
1085 ;; for "AB" as a symbol but a rule for "ABC" is already | |
1086 ;; defined. | |
1087 (error "Quail key %s is too short" key) | |
1088 (if (not (listp (cdr trans))) | |
1089 (if (cdr map) | |
1090 ;; We come here, for example, when we try to | |
1091 ;; define a rule for "AB" as a symbol but a rule | |
1092 ;; for "ABC" is already defined. | |
1093 (error "Quail key %s is too short" key) | |
1094 (setcdr entry trans)) | |
1095 (setcdr entry (append trans (cdr map))))) | |
30656
321084a896d1
(quail-define-rules): Handle Quail decode
Kenichi Handa <handa@m17n.org>
parents:
29690
diff
changeset
|
1096 ;; If PROPS is non-nil or DECODE-MAP is non-nil, convert TRANS |
321084a896d1
(quail-define-rules): Handle Quail decode
Kenichi Handa <handa@m17n.org>
parents:
29690
diff
changeset
|
1097 ;; to a vector of strings, add PROPS to each string and record |
321084a896d1
(quail-define-rules): Handle Quail decode
Kenichi Handa <handa@m17n.org>
parents:
29690
diff
changeset
|
1098 ;; this rule in DECODE-MAP. |
321084a896d1
(quail-define-rules): Handle Quail decode
Kenichi Handa <handa@m17n.org>
parents:
29690
diff
changeset
|
1099 (when (and (or props decode-map) |
321084a896d1
(quail-define-rules): Handle Quail decode
Kenichi Handa <handa@m17n.org>
parents:
29690
diff
changeset
|
1100 (not (consp trans)) (not (symbolp trans))) |
321084a896d1
(quail-define-rules): Handle Quail decode
Kenichi Handa <handa@m17n.org>
parents:
29690
diff
changeset
|
1101 (if (integerp trans) |
321084a896d1
(quail-define-rules): Handle Quail decode
Kenichi Handa <handa@m17n.org>
parents:
29690
diff
changeset
|
1102 (setq trans (vector trans)) |
321084a896d1
(quail-define-rules): Handle Quail decode
Kenichi Handa <handa@m17n.org>
parents:
29690
diff
changeset
|
1103 (if (stringp trans) |
321084a896d1
(quail-define-rules): Handle Quail decode
Kenichi Handa <handa@m17n.org>
parents:
29690
diff
changeset
|
1104 (setq trans (string-to-vector trans)))) |
321084a896d1
(quail-define-rules): Handle Quail decode
Kenichi Handa <handa@m17n.org>
parents:
29690
diff
changeset
|
1105 (let ((len (length trans)) |
321084a896d1
(quail-define-rules): Handle Quail decode
Kenichi Handa <handa@m17n.org>
parents:
29690
diff
changeset
|
1106 elt) |
321084a896d1
(quail-define-rules): Handle Quail decode
Kenichi Handa <handa@m17n.org>
parents:
29690
diff
changeset
|
1107 (while (> len 0) |
321084a896d1
(quail-define-rules): Handle Quail decode
Kenichi Handa <handa@m17n.org>
parents:
29690
diff
changeset
|
1108 (setq len (1- len)) |
321084a896d1
(quail-define-rules): Handle Quail decode
Kenichi Handa <handa@m17n.org>
parents:
29690
diff
changeset
|
1109 (setq elt (aref trans len)) |
321084a896d1
(quail-define-rules): Handle Quail decode
Kenichi Handa <handa@m17n.org>
parents:
29690
diff
changeset
|
1110 (if (integerp elt) |
321084a896d1
(quail-define-rules): Handle Quail decode
Kenichi Handa <handa@m17n.org>
parents:
29690
diff
changeset
|
1111 (setq elt (char-to-string elt))) |
321084a896d1
(quail-define-rules): Handle Quail decode
Kenichi Handa <handa@m17n.org>
parents:
29690
diff
changeset
|
1112 (aset trans len elt) |
321084a896d1
(quail-define-rules): Handle Quail decode
Kenichi Handa <handa@m17n.org>
parents:
29690
diff
changeset
|
1113 (if props |
321084a896d1
(quail-define-rules): Handle Quail decode
Kenichi Handa <handa@m17n.org>
parents:
29690
diff
changeset
|
1114 (add-text-properties 0 (length elt) props elt)) |
321084a896d1
(quail-define-rules): Handle Quail decode
Kenichi Handa <handa@m17n.org>
parents:
29690
diff
changeset
|
1115 (if decode-map |
321084a896d1
(quail-define-rules): Handle Quail decode
Kenichi Handa <handa@m17n.org>
parents:
29690
diff
changeset
|
1116 (setcdr decode-map |
321084a896d1
(quail-define-rules): Handle Quail decode
Kenichi Handa <handa@m17n.org>
parents:
29690
diff
changeset
|
1117 (cons (cons elt key) (cdr decode-map))))))) |
23401
a83ca83c8626
(quail-defrule): New optional arg APPEND.
Kenichi Handa <handa@m17n.org>
parents:
23304
diff
changeset
|
1118 (if (and (car map) append) |
a83ca83c8626
(quail-defrule): New optional arg APPEND.
Kenichi Handa <handa@m17n.org>
parents:
23304
diff
changeset
|
1119 (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
|
1120 (if (integerp prev) |
a83ca83c8626
(quail-defrule): New optional arg APPEND.
Kenichi Handa <handa@m17n.org>
parents:
23304
diff
changeset
|
1121 (setq prev (vector prev)) |
a83ca83c8626
(quail-defrule): New optional arg APPEND.
Kenichi Handa <handa@m17n.org>
parents:
23304
diff
changeset
|
1122 (setq prev (cdr prev))) |
a83ca83c8626
(quail-defrule): New optional arg APPEND.
Kenichi Handa <handa@m17n.org>
parents:
23304
diff
changeset
|
1123 (if (integerp trans) |
a83ca83c8626
(quail-defrule): New optional arg APPEND.
Kenichi Handa <handa@m17n.org>
parents:
23304
diff
changeset
|
1124 (setq trans (vector trans)) |
a83ca83c8626
(quail-defrule): New optional arg APPEND.
Kenichi Handa <handa@m17n.org>
parents:
23304
diff
changeset
|
1125 (if (stringp trans) |
a83ca83c8626
(quail-defrule): New optional arg APPEND.
Kenichi Handa <handa@m17n.org>
parents:
23304
diff
changeset
|
1126 (setq trans (string-to-vector trans)))) |
a83ca83c8626
(quail-defrule): New optional arg APPEND.
Kenichi Handa <handa@m17n.org>
parents:
23304
diff
changeset
|
1127 (setq trans |
a83ca83c8626
(quail-defrule): New optional arg APPEND.
Kenichi Handa <handa@m17n.org>
parents:
23304
diff
changeset
|
1128 (cons (list 0 0 0 0 nil) |
a83ca83c8626
(quail-defrule): New optional arg APPEND.
Kenichi Handa <handa@m17n.org>
parents:
23304
diff
changeset
|
1129 (vconcat prev trans))))) |
a83ca83c8626
(quail-defrule): New optional arg APPEND.
Kenichi Handa <handa@m17n.org>
parents:
23304
diff
changeset
|
1130 (setcar map trans))))) |
17052 | 1131 |
18297
5c8e37591da5
(quail-current-data): New variable.
Kenichi Handa <handa@m17n.org>
parents:
18201
diff
changeset
|
1132 (defun quail-get-translation (def key len) |
5c8e37591da5
(quail-current-data): New variable.
Kenichi Handa <handa@m17n.org>
parents:
18201
diff
changeset
|
1133 "Return the translation specified as DEF for KEY of length LEN. |
17052 | 1134 The translation is either a character or a cons of the form (INDEX . VECTOR), |
1135 where VECTOR is a vector of candidates (character or string) for | |
1136 the translation, and INDEX points into VECTOR to specify the currently | |
1137 selected translation." | |
18297
5c8e37591da5
(quail-current-data): New variable.
Kenichi Handa <handa@m17n.org>
parents:
18201
diff
changeset
|
1138 (if (and def (symbolp def)) |
26891
651d521c8f52
(quail-install-map): New optional arg
Kenichi Handa <handa@m17n.org>
parents:
24821
diff
changeset
|
1139 (if (functionp def) |
651d521c8f52
(quail-install-map): New optional arg
Kenichi Handa <handa@m17n.org>
parents:
24821
diff
changeset
|
1140 ;; 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
|
1141 (setq def (funcall def key len)) |
651d521c8f52
(quail-install-map): New optional arg
Kenichi Handa <handa@m17n.org>
parents:
24821
diff
changeset
|
1142 (setq def nil))) |
18297
5c8e37591da5
(quail-current-data): New variable.
Kenichi Handa <handa@m17n.org>
parents:
18201
diff
changeset
|
1143 (if (and (consp def) (not (vectorp (cdr def)))) |
5c8e37591da5
(quail-current-data): New variable.
Kenichi Handa <handa@m17n.org>
parents:
18201
diff
changeset
|
1144 (setq def (car def))) |
17052 | 1145 |
18297
5c8e37591da5
(quail-current-data): New variable.
Kenichi Handa <handa@m17n.org>
parents:
18201
diff
changeset
|
1146 (cond |
5c8e37591da5
(quail-current-data): New variable.
Kenichi Handa <handa@m17n.org>
parents:
18201
diff
changeset
|
1147 ((or (integerp def) (consp def)) |
5c8e37591da5
(quail-current-data): New variable.
Kenichi Handa <handa@m17n.org>
parents:
18201
diff
changeset
|
1148 def) |
5c8e37591da5
(quail-current-data): New variable.
Kenichi Handa <handa@m17n.org>
parents:
18201
diff
changeset
|
1149 |
5c8e37591da5
(quail-current-data): New variable.
Kenichi Handa <handa@m17n.org>
parents:
18201
diff
changeset
|
1150 ((null def) |
5c8e37591da5
(quail-current-data): New variable.
Kenichi Handa <handa@m17n.org>
parents:
18201
diff
changeset
|
1151 ;; No translation. |
5c8e37591da5
(quail-current-data): New variable.
Kenichi Handa <handa@m17n.org>
parents:
18201
diff
changeset
|
1152 nil) |
17052 | 1153 |
18297
5c8e37591da5
(quail-current-data): New variable.
Kenichi Handa <handa@m17n.org>
parents:
18201
diff
changeset
|
1154 ((stringp def) |
31424 | 1155 ;; If the length is 1, we don't need vector but a single candidate |
1156 ;; as the translation. | |
18297
5c8e37591da5
(quail-current-data): New variable.
Kenichi Handa <handa@m17n.org>
parents:
18201
diff
changeset
|
1157 (if (= (length def) 1) |
5c8e37591da5
(quail-current-data): New variable.
Kenichi Handa <handa@m17n.org>
parents:
18201
diff
changeset
|
1158 (aref def 0) |
31424 | 1159 ;; Each character in DEF is a candidate of translation. Reform |
1160 ;; it as (INDICES . VECTOR). | |
1161 (cons (list 0 0 0 0 nil) (string-to-vector def)))) | |
17052 | 1162 |
18297
5c8e37591da5
(quail-current-data): New variable.
Kenichi Handa <handa@m17n.org>
parents:
18201
diff
changeset
|
1163 ((vectorp def) |
31424 | 1164 ;; If the length is 1, and the length of element string is 1, we |
1165 ;; don't need vector but a single candidate as the translation. | |
1166 (if (and (= (length def) 1) | |
1167 (= (length (aref def 0)) 1)) | |
1168 (aref (aref def 0) 0) | |
1169 ;; Each element (string or character) in DEF is a candidate of | |
1170 ;; translation. Reform it as (INDICES . VECTOR). | |
1171 (cons (list 0 0 0 0 nil) def))) | |
17052 | 1172 |
18297
5c8e37591da5
(quail-current-data): New variable.
Kenichi Handa <handa@m17n.org>
parents:
18201
diff
changeset
|
1173 (t |
5c8e37591da5
(quail-current-data): New variable.
Kenichi Handa <handa@m17n.org>
parents:
18201
diff
changeset
|
1174 (error "Invalid object in Quail map: %s" def)))) |
17052 | 1175 |
18556
99e8ae18137f
(quail-guidance-buf): Make it buffer
Kenichi Handa <handa@m17n.org>
parents:
18377
diff
changeset
|
1176 (defun quail-lookup-key (key &optional len) |
17052 | 1177 "Lookup KEY of length LEN in the current Quail map and return the definition. |
1178 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
|
1179 (or len |
99e8ae18137f
(quail-guidance-buf): Make it buffer
Kenichi Handa <handa@m17n.org>
parents:
18377
diff
changeset
|
1180 (setq len (length key))) |
17052 | 1181 (let ((idx 0) |
1182 (map (quail-map)) | |
1183 (kbd-translate (quail-kbd-translate)) | |
18297
5c8e37591da5
(quail-current-data): New variable.
Kenichi Handa <handa@m17n.org>
parents:
18201
diff
changeset
|
1184 slot ch translation def) |
17052 | 1185 (while (and map (< idx len)) |
1186 (setq ch (if kbd-translate (quail-keyboard-translate (aref key idx)) | |
1187 (aref key idx))) | |
1188 (setq idx (1+ idx)) | |
1189 (if (and (cdr map) (symbolp (cdr map))) | |
1190 (setcdr map (funcall (cdr map) key idx))) | |
1191 (setq slot (assq ch (cdr map))) | |
1192 (if (and (cdr slot) (symbolp (cdr slot))) | |
1193 (setcdr slot (funcall (cdr slot) key idx))) | |
1194 (setq map (cdr slot))) | |
18297
5c8e37591da5
(quail-current-data): New variable.
Kenichi Handa <handa@m17n.org>
parents:
18201
diff
changeset
|
1195 (setq def (car map)) |
18556
99e8ae18137f
(quail-guidance-buf): Make it buffer
Kenichi Handa <handa@m17n.org>
parents:
18377
diff
changeset
|
1196 (setq quail-current-translations nil) |
18297
5c8e37591da5
(quail-current-data): New variable.
Kenichi Handa <handa@m17n.org>
parents:
18201
diff
changeset
|
1197 (if (and map (setq translation (quail-get-translation def key len))) |
17052 | 1198 (progn |
18297
5c8e37591da5
(quail-current-data): New variable.
Kenichi Handa <handa@m17n.org>
parents:
18201
diff
changeset
|
1199 (if (and (consp def) (not (vectorp (cdr def)))) |
5c8e37591da5
(quail-current-data): New variable.
Kenichi Handa <handa@m17n.org>
parents:
18201
diff
changeset
|
1200 (progn |
5c8e37591da5
(quail-current-data): New variable.
Kenichi Handa <handa@m17n.org>
parents:
18201
diff
changeset
|
1201 (if (not (equal (car def) translation)) |
5c8e37591da5
(quail-current-data): New variable.
Kenichi Handa <handa@m17n.org>
parents:
18201
diff
changeset
|
1202 ;; We must reflect TRANSLATION to car part of DEF. |
5c8e37591da5
(quail-current-data): New variable.
Kenichi Handa <handa@m17n.org>
parents:
18201
diff
changeset
|
1203 (setcar def translation)) |
5c8e37591da5
(quail-current-data): New variable.
Kenichi Handa <handa@m17n.org>
parents:
18201
diff
changeset
|
1204 (setq quail-current-data |
5c8e37591da5
(quail-current-data): New variable.
Kenichi Handa <handa@m17n.org>
parents:
18201
diff
changeset
|
1205 (if (functionp (cdr def)) |
5c8e37591da5
(quail-current-data): New variable.
Kenichi Handa <handa@m17n.org>
parents:
18201
diff
changeset
|
1206 (funcall (cdr def)) |
5c8e37591da5
(quail-current-data): New variable.
Kenichi Handa <handa@m17n.org>
parents:
18201
diff
changeset
|
1207 (cdr def)))) |
5c8e37591da5
(quail-current-data): New variable.
Kenichi Handa <handa@m17n.org>
parents:
18201
diff
changeset
|
1208 (if (not (equal def translation)) |
5c8e37591da5
(quail-current-data): New variable.
Kenichi Handa <handa@m17n.org>
parents:
18201
diff
changeset
|
1209 ;; We must reflect TRANSLATION to car part of MAP. |
5c8e37591da5
(quail-current-data): New variable.
Kenichi Handa <handa@m17n.org>
parents:
18201
diff
changeset
|
1210 (setcar map translation))) |
5c8e37591da5
(quail-current-data): New variable.
Kenichi Handa <handa@m17n.org>
parents:
18201
diff
changeset
|
1211 (if (and (consp translation) (vectorp (cdr translation))) |
17052 | 1212 (progn |
1213 (setq quail-current-translations translation) | |
1214 (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
|
1215 (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
|
1216 ;; 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
|
1217 (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
|
1218 (setcdr map (funcall (cdr map) key len))) |
17052 | 1219 map)) |
1220 | |
22765
7cf2c3800e8f
(quail-mode): This variable deleted.
Kenichi Handa <handa@m17n.org>
parents:
22124
diff
changeset
|
1221 (put 'quail-error 'error-conditions '(quail-error error)) |
7cf2c3800e8f
(quail-mode): This variable deleted.
Kenichi Handa <handa@m17n.org>
parents:
22124
diff
changeset
|
1222 (defun quail-error (&rest args) |
7cf2c3800e8f
(quail-mode): This variable deleted.
Kenichi Handa <handa@m17n.org>
parents:
22124
diff
changeset
|
1223 (signal 'quail-error (apply 'format args))) |
17052 | 1224 |
22765
7cf2c3800e8f
(quail-mode): This variable deleted.
Kenichi Handa <handa@m17n.org>
parents:
22124
diff
changeset
|
1225 (defvar quail-translating nil) |
7cf2c3800e8f
(quail-mode): This variable deleted.
Kenichi Handa <handa@m17n.org>
parents:
22124
diff
changeset
|
1226 (defvar quail-converting nil) |
22917
00f3497854c4
(quail-translation-keymap): Declare it as
Kenichi Handa <handa@m17n.org>
parents:
22883
diff
changeset
|
1227 (defvar quail-conversion-str nil) |
18201
feea31893155
(quail-prefix-arg): New variable.
Kenichi Handa <handa@m17n.org>
parents:
17764
diff
changeset
|
1228 |
22765
7cf2c3800e8f
(quail-mode): This variable deleted.
Kenichi Handa <handa@m17n.org>
parents:
22124
diff
changeset
|
1229 (defun quail-input-method (key) |
7cf2c3800e8f
(quail-mode): This variable deleted.
Kenichi Handa <handa@m17n.org>
parents:
22124
diff
changeset
|
1230 (if (or buffer-read-only |
22777
1b0761cbc15b
(quail-conversion-keymap): New binding
Kenichi Handa <handa@m17n.org>
parents:
22765
diff
changeset
|
1231 overriding-terminal-local-map |
1b0761cbc15b
(quail-conversion-keymap): New binding
Kenichi Handa <handa@m17n.org>
parents:
22765
diff
changeset
|
1232 overriding-local-map) |
22765
7cf2c3800e8f
(quail-mode): This variable deleted.
Kenichi Handa <handa@m17n.org>
parents:
22124
diff
changeset
|
1233 (list key) |
7cf2c3800e8f
(quail-mode): This variable deleted.
Kenichi Handa <handa@m17n.org>
parents:
22124
diff
changeset
|
1234 (quail-setup-overlays (quail-conversion-keymap)) |
22917
00f3497854c4
(quail-translation-keymap): Declare it as
Kenichi Handa <handa@m17n.org>
parents:
22883
diff
changeset
|
1235 (let ((modified-p (buffer-modified-p)) |
00f3497854c4
(quail-translation-keymap): Declare it as
Kenichi Handa <handa@m17n.org>
parents:
22883
diff
changeset
|
1236 (buffer-undo-list t)) |
00f3497854c4
(quail-translation-keymap): Declare it as
Kenichi Handa <handa@m17n.org>
parents:
22883
diff
changeset
|
1237 (or (and quail-guidance-win |
00f3497854c4
(quail-translation-keymap): Declare it as
Kenichi Handa <handa@m17n.org>
parents:
22883
diff
changeset
|
1238 (window-live-p quail-guidance-win) |
00f3497854c4
(quail-translation-keymap): Declare it as
Kenichi Handa <handa@m17n.org>
parents:
22883
diff
changeset
|
1239 (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
|
1240 (not input-method-use-echo-area)) |
00f3497854c4
(quail-translation-keymap): Declare it as
Kenichi Handa <handa@m17n.org>
parents:
22883
diff
changeset
|
1241 (quail-show-guidance-buf)) |
22765
7cf2c3800e8f
(quail-mode): This variable deleted.
Kenichi Handa <handa@m17n.org>
parents:
22124
diff
changeset
|
1242 (unwind-protect |
7cf2c3800e8f
(quail-mode): This variable deleted.
Kenichi Handa <handa@m17n.org>
parents:
22124
diff
changeset
|
1243 (if (quail-conversion-keymap) |
7cf2c3800e8f
(quail-mode): This variable deleted.
Kenichi Handa <handa@m17n.org>
parents:
22124
diff
changeset
|
1244 (quail-start-conversion key) |
7cf2c3800e8f
(quail-mode): This variable deleted.
Kenichi Handa <handa@m17n.org>
parents:
22124
diff
changeset
|
1245 (quail-start-translation key)) |
22777
1b0761cbc15b
(quail-conversion-keymap): New binding
Kenichi Handa <handa@m17n.org>
parents:
22765
diff
changeset
|
1246 (quail-delete-overlays) |
1b0761cbc15b
(quail-conversion-keymap): New binding
Kenichi Handa <handa@m17n.org>
parents:
22765
diff
changeset
|
1247 (if (buffer-live-p quail-guidance-buf) |
1b0761cbc15b
(quail-conversion-keymap): New binding
Kenichi Handa <handa@m17n.org>
parents:
22765
diff
changeset
|
1248 (save-excursion |
1b0761cbc15b
(quail-conversion-keymap): New binding
Kenichi Handa <handa@m17n.org>
parents:
22765
diff
changeset
|
1249 (set-buffer quail-guidance-buf) |
1b0761cbc15b
(quail-conversion-keymap): New binding
Kenichi Handa <handa@m17n.org>
parents:
22765
diff
changeset
|
1250 (erase-buffer))) |
34701
1afa708b89ea
(quail-input-method): Always hide the guidance buffer on exiting.
Kenichi Handa <handa@m17n.org>
parents:
34357
diff
changeset
|
1251 (quail-hide-guidance-buf) |
22765
7cf2c3800e8f
(quail-mode): This variable deleted.
Kenichi Handa <handa@m17n.org>
parents:
22124
diff
changeset
|
1252 (set-buffer-modified-p modified-p) |
22777
1b0761cbc15b
(quail-conversion-keymap): New binding
Kenichi Handa <handa@m17n.org>
parents:
22765
diff
changeset
|
1253 ;; 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
|
1254 ;; conversion. When conversion is required, the conversion function |
1b0761cbc15b
(quail-conversion-keymap): New binding
Kenichi Handa <handa@m17n.org>
parents:
22765
diff
changeset
|
1255 ;; should run this hook at a proper timing. |
1b0761cbc15b
(quail-conversion-keymap): New binding
Kenichi Handa <handa@m17n.org>
parents:
22765
diff
changeset
|
1256 (unless (quail-conversion-keymap) |
1b0761cbc15b
(quail-conversion-keymap): New binding
Kenichi Handa <handa@m17n.org>
parents:
22765
diff
changeset
|
1257 (run-hooks 'input-method-after-insert-chunk-hook)))))) |
22765
7cf2c3800e8f
(quail-mode): This variable deleted.
Kenichi Handa <handa@m17n.org>
parents:
22124
diff
changeset
|
1258 |
7cf2c3800e8f
(quail-mode): This variable deleted.
Kenichi Handa <handa@m17n.org>
parents:
22124
diff
changeset
|
1259 (defun quail-overlay-region-events (overlay) |
7cf2c3800e8f
(quail-mode): This variable deleted.
Kenichi Handa <handa@m17n.org>
parents:
22124
diff
changeset
|
1260 (let ((start (overlay-start overlay)) |
7cf2c3800e8f
(quail-mode): This variable deleted.
Kenichi Handa <handa@m17n.org>
parents:
22124
diff
changeset
|
1261 (end (overlay-end overlay))) |
7cf2c3800e8f
(quail-mode): This variable deleted.
Kenichi Handa <handa@m17n.org>
parents:
22124
diff
changeset
|
1262 (if (< start end) |
7cf2c3800e8f
(quail-mode): This variable deleted.
Kenichi Handa <handa@m17n.org>
parents:
22124
diff
changeset
|
1263 (prog1 |
7cf2c3800e8f
(quail-mode): This variable deleted.
Kenichi Handa <handa@m17n.org>
parents:
22124
diff
changeset
|
1264 (string-to-list (buffer-substring start end)) |
7cf2c3800e8f
(quail-mode): This variable deleted.
Kenichi Handa <handa@m17n.org>
parents:
22124
diff
changeset
|
1265 (delete-region start end))))) |
7cf2c3800e8f
(quail-mode): This variable deleted.
Kenichi Handa <handa@m17n.org>
parents:
22124
diff
changeset
|
1266 |
22917
00f3497854c4
(quail-translation-keymap): Declare it as
Kenichi Handa <handa@m17n.org>
parents:
22883
diff
changeset
|
1267 (defsubst quail-delete-region () |
00f3497854c4
(quail-translation-keymap): Declare it as
Kenichi Handa <handa@m17n.org>
parents:
22883
diff
changeset
|
1268 "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
|
1269 (if (overlay-start quail-overlay) |
00f3497854c4
(quail-translation-keymap): Declare it as
Kenichi Handa <handa@m17n.org>
parents:
22883
diff
changeset
|
1270 (delete-region (overlay-start quail-overlay) |
00f3497854c4
(quail-translation-keymap): Declare it as
Kenichi Handa <handa@m17n.org>
parents:
22883
diff
changeset
|
1271 (overlay-end quail-overlay)))) |
00f3497854c4
(quail-translation-keymap): Declare it as
Kenichi Handa <handa@m17n.org>
parents:
22883
diff
changeset
|
1272 |
22765
7cf2c3800e8f
(quail-mode): This variable deleted.
Kenichi Handa <handa@m17n.org>
parents:
22124
diff
changeset
|
1273 (defun quail-start-translation (key) |
7cf2c3800e8f
(quail-mode): This variable deleted.
Kenichi Handa <handa@m17n.org>
parents:
22124
diff
changeset
|
1274 "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
|
1275 ;; Check the possibility of translating KEY. |
22917
00f3497854c4
(quail-translation-keymap): Declare it as
Kenichi Handa <handa@m17n.org>
parents:
22883
diff
changeset
|
1276 ;; 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
|
1277 (if (or (and (integerp key) |
00f3497854c4
(quail-translation-keymap): Declare it as
Kenichi Handa <handa@m17n.org>
parents:
22883
diff
changeset
|
1278 (assq (if (quail-kbd-translate) |
00f3497854c4
(quail-translation-keymap): Declare it as
Kenichi Handa <handa@m17n.org>
parents:
22883
diff
changeset
|
1279 (quail-keyboard-translate key) key) |
00f3497854c4
(quail-translation-keymap): Declare it as
Kenichi Handa <handa@m17n.org>
parents:
22883
diff
changeset
|
1280 (cdr (quail-map)))) |
00f3497854c4
(quail-translation-keymap): Declare it as
Kenichi Handa <handa@m17n.org>
parents:
22883
diff
changeset
|
1281 (null key)) |
23176 | 1282 ;; OK, we can start translation. |
22917
00f3497854c4
(quail-translation-keymap): Declare it as
Kenichi Handa <handa@m17n.org>
parents:
22883
diff
changeset
|
1283 (let* ((echo-keystrokes 0) |
00f3497854c4
(quail-translation-keymap): Declare it as
Kenichi Handa <handa@m17n.org>
parents:
22883
diff
changeset
|
1284 (help-char nil) |
00f3497854c4
(quail-translation-keymap): Declare it as
Kenichi Handa <handa@m17n.org>
parents:
22883
diff
changeset
|
1285 (overriding-terminal-local-map (quail-translation-keymap)) |
22765
7cf2c3800e8f
(quail-mode): This variable deleted.
Kenichi Handa <handa@m17n.org>
parents:
22124
diff
changeset
|
1286 (generated-events nil) |
29145
79b2b42f9a7b
(quail-start-translation): Don't change
Kenichi Handa <handa@m17n.org>
parents:
29129
diff
changeset
|
1287 (input-method-function nil) |
79b2b42f9a7b
(quail-start-translation): Don't change
Kenichi Handa <handa@m17n.org>
parents:
29129
diff
changeset
|
1288 (modified-p (buffer-modified-p))) |
22765
7cf2c3800e8f
(quail-mode): This variable deleted.
Kenichi Handa <handa@m17n.org>
parents:
22124
diff
changeset
|
1289 (setq quail-current-key "" |
22917
00f3497854c4
(quail-translation-keymap): Declare it as
Kenichi Handa <handa@m17n.org>
parents:
22883
diff
changeset
|
1290 quail-current-str "" |
00f3497854c4
(quail-translation-keymap): Declare it as
Kenichi Handa <handa@m17n.org>
parents:
22883
diff
changeset
|
1291 quail-translating t) |
00f3497854c4
(quail-translation-keymap): Declare it as
Kenichi Handa <handa@m17n.org>
parents:
22883
diff
changeset
|
1292 (if key |
00f3497854c4
(quail-translation-keymap): Declare it as
Kenichi Handa <handa@m17n.org>
parents:
22883
diff
changeset
|
1293 (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
|
1294 (while quail-translating |
29145
79b2b42f9a7b
(quail-start-translation): Don't change
Kenichi Handa <handa@m17n.org>
parents:
29129
diff
changeset
|
1295 (set-buffer-modified-p modified-p) |
22917
00f3497854c4
(quail-translation-keymap): Declare it as
Kenichi Handa <handa@m17n.org>
parents:
22883
diff
changeset
|
1296 (let* ((keyseq (read-key-sequence |
00f3497854c4
(quail-translation-keymap): Declare it as
Kenichi Handa <handa@m17n.org>
parents:
22883
diff
changeset
|
1297 (and input-method-use-echo-area |
00f3497854c4
(quail-translation-keymap): Declare it as
Kenichi Handa <handa@m17n.org>
parents:
22883
diff
changeset
|
1298 (concat input-method-previous-message |
23599
ab69e7987be0
(quail-start-translation): Handle
Kenichi Handa <handa@m17n.org>
parents:
23401
diff
changeset
|
1299 quail-current-str)) |
ab69e7987be0
(quail-start-translation): Handle
Kenichi Handa <handa@m17n.org>
parents:
23401
diff
changeset
|
1300 nil nil t)) |
22917
00f3497854c4
(quail-translation-keymap): Declare it as
Kenichi Handa <handa@m17n.org>
parents:
22883
diff
changeset
|
1301 (cmd (lookup-key (quail-translation-keymap) keyseq))) |
00f3497854c4
(quail-translation-keymap): Declare it as
Kenichi Handa <handa@m17n.org>
parents:
22883
diff
changeset
|
1302 (if (if key |
00f3497854c4
(quail-translation-keymap): Declare it as
Kenichi Handa <handa@m17n.org>
parents:
22883
diff
changeset
|
1303 (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
|
1304 (eq cmd 'quail-self-insert-command)) |
31284
599904d1058b
(quail-start-translation): Bind locally
Kenichi Handa <handa@m17n.org>
parents:
31247
diff
changeset
|
1305 (let ((last-command-event (aref keyseq (1- (length keyseq)))) |
599904d1058b
(quail-start-translation): Bind locally
Kenichi Handa <handa@m17n.org>
parents:
31247
diff
changeset
|
1306 (last-command this-command) |
599904d1058b
(quail-start-translation): Bind locally
Kenichi Handa <handa@m17n.org>
parents:
31247
diff
changeset
|
1307 (this-command cmd)) |
22917
00f3497854c4
(quail-translation-keymap): Declare it as
Kenichi Handa <handa@m17n.org>
parents:
22883
diff
changeset
|
1308 (setq key t) |
22765
7cf2c3800e8f
(quail-mode): This variable deleted.
Kenichi Handa <handa@m17n.org>
parents:
22124
diff
changeset
|
1309 (condition-case err |
7cf2c3800e8f
(quail-mode): This variable deleted.
Kenichi Handa <handa@m17n.org>
parents:
22124
diff
changeset
|
1310 (call-interactively cmd) |
7cf2c3800e8f
(quail-mode): This variable deleted.
Kenichi Handa <handa@m17n.org>
parents:
22124
diff
changeset
|
1311 (quail-error (message "%s" (cdr err)) (beep)))) |
7cf2c3800e8f
(quail-mode): This variable deleted.
Kenichi Handa <handa@m17n.org>
parents:
22124
diff
changeset
|
1312 ;; KEYSEQ is not defined in the translation keymap. |
7cf2c3800e8f
(quail-mode): This variable deleted.
Kenichi Handa <handa@m17n.org>
parents:
22124
diff
changeset
|
1313 ;; 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
|
1314 (setq unread-command-events |
22917
00f3497854c4
(quail-translation-keymap): Declare it as
Kenichi Handa <handa@m17n.org>
parents:
22883
diff
changeset
|
1315 (string-to-list (this-single-command-raw-keys))) |
00f3497854c4
(quail-translation-keymap): Declare it as
Kenichi Handa <handa@m17n.org>
parents:
22883
diff
changeset
|
1316 (setq quail-translating nil)))) |
00f3497854c4
(quail-translation-keymap): Declare it as
Kenichi Handa <handa@m17n.org>
parents:
22883
diff
changeset
|
1317 (quail-delete-region) |
00f3497854c4
(quail-translation-keymap): Declare it as
Kenichi Handa <handa@m17n.org>
parents:
22883
diff
changeset
|
1318 (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
|
1319 (let* ((len (length quail-current-str)) |
651d521c8f52
(quail-install-map): New optional arg
Kenichi Handa <handa@m17n.org>
parents:
24821
diff
changeset
|
1320 (idx 0) |
651d521c8f52
(quail-install-map): New optional arg
Kenichi Handa <handa@m17n.org>
parents:
24821
diff
changeset
|
1321 (val (find-composition 0 len quail-current-str)) |
30656
321084a896d1
(quail-define-rules): Handle Quail decode
Kenichi Handa <handa@m17n.org>
parents:
29690
diff
changeset
|
1322 (advice (get-text-property idx 'advice quail-current-str)) |
26891
651d521c8f52
(quail-install-map): New optional arg
Kenichi Handa <handa@m17n.org>
parents:
24821
diff
changeset
|
1323 char) |
30656
321084a896d1
(quail-define-rules): Handle Quail decode
Kenichi Handa <handa@m17n.org>
parents:
29690
diff
changeset
|
1324 ;; If the selected input has `advice' function, generate |
321084a896d1
(quail-define-rules): Handle Quail decode
Kenichi Handa <handa@m17n.org>
parents:
29690
diff
changeset
|
1325 ;; a special event (quail-advice QUAIL-CURRENT-STR). |
321084a896d1
(quail-define-rules): Handle Quail decode
Kenichi Handa <handa@m17n.org>
parents:
29690
diff
changeset
|
1326 (if advice |
321084a896d1
(quail-define-rules): Handle Quail decode
Kenichi Handa <handa@m17n.org>
parents:
29690
diff
changeset
|
1327 (setq generated-events |
321084a896d1
(quail-define-rules): Handle Quail decode
Kenichi Handa <handa@m17n.org>
parents:
29690
diff
changeset
|
1328 (cons (list 'quail-advice quail-current-str) |
321084a896d1
(quail-define-rules): Handle Quail decode
Kenichi Handa <handa@m17n.org>
parents:
29690
diff
changeset
|
1329 generated-events))) |
26891
651d521c8f52
(quail-install-map): New optional arg
Kenichi Handa <handa@m17n.org>
parents:
24821
diff
changeset
|
1330 ;; 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
|
1331 ;; generated-events while interleaving it with a special |
651d521c8f52
(quail-install-map): New optional arg
Kenichi Handa <handa@m17n.org>
parents:
24821
diff
changeset
|
1332 ;; event (compose-last-chars LEN) at each composition |
651d521c8f52
(quail-install-map): New optional arg
Kenichi Handa <handa@m17n.org>
parents:
24821
diff
changeset
|
1333 ;; end. |
651d521c8f52
(quail-install-map): New optional arg
Kenichi Handa <handa@m17n.org>
parents:
24821
diff
changeset
|
1334 (while (<= idx len) |
651d521c8f52
(quail-install-map): New optional arg
Kenichi Handa <handa@m17n.org>
parents:
24821
diff
changeset
|
1335 (when (and val (= idx (nth 1 val))) |
651d521c8f52
(quail-install-map): New optional arg
Kenichi Handa <handa@m17n.org>
parents:
24821
diff
changeset
|
1336 (setq generated-events |
651d521c8f52
(quail-install-map): New optional arg
Kenichi Handa <handa@m17n.org>
parents:
24821
diff
changeset
|
1337 (cons (list 'compose-last-chars (- idx (car val))) |
651d521c8f52
(quail-install-map): New optional arg
Kenichi Handa <handa@m17n.org>
parents:
24821
diff
changeset
|
1338 generated-events)) |
651d521c8f52
(quail-install-map): New optional arg
Kenichi Handa <handa@m17n.org>
parents:
24821
diff
changeset
|
1339 (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
|
1340 (when (< idx len) |
651d521c8f52
(quail-install-map): New optional arg
Kenichi Handa <handa@m17n.org>
parents:
24821
diff
changeset
|
1341 (setq char (aref quail-current-str idx)) |
651d521c8f52
(quail-install-map): New optional arg
Kenichi Handa <handa@m17n.org>
parents:
24821
diff
changeset
|
1342 (or enable-multibyte-characters |
651d521c8f52
(quail-install-map): New optional arg
Kenichi Handa <handa@m17n.org>
parents:
24821
diff
changeset
|
1343 (setq char (multibyte-char-to-unibyte char))) |
651d521c8f52
(quail-install-map): New optional arg
Kenichi Handa <handa@m17n.org>
parents:
24821
diff
changeset
|
1344 (setq generated-events (cons char generated-events))) |
651d521c8f52
(quail-install-map): New optional arg
Kenichi Handa <handa@m17n.org>
parents:
24821
diff
changeset
|
1345 (setq idx (1+ idx))) |
651d521c8f52
(quail-install-map): New optional arg
Kenichi Handa <handa@m17n.org>
parents:
24821
diff
changeset
|
1346 ;; Reorder generated-events. |
651d521c8f52
(quail-install-map): New optional arg
Kenichi Handa <handa@m17n.org>
parents:
24821
diff
changeset
|
1347 (setq generated-events (nreverse generated-events)))) |
22917
00f3497854c4
(quail-translation-keymap): Declare it as
Kenichi Handa <handa@m17n.org>
parents:
22883
diff
changeset
|
1348 (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
|
1349 (list (car generated-events)) |
00f3497854c4
(quail-translation-keymap): Declare it as
Kenichi Handa <handa@m17n.org>
parents:
22883
diff
changeset
|
1350 generated-events)) |
17052 | 1351 |
22765
7cf2c3800e8f
(quail-mode): This variable deleted.
Kenichi Handa <handa@m17n.org>
parents:
22124
diff
changeset
|
1352 ;; Since KEY doesn't start any translation, just return it. |
31828
c6cdd9deac21
(quail-help): The output message is improved.
Kenichi Handa <handa@m17n.org>
parents:
31584
diff
changeset
|
1353 ;; But translate KEY if necessary. |
31584
a5e682286ab6
(quail-start-translation): Translate KEY if necessary even if it
Kenichi Handa <handa@m17n.org>
parents:
31549
diff
changeset
|
1354 (if (and (integerp key) |
a5e682286ab6
(quail-start-translation): Translate KEY if necessary even if it
Kenichi Handa <handa@m17n.org>
parents:
31549
diff
changeset
|
1355 (quail-kbd-translate)) |
a5e682286ab6
(quail-start-translation): Translate KEY if necessary even if it
Kenichi Handa <handa@m17n.org>
parents:
31549
diff
changeset
|
1356 (setq key (quail-keyboard-translate key))) |
22765
7cf2c3800e8f
(quail-mode): This variable deleted.
Kenichi Handa <handa@m17n.org>
parents:
22124
diff
changeset
|
1357 (list key))) |
17052 | 1358 |
22765
7cf2c3800e8f
(quail-mode): This variable deleted.
Kenichi Handa <handa@m17n.org>
parents:
22124
diff
changeset
|
1359 (defun quail-start-conversion (key) |
7cf2c3800e8f
(quail-mode): This variable deleted.
Kenichi Handa <handa@m17n.org>
parents:
22124
diff
changeset
|
1360 "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
|
1361 ;; Check the possibility of translating KEY. |
22917
00f3497854c4
(quail-translation-keymap): Declare it as
Kenichi Handa <handa@m17n.org>
parents:
22883
diff
changeset
|
1362 ;; 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
|
1363 (if (or (and (integerp key) |
00f3497854c4
(quail-translation-keymap): Declare it as
Kenichi Handa <handa@m17n.org>
parents:
22883
diff
changeset
|
1364 (assq (if (quail-kbd-translate) |
00f3497854c4
(quail-translation-keymap): Declare it as
Kenichi Handa <handa@m17n.org>
parents:
22883
diff
changeset
|
1365 (quail-keyboard-translate key) key) |
00f3497854c4
(quail-translation-keymap): Declare it as
Kenichi Handa <handa@m17n.org>
parents:
22883
diff
changeset
|
1366 (cdr (quail-map)))) |
00f3497854c4
(quail-translation-keymap): Declare it as
Kenichi Handa <handa@m17n.org>
parents:
22883
diff
changeset
|
1367 (null key)) |
22765
7cf2c3800e8f
(quail-mode): This variable deleted.
Kenichi Handa <handa@m17n.org>
parents:
22124
diff
changeset
|
1368 ;; Ok, we can start translation and conversion. |
22917
00f3497854c4
(quail-translation-keymap): Declare it as
Kenichi Handa <handa@m17n.org>
parents:
22883
diff
changeset
|
1369 (let* ((echo-keystrokes 0) |
00f3497854c4
(quail-translation-keymap): Declare it as
Kenichi Handa <handa@m17n.org>
parents:
22883
diff
changeset
|
1370 (help-char nil) |
00f3497854c4
(quail-translation-keymap): Declare it as
Kenichi Handa <handa@m17n.org>
parents:
22883
diff
changeset
|
1371 (overriding-terminal-local-map (quail-conversion-keymap)) |
22765
7cf2c3800e8f
(quail-mode): This variable deleted.
Kenichi Handa <handa@m17n.org>
parents:
22124
diff
changeset
|
1372 (generated-events nil) |
29145
79b2b42f9a7b
(quail-start-translation): Don't change
Kenichi Handa <handa@m17n.org>
parents:
29129
diff
changeset
|
1373 (input-method-function nil) |
79b2b42f9a7b
(quail-start-translation): Don't change
Kenichi Handa <handa@m17n.org>
parents:
29129
diff
changeset
|
1374 (modified-p (buffer-modified-p))) |
22765
7cf2c3800e8f
(quail-mode): This variable deleted.
Kenichi Handa <handa@m17n.org>
parents:
22124
diff
changeset
|
1375 (setq quail-current-key "" |
22917
00f3497854c4
(quail-translation-keymap): Declare it as
Kenichi Handa <handa@m17n.org>
parents:
22883
diff
changeset
|
1376 quail-current-str "" |
00f3497854c4
(quail-translation-keymap): Declare it as
Kenichi Handa <handa@m17n.org>
parents:
22883
diff
changeset
|
1377 quail-translating t |
22765
7cf2c3800e8f
(quail-mode): This variable deleted.
Kenichi Handa <handa@m17n.org>
parents:
22124
diff
changeset
|
1378 quail-converting t |
22917
00f3497854c4
(quail-translation-keymap): Declare it as
Kenichi Handa <handa@m17n.org>
parents:
22883
diff
changeset
|
1379 quail-conversion-str "") |
00f3497854c4
(quail-translation-keymap): Declare it as
Kenichi Handa <handa@m17n.org>
parents:
22883
diff
changeset
|
1380 (if key |
00f3497854c4
(quail-translation-keymap): Declare it as
Kenichi Handa <handa@m17n.org>
parents:
22883
diff
changeset
|
1381 (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
|
1382 (while quail-converting |
29145
79b2b42f9a7b
(quail-start-translation): Don't change
Kenichi Handa <handa@m17n.org>
parents:
29129
diff
changeset
|
1383 (set-buffer-modified-p modified-p) |
22765
7cf2c3800e8f
(quail-mode): This variable deleted.
Kenichi Handa <handa@m17n.org>
parents:
22124
diff
changeset
|
1384 (or quail-translating |
7cf2c3800e8f
(quail-mode): This variable deleted.
Kenichi Handa <handa@m17n.org>
parents:
22124
diff
changeset
|
1385 (progn |
7cf2c3800e8f
(quail-mode): This variable deleted.
Kenichi Handa <handa@m17n.org>
parents:
22124
diff
changeset
|
1386 (setq quail-current-key "" |
22917
00f3497854c4
(quail-translation-keymap): Declare it as
Kenichi Handa <handa@m17n.org>
parents:
22883
diff
changeset
|
1387 quail-current-str "" |
22765
7cf2c3800e8f
(quail-mode): This variable deleted.
Kenichi Handa <handa@m17n.org>
parents:
22124
diff
changeset
|
1388 quail-translating t) |
7cf2c3800e8f
(quail-mode): This variable deleted.
Kenichi Handa <handa@m17n.org>
parents:
22124
diff
changeset
|
1389 (quail-setup-overlays nil))) |
31217
8e8fa4dbc0bc
(quail-use-package): Hide "... loaded" message.
Kenichi Handa <handa@m17n.org>
parents:
30656
diff
changeset
|
1390 ;; Hide '... loaded' message. |
8e8fa4dbc0bc
(quail-use-package): Hide "... loaded" message.
Kenichi Handa <handa@m17n.org>
parents:
30656
diff
changeset
|
1391 (message nil) |
22917
00f3497854c4
(quail-translation-keymap): Declare it as
Kenichi Handa <handa@m17n.org>
parents:
22883
diff
changeset
|
1392 (let* ((keyseq (read-key-sequence |
00f3497854c4
(quail-translation-keymap): Declare it as
Kenichi Handa <handa@m17n.org>
parents:
22883
diff
changeset
|
1393 (and input-method-use-echo-area |
00f3497854c4
(quail-translation-keymap): Declare it as
Kenichi Handa <handa@m17n.org>
parents:
22883
diff
changeset
|
1394 (concat input-method-previous-message |
00f3497854c4
(quail-translation-keymap): Declare it as
Kenichi Handa <handa@m17n.org>
parents:
22883
diff
changeset
|
1395 quail-conversion-str |
23599
ab69e7987be0
(quail-start-translation): Handle
Kenichi Handa <handa@m17n.org>
parents:
23401
diff
changeset
|
1396 quail-current-str)) |
ab69e7987be0
(quail-start-translation): Handle
Kenichi Handa <handa@m17n.org>
parents:
23401
diff
changeset
|
1397 nil nil t)) |
22917
00f3497854c4
(quail-translation-keymap): Declare it as
Kenichi Handa <handa@m17n.org>
parents:
22883
diff
changeset
|
1398 (cmd (lookup-key (quail-conversion-keymap) keyseq))) |
00f3497854c4
(quail-translation-keymap): Declare it as
Kenichi Handa <handa@m17n.org>
parents:
22883
diff
changeset
|
1399 (if (if key (commandp cmd) (eq cmd 'quail-self-insert-command)) |
31284
599904d1058b
(quail-start-translation): Bind locally
Kenichi Handa <handa@m17n.org>
parents:
31247
diff
changeset
|
1400 (let ((last-command-event (aref keyseq (1- (length keyseq)))) |
599904d1058b
(quail-start-translation): Bind locally
Kenichi Handa <handa@m17n.org>
parents:
31247
diff
changeset
|
1401 (last-command this-command) |
599904d1058b
(quail-start-translation): Bind locally
Kenichi Handa <handa@m17n.org>
parents:
31247
diff
changeset
|
1402 (this-command cmd)) |
22917
00f3497854c4
(quail-translation-keymap): Declare it as
Kenichi Handa <handa@m17n.org>
parents:
22883
diff
changeset
|
1403 (setq key t) |
22765
7cf2c3800e8f
(quail-mode): This variable deleted.
Kenichi Handa <handa@m17n.org>
parents:
22124
diff
changeset
|
1404 (condition-case err |
7cf2c3800e8f
(quail-mode): This variable deleted.
Kenichi Handa <handa@m17n.org>
parents:
22124
diff
changeset
|
1405 (call-interactively cmd) |
22917
00f3497854c4
(quail-translation-keymap): Declare it as
Kenichi Handa <handa@m17n.org>
parents:
22883
diff
changeset
|
1406 (quail-error (message "%s" (cdr err)) (beep))) |
00f3497854c4
(quail-translation-keymap): Declare it as
Kenichi Handa <handa@m17n.org>
parents:
22883
diff
changeset
|
1407 (or quail-translating |
00f3497854c4
(quail-translation-keymap): Declare it as
Kenichi Handa <handa@m17n.org>
parents:
22883
diff
changeset
|
1408 (progn |
00f3497854c4
(quail-translation-keymap): Declare it as
Kenichi Handa <handa@m17n.org>
parents:
22883
diff
changeset
|
1409 (if quail-current-str |
00f3497854c4
(quail-translation-keymap): Declare it as
Kenichi Handa <handa@m17n.org>
parents:
22883
diff
changeset
|
1410 (setq quail-conversion-str |
00f3497854c4
(quail-translation-keymap): Declare it as
Kenichi Handa <handa@m17n.org>
parents:
22883
diff
changeset
|
1411 (concat quail-conversion-str |
00f3497854c4
(quail-translation-keymap): Declare it as
Kenichi Handa <handa@m17n.org>
parents:
22883
diff
changeset
|
1412 (if (stringp quail-current-str) |
00f3497854c4
(quail-translation-keymap): Declare it as
Kenichi Handa <handa@m17n.org>
parents:
22883
diff
changeset
|
1413 quail-current-str |
00f3497854c4
(quail-translation-keymap): Declare it as
Kenichi Handa <handa@m17n.org>
parents:
22883
diff
changeset
|
1414 (char-to-string quail-current-str))))) |
29326
44c929164604
(quail-start-conversion): Don't include
Kenichi Handa <handa@m17n.org>
parents:
29145
diff
changeset
|
1415 (if (or input-method-exit-on-first-char |
44c929164604
(quail-start-conversion): Don't include
Kenichi Handa <handa@m17n.org>
parents:
29145
diff
changeset
|
1416 (= (length quail-conversion-str) 0)) |
22917
00f3497854c4
(quail-translation-keymap): Declare it as
Kenichi Handa <handa@m17n.org>
parents:
22883
diff
changeset
|
1417 (setq quail-converting nil))))) |
22765
7cf2c3800e8f
(quail-mode): This variable deleted.
Kenichi Handa <handa@m17n.org>
parents:
22124
diff
changeset
|
1418 ;; KEYSEQ is not defined in the conversion keymap. |
7cf2c3800e8f
(quail-mode): This variable deleted.
Kenichi Handa <handa@m17n.org>
parents:
22124
diff
changeset
|
1419 ;; 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
|
1420 (setq unread-command-events |
22917
00f3497854c4
(quail-translation-keymap): Declare it as
Kenichi Handa <handa@m17n.org>
parents:
22883
diff
changeset
|
1421 (string-to-list (this-single-command-raw-keys))) |
00f3497854c4
(quail-translation-keymap): Declare it as
Kenichi Handa <handa@m17n.org>
parents:
22883
diff
changeset
|
1422 (setq quail-converting nil)))) |
22793
c3ab1de66dfc
(quail-simple-translation-keymap): Typo
Kenichi Handa <handa@m17n.org>
parents:
22777
diff
changeset
|
1423 (if (overlay-start quail-conv-overlay) |
22917
00f3497854c4
(quail-translation-keymap): Declare it as
Kenichi Handa <handa@m17n.org>
parents:
22883
diff
changeset
|
1424 (delete-region (overlay-start quail-conv-overlay) |
00f3497854c4
(quail-translation-keymap): Declare it as
Kenichi Handa <handa@m17n.org>
parents:
22883
diff
changeset
|
1425 (overlay-end quail-conv-overlay))) |
00f3497854c4
(quail-translation-keymap): Declare it as
Kenichi Handa <handa@m17n.org>
parents:
22883
diff
changeset
|
1426 (if (> (length quail-conversion-str) 0) |
22793
c3ab1de66dfc
(quail-simple-translation-keymap): Typo
Kenichi Handa <handa@m17n.org>
parents:
22777
diff
changeset
|
1427 (setq generated-events |
29326
44c929164604
(quail-start-conversion): Don't include
Kenichi Handa <handa@m17n.org>
parents:
29145
diff
changeset
|
1428 (string-to-list |
44c929164604
(quail-start-conversion): Don't include
Kenichi Handa <handa@m17n.org>
parents:
29145
diff
changeset
|
1429 (if enable-multibyte-characters |
44c929164604
(quail-start-conversion): Don't include
Kenichi Handa <handa@m17n.org>
parents:
29145
diff
changeset
|
1430 quail-conversion-str |
44c929164604
(quail-start-conversion): Don't include
Kenichi Handa <handa@m17n.org>
parents:
29145
diff
changeset
|
1431 (string-make-unibyte quail-conversion-str))))) |
22917
00f3497854c4
(quail-translation-keymap): Declare it as
Kenichi Handa <handa@m17n.org>
parents:
22883
diff
changeset
|
1432 (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
|
1433 (list (car generated-events)) |
00f3497854c4
(quail-translation-keymap): Declare it as
Kenichi Handa <handa@m17n.org>
parents:
22883
diff
changeset
|
1434 generated-events)) |
22765
7cf2c3800e8f
(quail-mode): This variable deleted.
Kenichi Handa <handa@m17n.org>
parents:
22124
diff
changeset
|
1435 |
7cf2c3800e8f
(quail-mode): This variable deleted.
Kenichi Handa <handa@m17n.org>
parents:
22124
diff
changeset
|
1436 ;; Since KEY doesn't start any translation, just return it. |
31828
c6cdd9deac21
(quail-help): The output message is improved.
Kenichi Handa <handa@m17n.org>
parents:
31584
diff
changeset
|
1437 ;; But translate KEY if necessary. |
31584
a5e682286ab6
(quail-start-translation): Translate KEY if necessary even if it
Kenichi Handa <handa@m17n.org>
parents:
31549
diff
changeset
|
1438 (if (and (integerp key) |
a5e682286ab6
(quail-start-translation): Translate KEY if necessary even if it
Kenichi Handa <handa@m17n.org>
parents:
31549
diff
changeset
|
1439 (quail-kbd-translate)) |
a5e682286ab6
(quail-start-translation): Translate KEY if necessary even if it
Kenichi Handa <handa@m17n.org>
parents:
31549
diff
changeset
|
1440 (setq key (quail-keyboard-translate key))) |
22765
7cf2c3800e8f
(quail-mode): This variable deleted.
Kenichi Handa <handa@m17n.org>
parents:
22124
diff
changeset
|
1441 (list key))) |
17052 | 1442 |
1443 (defun quail-terminate-translation () | |
19519
1c0ecc266e38
(quail-terminate-translation): Doc-string
Kenichi Handa <handa@m17n.org>
parents:
19453
diff
changeset
|
1444 "Terminate the translation of the current key." |
22765
7cf2c3800e8f
(quail-mode): This variable deleted.
Kenichi Handa <handa@m17n.org>
parents:
22124
diff
changeset
|
1445 (setq quail-translating nil) |
17052 | 1446 (if (buffer-live-p quail-guidance-buf) |
1447 (save-excursion | |
1448 (set-buffer quail-guidance-buf) | |
22765
7cf2c3800e8f
(quail-mode): This variable deleted.
Kenichi Handa <handa@m17n.org>
parents:
22124
diff
changeset
|
1449 (erase-buffer)))) |
17052 | 1450 |
1451 (defun quail-select-current () | |
31546
09bc2badb9e6
(quail-translation-docstring): New variable.
Kenichi Handa <handa@m17n.org>
parents:
31453
diff
changeset
|
1452 "Accept the currently selected translation." |
17052 | 1453 (interactive) |
1454 (quail-terminate-translation)) | |
1455 | |
1456 ;; Update the current translation status according to CONTROL-FLAG. | |
1457 ;; If CONTROL-FLAG is integer value, it is the number of keys in the | |
1458 ;; 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
|
1459 ;; 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
|
1460 ;; 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
|
1461 ;; 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
|
1462 ;; with more keys. |
17052 | 1463 |
1464 (defun quail-update-translation (control-flag) | |
1465 (let ((func (quail-update-translation-function))) | |
1466 (if func | |
22917
00f3497854c4
(quail-translation-keymap): Declare it as
Kenichi Handa <handa@m17n.org>
parents:
22883
diff
changeset
|
1467 (setq control-flag (funcall func control-flag)) |
31828
c6cdd9deac21
(quail-help): The output message is improved.
Kenichi Handa <handa@m17n.org>
parents:
31584
diff
changeset
|
1468 (cond ((numberp control-flag) |
c6cdd9deac21
(quail-help): The output message is improved.
Kenichi Handa <handa@m17n.org>
parents:
31584
diff
changeset
|
1469 (let ((len (length quail-current-key))) |
c6cdd9deac21
(quail-help): The output message is improved.
Kenichi Handa <handa@m17n.org>
parents:
31584
diff
changeset
|
1470 (if (= control-flag 0) |
c6cdd9deac21
(quail-help): The output message is improved.
Kenichi Handa <handa@m17n.org>
parents:
31584
diff
changeset
|
1471 (setq quail-current-str |
c6cdd9deac21
(quail-help): The output message is improved.
Kenichi Handa <handa@m17n.org>
parents:
31584
diff
changeset
|
1472 (if (quail-kbd-translate) |
c6cdd9deac21
(quail-help): The output message is improved.
Kenichi Handa <handa@m17n.org>
parents:
31584
diff
changeset
|
1473 (quail-keyseq-translate quail-current-key) |
c6cdd9deac21
(quail-help): The output message is improved.
Kenichi Handa <handa@m17n.org>
parents:
31584
diff
changeset
|
1474 quail-current-key))) |
c6cdd9deac21
(quail-help): The output message is improved.
Kenichi Handa <handa@m17n.org>
parents:
31584
diff
changeset
|
1475 (or input-method-exit-on-first-char |
c6cdd9deac21
(quail-help): The output message is improved.
Kenichi Handa <handa@m17n.org>
parents:
31584
diff
changeset
|
1476 (while (> len control-flag) |
c6cdd9deac21
(quail-help): The output message is improved.
Kenichi Handa <handa@m17n.org>
parents:
31584
diff
changeset
|
1477 (setq len (1- len)) |
c6cdd9deac21
(quail-help): The output message is improved.
Kenichi Handa <handa@m17n.org>
parents:
31584
diff
changeset
|
1478 (setq unread-command-events |
c6cdd9deac21
(quail-help): The output message is improved.
Kenichi Handa <handa@m17n.org>
parents:
31584
diff
changeset
|
1479 (cons (aref quail-current-key len) |
c6cdd9deac21
(quail-help): The output message is improved.
Kenichi Handa <handa@m17n.org>
parents:
31584
diff
changeset
|
1480 unread-command-events)))))) |
c6cdd9deac21
(quail-help): The output message is improved.
Kenichi Handa <handa@m17n.org>
parents:
31584
diff
changeset
|
1481 ((null control-flag) |
c6cdd9deac21
(quail-help): The output message is improved.
Kenichi Handa <handa@m17n.org>
parents:
31584
diff
changeset
|
1482 (unless quail-current-str |
c6cdd9deac21
(quail-help): The output message is improved.
Kenichi Handa <handa@m17n.org>
parents:
31584
diff
changeset
|
1483 (setq quail-current-str |
c6cdd9deac21
(quail-help): The output message is improved.
Kenichi Handa <handa@m17n.org>
parents:
31584
diff
changeset
|
1484 (if (quail-kbd-translate) |
c6cdd9deac21
(quail-help): The output message is improved.
Kenichi Handa <handa@m17n.org>
parents:
31584
diff
changeset
|
1485 (quail-keyseq-translate quail-current-key) |
c6cdd9deac21
(quail-help): The output message is improved.
Kenichi Handa <handa@m17n.org>
parents:
31584
diff
changeset
|
1486 quail-current-key)) |
c6cdd9deac21
(quail-help): The output message is improved.
Kenichi Handa <handa@m17n.org>
parents:
31584
diff
changeset
|
1487 (if (and input-method-exit-on-first-char |
c6cdd9deac21
(quail-help): The output message is improved.
Kenichi Handa <handa@m17n.org>
parents:
31584
diff
changeset
|
1488 (quail-simple)) |
c6cdd9deac21
(quail-help): The output message is improved.
Kenichi Handa <handa@m17n.org>
parents:
31584
diff
changeset
|
1489 (setq control-flag t))))))) |
23304
3a7a029df593
(quail-update-guidance): Check for the
Kenichi Handa <handa@m17n.org>
parents:
23176
diff
changeset
|
1490 (or input-method-use-echo-area |
3a7a029df593
(quail-update-guidance): Check for the
Kenichi Handa <handa@m17n.org>
parents:
23176
diff
changeset
|
1491 (progn |
3a7a029df593
(quail-update-guidance): Check for the
Kenichi Handa <handa@m17n.org>
parents:
23176
diff
changeset
|
1492 (quail-delete-region) |
3a7a029df593
(quail-update-guidance): Check for the
Kenichi Handa <handa@m17n.org>
parents:
23176
diff
changeset
|
1493 (insert quail-current-str))) |
3a7a029df593
(quail-update-guidance): Check for the
Kenichi Handa <handa@m17n.org>
parents:
23176
diff
changeset
|
1494 (let (quail-current-str) |
3a7a029df593
(quail-update-guidance): Check for the
Kenichi Handa <handa@m17n.org>
parents:
23176
diff
changeset
|
1495 (quail-update-guidance)) |
22917
00f3497854c4
(quail-translation-keymap): Declare it as
Kenichi Handa <handa@m17n.org>
parents:
22883
diff
changeset
|
1496 (or (stringp quail-current-str) |
00f3497854c4
(quail-translation-keymap): Declare it as
Kenichi Handa <handa@m17n.org>
parents:
22883
diff
changeset
|
1497 (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
|
1498 (if control-flag |
4492653b04e8
(quail-exit-from-minibuffer): Call
Kenichi Handa <handa@m17n.org>
parents:
19404
diff
changeset
|
1499 (quail-terminate-translation))) |
17052 | 1500 |
1501 (defun quail-self-insert-command () | |
31286
62621544edd2
(quail-self-insert-command): Fix docstring.
Kenichi Handa <handa@m17n.org>
parents:
31284
diff
changeset
|
1502 "Translate the typed key by the current Quail map, and insert." |
17052 | 1503 (interactive "*") |
1504 (setq quail-current-key | |
1505 (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
|
1506 (or (catch 'quail-tag |
00f3497854c4
(quail-translation-keymap): Declare it as
Kenichi Handa <handa@m17n.org>
parents:
22883
diff
changeset
|
1507 (quail-update-translation (quail-translate-key)) |
00f3497854c4
(quail-translation-keymap): Declare it as
Kenichi Handa <handa@m17n.org>
parents:
22883
diff
changeset
|
1508 t) |
00f3497854c4
(quail-translation-keymap): Declare it as
Kenichi Handa <handa@m17n.org>
parents:
22883
diff
changeset
|
1509 ;; 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
|
1510 ;; translation mode. |
00f3497854c4
(quail-translation-keymap): Declare it as
Kenichi Handa <handa@m17n.org>
parents:
22883
diff
changeset
|
1511 (setq quail-translating nil))) |
17052 | 1512 |
18556
99e8ae18137f
(quail-guidance-buf): Make it buffer
Kenichi Handa <handa@m17n.org>
parents:
18377
diff
changeset
|
1513 ;; 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
|
1514 (defun quail-map-definition (map) |
99e8ae18137f
(quail-guidance-buf): Make it buffer
Kenichi Handa <handa@m17n.org>
parents:
18377
diff
changeset
|
1515 (let ((def (car map))) |
99e8ae18137f
(quail-guidance-buf): Make it buffer
Kenichi Handa <handa@m17n.org>
parents:
18377
diff
changeset
|
1516 (if (and (consp def) (not (vectorp (cdr def)))) |
99e8ae18137f
(quail-guidance-buf): Make it buffer
Kenichi Handa <handa@m17n.org>
parents:
18377
diff
changeset
|
1517 (setq def (car def))) |
26891
651d521c8f52
(quail-install-map): New optional arg
Kenichi Handa <handa@m17n.org>
parents:
24821
diff
changeset
|
1518 (if (eq def t) |
651d521c8f52
(quail-install-map): New optional arg
Kenichi Handa <handa@m17n.org>
parents:
24821
diff
changeset
|
1519 (setq def nil)) |
18556
99e8ae18137f
(quail-guidance-buf): Make it buffer
Kenichi Handa <handa@m17n.org>
parents:
18377
diff
changeset
|
1520 def)) |
99e8ae18137f
(quail-guidance-buf): Make it buffer
Kenichi Handa <handa@m17n.org>
parents:
18377
diff
changeset
|
1521 |
99e8ae18137f
(quail-guidance-buf): Make it buffer
Kenichi Handa <handa@m17n.org>
parents:
18377
diff
changeset
|
1522 ;; 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
|
1523 ;; 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
|
1524 ;; the sequence. |
99e8ae18137f
(quail-guidance-buf): Make it buffer
Kenichi Handa <handa@m17n.org>
parents:
18377
diff
changeset
|
1525 (defun quail-get-current-str (len def) |
99e8ae18137f
(quail-guidance-buf): Make it buffer
Kenichi Handa <handa@m17n.org>
parents:
18377
diff
changeset
|
1526 (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
|
1527 def |
99e8ae18137f
(quail-guidance-buf): Make it buffer
Kenichi Handa <handa@m17n.org>
parents:
18377
diff
changeset
|
1528 (and (> len 1) |
99e8ae18137f
(quail-guidance-buf): Make it buffer
Kenichi Handa <handa@m17n.org>
parents:
18377
diff
changeset
|
1529 (let ((str (quail-get-current-str |
99e8ae18137f
(quail-guidance-buf): Make it buffer
Kenichi Handa <handa@m17n.org>
parents:
18377
diff
changeset
|
1530 (1- len) |
99e8ae18137f
(quail-guidance-buf): Make it buffer
Kenichi Handa <handa@m17n.org>
parents:
18377
diff
changeset
|
1531 (quail-map-definition (quail-lookup-key |
99e8ae18137f
(quail-guidance-buf): Make it buffer
Kenichi Handa <handa@m17n.org>
parents:
18377
diff
changeset
|
1532 quail-current-key (1- len)))))) |
99e8ae18137f
(quail-guidance-buf): Make it buffer
Kenichi Handa <handa@m17n.org>
parents:
18377
diff
changeset
|
1533 (if str |
99e8ae18137f
(quail-guidance-buf): Make it buffer
Kenichi Handa <handa@m17n.org>
parents:
18377
diff
changeset
|
1534 (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
|
1535 (substring quail-current-key (1- len) len))))))) |
99e8ae18137f
(quail-guidance-buf): Make it buffer
Kenichi Handa <handa@m17n.org>
parents:
18377
diff
changeset
|
1536 |
99e8ae18137f
(quail-guidance-buf): Make it buffer
Kenichi Handa <handa@m17n.org>
parents:
18377
diff
changeset
|
1537 (defvar quail-guidance-translations-starting-column 20) |
99e8ae18137f
(quail-guidance-buf): Make it buffer
Kenichi Handa <handa@m17n.org>
parents:
18377
diff
changeset
|
1538 |
99e8ae18137f
(quail-guidance-buf): Make it buffer
Kenichi Handa <handa@m17n.org>
parents:
18377
diff
changeset
|
1539 ;; 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
|
1540 ;; current translation. |
99e8ae18137f
(quail-guidance-buf): Make it buffer
Kenichi Handa <handa@m17n.org>
parents:
18377
diff
changeset
|
1541 (defun quail-update-current-translations (&optional relative-index) |
99e8ae18137f
(quail-guidance-buf): Make it buffer
Kenichi Handa <handa@m17n.org>
parents:
18377
diff
changeset
|
1542 (let* ((indices (car quail-current-translations)) |
99e8ae18137f
(quail-guidance-buf): Make it buffer
Kenichi Handa <handa@m17n.org>
parents:
18377
diff
changeset
|
1543 (cur (car indices)) |
99e8ae18137f
(quail-guidance-buf): Make it buffer
Kenichi Handa <handa@m17n.org>
parents:
18377
diff
changeset
|
1544 (start (nth 1 indices)) |
99e8ae18137f
(quail-guidance-buf): Make it buffer
Kenichi Handa <handa@m17n.org>
parents:
18377
diff
changeset
|
1545 (end (nth 2 indices))) |
99e8ae18137f
(quail-guidance-buf): Make it buffer
Kenichi Handa <handa@m17n.org>
parents:
18377
diff
changeset
|
1546 ;; Validate the index number of current translation. |
99e8ae18137f
(quail-guidance-buf): Make it buffer
Kenichi Handa <handa@m17n.org>
parents:
18377
diff
changeset
|
1547 (if (< cur 0) |
99e8ae18137f
(quail-guidance-buf): Make it buffer
Kenichi Handa <handa@m17n.org>
parents:
18377
diff
changeset
|
1548 (setcar indices (setq cur 0)) |
99e8ae18137f
(quail-guidance-buf): Make it buffer
Kenichi Handa <handa@m17n.org>
parents:
18377
diff
changeset
|
1549 (if (>= cur (length (cdr quail-current-translations))) |
99e8ae18137f
(quail-guidance-buf): Make it buffer
Kenichi Handa <handa@m17n.org>
parents:
18377
diff
changeset
|
1550 (setcar indices |
99e8ae18137f
(quail-guidance-buf): Make it buffer
Kenichi Handa <handa@m17n.org>
parents:
18377
diff
changeset
|
1551 (setq cur (1- (length (cdr quail-current-translations))))))) |
99e8ae18137f
(quail-guidance-buf): Make it buffer
Kenichi Handa <handa@m17n.org>
parents:
18377
diff
changeset
|
1552 |
99e8ae18137f
(quail-guidance-buf): Make it buffer
Kenichi Handa <handa@m17n.org>
parents:
18377
diff
changeset
|
1553 (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
|
1554 (< cur start) ; We moved to the previous block. |
99e8ae18137f
(quail-guidance-buf): Make it buffer
Kenichi Handa <handa@m17n.org>
parents:
18377
diff
changeset
|
1555 (>= cur end)) ; We moved to the next block. |
99e8ae18137f
(quail-guidance-buf): Make it buffer
Kenichi Handa <handa@m17n.org>
parents:
18377
diff
changeset
|
1556 (let ((len (length (cdr quail-current-translations))) |
99e8ae18137f
(quail-guidance-buf): Make it buffer
Kenichi Handa <handa@m17n.org>
parents:
18377
diff
changeset
|
1557 (maxcol (- (window-width quail-guidance-win) |
99e8ae18137f
(quail-guidance-buf): Make it buffer
Kenichi Handa <handa@m17n.org>
parents:
18377
diff
changeset
|
1558 quail-guidance-translations-starting-column)) |
99e8ae18137f
(quail-guidance-buf): Make it buffer
Kenichi Handa <handa@m17n.org>
parents:
18377
diff
changeset
|
1559 (block (nth 3 indices)) |
99e8ae18137f
(quail-guidance-buf): Make it buffer
Kenichi Handa <handa@m17n.org>
parents:
18377
diff
changeset
|
1560 col idx width trans num-items blocks) |
99e8ae18137f
(quail-guidance-buf): Make it buffer
Kenichi Handa <handa@m17n.org>
parents:
18377
diff
changeset
|
1561 (if (< cur start) |
99e8ae18137f
(quail-guidance-buf): Make it buffer
Kenichi Handa <handa@m17n.org>
parents:
18377
diff
changeset
|
1562 ;; We must calculate from the head. |
99e8ae18137f
(quail-guidance-buf): Make it buffer
Kenichi Handa <handa@m17n.org>
parents:
18377
diff
changeset
|
1563 (setq start 0 block 0) |
99e8ae18137f
(quail-guidance-buf): Make it buffer
Kenichi Handa <handa@m17n.org>
parents:
18377
diff
changeset
|
1564 (if end ; i.e. (>= cur end) |
99e8ae18137f
(quail-guidance-buf): Make it buffer
Kenichi Handa <handa@m17n.org>
parents:
18377
diff
changeset
|
1565 (setq start end))) |
99e8ae18137f
(quail-guidance-buf): Make it buffer
Kenichi Handa <handa@m17n.org>
parents:
18377
diff
changeset
|
1566 (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
|
1567 ;; 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
|
1568 (while (and (< idx len) (>= cur end)) |
99e8ae18137f
(quail-guidance-buf): Make it buffer
Kenichi Handa <handa@m17n.org>
parents:
18377
diff
changeset
|
1569 (if (= num-items 0) |
99e8ae18137f
(quail-guidance-buf): Make it buffer
Kenichi Handa <handa@m17n.org>
parents:
18377
diff
changeset
|
1570 (setq start idx col 0 block (1+ block))) |
99e8ae18137f
(quail-guidance-buf): Make it buffer
Kenichi Handa <handa@m17n.org>
parents:
18377
diff
changeset
|
1571 (setq trans (aref (cdr quail-current-translations) idx)) |
99e8ae18137f
(quail-guidance-buf): Make it buffer
Kenichi Handa <handa@m17n.org>
parents:
18377
diff
changeset
|
1572 (setq width (if (integerp trans) (char-width trans) |
99e8ae18137f
(quail-guidance-buf): Make it buffer
Kenichi Handa <handa@m17n.org>
parents:
18377
diff
changeset
|
1573 (string-width trans))) |
99e8ae18137f
(quail-guidance-buf): Make it buffer
Kenichi Handa <handa@m17n.org>
parents:
18377
diff
changeset
|
1574 (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
|
1575 (if (and (> num-items 0) |
99e8ae18137f
(quail-guidance-buf): Make it buffer
Kenichi Handa <handa@m17n.org>
parents:
18377
diff
changeset
|
1576 (or (>= col maxcol) (> num-items 10))) |
99e8ae18137f
(quail-guidance-buf): Make it buffer
Kenichi Handa <handa@m17n.org>
parents:
18377
diff
changeset
|
1577 (setq end idx num-items 0) |
99e8ae18137f
(quail-guidance-buf): Make it buffer
Kenichi Handa <handa@m17n.org>
parents:
18377
diff
changeset
|
1578 (setq idx (1+ idx)))) |
99e8ae18137f
(quail-guidance-buf): Make it buffer
Kenichi Handa <handa@m17n.org>
parents:
18377
diff
changeset
|
1579 (setcar (nthcdr 3 indices) block) |
99e8ae18137f
(quail-guidance-buf): Make it buffer
Kenichi Handa <handa@m17n.org>
parents:
18377
diff
changeset
|
1580 (if (>= idx len) |
99e8ae18137f
(quail-guidance-buf): Make it buffer
Kenichi Handa <handa@m17n.org>
parents:
18377
diff
changeset
|
1581 (progn |
99e8ae18137f
(quail-guidance-buf): Make it buffer
Kenichi Handa <handa@m17n.org>
parents:
18377
diff
changeset
|
1582 ;; We hit the tail before reaching MAXCOL. |
99e8ae18137f
(quail-guidance-buf): Make it buffer
Kenichi Handa <handa@m17n.org>
parents:
18377
diff
changeset
|
1583 (setq end idx) |
99e8ae18137f
(quail-guidance-buf): Make it buffer
Kenichi Handa <handa@m17n.org>
parents:
18377
diff
changeset
|
1584 (setcar (nthcdr 4 indices) block))) |
99e8ae18137f
(quail-guidance-buf): Make it buffer
Kenichi Handa <handa@m17n.org>
parents:
18377
diff
changeset
|
1585 (setcar (cdr indices) start) |
99e8ae18137f
(quail-guidance-buf): Make it buffer
Kenichi Handa <handa@m17n.org>
parents:
18377
diff
changeset
|
1586 (setcar (nthcdr 2 indices) end))) |
99e8ae18137f
(quail-guidance-buf): Make it buffer
Kenichi Handa <handa@m17n.org>
parents:
18377
diff
changeset
|
1587 (if relative-index |
99e8ae18137f
(quail-guidance-buf): Make it buffer
Kenichi Handa <handa@m17n.org>
parents:
18377
diff
changeset
|
1588 (if (>= (+ start relative-index) end) |
31424 | 1589 (setcar indices (1- end)) |
18556
99e8ae18137f
(quail-guidance-buf): Make it buffer
Kenichi Handa <handa@m17n.org>
parents:
18377
diff
changeset
|
1590 (setcar indices (+ start relative-index)))) |
99e8ae18137f
(quail-guidance-buf): Make it buffer
Kenichi Handa <handa@m17n.org>
parents:
18377
diff
changeset
|
1591 (setq quail-current-str |
22917
00f3497854c4
(quail-translation-keymap): Declare it as
Kenichi Handa <handa@m17n.org>
parents:
22883
diff
changeset
|
1592 (aref (cdr quail-current-translations) (car indices))) |
00f3497854c4
(quail-translation-keymap): Declare it as
Kenichi Handa <handa@m17n.org>
parents:
22883
diff
changeset
|
1593 (or (stringp quail-current-str) |
00f3497854c4
(quail-translation-keymap): Declare it as
Kenichi Handa <handa@m17n.org>
parents:
22883
diff
changeset
|
1594 (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
|
1595 |
17052 | 1596 (defun quail-translate-key () |
1597 "Translate the current key sequence according to the current Quail map. | |
1598 Return t if we can terminate the translation. | |
1599 Return nil if the current key sequence may be followed by more keys. | |
1600 Return number if we can't find any translation for the current key | |
1601 sequence. The number is the count of valid keys in the current | |
1602 sequence counting from the head." | |
1603 (let* ((len (length quail-current-key)) | |
1604 (map (quail-lookup-key quail-current-key len)) | |
1605 def ch) | |
1606 (if map | |
18556
99e8ae18137f
(quail-guidance-buf): Make it buffer
Kenichi Handa <handa@m17n.org>
parents:
18377
diff
changeset
|
1607 (let ((def (quail-map-definition map))) |
99e8ae18137f
(quail-guidance-buf): Make it buffer
Kenichi Handa <handa@m17n.org>
parents:
18377
diff
changeset
|
1608 (setq quail-current-str (quail-get-current-str len def)) |
17052 | 1609 ;; Return t only if we can terminate the current translation. |
1610 (and | |
1611 ;; No alternative translations. | |
1612 (or (null (consp def)) (= (length (cdr def)) 1)) | |
1613 ;; No translation for the longer key. | |
1614 (null (cdr map)) | |
1615 ;; No shorter breaking point. | |
1616 (or (null (quail-maximum-shortest)) | |
1617 (< len 3) | |
1618 (null (quail-lookup-key quail-current-key (1- len))) | |
1619 (null (quail-lookup-key | |
1620 (substring quail-current-key -2 -1) 1))))) | |
1621 | |
1622 ;; There's no translation for the current key sequence. Before | |
1623 ;; giving up, we must check two possibilities. | |
1624 (cond ((and | |
1625 (quail-maximum-shortest) | |
1626 (>= len 4) | |
18556
99e8ae18137f
(quail-guidance-buf): Make it buffer
Kenichi Handa <handa@m17n.org>
parents:
18377
diff
changeset
|
1627 (setq def (quail-map-definition |
99e8ae18137f
(quail-guidance-buf): Make it buffer
Kenichi Handa <handa@m17n.org>
parents:
18377
diff
changeset
|
1628 (quail-lookup-key quail-current-key (- len 2)))) |
17052 | 1629 (quail-lookup-key (substring quail-current-key -2) 2)) |
1630 ;; Now the sequence is "...ABCD", which can be split into | |
1631 ;; "...AB" and "CD..." to get valid translation. | |
1632 ;; At first, get translation of "...AB". | |
18556
99e8ae18137f
(quail-guidance-buf): Make it buffer
Kenichi Handa <handa@m17n.org>
parents:
18377
diff
changeset
|
1633 (setq quail-current-str (quail-get-current-str (- len 2) def)) |
17052 | 1634 ;; Then, return the length of "...AB". |
1635 (- len 2)) | |
1636 | |
18797
e9aa787f0154
(quail-translate-key): Fix previous change.
Kenichi Handa <handa@m17n.org>
parents:
18642
diff
changeset
|
1637 ((and (> len 0) |
e9aa787f0154
(quail-translate-key): Fix previous change.
Kenichi Handa <handa@m17n.org>
parents:
18642
diff
changeset
|
1638 (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
|
1639 quail-current-translations |
17052 | 1640 (not (quail-deterministic)) |
1641 (setq ch (aref quail-current-key (1- len))) | |
1642 (>= ch ?0) (<= ch ?9)) | |
1643 ;; A numeric key is entered to select a desirable translation. | |
1644 (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
|
1645 ;; 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
|
1646 (setq ch (if (= ch ?0) 9 (- ch ?1))) |
99e8ae18137f
(quail-guidance-buf): Make it buffer
Kenichi Handa <handa@m17n.org>
parents:
18377
diff
changeset
|
1647 (quail-update-current-translations ch) |
17052 | 1648 ;; And, we can terminate the current translation. |
1649 t) | |
1650 | |
1651 (t | |
1652 ;; No way to handle the last character in this context. | |
1653 (1- len)))))) | |
1654 | |
1655 (defun quail-next-translation () | |
1656 "Select next translation in the current batch of candidates." | |
1657 (interactive) | |
1658 (if quail-current-translations | |
18556
99e8ae18137f
(quail-guidance-buf): Make it buffer
Kenichi Handa <handa@m17n.org>
parents:
18377
diff
changeset
|
1659 (let ((indices (car quail-current-translations))) |
99e8ae18137f
(quail-guidance-buf): Make it buffer
Kenichi Handa <handa@m17n.org>
parents:
18377
diff
changeset
|
1660 (if (= (1+ (car indices)) (length (cdr quail-current-translations))) |
19084
9f4b95f30c4f
(quail-next-translation): Call
Kenichi Handa <handa@m17n.org>
parents:
18983
diff
changeset
|
1661 ;; We are already at the tail. |
18556
99e8ae18137f
(quail-guidance-buf): Make it buffer
Kenichi Handa <handa@m17n.org>
parents:
18377
diff
changeset
|
1662 (beep) |
99e8ae18137f
(quail-guidance-buf): Make it buffer
Kenichi Handa <handa@m17n.org>
parents:
18377
diff
changeset
|
1663 (setcar indices (1+ (car indices))) |
99e8ae18137f
(quail-guidance-buf): Make it buffer
Kenichi Handa <handa@m17n.org>
parents:
18377
diff
changeset
|
1664 (quail-update-current-translations) |
99e8ae18137f
(quail-guidance-buf): Make it buffer
Kenichi Handa <handa@m17n.org>
parents:
18377
diff
changeset
|
1665 (quail-update-translation nil))) |
22765
7cf2c3800e8f
(quail-mode): This variable deleted.
Kenichi Handa <handa@m17n.org>
parents:
22124
diff
changeset
|
1666 (setq unread-command-events |
7cf2c3800e8f
(quail-mode): This variable deleted.
Kenichi Handa <handa@m17n.org>
parents:
22124
diff
changeset
|
1667 (cons last-command-event unread-command-events)) |
7cf2c3800e8f
(quail-mode): This variable deleted.
Kenichi Handa <handa@m17n.org>
parents:
22124
diff
changeset
|
1668 (quail-terminate-translation))) |
17052 | 1669 |
1670 (defun quail-prev-translation () | |
1671 "Select previous translation in the current batch of candidates." | |
1672 (interactive) | |
1673 (if quail-current-translations | |
18556
99e8ae18137f
(quail-guidance-buf): Make it buffer
Kenichi Handa <handa@m17n.org>
parents:
18377
diff
changeset
|
1674 (let ((indices (car quail-current-translations))) |
99e8ae18137f
(quail-guidance-buf): Make it buffer
Kenichi Handa <handa@m17n.org>
parents:
18377
diff
changeset
|
1675 (if (= (car indices) 0) |
99e8ae18137f
(quail-guidance-buf): Make it buffer
Kenichi Handa <handa@m17n.org>
parents:
18377
diff
changeset
|
1676 ;; We are already at the head. |
99e8ae18137f
(quail-guidance-buf): Make it buffer
Kenichi Handa <handa@m17n.org>
parents:
18377
diff
changeset
|
1677 (beep) |
99e8ae18137f
(quail-guidance-buf): Make it buffer
Kenichi Handa <handa@m17n.org>
parents:
18377
diff
changeset
|
1678 (setcar indices (1- (car indices))) |
99e8ae18137f
(quail-guidance-buf): Make it buffer
Kenichi Handa <handa@m17n.org>
parents:
18377
diff
changeset
|
1679 (quail-update-current-translations) |
99e8ae18137f
(quail-guidance-buf): Make it buffer
Kenichi Handa <handa@m17n.org>
parents:
18377
diff
changeset
|
1680 (quail-update-translation nil))) |
22765
7cf2c3800e8f
(quail-mode): This variable deleted.
Kenichi Handa <handa@m17n.org>
parents:
22124
diff
changeset
|
1681 (setq unread-command-events |
7cf2c3800e8f
(quail-mode): This variable deleted.
Kenichi Handa <handa@m17n.org>
parents:
22124
diff
changeset
|
1682 (cons last-command-event unread-command-events)) |
7cf2c3800e8f
(quail-mode): This variable deleted.
Kenichi Handa <handa@m17n.org>
parents:
22124
diff
changeset
|
1683 (quail-terminate-translation))) |
17052 | 1684 |
1685 (defun quail-next-translation-block () | |
18556
99e8ae18137f
(quail-guidance-buf): Make it buffer
Kenichi Handa <handa@m17n.org>
parents:
18377
diff
changeset
|
1686 "Select from the next block of translations." |
17052 | 1687 (interactive) |
1688 (if quail-current-translations | |
18556
99e8ae18137f
(quail-guidance-buf): Make it buffer
Kenichi Handa <handa@m17n.org>
parents:
18377
diff
changeset
|
1689 (let* ((indices (car quail-current-translations)) |
99e8ae18137f
(quail-guidance-buf): Make it buffer
Kenichi Handa <handa@m17n.org>
parents:
18377
diff
changeset
|
1690 (offset (- (car indices) (nth 1 indices)))) |
99e8ae18137f
(quail-guidance-buf): Make it buffer
Kenichi Handa <handa@m17n.org>
parents:
18377
diff
changeset
|
1691 (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
|
1692 ;; We are already at the last block. |
99e8ae18137f
(quail-guidance-buf): Make it buffer
Kenichi Handa <handa@m17n.org>
parents:
18377
diff
changeset
|
1693 (beep) |
99e8ae18137f
(quail-guidance-buf): Make it buffer
Kenichi Handa <handa@m17n.org>
parents:
18377
diff
changeset
|
1694 (setcar indices (+ (nth 2 indices) offset)) |
99e8ae18137f
(quail-guidance-buf): Make it buffer
Kenichi Handa <handa@m17n.org>
parents:
18377
diff
changeset
|
1695 (quail-update-current-translations) |
99e8ae18137f
(quail-guidance-buf): Make it buffer
Kenichi Handa <handa@m17n.org>
parents:
18377
diff
changeset
|
1696 (quail-update-translation nil))) |
22765
7cf2c3800e8f
(quail-mode): This variable deleted.
Kenichi Handa <handa@m17n.org>
parents:
22124
diff
changeset
|
1697 (setq unread-command-events |
22917
00f3497854c4
(quail-translation-keymap): Declare it as
Kenichi Handa <handa@m17n.org>
parents:
22883
diff
changeset
|
1698 (cons last-command-event unread-command-events)) |
22765
7cf2c3800e8f
(quail-mode): This variable deleted.
Kenichi Handa <handa@m17n.org>
parents:
22124
diff
changeset
|
1699 (quail-terminate-translation))) |
17052 | 1700 |
1701 (defun quail-prev-translation-block () | |
1702 "Select the previous batch of 10 translation candidates." | |
1703 (interactive) | |
18556
99e8ae18137f
(quail-guidance-buf): Make it buffer
Kenichi Handa <handa@m17n.org>
parents:
18377
diff
changeset
|
1704 (if quail-current-translations |
99e8ae18137f
(quail-guidance-buf): Make it buffer
Kenichi Handa <handa@m17n.org>
parents:
18377
diff
changeset
|
1705 (let* ((indices (car quail-current-translations)) |
99e8ae18137f
(quail-guidance-buf): Make it buffer
Kenichi Handa <handa@m17n.org>
parents:
18377
diff
changeset
|
1706 (offset (- (car indices) (nth 1 indices)))) |
99e8ae18137f
(quail-guidance-buf): Make it buffer
Kenichi Handa <handa@m17n.org>
parents:
18377
diff
changeset
|
1707 (if (= (nth 1 indices) 0) |
99e8ae18137f
(quail-guidance-buf): Make it buffer
Kenichi Handa <handa@m17n.org>
parents:
18377
diff
changeset
|
1708 ;; We are already at the first block. |
99e8ae18137f
(quail-guidance-buf): Make it buffer
Kenichi Handa <handa@m17n.org>
parents:
18377
diff
changeset
|
1709 (beep) |
99e8ae18137f
(quail-guidance-buf): Make it buffer
Kenichi Handa <handa@m17n.org>
parents:
18377
diff
changeset
|
1710 (setcar indices (1- (nth 1 indices))) |
99e8ae18137f
(quail-guidance-buf): Make it buffer
Kenichi Handa <handa@m17n.org>
parents:
18377
diff
changeset
|
1711 (quail-update-current-translations) |
99e8ae18137f
(quail-guidance-buf): Make it buffer
Kenichi Handa <handa@m17n.org>
parents:
18377
diff
changeset
|
1712 (if (< (+ (nth 1 indices) offset) (nth 2 indices)) |
99e8ae18137f
(quail-guidance-buf): Make it buffer
Kenichi Handa <handa@m17n.org>
parents:
18377
diff
changeset
|
1713 (progn |
99e8ae18137f
(quail-guidance-buf): Make it buffer
Kenichi Handa <handa@m17n.org>
parents:
18377
diff
changeset
|
1714 (setcar indices (+ (nth 1 indices) offset)) |
99e8ae18137f
(quail-guidance-buf): Make it buffer
Kenichi Handa <handa@m17n.org>
parents:
18377
diff
changeset
|
1715 (quail-update-current-translations))) |
99e8ae18137f
(quail-guidance-buf): Make it buffer
Kenichi Handa <handa@m17n.org>
parents:
18377
diff
changeset
|
1716 (quail-update-translation nil))) |
22765
7cf2c3800e8f
(quail-mode): This variable deleted.
Kenichi Handa <handa@m17n.org>
parents:
22124
diff
changeset
|
1717 (setq unread-command-events |
7cf2c3800e8f
(quail-mode): This variable deleted.
Kenichi Handa <handa@m17n.org>
parents:
22124
diff
changeset
|
1718 (cons last-command-event unread-command-events)) |
7cf2c3800e8f
(quail-mode): This variable deleted.
Kenichi Handa <handa@m17n.org>
parents:
22124
diff
changeset
|
1719 (quail-terminate-translation))) |
17052 | 1720 |
1721 (defun quail-abort-translation () | |
1722 "Abort translation and delete the current Quail key sequence." | |
1723 (interactive) | |
1724 (quail-delete-region) | |
22917
00f3497854c4
(quail-translation-keymap): Declare it as
Kenichi Handa <handa@m17n.org>
parents:
22883
diff
changeset
|
1725 (setq quail-current-str nil) |
17052 | 1726 (quail-terminate-translation)) |
1727 | |
1728 (defun quail-delete-last-char () | |
1729 "Delete the last input character from the current Quail key sequence." | |
1730 (interactive) | |
1731 (if (= (length quail-current-key) 1) | |
1732 (quail-abort-translation) | |
1733 (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
|
1734 (quail-delete-region) |
17052 | 1735 (quail-update-translation (quail-translate-key)))) |
1736 | |
1737 ;; For conversion mode. | |
1738 | |
23887
3a4d3e2418dc
(quail-point-in-conversion-region): New
Kenichi Handa <handa@m17n.org>
parents:
23629
diff
changeset
|
1739 (defsubst quail-point-in-conversion-region () |
3a4d3e2418dc
(quail-point-in-conversion-region): New
Kenichi Handa <handa@m17n.org>
parents:
23629
diff
changeset
|
1740 "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
|
1741 (let (start pos) |
3a4d3e2418dc
(quail-point-in-conversion-region): New
Kenichi Handa <handa@m17n.org>
parents:
23629
diff
changeset
|
1742 (and (setq start (overlay-start quail-conv-overlay)) |
3a4d3e2418dc
(quail-point-in-conversion-region): New
Kenichi Handa <handa@m17n.org>
parents:
23629
diff
changeset
|
1743 (>= (setq pos (point)) start) |
3a4d3e2418dc
(quail-point-in-conversion-region): New
Kenichi Handa <handa@m17n.org>
parents:
23629
diff
changeset
|
1744 (<= pos (overlay-end quail-conv-overlay))))) |
3a4d3e2418dc
(quail-point-in-conversion-region): New
Kenichi Handa <handa@m17n.org>
parents:
23629
diff
changeset
|
1745 |
17052 | 1746 (defun quail-conversion-backward-char () |
1747 (interactive) | |
1748 (if (<= (point) (overlay-start quail-conv-overlay)) | |
22765
7cf2c3800e8f
(quail-mode): This variable deleted.
Kenichi Handa <handa@m17n.org>
parents:
22124
diff
changeset
|
1749 (quail-error "Beginning of conversion region")) |
7cf2c3800e8f
(quail-mode): This variable deleted.
Kenichi Handa <handa@m17n.org>
parents:
22124
diff
changeset
|
1750 (setq quail-translating nil) |
17052 | 1751 (forward-char -1)) |
1752 | |
1753 (defun quail-conversion-forward-char () | |
1754 (interactive) | |
1755 (if (>= (point) (overlay-end quail-conv-overlay)) | |
22765
7cf2c3800e8f
(quail-mode): This variable deleted.
Kenichi Handa <handa@m17n.org>
parents:
22124
diff
changeset
|
1756 (quail-error "End of conversion region")) |
7cf2c3800e8f
(quail-mode): This variable deleted.
Kenichi Handa <handa@m17n.org>
parents:
22124
diff
changeset
|
1757 (setq quail-translating nil) |
17052 | 1758 (forward-char 1)) |
1759 | |
1760 (defun quail-conversion-beginning-of-region () | |
1761 (interactive) | |
22777
1b0761cbc15b
(quail-conversion-keymap): New binding
Kenichi Handa <handa@m17n.org>
parents:
22765
diff
changeset
|
1762 (setq quail-translating nil) |
17052 | 1763 (goto-char (overlay-start quail-conv-overlay))) |
1764 | |
1765 (defun quail-conversion-end-of-region () | |
1766 (interactive) | |
22777
1b0761cbc15b
(quail-conversion-keymap): New binding
Kenichi Handa <handa@m17n.org>
parents:
22765
diff
changeset
|
1767 (setq quail-translating nil) |
17052 | 1768 (goto-char (overlay-end quail-conv-overlay))) |
1769 | |
1770 (defun quail-conversion-delete-char () | |
1771 (interactive) | |
22777
1b0761cbc15b
(quail-conversion-keymap): New binding
Kenichi Handa <handa@m17n.org>
parents:
22765
diff
changeset
|
1772 (setq quail-translating nil) |
17052 | 1773 (if (>= (point) (overlay-end quail-conv-overlay)) |
22765
7cf2c3800e8f
(quail-mode): This variable deleted.
Kenichi Handa <handa@m17n.org>
parents:
22124
diff
changeset
|
1774 (quail-error "End of conversion region")) |
17052 | 1775 (delete-char 1) |
22917
00f3497854c4
(quail-translation-keymap): Declare it as
Kenichi Handa <handa@m17n.org>
parents:
22883
diff
changeset
|
1776 (let ((start (overlay-start quail-conv-overlay)) |
00f3497854c4
(quail-translation-keymap): Declare it as
Kenichi Handa <handa@m17n.org>
parents:
22883
diff
changeset
|
1777 (end (overlay-end quail-conv-overlay))) |
00f3497854c4
(quail-translation-keymap): Declare it as
Kenichi Handa <handa@m17n.org>
parents:
22883
diff
changeset
|
1778 (setq quail-conversion-str (buffer-substring start end)) |
00f3497854c4
(quail-translation-keymap): Declare it as
Kenichi Handa <handa@m17n.org>
parents:
22883
diff
changeset
|
1779 (if (= start end) |
00f3497854c4
(quail-translation-keymap): Declare it as
Kenichi Handa <handa@m17n.org>
parents:
22883
diff
changeset
|
1780 (setq quail-converting nil)))) |
17052 | 1781 |
22777
1b0761cbc15b
(quail-conversion-keymap): New binding
Kenichi Handa <handa@m17n.org>
parents:
22765
diff
changeset
|
1782 (defun quail-conversion-delete-tail () |
1b0761cbc15b
(quail-conversion-keymap): New binding
Kenichi Handa <handa@m17n.org>
parents:
22765
diff
changeset
|
1783 (interactive) |
1b0761cbc15b
(quail-conversion-keymap): New binding
Kenichi Handa <handa@m17n.org>
parents:
22765
diff
changeset
|
1784 (if (>= (point) (overlay-end quail-conv-overlay)) |
1b0761cbc15b
(quail-conversion-keymap): New binding
Kenichi Handa <handa@m17n.org>
parents:
22765
diff
changeset
|
1785 (quail-error "End of conversion region")) |
1b0761cbc15b
(quail-conversion-keymap): New binding
Kenichi Handa <handa@m17n.org>
parents:
22765
diff
changeset
|
1786 (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
|
1787 (let ((start (overlay-start quail-conv-overlay)) |
00f3497854c4
(quail-translation-keymap): Declare it as
Kenichi Handa <handa@m17n.org>
parents:
22883
diff
changeset
|
1788 (end (overlay-end quail-conv-overlay))) |
00f3497854c4
(quail-translation-keymap): Declare it as
Kenichi Handa <handa@m17n.org>
parents:
22883
diff
changeset
|
1789 (setq quail-conversion-str (buffer-substring start end)) |
00f3497854c4
(quail-translation-keymap): Declare it as
Kenichi Handa <handa@m17n.org>
parents:
22883
diff
changeset
|
1790 (if (= start end) |
00f3497854c4
(quail-translation-keymap): Declare it as
Kenichi Handa <handa@m17n.org>
parents:
22883
diff
changeset
|
1791 (setq quail-converting nil)))) |
22777
1b0761cbc15b
(quail-conversion-keymap): New binding
Kenichi Handa <handa@m17n.org>
parents:
22765
diff
changeset
|
1792 |
17052 | 1793 (defun quail-conversion-backward-delete-char () |
1794 (interactive) | |
23887
3a4d3e2418dc
(quail-point-in-conversion-region): New
Kenichi Handa <handa@m17n.org>
parents:
23629
diff
changeset
|
1795 (if (> (length quail-current-key) 0) |
3a4d3e2418dc
(quail-point-in-conversion-region): New
Kenichi Handa <handa@m17n.org>
parents:
23629
diff
changeset
|
1796 (quail-delete-last-char) |
3a4d3e2418dc
(quail-point-in-conversion-region): New
Kenichi Handa <handa@m17n.org>
parents:
23629
diff
changeset
|
1797 (if (<= (point) (overlay-start quail-conv-overlay)) |
3a4d3e2418dc
(quail-point-in-conversion-region): New
Kenichi Handa <handa@m17n.org>
parents:
23629
diff
changeset
|
1798 (quail-error "Beginning of conversion region")) |
3a4d3e2418dc
(quail-point-in-conversion-region): New
Kenichi Handa <handa@m17n.org>
parents:
23629
diff
changeset
|
1799 (delete-char -1) |
3a4d3e2418dc
(quail-point-in-conversion-region): New
Kenichi Handa <handa@m17n.org>
parents:
23629
diff
changeset
|
1800 (let ((start (overlay-start quail-conv-overlay)) |
3a4d3e2418dc
(quail-point-in-conversion-region): New
Kenichi Handa <handa@m17n.org>
parents:
23629
diff
changeset
|
1801 (end (overlay-end quail-conv-overlay))) |
3a4d3e2418dc
(quail-point-in-conversion-region): New
Kenichi Handa <handa@m17n.org>
parents:
23629
diff
changeset
|
1802 (setq quail-conversion-str (buffer-substring start end)) |
3a4d3e2418dc
(quail-point-in-conversion-region): New
Kenichi Handa <handa@m17n.org>
parents:
23629
diff
changeset
|
1803 (if (= start end) |
3a4d3e2418dc
(quail-point-in-conversion-region): New
Kenichi Handa <handa@m17n.org>
parents:
23629
diff
changeset
|
1804 (setq quail-converting nil))))) |
17052 | 1805 |
1806 (defun quail-do-conversion (func &rest args) | |
1807 "Call FUNC to convert text in the current conversion region of Quail. | |
1808 Remaining args are for FUNC." | |
1809 (delete-overlay quail-overlay) | |
1810 (apply func args)) | |
1811 | |
1812 (defun quail-no-conversion () | |
1813 "Do no conversion of the current conversion region of Quail." | |
1814 (interactive) | |
22777
1b0761cbc15b
(quail-conversion-keymap): New binding
Kenichi Handa <handa@m17n.org>
parents:
22765
diff
changeset
|
1815 (setq quail-converting nil)) |
17052 | 1816 |
1817 ;; Guidance, Completion, and Help buffer handlers. | |
1818 | |
18556
99e8ae18137f
(quail-guidance-buf): Make it buffer
Kenichi Handa <handa@m17n.org>
parents:
18377
diff
changeset
|
1819 ;; 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
|
1820 (defun quail-make-guidance-frame (buf) |
99e8ae18137f
(quail-guidance-buf): Make it buffer
Kenichi Handa <handa@m17n.org>
parents:
18377
diff
changeset
|
1821 (let* ((fparam (frame-parameters)) |
99e8ae18137f
(quail-guidance-buf): Make it buffer
Kenichi Handa <handa@m17n.org>
parents:
18377
diff
changeset
|
1822 (top (cdr (assq 'top fparam))) |
99e8ae18137f
(quail-guidance-buf): Make it buffer
Kenichi Handa <handa@m17n.org>
parents:
18377
diff
changeset
|
1823 (border (cdr (assq 'border-width fparam))) |
99e8ae18137f
(quail-guidance-buf): Make it buffer
Kenichi Handa <handa@m17n.org>
parents:
18377
diff
changeset
|
1824 (internal-border (cdr (assq 'internal-border-width fparam))) |
99e8ae18137f
(quail-guidance-buf): Make it buffer
Kenichi Handa <handa@m17n.org>
parents:
18377
diff
changeset
|
1825 (newtop (- top |
99e8ae18137f
(quail-guidance-buf): Make it buffer
Kenichi Handa <handa@m17n.org>
parents:
18377
diff
changeset
|
1826 (frame-char-height) (* internal-border 2) (* border 2)))) |
99e8ae18137f
(quail-guidance-buf): Make it buffer
Kenichi Handa <handa@m17n.org>
parents:
18377
diff
changeset
|
1827 (if (< newtop 0) |
99e8ae18137f
(quail-guidance-buf): Make it buffer
Kenichi Handa <handa@m17n.org>
parents:
18377
diff
changeset
|
1828 (setq newtop (+ top (frame-pixel-height)))) |
99e8ae18137f
(quail-guidance-buf): Make it buffer
Kenichi Handa <handa@m17n.org>
parents:
18377
diff
changeset
|
1829 (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
|
1830 (minibuffer) (menu-bar-lines . 0)) |
99e8ae18137f
(quail-guidance-buf): Make it buffer
Kenichi Handa <handa@m17n.org>
parents:
18377
diff
changeset
|
1831 (cons (cons 'top newtop) fparam)))) |
99e8ae18137f
(quail-guidance-buf): Make it buffer
Kenichi Handa <handa@m17n.org>
parents:
18377
diff
changeset
|
1832 (win (frame-first-window frame))) |
99e8ae18137f
(quail-guidance-buf): Make it buffer
Kenichi Handa <handa@m17n.org>
parents:
18377
diff
changeset
|
1833 (set-window-buffer win buf) |
19878
a69ae37e6932
(quail-update-translation): Fix previous change.
Richard M. Stallman <rms@gnu.org>
parents:
19849
diff
changeset
|
1834 ;;(set-window-dedicated-p win t) |
a69ae37e6932
(quail-update-translation): Fix previous change.
Richard M. Stallman <rms@gnu.org>
parents:
19849
diff
changeset
|
1835 ))) |
17052 | 1836 |
19432
4492653b04e8
(quail-exit-from-minibuffer): Call
Kenichi Handa <handa@m17n.org>
parents:
19404
diff
changeset
|
1837 ;; Setup Quail completion buffer. |
4492653b04e8
(quail-exit-from-minibuffer): Call
Kenichi Handa <handa@m17n.org>
parents:
19404
diff
changeset
|
1838 (defun quail-setup-completion-buf () |
4492653b04e8
(quail-exit-from-minibuffer): Call
Kenichi Handa <handa@m17n.org>
parents:
19404
diff
changeset
|
1839 (unless (buffer-live-p quail-completion-buf) |
4492653b04e8
(quail-exit-from-minibuffer): Call
Kenichi Handa <handa@m17n.org>
parents:
19404
diff
changeset
|
1840 (setq quail-completion-buf (get-buffer-create "*Quail Completions*")) |
4492653b04e8
(quail-exit-from-minibuffer): Call
Kenichi Handa <handa@m17n.org>
parents:
19404
diff
changeset
|
1841 (save-excursion |
4492653b04e8
(quail-exit-from-minibuffer): Call
Kenichi Handa <handa@m17n.org>
parents:
19404
diff
changeset
|
1842 (set-buffer quail-completion-buf) |
4492653b04e8
(quail-exit-from-minibuffer): Call
Kenichi Handa <handa@m17n.org>
parents:
19404
diff
changeset
|
1843 (setq quail-overlay (make-overlay 1 1)) |
4492653b04e8
(quail-exit-from-minibuffer): Call
Kenichi Handa <handa@m17n.org>
parents:
19404
diff
changeset
|
1844 (overlay-put quail-overlay 'face 'highlight)))) |
4492653b04e8
(quail-exit-from-minibuffer): Call
Kenichi Handa <handa@m17n.org>
parents:
19404
diff
changeset
|
1845 |
19849
1c5164d81426
(quail-simple): New function.
Kenichi Handa <handa@m17n.org>
parents:
19844
diff
changeset
|
1846 ;; Return t iff the current Quail package requires showing guidance |
1c5164d81426
(quail-simple): New function.
Kenichi Handa <handa@m17n.org>
parents:
19844
diff
changeset
|
1847 ;; buffer. |
1c5164d81426
(quail-simple): New function.
Kenichi Handa <handa@m17n.org>
parents:
19844
diff
changeset
|
1848 (defun quail-require-guidance-buf () |
1c5164d81426
(quail-simple): New function.
Kenichi Handa <handa@m17n.org>
parents:
19844
diff
changeset
|
1849 (and input-method-verbose-flag |
20160
b8234ea503cd
(quail-require-guidance-buf): Adjusted
Kenichi Handa <handa@m17n.org>
parents:
19987
diff
changeset
|
1850 (if (eq input-method-verbose-flag 'default) |
b8234ea503cd
(quail-require-guidance-buf): Adjusted
Kenichi Handa <handa@m17n.org>
parents:
19987
diff
changeset
|
1851 (not (and (eq (selected-window) (minibuffer-window)) |
b8234ea503cd
(quail-require-guidance-buf): Adjusted
Kenichi Handa <handa@m17n.org>
parents:
19987
diff
changeset
|
1852 (quail-simple))) |
b8234ea503cd
(quail-require-guidance-buf): Adjusted
Kenichi Handa <handa@m17n.org>
parents:
19987
diff
changeset
|
1853 (if (eq input-method-verbose-flag 'complex-only) |
b8234ea503cd
(quail-require-guidance-buf): Adjusted
Kenichi Handa <handa@m17n.org>
parents:
19987
diff
changeset
|
1854 (not (quail-simple)) |
b8234ea503cd
(quail-require-guidance-buf): Adjusted
Kenichi Handa <handa@m17n.org>
parents:
19987
diff
changeset
|
1855 t)))) |
19849
1c5164d81426
(quail-simple): New function.
Kenichi Handa <handa@m17n.org>
parents:
19844
diff
changeset
|
1856 |
18556
99e8ae18137f
(quail-guidance-buf): Make it buffer
Kenichi Handa <handa@m17n.org>
parents:
18377
diff
changeset
|
1857 (defun quail-show-guidance-buf () |
99e8ae18137f
(quail-guidance-buf): Make it buffer
Kenichi Handa <handa@m17n.org>
parents:
18377
diff
changeset
|
1858 "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
|
1859 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
|
1860 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
|
1861 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
|
1862 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
|
1863 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
|
1864 (when (quail-require-guidance-buf) |
18556
99e8ae18137f
(quail-guidance-buf): Make it buffer
Kenichi Handa <handa@m17n.org>
parents:
18377
diff
changeset
|
1865 ;; At first, setup a guidance buffer. |
99e8ae18137f
(quail-guidance-buf): Make it buffer
Kenichi Handa <handa@m17n.org>
parents:
18377
diff
changeset
|
1866 (or (buffer-live-p quail-guidance-buf) |
99e8ae18137f
(quail-guidance-buf): Make it buffer
Kenichi Handa <handa@m17n.org>
parents:
18377
diff
changeset
|
1867 (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
|
1868 (let ((name (quail-name)) |
1fad86b8adfc
(quail-show-guidance-buf): Set
Kenichi Handa <handa@m17n.org>
parents:
29073
diff
changeset
|
1869 (title (quail-title))) |
18556
99e8ae18137f
(quail-guidance-buf): Make it buffer
Kenichi Handa <handa@m17n.org>
parents:
18377
diff
changeset
|
1870 (save-excursion |
99e8ae18137f
(quail-guidance-buf): Make it buffer
Kenichi Handa <handa@m17n.org>
parents:
18377
diff
changeset
|
1871 (set-buffer quail-guidance-buf) |
99e8ae18137f
(quail-guidance-buf): Make it buffer
Kenichi Handa <handa@m17n.org>
parents:
18377
diff
changeset
|
1872 ;; To show the title of Quail package. |
29129
1fad86b8adfc
(quail-show-guidance-buf): Set
Kenichi Handa <handa@m17n.org>
parents:
29073
diff
changeset
|
1873 (setq current-input-method name |
18556
99e8ae18137f
(quail-guidance-buf): Make it buffer
Kenichi Handa <handa@m17n.org>
parents:
18377
diff
changeset
|
1874 current-input-method-title title) |
99e8ae18137f
(quail-guidance-buf): Make it buffer
Kenichi Handa <handa@m17n.org>
parents:
18377
diff
changeset
|
1875 (erase-buffer) |
99e8ae18137f
(quail-guidance-buf): Make it buffer
Kenichi Handa <handa@m17n.org>
parents:
18377
diff
changeset
|
1876 (or (overlayp quail-overlay) |
99e8ae18137f
(quail-guidance-buf): Make it buffer
Kenichi Handa <handa@m17n.org>
parents:
18377
diff
changeset
|
1877 (progn |
99e8ae18137f
(quail-guidance-buf): Make it buffer
Kenichi Handa <handa@m17n.org>
parents:
18377
diff
changeset
|
1878 (setq quail-overlay (make-overlay 1 1)) |
99e8ae18137f
(quail-guidance-buf): Make it buffer
Kenichi Handa <handa@m17n.org>
parents:
18377
diff
changeset
|
1879 (overlay-put quail-overlay 'face 'highlight))) |
99e8ae18137f
(quail-guidance-buf): Make it buffer
Kenichi Handa <handa@m17n.org>
parents:
18377
diff
changeset
|
1880 (delete-overlay quail-overlay) |
99e8ae18137f
(quail-guidance-buf): Make it buffer
Kenichi Handa <handa@m17n.org>
parents:
18377
diff
changeset
|
1881 (set-buffer-modified-p nil))) |
99e8ae18137f
(quail-guidance-buf): Make it buffer
Kenichi Handa <handa@m17n.org>
parents:
18377
diff
changeset
|
1882 (bury-buffer quail-guidance-buf) |
17052 | 1883 |
23599
ab69e7987be0
(quail-start-translation): Handle
Kenichi Handa <handa@m17n.org>
parents:
23401
diff
changeset
|
1884 ;; 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
|
1885 ;; displaying quail-guidance-buf. |
ab69e7987be0
(quail-start-translation): Handle
Kenichi Handa <handa@m17n.org>
parents:
23401
diff
changeset
|
1886 (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
|
1887 (while win-list |
ab69e7987be0
(quail-start-translation): Handle
Kenichi Handa <handa@m17n.org>
parents:
23401
diff
changeset
|
1888 (set-window-buffer (car win-list) |
ab69e7987be0
(quail-start-translation): Handle
Kenichi Handa <handa@m17n.org>
parents:
23401
diff
changeset
|
1889 (format " *Minibuf-%d*" (minibuffer-depth))) |
ab69e7987be0
(quail-start-translation): Handle
Kenichi Handa <handa@m17n.org>
parents:
23401
diff
changeset
|
1890 (setq win-list (cdr win-list)))) |
ab69e7987be0
(quail-start-translation): Handle
Kenichi Handa <handa@m17n.org>
parents:
23401
diff
changeset
|
1891 |
18556
99e8ae18137f
(quail-guidance-buf): Make it buffer
Kenichi Handa <handa@m17n.org>
parents:
18377
diff
changeset
|
1892 ;; Then, display it in an appropriate window. |
99e8ae18137f
(quail-guidance-buf): Make it buffer
Kenichi Handa <handa@m17n.org>
parents:
18377
diff
changeset
|
1893 (let ((win (minibuffer-window))) |
22917
00f3497854c4
(quail-translation-keymap): Declare it as
Kenichi Handa <handa@m17n.org>
parents:
22883
diff
changeset
|
1894 (if (or (eq (selected-window) win) |
00f3497854c4
(quail-translation-keymap): Declare it as
Kenichi Handa <handa@m17n.org>
parents:
22883
diff
changeset
|
1895 input-method-use-echo-area) |
18556
99e8ae18137f
(quail-guidance-buf): Make it buffer
Kenichi Handa <handa@m17n.org>
parents:
18377
diff
changeset
|
1896 ;; 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
|
1897 (if (eq win (frame-root-window)) |
99e8ae18137f
(quail-guidance-buf): Make it buffer
Kenichi Handa <handa@m17n.org>
parents:
18377
diff
changeset
|
1898 ;; 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
|
1899 ;; window system. |
99e8ae18137f
(quail-guidance-buf): Make it buffer
Kenichi Handa <handa@m17n.org>
parents:
18377
diff
changeset
|
1900 (quail-make-guidance-frame quail-guidance-buf) |
99e8ae18137f
(quail-guidance-buf): Make it buffer
Kenichi Handa <handa@m17n.org>
parents:
18377
diff
changeset
|
1901 ;; Find the bottom window and split it if necessary. |
32696
a384f310fd27
(quail-show-guidance-buf): Make sure guidance window really has enough room.
Miles Bader <miles@gnu.org>
parents:
31920
diff
changeset
|
1902 (setq win (window-at |
a384f310fd27
(quail-show-guidance-buf): Make sure guidance window really has enough room.
Miles Bader <miles@gnu.org>
parents:
31920
diff
changeset
|
1903 0 (1- (- (frame-height) (window-height win))))) |
a384f310fd27
(quail-show-guidance-buf): Make sure guidance window really has enough room.
Miles Bader <miles@gnu.org>
parents:
31920
diff
changeset
|
1904 (let ((height (window-height win)) |
a384f310fd27
(quail-show-guidance-buf): Make sure guidance window really has enough room.
Miles Bader <miles@gnu.org>
parents:
31920
diff
changeset
|
1905 (window-min-height 2)) |
18556
99e8ae18137f
(quail-guidance-buf): Make it buffer
Kenichi Handa <handa@m17n.org>
parents:
18377
diff
changeset
|
1906 ;; 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
|
1907 ;; the lower one. |
32696
a384f310fd27
(quail-show-guidance-buf): Make sure guidance window really has enough room.
Miles Bader <miles@gnu.org>
parents:
31920
diff
changeset
|
1908 (when (>= height 4) |
a384f310fd27
(quail-show-guidance-buf): Make sure guidance window really has enough room.
Miles Bader <miles@gnu.org>
parents:
31920
diff
changeset
|
1909 ;; Here, `split-window' returns a lower window |
a384f310fd27
(quail-show-guidance-buf): Make sure guidance window really has enough room.
Miles Bader <miles@gnu.org>
parents:
31920
diff
changeset
|
1910 ;; which is what we wanted. |
a384f310fd27
(quail-show-guidance-buf): Make sure guidance window really has enough room.
Miles Bader <miles@gnu.org>
parents:
31920
diff
changeset
|
1911 (setq win (split-window win (- height 2)))) |
18556
99e8ae18137f
(quail-guidance-buf): Make it buffer
Kenichi Handa <handa@m17n.org>
parents:
18377
diff
changeset
|
1912 (set-window-buffer win quail-guidance-buf) |
33476
51bec48940dd
(quail-show-guidance-buf): Call fit-window-to-buffer to assure the
Kenichi Handa <handa@m17n.org>
parents:
32958
diff
changeset
|
1913 (save-excursion |
51bec48940dd
(quail-show-guidance-buf): Call fit-window-to-buffer to assure the
Kenichi Handa <handa@m17n.org>
parents:
32958
diff
changeset
|
1914 (set-buffer quail-guidance-buf) |
51bec48940dd
(quail-show-guidance-buf): Call fit-window-to-buffer to assure the
Kenichi Handa <handa@m17n.org>
parents:
32958
diff
changeset
|
1915 (fit-window-to-buffer win nil (window-height win))))) |
23629
ab6b58c72a04
(quail-show-guidance-buf): Call
Kenichi Handa <handa@m17n.org>
parents:
23599
diff
changeset
|
1916 (set-window-buffer win quail-guidance-buf) |
ab6b58c72a04
(quail-show-guidance-buf): Call
Kenichi Handa <handa@m17n.org>
parents:
23599
diff
changeset
|
1917 (set-minibuffer-window win)) |
18556
99e8ae18137f
(quail-guidance-buf): Make it buffer
Kenichi Handa <handa@m17n.org>
parents:
18377
diff
changeset
|
1918 (setq quail-guidance-win win))) |
17052 | 1919 |
1920 ;; And, create a buffer for completion. | |
19432
4492653b04e8
(quail-exit-from-minibuffer): Call
Kenichi Handa <handa@m17n.org>
parents:
19404
diff
changeset
|
1921 (quail-setup-completion-buf) |
17052 | 1922 (bury-buffer quail-completion-buf)) |
1923 | |
1924 (defun quail-hide-guidance-buf () | |
1925 "Hide the Quail guidance buffer." | |
18556
99e8ae18137f
(quail-guidance-buf): Make it buffer
Kenichi Handa <handa@m17n.org>
parents:
18377
diff
changeset
|
1926 (if (buffer-live-p quail-guidance-buf) |
99e8ae18137f
(quail-guidance-buf): Make it buffer
Kenichi Handa <handa@m17n.org>
parents:
18377
diff
changeset
|
1927 (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
|
1928 win) |
99e8ae18137f
(quail-guidance-buf): Make it buffer
Kenichi Handa <handa@m17n.org>
parents:
18377
diff
changeset
|
1929 (while win-list |
99e8ae18137f
(quail-guidance-buf): Make it buffer
Kenichi Handa <handa@m17n.org>
parents:
18377
diff
changeset
|
1930 (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
|
1931 (if (window-minibuffer-p win) |
18556
99e8ae18137f
(quail-guidance-buf): Make it buffer
Kenichi Handa <handa@m17n.org>
parents:
18377
diff
changeset
|
1932 ;; 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
|
1933 ;; Vacate it to the deepest minibuffer. |
99e8ae18137f
(quail-guidance-buf): Make it buffer
Kenichi Handa <handa@m17n.org>
parents:
18377
diff
changeset
|
1934 (set-window-buffer win |
99e8ae18137f
(quail-guidance-buf): Make it buffer
Kenichi Handa <handa@m17n.org>
parents:
18377
diff
changeset
|
1935 (format " *Minibuf-%d*" (minibuffer-depth))) |
99e8ae18137f
(quail-guidance-buf): Make it buffer
Kenichi Handa <handa@m17n.org>
parents:
18377
diff
changeset
|
1936 (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
|
1937 (progn |
99e8ae18137f
(quail-guidance-buf): Make it buffer
Kenichi Handa <handa@m17n.org>
parents:
18377
diff
changeset
|
1938 ;; 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
|
1939 ;;(set-window-dedicated-p win nil) |
99e8ae18137f
(quail-guidance-buf): Make it buffer
Kenichi Handa <handa@m17n.org>
parents:
18377
diff
changeset
|
1940 (delete-frame (window-frame win))) |
19878
a69ae37e6932
(quail-update-translation): Fix previous change.
Richard M. Stallman <rms@gnu.org>
parents:
19849
diff
changeset
|
1941 ;;(set-window-dedicated-p win nil) |
23599
ab69e7987be0
(quail-start-translation): Handle
Kenichi Handa <handa@m17n.org>
parents:
23401
diff
changeset
|
1942 (delete-window win)))) |
ab69e7987be0
(quail-start-translation): Handle
Kenichi Handa <handa@m17n.org>
parents:
23401
diff
changeset
|
1943 (setq quail-guidance-win nil)))) |
17052 | 1944 |
1945 (defun quail-update-guidance () | |
1946 "Update the Quail guidance buffer and completion buffer (if displayed now)." | |
1947 ;; Update guidance buffer. | |
19849
1c5164d81426
(quail-simple): New function.
Kenichi Handa <handa@m17n.org>
parents:
19844
diff
changeset
|
1948 (if (quail-require-guidance-buf) |
17052 | 1949 (let ((guidance (quail-guidance))) |
32708 | 1950 (unless (and (eq (selected-frame) (window-frame (minibuffer-window))) |
1951 (eq (selected-frame) (window-frame quail-guidance-win))) | |
33476
51bec48940dd
(quail-show-guidance-buf): Call fit-window-to-buffer to assure the
Kenichi Handa <handa@m17n.org>
parents:
32958
diff
changeset
|
1952 ;; The guidance window is not shown in this frame, show it. |
32708 | 1953 (quail-show-guidance-buf)) |
19723
3ada64a43911
(quail-update-guidance): If PROMPTKEY is
Kenichi Handa <handa@m17n.org>
parents:
19675
diff
changeset
|
1954 (cond ((or (eq guidance t) |
23304
3a7a029df593
(quail-update-guidance): Check for the
Kenichi Handa <handa@m17n.org>
parents:
23176
diff
changeset
|
1955 (consp guidance)) |
17052 | 1956 ;; Show the current possible translations. |
1957 (quail-show-translations)) | |
1958 ((null guidance) | |
1959 ;; Show the current input keys. | |
1960 (let ((key quail-current-key)) | |
31828
c6cdd9deac21
(quail-help): The output message is improved.
Kenichi Handa <handa@m17n.org>
parents:
31584
diff
changeset
|
1961 (if (quail-kbd-translate) |
c6cdd9deac21
(quail-help): The output message is improved.
Kenichi Handa <handa@m17n.org>
parents:
31584
diff
changeset
|
1962 (setq key (quail-keyseq-translate key))) |
17052 | 1963 (save-excursion |
1964 (set-buffer quail-guidance-buf) | |
1965 (erase-buffer) | |
32708 | 1966 (insert key))))) |
32713
b1d56a204fe6
(quail-update-guidance): Balance parens.
Miles Bader <miles@gnu.org>
parents:
32708
diff
changeset
|
1967 ;; Make sure the height of the guidance window is OK -- |
b1d56a204fe6
(quail-update-guidance): Balance parens.
Miles Bader <miles@gnu.org>
parents:
32708
diff
changeset
|
1968 ;; sometimes, if the minibuffer window expands due to user |
b1d56a204fe6
(quail-update-guidance): Balance parens.
Miles Bader <miles@gnu.org>
parents:
32708
diff
changeset
|
1969 ;; input (for instance if the newly inserted character is in a |
b1d56a204fe6
(quail-update-guidance): Balance parens.
Miles Bader <miles@gnu.org>
parents:
32708
diff
changeset
|
1970 ;; different font), it will cause the guidance window to be |
b1d56a204fe6
(quail-update-guidance): Balance parens.
Miles Bader <miles@gnu.org>
parents:
32708
diff
changeset
|
1971 ;; only partially visible. We force a redisplay first because |
b1d56a204fe6
(quail-update-guidance): Balance parens.
Miles Bader <miles@gnu.org>
parents:
32708
diff
changeset
|
1972 ;; this automatic expansion doesn't happen until then, and we |
b1d56a204fe6
(quail-update-guidance): Balance parens.
Miles Bader <miles@gnu.org>
parents:
32708
diff
changeset
|
1973 ;; want to see the window sizes after the expansion. |
b1d56a204fe6
(quail-update-guidance): Balance parens.
Miles Bader <miles@gnu.org>
parents:
32708
diff
changeset
|
1974 (sit-for 0) |
33476
51bec48940dd
(quail-show-guidance-buf): Call fit-window-to-buffer to assure the
Kenichi Handa <handa@m17n.org>
parents:
32958
diff
changeset
|
1975 (fit-window-to-buffer quail-guidance-win nil |
51bec48940dd
(quail-show-guidance-buf): Call fit-window-to-buffer to assure the
Kenichi Handa <handa@m17n.org>
parents:
32958
diff
changeset
|
1976 (window-height quail-guidance-win)))) |
17052 | 1977 |
1978 ;; Update completion buffer if displayed now. We highlight the | |
1979 ;; selected candidate string in *Completion* buffer if any. | |
1980 (let ((win (get-buffer-window quail-completion-buf)) | |
1981 key str pos) | |
1982 (if win | |
1983 (save-excursion | |
1984 (setq str (if (stringp quail-current-str) | |
1985 quail-current-str | |
1986 (if (numberp quail-current-str) | |
1987 (char-to-string quail-current-str))) | |
1988 key quail-current-key) | |
1989 (set-buffer quail-completion-buf) | |
1990 (goto-char (point-min)) | |
1991 (if (null (search-forward (concat " " key ":") nil t)) | |
1992 (delete-overlay quail-overlay) | |
1993 (setq pos (point)) | |
1994 (if (and str (search-forward (concat "." str) nil t)) | |
1995 (move-overlay quail-overlay (1+ (match-beginning 0)) (point)) | |
1996 (move-overlay quail-overlay (match-beginning 0) (point))) | |
1997 ;; Now POS points end of KEY and (point) points end of STR. | |
1998 (if (pos-visible-in-window-p (point) win) | |
1999 ;; STR is already visible. | |
2000 nil | |
2001 ;; We want to make both KEY and STR visible, but if the | |
2002 ;; window is too short, make at least STR visible. | |
2003 (setq pos (progn (point) (goto-char pos))) | |
2004 (beginning-of-line) | |
2005 (set-window-start win (point)) | |
2006 (if (not (pos-visible-in-window-p pos win)) | |
2007 (set-window-start win pos)) | |
2008 )))))) | |
2009 | |
2010 (defun quail-show-translations () | |
2011 "Show the current possible translations." | |
18297
5c8e37591da5
(quail-current-data): New variable.
Kenichi Handa <handa@m17n.org>
parents:
18201
diff
changeset
|
2012 (let* ((key quail-current-key) |
22917
00f3497854c4
(quail-translation-keymap): Declare it as
Kenichi Handa <handa@m17n.org>
parents:
22883
diff
changeset
|
2013 (map (quail-lookup-key quail-current-key)) |
00f3497854c4
(quail-translation-keymap): Declare it as
Kenichi Handa <handa@m17n.org>
parents:
22883
diff
changeset
|
2014 (current-translations quail-current-translations)) |
18556
99e8ae18137f
(quail-guidance-buf): Make it buffer
Kenichi Handa <handa@m17n.org>
parents:
18377
diff
changeset
|
2015 (if quail-current-translations |
99e8ae18137f
(quail-guidance-buf): Make it buffer
Kenichi Handa <handa@m17n.org>
parents:
18377
diff
changeset
|
2016 (quail-update-current-translations)) |
17052 | 2017 (save-excursion |
2018 (set-buffer quail-guidance-buf) | |
2019 (erase-buffer) | |
2020 | |
2021 ;; Show the current key. | |
19723
3ada64a43911
(quail-update-guidance): If PROMPTKEY is
Kenichi Handa <handa@m17n.org>
parents:
19675
diff
changeset
|
2022 (let ((guidance (quail-guidance))) |
3ada64a43911
(quail-update-guidance): If PROMPTKEY is
Kenichi Handa <handa@m17n.org>
parents:
19675
diff
changeset
|
2023 (if (listp guidance) |
3ada64a43911
(quail-update-guidance): If PROMPTKEY is
Kenichi Handa <handa@m17n.org>
parents:
19675
diff
changeset
|
2024 ;; 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
|
2025 ;; actual typed keys. |
3ada64a43911
(quail-update-guidance): If PROMPTKEY is
Kenichi Handa <handa@m17n.org>
parents:
19675
diff
changeset
|
2026 (let ((i 0) |
3ada64a43911
(quail-update-guidance): If PROMPTKEY is
Kenichi Handa <handa@m17n.org>
parents:
19675
diff
changeset
|
2027 (len (length key)) |
3ada64a43911
(quail-update-guidance): If PROMPTKEY is
Kenichi Handa <handa@m17n.org>
parents:
19675
diff
changeset
|
2028 prompt-key) |
3ada64a43911
(quail-update-guidance): If PROMPTKEY is
Kenichi Handa <handa@m17n.org>
parents:
19675
diff
changeset
|
2029 (while (< i len) |
3ada64a43911
(quail-update-guidance): If PROMPTKEY is
Kenichi Handa <handa@m17n.org>
parents:
19675
diff
changeset
|
2030 (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
|
2031 (insert (or prompt-key (aref key i))) |
3ada64a43911
(quail-update-guidance): If PROMPTKEY is
Kenichi Handa <handa@m17n.org>
parents:
19675
diff
changeset
|
2032 (setq i (1+ i)))) |
3ada64a43911
(quail-update-guidance): If PROMPTKEY is
Kenichi Handa <handa@m17n.org>
parents:
19675
diff
changeset
|
2033 (insert key))) |
17052 | 2034 |
18556
99e8ae18137f
(quail-guidance-buf): Make it buffer
Kenichi Handa <handa@m17n.org>
parents:
18377
diff
changeset
|
2035 ;; Show followable keys. |
22917
00f3497854c4
(quail-translation-keymap): Declare it as
Kenichi Handa <handa@m17n.org>
parents:
22883
diff
changeset
|
2036 (if (and (> (length key) 0) (cdr map)) |
21881
1a80d464c77a
(quail-show-translations): Show
Kenichi Handa <handa@m17n.org>
parents:
21659
diff
changeset
|
2037 (let ((keys (mapcar (function (lambda (x) (car x))) |
1a80d464c77a
(quail-show-translations): Show
Kenichi Handa <handa@m17n.org>
parents:
21659
diff
changeset
|
2038 (cdr map)))) |
1a80d464c77a
(quail-show-translations): Show
Kenichi Handa <handa@m17n.org>
parents:
21659
diff
changeset
|
2039 (setq keys (sort keys '<)) |
17052 | 2040 (insert "[") |
21881
1a80d464c77a
(quail-show-translations): Show
Kenichi Handa <handa@m17n.org>
parents:
21659
diff
changeset
|
2041 (while keys |
1a80d464c77a
(quail-show-translations): Show
Kenichi Handa <handa@m17n.org>
parents:
21659
diff
changeset
|
2042 (insert (car keys)) |
1a80d464c77a
(quail-show-translations): Show
Kenichi Handa <handa@m17n.org>
parents:
21659
diff
changeset
|
2043 (setq keys (cdr keys))) |
17052 | 2044 (insert "]"))) |
2045 | |
2046 ;; Show list of translations. | |
26891
651d521c8f52
(quail-install-map): New optional arg
Kenichi Handa <handa@m17n.org>
parents:
24821
diff
changeset
|
2047 (if (and current-translations |
651d521c8f52
(quail-install-map): New optional arg
Kenichi Handa <handa@m17n.org>
parents:
24821
diff
changeset
|
2048 (not (quail-deterministic))) |
22917
00f3497854c4
(quail-translation-keymap): Declare it as
Kenichi Handa <handa@m17n.org>
parents:
22883
diff
changeset
|
2049 (let* ((indices (car current-translations)) |
18556
99e8ae18137f
(quail-guidance-buf): Make it buffer
Kenichi Handa <handa@m17n.org>
parents:
18377
diff
changeset
|
2050 (cur (car indices)) |
99e8ae18137f
(quail-guidance-buf): Make it buffer
Kenichi Handa <handa@m17n.org>
parents:
18377
diff
changeset
|
2051 (start (nth 1 indices)) |
99e8ae18137f
(quail-guidance-buf): Make it buffer
Kenichi Handa <handa@m17n.org>
parents:
18377
diff
changeset
|
2052 (end (nth 2 indices)) |
99e8ae18137f
(quail-guidance-buf): Make it buffer
Kenichi Handa <handa@m17n.org>
parents:
18377
diff
changeset
|
2053 (idx start)) |
99e8ae18137f
(quail-guidance-buf): Make it buffer
Kenichi Handa <handa@m17n.org>
parents:
18377
diff
changeset
|
2054 (indent-to (- quail-guidance-translations-starting-column 7)) |
99e8ae18137f
(quail-guidance-buf): Make it buffer
Kenichi Handa <handa@m17n.org>
parents:
18377
diff
changeset
|
2055 (insert (format "(%02d/"(nth 3 indices)) |
99e8ae18137f
(quail-guidance-buf): Make it buffer
Kenichi Handa <handa@m17n.org>
parents:
18377
diff
changeset
|
2056 (if (nth 4 indices) |
99e8ae18137f
(quail-guidance-buf): Make it buffer
Kenichi Handa <handa@m17n.org>
parents:
18377
diff
changeset
|
2057 (format "%02d)" (nth 4 indices)) |
99e8ae18137f
(quail-guidance-buf): Make it buffer
Kenichi Handa <handa@m17n.org>
parents:
18377
diff
changeset
|
2058 "??)")) |
99e8ae18137f
(quail-guidance-buf): Make it buffer
Kenichi Handa <handa@m17n.org>
parents:
18377
diff
changeset
|
2059 (while (< idx end) |
99e8ae18137f
(quail-guidance-buf): Make it buffer
Kenichi Handa <handa@m17n.org>
parents:
18377
diff
changeset
|
2060 (insert (format " %d." (if (= (- idx start) 9) 0 |
99e8ae18137f
(quail-guidance-buf): Make it buffer
Kenichi Handa <handa@m17n.org>
parents:
18377
diff
changeset
|
2061 (1+ (- idx start))))) |
17052 | 2062 (let ((pos (point))) |
22917
00f3497854c4
(quail-translation-keymap): Declare it as
Kenichi Handa <handa@m17n.org>
parents:
22883
diff
changeset
|
2063 (insert (aref (cdr current-translations) idx)) |
18556
99e8ae18137f
(quail-guidance-buf): Make it buffer
Kenichi Handa <handa@m17n.org>
parents:
18377
diff
changeset
|
2064 (if (= idx cur) |
17052 | 2065 (move-overlay quail-overlay pos (point)))) |
18556
99e8ae18137f
(quail-guidance-buf): Make it buffer
Kenichi Handa <handa@m17n.org>
parents:
18377
diff
changeset
|
2066 (setq idx (1+ idx))))) |
17052 | 2067 ))) |
2068 | |
26891
651d521c8f52
(quail-install-map): New optional arg
Kenichi Handa <handa@m17n.org>
parents:
24821
diff
changeset
|
2069 (defvar quail-completion-max-depth 5 |
651d521c8f52
(quail-install-map): New optional arg
Kenichi Handa <handa@m17n.org>
parents:
24821
diff
changeset
|
2070 "The maximum depth of Quail completion list.") |
651d521c8f52
(quail-install-map): New optional arg
Kenichi Handa <handa@m17n.org>
parents:
24821
diff
changeset
|
2071 |
17052 | 2072 (defun quail-completion () |
2073 "List all completions for the current key. | |
2074 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
|
2075 are shown (at most to the depth specified `quail-completion-max-depth')." |
17052 | 2076 (interactive) |
19432
4492653b04e8
(quail-exit-from-minibuffer): Call
Kenichi Handa <handa@m17n.org>
parents:
19404
diff
changeset
|
2077 (quail-setup-completion-buf) |
22124
10b3c1cd7f18
(quail-completion): Consecutive call of
Kenichi Handa <handa@m17n.org>
parents:
21881
diff
changeset
|
2078 (let ((win (get-buffer-window quail-completion-buf 'visible)) |
10b3c1cd7f18
(quail-completion): Consecutive call of
Kenichi Handa <handa@m17n.org>
parents:
21881
diff
changeset
|
2079 (key quail-current-key) |
10b3c1cd7f18
(quail-completion): Consecutive call of
Kenichi Handa <handa@m17n.org>
parents:
21881
diff
changeset
|
2080 (map (quail-lookup-key quail-current-key)) |
10b3c1cd7f18
(quail-completion): Consecutive call of
Kenichi Handa <handa@m17n.org>
parents:
21881
diff
changeset
|
2081 (require-update nil)) |
17052 | 2082 (save-excursion |
2083 (set-buffer quail-completion-buf) | |
22124
10b3c1cd7f18
(quail-completion): Consecutive call of
Kenichi Handa <handa@m17n.org>
parents:
21881
diff
changeset
|
2084 (if (and win |
10b3c1cd7f18
(quail-completion): Consecutive call of
Kenichi Handa <handa@m17n.org>
parents:
21881
diff
changeset
|
2085 (equal key quail-current-key) |
10b3c1cd7f18
(quail-completion): Consecutive call of
Kenichi Handa <handa@m17n.org>
parents:
21881
diff
changeset
|
2086 (eq last-command 'quail-completion)) |
10b3c1cd7f18
(quail-completion): Consecutive call of
Kenichi Handa <handa@m17n.org>
parents:
21881
diff
changeset
|
2087 ;; The window for Quail completion buffer has already been |
10b3c1cd7f18
(quail-completion): Consecutive call of
Kenichi Handa <handa@m17n.org>
parents:
21881
diff
changeset
|
2088 ;; shown. We just scroll it appropriately. |
10b3c1cd7f18
(quail-completion): Consecutive call of
Kenichi Handa <handa@m17n.org>
parents:
21881
diff
changeset
|
2089 (if (pos-visible-in-window-p (point-max) win) |
10b3c1cd7f18
(quail-completion): Consecutive call of
Kenichi Handa <handa@m17n.org>
parents:
21881
diff
changeset
|
2090 (set-window-start win (point-min)) |
10b3c1cd7f18
(quail-completion): Consecutive call of
Kenichi Handa <handa@m17n.org>
parents:
21881
diff
changeset
|
2091 (let ((other-window-scroll-buffer quail-completion-buf)) |
10b3c1cd7f18
(quail-completion): Consecutive call of
Kenichi Handa <handa@m17n.org>
parents:
21881
diff
changeset
|
2092 (scroll-other-window))) |
10b3c1cd7f18
(quail-completion): Consecutive call of
Kenichi Handa <handa@m17n.org>
parents:
21881
diff
changeset
|
2093 (setq quail-current-key key) |
10b3c1cd7f18
(quail-completion): Consecutive call of
Kenichi Handa <handa@m17n.org>
parents:
21881
diff
changeset
|
2094 (erase-buffer) |
10b3c1cd7f18
(quail-completion): Consecutive call of
Kenichi Handa <handa@m17n.org>
parents:
21881
diff
changeset
|
2095 (insert "Possible completion and corresponding translations are:\n") |
10b3c1cd7f18
(quail-completion): Consecutive call of
Kenichi Handa <handa@m17n.org>
parents:
21881
diff
changeset
|
2096 (quail-completion-1 key map 1) |
10b3c1cd7f18
(quail-completion): Consecutive call of
Kenichi Handa <handa@m17n.org>
parents:
21881
diff
changeset
|
2097 (goto-char (point-min)) |
10b3c1cd7f18
(quail-completion): Consecutive call of
Kenichi Handa <handa@m17n.org>
parents:
21881
diff
changeset
|
2098 (display-buffer (current-buffer)) |
10b3c1cd7f18
(quail-completion): Consecutive call of
Kenichi Handa <handa@m17n.org>
parents:
21881
diff
changeset
|
2099 (setq require-update t))) |
10b3c1cd7f18
(quail-completion): Consecutive call of
Kenichi Handa <handa@m17n.org>
parents:
21881
diff
changeset
|
2100 (if require-update |
10b3c1cd7f18
(quail-completion): Consecutive call of
Kenichi Handa <handa@m17n.org>
parents:
21881
diff
changeset
|
2101 (quail-update-guidance))) |
10b3c1cd7f18
(quail-completion): Consecutive call of
Kenichi Handa <handa@m17n.org>
parents:
21881
diff
changeset
|
2102 (setq this-command 'quail-completion)) |
17052 | 2103 |
2104 ;; List all completions of KEY in MAP with indentation INDENT. | |
2105 (defun quail-completion-1 (key map indent) | |
2106 (let ((len (length key))) | |
2107 (indent-to indent) | |
2108 (insert key ":") | |
2109 (if (and (symbolp map) (fboundp map)) | |
2110 (setq map (funcall map key len))) | |
2111 (if (car map) | |
2112 (quail-completion-list-translations map key (+ indent len 1)) | |
2113 (insert " -\n")) | |
2114 (setq indent (+ indent 2)) | |
26891
651d521c8f52
(quail-install-map): New optional arg
Kenichi Handa <handa@m17n.org>
parents:
24821
diff
changeset
|
2115 (if (and (cdr map) (< (/ (1- indent) 2) quail-completion-max-depth)) |
17052 | 2116 (let ((l (cdr map)) |
2117 (newkey (make-string (1+ len) 0)) | |
2118 (i 0)) | |
26891
651d521c8f52
(quail-install-map): New optional arg
Kenichi Handa <handa@m17n.org>
parents:
24821
diff
changeset
|
2119 (if (functionp l) |
651d521c8f52
(quail-install-map): New optional arg
Kenichi Handa <handa@m17n.org>
parents:
24821
diff
changeset
|
2120 (setq l (funcall l))) |
17052 | 2121 ;; Set KEY in the first LEN characters of NEWKEY. |
2122 (while (< i len) | |
2123 (aset newkey i (aref key i)) | |
2124 (setq i (1+ i))) | |
2125 (while l ; L = ((CHAR . DEFN) ....) ; | |
2126 (aset newkey len (car (car l))) | |
2127 (quail-completion-1 newkey (cdr (car l)) indent) | |
2128 (setq l (cdr l))))))) | |
2129 | |
2130 ;; 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
|
2131 ;; indentation INDENT. |
17052 | 2132 (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
|
2133 (let (beg (translations |
18297
5c8e37591da5
(quail-current-data): New variable.
Kenichi Handa <handa@m17n.org>
parents:
18201
diff
changeset
|
2134 (quail-get-translation (car map) key (length key)))) |
17052 | 2135 (if (integerp translations) |
20169
d938bdf82445
(quail-translation-keymap): KP_Enter key
Kenichi Handa <handa@m17n.org>
parents:
20160
diff
changeset
|
2136 (progn |
d938bdf82445
(quail-translation-keymap): KP_Enter key
Kenichi Handa <handa@m17n.org>
parents:
20160
diff
changeset
|
2137 (insert "(1/1) 1.") |
d938bdf82445
(quail-translation-keymap): KP_Enter key
Kenichi Handa <handa@m17n.org>
parents:
20160
diff
changeset
|
2138 ;; Endow the character `translations' with `mouse-face' text |
d938bdf82445
(quail-translation-keymap): KP_Enter key
Kenichi Handa <handa@m17n.org>
parents:
20160
diff
changeset
|
2139 ;; property to enable `mouse-2' completion. |
d938bdf82445
(quail-translation-keymap): KP_Enter key
Kenichi Handa <handa@m17n.org>
parents:
20160
diff
changeset
|
2140 (setq beg (point)) |
d938bdf82445
(quail-translation-keymap): KP_Enter key
Kenichi Handa <handa@m17n.org>
parents:
20160
diff
changeset
|
2141 (insert translations) |
d938bdf82445
(quail-translation-keymap): KP_Enter key
Kenichi Handa <handa@m17n.org>
parents:
20160
diff
changeset
|
2142 (put-text-property beg (point) 'mouse-face 'highlight) |
d938bdf82445
(quail-translation-keymap): KP_Enter key
Kenichi Handa <handa@m17n.org>
parents:
20160
diff
changeset
|
2143 (insert "\n")) |
17052 | 2144 ;; We need only vector part. |
2145 (setq translations (cdr translations)) | |
2146 ;; Insert every 10 elements with indices in a line. | |
2147 (let ((len (length translations)) | |
2148 (i 0) | |
2149 num) | |
2150 (while (< i len) | |
19944
e274dc2d61f1
(quail-completion-list-translations): Fix
Richard M. Stallman <rms@gnu.org>
parents:
19934
diff
changeset
|
2151 (when (zerop (% i 10)) |
e274dc2d61f1
(quail-completion-list-translations): Fix
Richard M. Stallman <rms@gnu.org>
parents:
19934
diff
changeset
|
2152 (when (>= i 10) |
20169
d938bdf82445
(quail-translation-keymap): KP_Enter key
Kenichi Handa <handa@m17n.org>
parents:
20160
diff
changeset
|
2153 (insert "\n") |
19944
e274dc2d61f1
(quail-completion-list-translations): Fix
Richard M. Stallman <rms@gnu.org>
parents:
19934
diff
changeset
|
2154 (indent-to indent)) |
e274dc2d61f1
(quail-completion-list-translations): Fix
Richard M. Stallman <rms@gnu.org>
parents:
19934
diff
changeset
|
2155 (insert (format "(%d/%d)" (1+ (/ i 10)) (1+ (/ len 10))))) |
17052 | 2156 ;; We show the last digit of FROM while converting |
2157 ;; 0,1,..,9 to 1,2,..,0. | |
19944
e274dc2d61f1
(quail-completion-list-translations): Fix
Richard M. Stallman <rms@gnu.org>
parents:
19934
diff
changeset
|
2158 (insert (format " %d." (% (1+ i) 10))) |
20169
d938bdf82445
(quail-translation-keymap): KP_Enter key
Kenichi Handa <handa@m17n.org>
parents:
20160
diff
changeset
|
2159 (setq beg (point)) |
17052 | 2160 (insert (aref translations i)) |
20169
d938bdf82445
(quail-translation-keymap): KP_Enter key
Kenichi Handa <handa@m17n.org>
parents:
20160
diff
changeset
|
2161 ;; Passing the mouse over a character will highlight. |
d938bdf82445
(quail-translation-keymap): KP_Enter key
Kenichi Handa <handa@m17n.org>
parents:
20160
diff
changeset
|
2162 (put-text-property beg (point) 'mouse-face 'highlight) |
17052 | 2163 (setq i (1+ i))) |
20169
d938bdf82445
(quail-translation-keymap): KP_Enter key
Kenichi Handa <handa@m17n.org>
parents:
20160
diff
changeset
|
2164 (insert "\n"))))) |
d938bdf82445
(quail-translation-keymap): KP_Enter key
Kenichi Handa <handa@m17n.org>
parents:
20160
diff
changeset
|
2165 |
d938bdf82445
(quail-translation-keymap): KP_Enter key
Kenichi Handa <handa@m17n.org>
parents:
20160
diff
changeset
|
2166 ;; 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
|
2167 |
d938bdf82445
(quail-translation-keymap): KP_Enter key
Kenichi Handa <handa@m17n.org>
parents:
20160
diff
changeset
|
2168 (defun quail-mouse-choose-completion (event) |
d938bdf82445
(quail-translation-keymap): KP_Enter key
Kenichi Handa <handa@m17n.org>
parents:
20160
diff
changeset
|
2169 "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
|
2170 (interactive "e") |
d938bdf82445
(quail-translation-keymap): KP_Enter key
Kenichi Handa <handa@m17n.org>
parents:
20160
diff
changeset
|
2171 ;; 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
|
2172 ;; `mouse-choose-completion' except that we: |
d938bdf82445
(quail-translation-keymap): KP_Enter key
Kenichi Handa <handa@m17n.org>
parents:
20160
diff
changeset
|
2173 ;; 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
|
2174 ;; the `mouse-2' click a little more leeway. |
d938bdf82445
(quail-translation-keymap): KP_Enter key
Kenichi Handa <handa@m17n.org>
parents:
20160
diff
changeset
|
2175 ;; 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
|
2176 ;; 3) delete/terminate the current quail selection here. |
d938bdf82445
(quail-translation-keymap): KP_Enter key
Kenichi Handa <handa@m17n.org>
parents:
20160
diff
changeset
|
2177 ;; 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
|
2178 (run-hooks 'mouse-leave-buffer-hook) |
d938bdf82445
(quail-translation-keymap): KP_Enter key
Kenichi Handa <handa@m17n.org>
parents:
20160
diff
changeset
|
2179 (let ((buffer (window-buffer)) |
d938bdf82445
(quail-translation-keymap): KP_Enter key
Kenichi Handa <handa@m17n.org>
parents:
20160
diff
changeset
|
2180 choice |
d938bdf82445
(quail-translation-keymap): KP_Enter key
Kenichi Handa <handa@m17n.org>
parents:
20160
diff
changeset
|
2181 base-size) |
d938bdf82445
(quail-translation-keymap): KP_Enter key
Kenichi Handa <handa@m17n.org>
parents:
20160
diff
changeset
|
2182 (save-excursion |
d938bdf82445
(quail-translation-keymap): KP_Enter key
Kenichi Handa <handa@m17n.org>
parents:
20160
diff
changeset
|
2183 (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
|
2184 (if completion-reference-buffer |
d938bdf82445
(quail-translation-keymap): KP_Enter key
Kenichi Handa <handa@m17n.org>
parents:
20160
diff
changeset
|
2185 (setq buffer completion-reference-buffer)) |
d938bdf82445
(quail-translation-keymap): KP_Enter key
Kenichi Handa <handa@m17n.org>
parents:
20160
diff
changeset
|
2186 (setq base-size completion-base-size) |
d938bdf82445
(quail-translation-keymap): KP_Enter key
Kenichi Handa <handa@m17n.org>
parents:
20160
diff
changeset
|
2187 (save-excursion |
d938bdf82445
(quail-translation-keymap): KP_Enter key
Kenichi Handa <handa@m17n.org>
parents:
20160
diff
changeset
|
2188 (goto-char (posn-point (event-start event))) |
d938bdf82445
(quail-translation-keymap): KP_Enter key
Kenichi Handa <handa@m17n.org>
parents:
20160
diff
changeset
|
2189 (let (beg end) |
d938bdf82445
(quail-translation-keymap): KP_Enter key
Kenichi Handa <handa@m17n.org>
parents:
20160
diff
changeset
|
2190 (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
|
2191 (setq end (point) beg (1+ (point)))) |
d938bdf82445
(quail-translation-keymap): KP_Enter key
Kenichi Handa <handa@m17n.org>
parents:
20160
diff
changeset
|
2192 (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
|
2193 (setq end (1- (point)) beg (point))) |
d938bdf82445
(quail-translation-keymap): KP_Enter key
Kenichi Handa <handa@m17n.org>
parents:
20160
diff
changeset
|
2194 (if (null beg) |
22765
7cf2c3800e8f
(quail-mode): This variable deleted.
Kenichi Handa <handa@m17n.org>
parents:
22124
diff
changeset
|
2195 (quail-error "No completion here")) |
20169
d938bdf82445
(quail-translation-keymap): KP_Enter key
Kenichi Handa <handa@m17n.org>
parents:
20160
diff
changeset
|
2196 (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
|
2197 (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
|
2198 (point-max))) |
d938bdf82445
(quail-translation-keymap): KP_Enter key
Kenichi Handa <handa@m17n.org>
parents:
20160
diff
changeset
|
2199 (setq choice (buffer-substring beg end))))) |
d938bdf82445
(quail-translation-keymap): KP_Enter key
Kenichi Handa <handa@m17n.org>
parents:
20160
diff
changeset
|
2200 ; (let ((owindow (selected-window))) |
d938bdf82445
(quail-translation-keymap): KP_Enter key
Kenichi Handa <handa@m17n.org>
parents:
20160
diff
changeset
|
2201 ; (select-window (posn-window (event-start event))) |
d938bdf82445
(quail-translation-keymap): KP_Enter key
Kenichi Handa <handa@m17n.org>
parents:
20160
diff
changeset
|
2202 ; (if (and (one-window-p t 'selected-frame) |
d938bdf82445
(quail-translation-keymap): KP_Enter key
Kenichi Handa <handa@m17n.org>
parents:
20160
diff
changeset
|
2203 ; (window-dedicated-p (selected-window))) |
d938bdf82445
(quail-translation-keymap): KP_Enter key
Kenichi Handa <handa@m17n.org>
parents:
20160
diff
changeset
|
2204 ; ;; This is a special buffer's frame |
d938bdf82445
(quail-translation-keymap): KP_Enter key
Kenichi Handa <handa@m17n.org>
parents:
20160
diff
changeset
|
2205 ; (iconify-frame (selected-frame)) |
d938bdf82445
(quail-translation-keymap): KP_Enter key
Kenichi Handa <handa@m17n.org>
parents:
20160
diff
changeset
|
2206 ; (or (window-dedicated-p (selected-window)) |
d938bdf82445
(quail-translation-keymap): KP_Enter key
Kenichi Handa <handa@m17n.org>
parents:
20160
diff
changeset
|
2207 ; (bury-buffer))) |
d938bdf82445
(quail-translation-keymap): KP_Enter key
Kenichi Handa <handa@m17n.org>
parents:
20160
diff
changeset
|
2208 ; (select-window owindow)) |
d938bdf82445
(quail-translation-keymap): KP_Enter key
Kenichi Handa <handa@m17n.org>
parents:
20160
diff
changeset
|
2209 (quail-delete-region) |
d938bdf82445
(quail-translation-keymap): KP_Enter key
Kenichi Handa <handa@m17n.org>
parents:
20160
diff
changeset
|
2210 (quail-choose-completion-string choice buffer base-size) |
d938bdf82445
(quail-translation-keymap): KP_Enter key
Kenichi Handa <handa@m17n.org>
parents:
20160
diff
changeset
|
2211 (quail-terminate-translation))) |
d938bdf82445
(quail-translation-keymap): KP_Enter key
Kenichi Handa <handa@m17n.org>
parents:
20160
diff
changeset
|
2212 |
d938bdf82445
(quail-translation-keymap): KP_Enter key
Kenichi Handa <handa@m17n.org>
parents:
20160
diff
changeset
|
2213 ;; 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
|
2214 ;; 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
|
2215 ;; 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
|
2216 |
d938bdf82445
(quail-translation-keymap): KP_Enter key
Kenichi Handa <handa@m17n.org>
parents:
20160
diff
changeset
|
2217 (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
|
2218 (let ((buffer (or buffer completion-reference-buffer))) |
d938bdf82445
(quail-translation-keymap): KP_Enter key
Kenichi Handa <handa@m17n.org>
parents:
20160
diff
changeset
|
2219 ;; 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
|
2220 ;; active minibuffer. |
d938bdf82445
(quail-translation-keymap): KP_Enter key
Kenichi Handa <handa@m17n.org>
parents:
20160
diff
changeset
|
2221 (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
|
2222 (or (not (active-minibuffer-window)) |
d938bdf82445
(quail-translation-keymap): KP_Enter key
Kenichi Handa <handa@m17n.org>
parents:
20160
diff
changeset
|
2223 (not (equal buffer |
d938bdf82445
(quail-translation-keymap): KP_Enter key
Kenichi Handa <handa@m17n.org>
parents:
20160
diff
changeset
|
2224 (window-buffer (active-minibuffer-window)))))) |
22765
7cf2c3800e8f
(quail-mode): This variable deleted.
Kenichi Handa <handa@m17n.org>
parents:
22124
diff
changeset
|
2225 (quail-error "Minibuffer is not active for completion") |
23172
a47eab4fc085
(quail-choose-completion-string): Store
Kenichi Handa <handa@m17n.org>
parents:
23014
diff
changeset
|
2226 ;; 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
|
2227 ;; 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
|
2228 ;; the buffer where completion was requested. |
20169
d938bdf82445
(quail-translation-keymap): KP_Enter key
Kenichi Handa <handa@m17n.org>
parents:
20160
diff
changeset
|
2229 (set-buffer buffer) |
d938bdf82445
(quail-translation-keymap): KP_Enter key
Kenichi Handa <handa@m17n.org>
parents:
20160
diff
changeset
|
2230 ; (if base-size |
d938bdf82445
(quail-translation-keymap): KP_Enter key
Kenichi Handa <handa@m17n.org>
parents:
20160
diff
changeset
|
2231 ; (delete-region (+ base-size (point-min)) (point)) |
d938bdf82445
(quail-translation-keymap): KP_Enter key
Kenichi Handa <handa@m17n.org>
parents:
20160
diff
changeset
|
2232 ; (choose-completion-delete-max-match choice)) |
23172
a47eab4fc085
(quail-choose-completion-string): Store
Kenichi Handa <handa@m17n.org>
parents:
23014
diff
changeset
|
2233 (setq quail-current-str choice) |
20169
d938bdf82445
(quail-translation-keymap): KP_Enter key
Kenichi Handa <handa@m17n.org>
parents:
20160
diff
changeset
|
2234 ;; 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
|
2235 (let ((window (get-buffer-window buffer t))) |
d938bdf82445
(quail-translation-keymap): KP_Enter key
Kenichi Handa <handa@m17n.org>
parents:
20160
diff
changeset
|
2236 (set-window-point window (point))) |
d938bdf82445
(quail-translation-keymap): KP_Enter key
Kenichi Handa <handa@m17n.org>
parents:
20160
diff
changeset
|
2237 ;; 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
|
2238 (and (not completion-no-auto-exit) |
d938bdf82445
(quail-translation-keymap): KP_Enter key
Kenichi Handa <handa@m17n.org>
parents:
20160
diff
changeset
|
2239 (equal buffer (window-buffer (minibuffer-window))) |
d938bdf82445
(quail-translation-keymap): KP_Enter key
Kenichi Handa <handa@m17n.org>
parents:
20160
diff
changeset
|
2240 minibuffer-completion-table |
d938bdf82445
(quail-translation-keymap): KP_Enter key
Kenichi Handa <handa@m17n.org>
parents:
20160
diff
changeset
|
2241 ;; 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
|
2242 ;; is a directory, don't exit the minibuffer. |
d938bdf82445
(quail-translation-keymap): KP_Enter key
Kenichi Handa <handa@m17n.org>
parents:
20160
diff
changeset
|
2243 (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
|
2244 (file-directory-p (buffer-string))) |
d938bdf82445
(quail-translation-keymap): KP_Enter key
Kenichi Handa <handa@m17n.org>
parents:
20160
diff
changeset
|
2245 (select-window (active-minibuffer-window)) |
d938bdf82445
(quail-translation-keymap): KP_Enter key
Kenichi Handa <handa@m17n.org>
parents:
20160
diff
changeset
|
2246 (exit-minibuffer)))))) |
17052 | 2247 |
31546
09bc2badb9e6
(quail-translation-docstring): New variable.
Kenichi Handa <handa@m17n.org>
parents:
31453
diff
changeset
|
2248 ;; Accumulate in the cdr part of DECODE-MAP all pairs of key sequences |
09bc2badb9e6
(quail-translation-docstring): New variable.
Kenichi Handa <handa@m17n.org>
parents:
31453
diff
changeset
|
2249 ;; vs the corresponding translations defined in the Quail map |
09bc2badb9e6
(quail-translation-docstring): New variable.
Kenichi Handa <handa@m17n.org>
parents:
31453
diff
changeset
|
2250 ;; specified by the first element MAP-LIST. Each pair has the form |
09bc2badb9e6
(quail-translation-docstring): New variable.
Kenichi Handa <handa@m17n.org>
parents:
31453
diff
changeset
|
2251 ;; (KEYSEQ . TRANSLATION). DECODE-MAP should have the form |
09bc2badb9e6
(quail-translation-docstring): New variable.
Kenichi Handa <handa@m17n.org>
parents:
31453
diff
changeset
|
2252 ;; (decode-map . ALIST), where ALIST is an alist of length NUM. KEY |
09bc2badb9e6
(quail-translation-docstring): New variable.
Kenichi Handa <handa@m17n.org>
parents:
31453
diff
changeset
|
2253 ;; is a key sequence to reach MAP. |
09bc2badb9e6
(quail-translation-docstring): New variable.
Kenichi Handa <handa@m17n.org>
parents:
31453
diff
changeset
|
2254 ;; Optional 5th arg MAXNUM limits the number of accumulated pairs. |
09bc2badb9e6
(quail-translation-docstring): New variable.
Kenichi Handa <handa@m17n.org>
parents:
31453
diff
changeset
|
2255 ;; Optional 6th arg IGNORES is a list of translations to ignore. |
09bc2badb9e6
(quail-translation-docstring): New variable.
Kenichi Handa <handa@m17n.org>
parents:
31453
diff
changeset
|
2256 |
09bc2badb9e6
(quail-translation-docstring): New variable.
Kenichi Handa <handa@m17n.org>
parents:
31453
diff
changeset
|
2257 (defun quail-build-decode-map (map-list key decode-map num |
09bc2badb9e6
(quail-translation-docstring): New variable.
Kenichi Handa <handa@m17n.org>
parents:
31453
diff
changeset
|
2258 &optional maxnum ignores) |
09bc2badb9e6
(quail-translation-docstring): New variable.
Kenichi Handa <handa@m17n.org>
parents:
31453
diff
changeset
|
2259 (let* ((map (car map-list)) |
09bc2badb9e6
(quail-translation-docstring): New variable.
Kenichi Handa <handa@m17n.org>
parents:
31453
diff
changeset
|
2260 (translation (quail-get-translation (car map) key (length key))) |
09bc2badb9e6
(quail-translation-docstring): New variable.
Kenichi Handa <handa@m17n.org>
parents:
31453
diff
changeset
|
2261 elt) |
31424 | 2262 (cond ((integerp translation) |
31546
09bc2badb9e6
(quail-translation-docstring): New variable.
Kenichi Handa <handa@m17n.org>
parents:
31453
diff
changeset
|
2263 ;; Accept only non-ASCII chars not listed in IGNORES. |
31424 | 2264 (when (and (> translation 255) (not (memq translation ignores))) |
2265 (setcdr decode-map | |
2266 (cons (cons key translation) (cdr decode-map))) | |
2267 (setq num (1+ num)))) | |
2268 ((consp translation) | |
2269 (setq translation (cdr translation)) | |
2270 (let ((multibyte nil)) | |
2271 (mapc (function (lambda (x) | |
31546
09bc2badb9e6
(quail-translation-docstring): New variable.
Kenichi Handa <handa@m17n.org>
parents:
31453
diff
changeset
|
2272 ;; Accept only non-ASCII chars not |
09bc2badb9e6
(quail-translation-docstring): New variable.
Kenichi Handa <handa@m17n.org>
parents:
31453
diff
changeset
|
2273 ;; listed in IGNORES. |
31424 | 2274 (if (and (if (integerp x) (> x 255) |
2275 (> (string-bytes x) (length x))) | |
2276 (not (member x ignores))) | |
2277 (setq multibyte t)))) | |
2278 translation) | |
2279 (when multibyte | |
2280 (setcdr decode-map | |
2281 (cons (cons key translation) (cdr decode-map))) | |
2282 (setq num (+ num (length translation))))))) | |
2283 (if (and maxnum (> num maxnum)) | |
2284 (- num) | |
2285 (setq map (cdr map)) | |
31546
09bc2badb9e6
(quail-translation-docstring): New variable.
Kenichi Handa <handa@m17n.org>
parents:
31453
diff
changeset
|
2286 ;; Recursively check the deeper map. |
31424 | 2287 (while (and map (>= num 0)) |
2288 (setq elt (car map) map (cdr map)) | |
31546
09bc2badb9e6
(quail-translation-docstring): New variable.
Kenichi Handa <handa@m17n.org>
parents:
31453
diff
changeset
|
2289 (when (and (integerp (car elt)) (consp (cdr elt)) |
09bc2badb9e6
(quail-translation-docstring): New variable.
Kenichi Handa <handa@m17n.org>
parents:
31453
diff
changeset
|
2290 (not (memq (cdr elt) map-list))) |
09bc2badb9e6
(quail-translation-docstring): New variable.
Kenichi Handa <handa@m17n.org>
parents:
31453
diff
changeset
|
2291 (setq num (quail-build-decode-map (cons (cdr elt) map-list) |
31424 | 2292 (format "%s%c" key (car elt)) |
2293 decode-map num maxnum ignores)))) | |
2294 num))) | |
2295 | |
31546
09bc2badb9e6
(quail-translation-docstring): New variable.
Kenichi Handa <handa@m17n.org>
parents:
31453
diff
changeset
|
2296 ;; Insert the pairs of key sequences vs the corresponding translations |
09bc2badb9e6
(quail-translation-docstring): New variable.
Kenichi Handa <handa@m17n.org>
parents:
31453
diff
changeset
|
2297 ;; stored in DECODE-MAP by the concise format. DECODE-MAP should be |
09bc2badb9e6
(quail-translation-docstring): New variable.
Kenichi Handa <handa@m17n.org>
parents:
31453
diff
changeset
|
2298 ;; made by `quail-build-decode-map' (which see). |
09bc2badb9e6
(quail-translation-docstring): New variable.
Kenichi Handa <handa@m17n.org>
parents:
31453
diff
changeset
|
2299 |
31424 | 2300 (defun quail-insert-decode-map (decode-map) |
2301 (setq decode-map | |
2302 (sort (cdr decode-map) | |
2303 (function (lambda (x y) | |
2304 (setq x (car x) y (car y)) | |
2305 (or (> (length x) (length y)) | |
2306 (and (= (length x) (length y)) | |
2307 (not (string< x y)))))))) | |
34357
30d5effa35e9
(quail-insert-decode-map): Check the
Kenichi Handa <handa@m17n.org>
parents:
33544
diff
changeset
|
2308 (let ((frame-width (frame-width (window-frame (get-buffer-window |
30d5effa35e9
(quail-insert-decode-map): Check the
Kenichi Handa <handa@m17n.org>
parents:
33544
diff
changeset
|
2309 (current-buffer) 'visible)))) |
31546
09bc2badb9e6
(quail-translation-docstring): New variable.
Kenichi Handa <handa@m17n.org>
parents:
31453
diff
changeset
|
2310 (single-key-width 3) |
09bc2badb9e6
(quail-translation-docstring): New variable.
Kenichi Handa <handa@m17n.org>
parents:
31453
diff
changeset
|
2311 (single-trans-width 4) |
09bc2badb9e6
(quail-translation-docstring): New variable.
Kenichi Handa <handa@m17n.org>
parents:
31453
diff
changeset
|
2312 (multiple-key-width 3) |
09bc2badb9e6
(quail-translation-docstring): New variable.
Kenichi Handa <handa@m17n.org>
parents:
31453
diff
changeset
|
2313 (single-list nil) |
09bc2badb9e6
(quail-translation-docstring): New variable.
Kenichi Handa <handa@m17n.org>
parents:
31453
diff
changeset
|
2314 (multiple-list nil) |
31424 | 2315 elt trans width pos cols rows col row str col-width) |
31546
09bc2badb9e6
(quail-translation-docstring): New variable.
Kenichi Handa <handa@m17n.org>
parents:
31453
diff
changeset
|
2316 ;; Divide the elements of decoding map into single ones (i.e. the |
09bc2badb9e6
(quail-translation-docstring): New variable.
Kenichi Handa <handa@m17n.org>
parents:
31453
diff
changeset
|
2317 ;; one that has single translation) and multibyte ones (i.e. the |
09bc2badb9e6
(quail-translation-docstring): New variable.
Kenichi Handa <handa@m17n.org>
parents:
31453
diff
changeset
|
2318 ;; one that has multiple translations). |
31424 | 2319 (while decode-map |
2320 (setq elt (car decode-map) decode-map (cdr decode-map) | |
2321 trans (cdr elt)) | |
2322 (if (and (vectorp trans) (= (length trans) 1)) | |
2323 (setq trans (aref trans 0))) | |
2324 (if (vectorp trans) | |
31546
09bc2badb9e6
(quail-translation-docstring): New variable.
Kenichi Handa <handa@m17n.org>
parents:
31453
diff
changeset
|
2325 (setq multiple-list (cons elt multiple-list)) |
09bc2badb9e6
(quail-translation-docstring): New variable.
Kenichi Handa <handa@m17n.org>
parents:
31453
diff
changeset
|
2326 (setq single-list (cons (cons (car elt) trans) single-list) |
31424 | 2327 width (if (stringp trans) (string-width trans) |
2328 (char-width trans))) | |
31546
09bc2badb9e6
(quail-translation-docstring): New variable.
Kenichi Handa <handa@m17n.org>
parents:
31453
diff
changeset
|
2329 (if (> width single-trans-width) |
09bc2badb9e6
(quail-translation-docstring): New variable.
Kenichi Handa <handa@m17n.org>
parents:
31453
diff
changeset
|
2330 (setq single-trans-width width))) |
31424 | 2331 (setq width (length (car elt))) |
31546
09bc2badb9e6
(quail-translation-docstring): New variable.
Kenichi Handa <handa@m17n.org>
parents:
31453
diff
changeset
|
2332 (if (> width single-key-width) |
09bc2badb9e6
(quail-translation-docstring): New variable.
Kenichi Handa <handa@m17n.org>
parents:
31453
diff
changeset
|
2333 (setq single-key-width width)) |
09bc2badb9e6
(quail-translation-docstring): New variable.
Kenichi Handa <handa@m17n.org>
parents:
31453
diff
changeset
|
2334 (if (> width multiple-key-width) |
09bc2badb9e6
(quail-translation-docstring): New variable.
Kenichi Handa <handa@m17n.org>
parents:
31453
diff
changeset
|
2335 (setq multiple-key-width width))) |
09bc2badb9e6
(quail-translation-docstring): New variable.
Kenichi Handa <handa@m17n.org>
parents:
31453
diff
changeset
|
2336 (when single-list |
09bc2badb9e6
(quail-translation-docstring): New variable.
Kenichi Handa <handa@m17n.org>
parents:
31453
diff
changeset
|
2337 (setq col-width (+ single-key-width 1 single-trans-width 1) |
31424 | 2338 cols (/ frame-width col-width) |
31546
09bc2badb9e6
(quail-translation-docstring): New variable.
Kenichi Handa <handa@m17n.org>
parents:
31453
diff
changeset
|
2339 rows (/ (length single-list) cols)) |
09bc2badb9e6
(quail-translation-docstring): New variable.
Kenichi Handa <handa@m17n.org>
parents:
31453
diff
changeset
|
2340 (if (> (% (length single-list) cols) 0) |
31424 | 2341 (setq rows (1+ rows))) |
2342 (insert "key") | |
31546
09bc2badb9e6
(quail-translation-docstring): New variable.
Kenichi Handa <handa@m17n.org>
parents:
31453
diff
changeset
|
2343 (indent-to (1+ single-key-width)) |
31424 | 2344 (insert "char") |
2345 (indent-to (1+ col-width)) | |
2346 (insert "[type a key sequence to insert the corresponding character]\n") | |
2347 (setq pos (point)) | |
2348 (insert-char ?\n (+ rows 2)) | |
2349 (goto-char pos) | |
2350 (setq col (- col-width) row 0) | |
31546
09bc2badb9e6
(quail-translation-docstring): New variable.
Kenichi Handa <handa@m17n.org>
parents:
31453
diff
changeset
|
2351 (while single-list |
09bc2badb9e6
(quail-translation-docstring): New variable.
Kenichi Handa <handa@m17n.org>
parents:
31453
diff
changeset
|
2352 (setq elt (car single-list) single-list (cdr single-list)) |
31424 | 2353 (when (= (% row rows) 0) |
2354 (goto-char pos) | |
2355 (setq col (+ col col-width)) | |
2356 (move-to-column col t) | |
31546
09bc2badb9e6
(quail-translation-docstring): New variable.
Kenichi Handa <handa@m17n.org>
parents:
31453
diff
changeset
|
2357 (insert-char ?- single-key-width) |
31424 | 2358 (insert ? ) |
31546
09bc2badb9e6
(quail-translation-docstring): New variable.
Kenichi Handa <handa@m17n.org>
parents:
31453
diff
changeset
|
2359 (insert-char ?- single-trans-width) |
31424 | 2360 (forward-line 1)) |
2361 (move-to-column col t) | |
2362 (insert (car elt)) | |
31546
09bc2badb9e6
(quail-translation-docstring): New variable.
Kenichi Handa <handa@m17n.org>
parents:
31453
diff
changeset
|
2363 (indent-to (+ col single-key-width 1)) |
31424 | 2364 (insert (cdr elt)) |
2365 (forward-line 1) | |
2366 (setq row (1+ row))) | |
2367 (goto-char (point-max))) | |
2368 | |
31546
09bc2badb9e6
(quail-translation-docstring): New variable.
Kenichi Handa <handa@m17n.org>
parents:
31453
diff
changeset
|
2369 (when multiple-list |
31424 | 2370 (insert "key") |
31546
09bc2badb9e6
(quail-translation-docstring): New variable.
Kenichi Handa <handa@m17n.org>
parents:
31453
diff
changeset
|
2371 (indent-to (1+ multiple-key-width)) |
31424 | 2372 (insert "character(s) [type a key (sequence) and select one from the list]\n") |
31546
09bc2badb9e6
(quail-translation-docstring): New variable.
Kenichi Handa <handa@m17n.org>
parents:
31453
diff
changeset
|
2373 (insert-char ?- multiple-key-width) |
31424 | 2374 (insert " ------------\n") |
31546
09bc2badb9e6
(quail-translation-docstring): New variable.
Kenichi Handa <handa@m17n.org>
parents:
31453
diff
changeset
|
2375 (while multiple-list |
09bc2badb9e6
(quail-translation-docstring): New variable.
Kenichi Handa <handa@m17n.org>
parents:
31453
diff
changeset
|
2376 (setq elt (car multiple-list) multiple-list (cdr multiple-list)) |
31424 | 2377 (insert (car elt)) |
31546
09bc2badb9e6
(quail-translation-docstring): New variable.
Kenichi Handa <handa@m17n.org>
parents:
31453
diff
changeset
|
2378 (indent-to multiple-key-width) |
31424 | 2379 (if (vectorp (cdr elt)) |
2380 (mapc (function | |
2381 (lambda (x) | |
2382 (let ((width (if (integerp x) (char-width x) | |
2383 (string-width x)))) | |
2384 (when (> (+ (current-column) 1 width) frame-width) | |
2385 (insert "\n") | |
31546
09bc2badb9e6
(quail-translation-docstring): New variable.
Kenichi Handa <handa@m17n.org>
parents:
31453
diff
changeset
|
2386 (indent-to multiple-key-width)) |
31424 | 2387 (insert " " x)))) |
2388 (cdr elt)) | |
2389 (insert " " (cdr elt))) | |
2390 (insert ?\n)) | |
2391 (insert ?\n)))) | |
2392 | |
31247
e49bf88ce1f8
(quail-help): New arg PACKAGE. Hyperlinks to mule related items.
Kenichi Handa <handa@m17n.org>
parents:
31217
diff
changeset
|
2393 (defun quail-help (&optional package) |
e49bf88ce1f8
(quail-help): New arg PACKAGE. Hyperlinks to mule related items.
Kenichi Handa <handa@m17n.org>
parents:
31217
diff
changeset
|
2394 "Show brief description of the current Quail package. |
31546
09bc2badb9e6
(quail-translation-docstring): New variable.
Kenichi Handa <handa@m17n.org>
parents:
31453
diff
changeset
|
2395 Optional 2nd arg PACKAGE specifies the name of alternative Quail |
09bc2badb9e6
(quail-translation-docstring): New variable.
Kenichi Handa <handa@m17n.org>
parents:
31453
diff
changeset
|
2396 package to describe." |
17052 | 2397 (interactive) |
31424 | 2398 (if package |
2399 (setq package (assoc package quail-package-alist)) | |
2400 (setq package quail-current-package)) | |
31247
e49bf88ce1f8
(quail-help): New arg PACKAGE. Hyperlinks to mule related items.
Kenichi Handa <handa@m17n.org>
parents:
31217
diff
changeset
|
2401 (let ((help-xref-mule-regexp help-xref-mule-regexp-template)) |
34357
30d5effa35e9
(quail-insert-decode-map): Check the
Kenichi Handa <handa@m17n.org>
parents:
33544
diff
changeset
|
2402 ;; At first, make sure that the help buffer has window. |
31247
e49bf88ce1f8
(quail-help): New arg PACKAGE. Hyperlinks to mule related items.
Kenichi Handa <handa@m17n.org>
parents:
31217
diff
changeset
|
2403 (with-output-to-temp-buffer "*Help*" |
18349
f468344dd2bd
(quail-help): Use with-output-to-temp-buffer.
Kenichi Handa <handa@m17n.org>
parents:
18297
diff
changeset
|
2404 (save-excursion |
f468344dd2bd
(quail-help): Use with-output-to-temp-buffer.
Kenichi Handa <handa@m17n.org>
parents:
18297
diff
changeset
|
2405 (set-buffer standard-output) |
34357
30d5effa35e9
(quail-insert-decode-map): Check the
Kenichi Handa <handa@m17n.org>
parents:
33544
diff
changeset
|
2406 (setq quail-current-package package))) |
30d5effa35e9
(quail-insert-decode-map): Check the
Kenichi Handa <handa@m17n.org>
parents:
33544
diff
changeset
|
2407 ;; Then, insert text in the help buffer while paying attention to |
30d5effa35e9
(quail-insert-decode-map): Check the
Kenichi Handa <handa@m17n.org>
parents:
33544
diff
changeset
|
2408 ;; the width of the frame in which the buffer displayed. |
30d5effa35e9
(quail-insert-decode-map): Check the
Kenichi Handa <handa@m17n.org>
parents:
33544
diff
changeset
|
2409 (save-excursion |
30d5effa35e9
(quail-insert-decode-map): Check the
Kenichi Handa <handa@m17n.org>
parents:
33544
diff
changeset
|
2410 (progn |
30d5effa35e9
(quail-insert-decode-map): Check the
Kenichi Handa <handa@m17n.org>
parents:
33544
diff
changeset
|
2411 (set-buffer (get-buffer "*Help*")) |
30d5effa35e9
(quail-insert-decode-map): Check the
Kenichi Handa <handa@m17n.org>
parents:
33544
diff
changeset
|
2412 (setq buffer-read-only nil) |
31424 | 2413 (insert "Input method: " (quail-name) |
2414 " (mode line indicator:" | |
31247
e49bf88ce1f8
(quail-help): New arg PACKAGE. Hyperlinks to mule related items.
Kenichi Handa <handa@m17n.org>
parents:
31217
diff
changeset
|
2415 (quail-title) |
31546
09bc2badb9e6
(quail-translation-docstring): New variable.
Kenichi Handa <handa@m17n.org>
parents:
31453
diff
changeset
|
2416 ")\n\n") |
09bc2badb9e6
(quail-translation-docstring): New variable.
Kenichi Handa <handa@m17n.org>
parents:
31453
diff
changeset
|
2417 (save-restriction |
09bc2badb9e6
(quail-translation-docstring): New variable.
Kenichi Handa <handa@m17n.org>
parents:
31453
diff
changeset
|
2418 (narrow-to-region (point) (point)) |
09bc2badb9e6
(quail-translation-docstring): New variable.
Kenichi Handa <handa@m17n.org>
parents:
31453
diff
changeset
|
2419 (insert (quail-docstring)) |
09bc2badb9e6
(quail-translation-docstring): New variable.
Kenichi Handa <handa@m17n.org>
parents:
31453
diff
changeset
|
2420 (goto-char (point-min)) |
09bc2badb9e6
(quail-translation-docstring): New variable.
Kenichi Handa <handa@m17n.org>
parents:
31453
diff
changeset
|
2421 (with-syntax-table emacs-lisp-mode-syntax-table |
09bc2badb9e6
(quail-translation-docstring): New variable.
Kenichi Handa <handa@m17n.org>
parents:
31453
diff
changeset
|
2422 (while (re-search-forward "\\\\<\\sw\\(\\sw\\|\\s_\\)+>" nil t) |
09bc2badb9e6
(quail-translation-docstring): New variable.
Kenichi Handa <handa@m17n.org>
parents:
31453
diff
changeset
|
2423 (let ((sym (intern-soft |
09bc2badb9e6
(quail-translation-docstring): New variable.
Kenichi Handa <handa@m17n.org>
parents:
31453
diff
changeset
|
2424 (buffer-substring (+ (match-beginning 0) 2) |
09bc2badb9e6
(quail-translation-docstring): New variable.
Kenichi Handa <handa@m17n.org>
parents:
31453
diff
changeset
|
2425 (1- (point)))))) |
09bc2badb9e6
(quail-translation-docstring): New variable.
Kenichi Handa <handa@m17n.org>
parents:
31453
diff
changeset
|
2426 (if (and (boundp sym) |
09bc2badb9e6
(quail-translation-docstring): New variable.
Kenichi Handa <handa@m17n.org>
parents:
31453
diff
changeset
|
2427 (stringp (symbol-value sym))) |
09bc2badb9e6
(quail-translation-docstring): New variable.
Kenichi Handa <handa@m17n.org>
parents:
31453
diff
changeset
|
2428 (replace-match (symbol-value sym) t t))))) |
09bc2badb9e6
(quail-translation-docstring): New variable.
Kenichi Handa <handa@m17n.org>
parents:
31453
diff
changeset
|
2429 (goto-char (point-max))) |
31424 | 2430 (or (bolp) |
2431 (insert "\n")) | |
2432 (insert "\n") | |
2433 | |
2434 (let ((done-list nil)) | |
2435 ;; Show keyboard layout if the current package requests it.. | |
2436 (when (quail-show-layout) | |
31546
09bc2badb9e6
(quail-translation-docstring): New variable.
Kenichi Handa <handa@m17n.org>
parents:
31453
diff
changeset
|
2437 (insert " |
09bc2badb9e6
(quail-translation-docstring): New variable.
Kenichi Handa <handa@m17n.org>
parents:
31453
diff
changeset
|
2438 KEYBOARD LAYOUT |
09bc2badb9e6
(quail-translation-docstring): New variable.
Kenichi Handa <handa@m17n.org>
parents:
31453
diff
changeset
|
2439 --------------- |
31828
c6cdd9deac21
(quail-help): The output message is improved.
Kenichi Handa <handa@m17n.org>
parents:
31584
diff
changeset
|
2440 This input method works by translating individual input characters. |
c6cdd9deac21
(quail-help): The output message is improved.
Kenichi Handa <handa@m17n.org>
parents:
31584
diff
changeset
|
2441 Assuming that your actual keyboard has the `") |
31424 | 2442 (help-insert-xref-button |
2443 quail-keyboard-layout-type | |
2444 #'quail-show-keyboard-layout quail-keyboard-layout-type | |
2445 "mouse-2, RET: show this layout") | |
31828
c6cdd9deac21
(quail-help): The output message is improved.
Kenichi Handa <handa@m17n.org>
parents:
31584
diff
changeset
|
2446 (insert "' layout, |
c6cdd9deac21
(quail-help): The output message is improved.
Kenichi Handa <handa@m17n.org>
parents:
31584
diff
changeset
|
2447 translation results in the following \"virtual\" keyboard layout: |
c6cdd9deac21
(quail-help): The output message is improved.
Kenichi Handa <handa@m17n.org>
parents:
31584
diff
changeset
|
2448 ") |
c6cdd9deac21
(quail-help): The output message is improved.
Kenichi Handa <handa@m17n.org>
parents:
31584
diff
changeset
|
2449 (setq done-list |
c6cdd9deac21
(quail-help): The output message is improved.
Kenichi Handa <handa@m17n.org>
parents:
31584
diff
changeset
|
2450 (quail-insert-kbd-layout quail-keyboard-layout)) |
c6cdd9deac21
(quail-help): The output message is improved.
Kenichi Handa <handa@m17n.org>
parents:
31584
diff
changeset
|
2451 (insert "If your keyboard has a different layout, rearranged from |
c6cdd9deac21
(quail-help): The output message is improved.
Kenichi Handa <handa@m17n.org>
parents:
31584
diff
changeset
|
2452 `") |
31424 | 2453 (help-insert-xref-button |
31828
c6cdd9deac21
(quail-help): The output message is improved.
Kenichi Handa <handa@m17n.org>
parents:
31584
diff
changeset
|
2454 "standard" |
c6cdd9deac21
(quail-help): The output message is improved.
Kenichi Handa <handa@m17n.org>
parents:
31584
diff
changeset
|
2455 #'quail-show-keyboard-layout "standard" |
c6cdd9deac21
(quail-help): The output message is improved.
Kenichi Handa <handa@m17n.org>
parents:
31584
diff
changeset
|
2456 "mouse-2, RET: show this layout") |
c6cdd9deac21
(quail-help): The output message is improved.
Kenichi Handa <handa@m17n.org>
parents:
31584
diff
changeset
|
2457 (insert "', the \"virtual\" keyboard you get with this input method |
c6cdd9deac21
(quail-help): The output message is improved.
Kenichi Handa <handa@m17n.org>
parents:
31584
diff
changeset
|
2458 will be rearranged in the same way. |
c6cdd9deac21
(quail-help): The output message is improved.
Kenichi Handa <handa@m17n.org>
parents:
31584
diff
changeset
|
2459 |
c6cdd9deac21
(quail-help): The output message is improved.
Kenichi Handa <handa@m17n.org>
parents:
31584
diff
changeset
|
2460 You can set the variable `quail-keyboard-layout-type' to specify |
c6cdd9deac21
(quail-help): The output message is improved.
Kenichi Handa <handa@m17n.org>
parents:
31584
diff
changeset
|
2461 the physical layout of your keyboard; the tables shown in |
c6cdd9deac21
(quail-help): The output message is improved.
Kenichi Handa <handa@m17n.org>
parents:
31584
diff
changeset
|
2462 documentation of input methods including this one are based on the |
c6cdd9deac21
(quail-help): The output message is improved.
Kenichi Handa <handa@m17n.org>
parents:
31584
diff
changeset
|
2463 physical keyboard layout as specified with that variable. |
c6cdd9deac21
(quail-help): The output message is improved.
Kenichi Handa <handa@m17n.org>
parents:
31584
diff
changeset
|
2464 ") |
c6cdd9deac21
(quail-help): The output message is improved.
Kenichi Handa <handa@m17n.org>
parents:
31584
diff
changeset
|
2465 (help-insert-xref-button |
31920
75b162c6dc9e
(quail-help): The output message is improved.
Kenichi Handa <handa@m17n.org>
parents:
31828
diff
changeset
|
2466 "[customize keyboard layout]" |
31424 | 2467 #'customize-variable 'quail-keyboard-layout-type |
2468 "mouse-2, RET: set keyboard layout type") | |
31828
c6cdd9deac21
(quail-help): The output message is improved.
Kenichi Handa <handa@m17n.org>
parents:
31584
diff
changeset
|
2469 (insert "\n")) |
31424 | 2470 |
2471 ;; Show key sequences. | |
2472 (let ((decode-map (list 'decode-map)) | |
2473 elt pos num) | |
31546
09bc2badb9e6
(quail-translation-docstring): New variable.
Kenichi Handa <handa@m17n.org>
parents:
31453
diff
changeset
|
2474 (setq num (quail-build-decode-map (list (quail-map)) "" decode-map |
31424 | 2475 0 512 done-list)) |
2476 (when (> num 0) | |
31546
09bc2badb9e6
(quail-translation-docstring): New variable.
Kenichi Handa <handa@m17n.org>
parents:
31453
diff
changeset
|
2477 (insert " |
09bc2badb9e6
(quail-translation-docstring): New variable.
Kenichi Handa <handa@m17n.org>
parents:
31453
diff
changeset
|
2478 KEY SEQUENCE |
09bc2badb9e6
(quail-translation-docstring): New variable.
Kenichi Handa <handa@m17n.org>
parents:
31453
diff
changeset
|
2479 ----------- |
09bc2badb9e6
(quail-translation-docstring): New variable.
Kenichi Handa <handa@m17n.org>
parents:
31453
diff
changeset
|
2480 ") |
31424 | 2481 (if (quail-show-layout) |
2482 (insert "You can also input more characters") | |
2483 (insert "You can input characters")) | |
2484 (insert " by the following key sequences:\n") | |
2485 (quail-insert-decode-map decode-map)))) | |
2486 | |
31247
e49bf88ce1f8
(quail-help): New arg PACKAGE. Hyperlinks to mule related items.
Kenichi Handa <handa@m17n.org>
parents:
31217
diff
changeset
|
2487 (quail-help-insert-keymap-description |
e49bf88ce1f8
(quail-help): New arg PACKAGE. Hyperlinks to mule related items.
Kenichi Handa <handa@m17n.org>
parents:
31217
diff
changeset
|
2488 (quail-translation-keymap) |
31546
09bc2badb9e6
(quail-translation-docstring): New variable.
Kenichi Handa <handa@m17n.org>
parents:
31453
diff
changeset
|
2489 "\ |
09bc2badb9e6
(quail-translation-docstring): New variable.
Kenichi Handa <handa@m17n.org>
parents:
31453
diff
changeset
|
2490 KEY BINDINGS FOR TRANSLATION |
09bc2badb9e6
(quail-translation-docstring): New variable.
Kenichi Handa <handa@m17n.org>
parents:
31453
diff
changeset
|
2491 ----------------------------\n") |
31424 | 2492 (insert ?\n) |
31247
e49bf88ce1f8
(quail-help): New arg PACKAGE. Hyperlinks to mule related items.
Kenichi Handa <handa@m17n.org>
parents:
31217
diff
changeset
|
2493 (if (quail-conversion-keymap) |
e49bf88ce1f8
(quail-help): New arg PACKAGE. Hyperlinks to mule related items.
Kenichi Handa <handa@m17n.org>
parents:
31217
diff
changeset
|
2494 (quail-help-insert-keymap-description |
e49bf88ce1f8
(quail-help): New arg PACKAGE. Hyperlinks to mule related items.
Kenichi Handa <handa@m17n.org>
parents:
31217
diff
changeset
|
2495 (quail-conversion-keymap) |
31546
09bc2badb9e6
(quail-translation-docstring): New variable.
Kenichi Handa <handa@m17n.org>
parents:
31453
diff
changeset
|
2496 "\ |
09bc2badb9e6
(quail-translation-docstring): New variable.
Kenichi Handa <handa@m17n.org>
parents:
31453
diff
changeset
|
2497 KEY BINDINGS FOR CONVERSION |
09bc2badb9e6
(quail-translation-docstring): New variable.
Kenichi Handa <handa@m17n.org>
parents:
31453
diff
changeset
|
2498 ---------------------------\n")) |
31453
8dff6bfed650
(quail-help): Fix previous change.
Kenichi Handa <handa@m17n.org>
parents:
31424
diff
changeset
|
2499 (help-setup-xref (list #'quail-help (quail-name)) |
8dff6bfed650
(quail-help): Fix previous change.
Kenichi Handa <handa@m17n.org>
parents:
31424
diff
changeset
|
2500 (interactive-p)) |
8dff6bfed650
(quail-help): Fix previous change.
Kenichi Handa <handa@m17n.org>
parents:
31424
diff
changeset
|
2501 (setq quail-current-package nil))))) |
18349
f468344dd2bd
(quail-help): Use with-output-to-temp-buffer.
Kenichi Handa <handa@m17n.org>
parents:
18297
diff
changeset
|
2502 |
17052 | 2503 (defun quail-help-insert-keymap-description (keymap &optional header) |
31424 | 2504 (let (pos1 pos2 eol) |
2505 (setq pos1 (point)) | |
17052 | 2506 (if header |
2507 (insert header)) | |
31546
09bc2badb9e6
(quail-translation-docstring): New variable.
Kenichi Handa <handa@m17n.org>
parents:
31453
diff
changeset
|
2508 (save-excursion |
09bc2badb9e6
(quail-translation-docstring): New variable.
Kenichi Handa <handa@m17n.org>
parents:
31453
diff
changeset
|
2509 (insert (substitute-command-keys "\\{keymap}"))) |
09bc2badb9e6
(quail-translation-docstring): New variable.
Kenichi Handa <handa@m17n.org>
parents:
31453
diff
changeset
|
2510 ;; Skip headers "key bindings", etc. |
31424 | 2511 (forward-line 3) |
2512 (setq pos2 (point)) | |
2513 (with-syntax-table emacs-lisp-mode-syntax-table | |
2514 (while (re-search-forward "\\sw\\(\\sw\\|\\s_\\)+" nil t) | |
2515 (let ((sym (intern-soft (buffer-substring (match-beginning 0) | |
2516 (point))))) | |
2517 (if (and sym (fboundp sym) | |
31546
09bc2badb9e6
(quail-translation-docstring): New variable.
Kenichi Handa <handa@m17n.org>
parents:
31453
diff
changeset
|
2518 (or (eq (get sym 'quail-help) 'hide) |
09bc2badb9e6
(quail-translation-docstring): New variable.
Kenichi Handa <handa@m17n.org>
parents:
31453
diff
changeset
|
2519 (and (quail-deterministic) |
09bc2badb9e6
(quail-translation-docstring): New variable.
Kenichi Handa <handa@m17n.org>
parents:
31453
diff
changeset
|
2520 (eq (get sym 'quail-help) 'non-deterministic)))) |
31424 | 2521 (delete-region (line-beginning-position) |
2522 (1+ (line-end-position))))))) | |
2523 (goto-char pos2) | |
2524 (while (not (eobp)) | |
2525 (if (looking-at "[ \t]*$") | |
2526 (delete-region (point) (1+ (line-end-position))) | |
2527 (forward-line 1))) | |
2528 (goto-char pos2) | |
2529 (if (eobp) | |
2530 (delete-region pos1 (point))) | |
2531 (goto-char (point-max)))) | |
17052 | 2532 |
2533 (defun quail-translation-help () | |
22917
00f3497854c4
(quail-translation-keymap): Declare it as
Kenichi Handa <handa@m17n.org>
parents:
22883
diff
changeset
|
2534 "Show help message while translating in Quail input method." |
17052 | 2535 (interactive) |
22917
00f3497854c4
(quail-translation-keymap): Declare it as
Kenichi Handa <handa@m17n.org>
parents:
22883
diff
changeset
|
2536 (if (not (eq this-command last-command)) |
00f3497854c4
(quail-translation-keymap): Declare it as
Kenichi Handa <handa@m17n.org>
parents:
22883
diff
changeset
|
2537 (let (state-msg keymap) |
00f3497854c4
(quail-translation-keymap): Declare it as
Kenichi Handa <handa@m17n.org>
parents:
22883
diff
changeset
|
2538 (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
|
2539 (setq state-msg |
00f3497854c4
(quail-translation-keymap): Declare it as
Kenichi Handa <handa@m17n.org>
parents:
22883
diff
changeset
|
2540 (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
|
2541 quail-conversion-str (quail-name)) |
00f3497854c4
(quail-translation-keymap): Declare it as
Kenichi Handa <handa@m17n.org>
parents:
22883
diff
changeset
|
2542 keymap (quail-conversion-keymap)) |
00f3497854c4
(quail-translation-keymap): Declare it as
Kenichi Handa <handa@m17n.org>
parents:
22883
diff
changeset
|
2543 (setq state-msg |
00f3497854c4
(quail-translation-keymap): Declare it as
Kenichi Handa <handa@m17n.org>
parents:
22883
diff
changeset
|
2544 (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
|
2545 quail-current-key (quail-name)) |
00f3497854c4
(quail-translation-keymap): Declare it as
Kenichi Handa <handa@m17n.org>
parents:
22883
diff
changeset
|
2546 keymap (quail-translation-keymap))) |
31247
e49bf88ce1f8
(quail-help): New arg PACKAGE. Hyperlinks to mule related items.
Kenichi Handa <handa@m17n.org>
parents:
31217
diff
changeset
|
2547 (with-output-to-temp-buffer "*Help*" |
22917
00f3497854c4
(quail-translation-keymap): Declare it as
Kenichi Handa <handa@m17n.org>
parents:
22883
diff
changeset
|
2548 (save-excursion |
00f3497854c4
(quail-translation-keymap): Declare it as
Kenichi Handa <handa@m17n.org>
parents:
22883
diff
changeset
|
2549 (set-buffer standard-output) |
00f3497854c4
(quail-translation-keymap): Declare it as
Kenichi Handa <handa@m17n.org>
parents:
22883
diff
changeset
|
2550 (insert state-msg) |
00f3497854c4
(quail-translation-keymap): Declare it as
Kenichi Handa <handa@m17n.org>
parents:
22883
diff
changeset
|
2551 (quail-help-insert-keymap-description |
00f3497854c4
(quail-translation-keymap): Declare it as
Kenichi Handa <handa@m17n.org>
parents:
22883
diff
changeset
|
2552 keymap |
31247
e49bf88ce1f8
(quail-help): New arg PACKAGE. Hyperlinks to mule related items.
Kenichi Handa <handa@m17n.org>
parents:
31217
diff
changeset
|
2553 "-----------------------\n") |
22917
00f3497854c4
(quail-translation-keymap): Declare it as
Kenichi Handa <handa@m17n.org>
parents:
22883
diff
changeset
|
2554 (help-mode))))) |
00f3497854c4
(quail-translation-keymap): Declare it as
Kenichi Handa <handa@m17n.org>
parents:
22883
diff
changeset
|
2555 (let (scroll-help) |
00f3497854c4
(quail-translation-keymap): Declare it as
Kenichi Handa <handa@m17n.org>
parents:
22883
diff
changeset
|
2556 (save-selected-window |
31247
e49bf88ce1f8
(quail-help): New arg PACKAGE. Hyperlinks to mule related items.
Kenichi Handa <handa@m17n.org>
parents:
31217
diff
changeset
|
2557 (select-window (get-buffer-window "*Help*")) |
22917
00f3497854c4
(quail-translation-keymap): Declare it as
Kenichi Handa <handa@m17n.org>
parents:
22883
diff
changeset
|
2558 (if (eq this-command last-command) |
00f3497854c4
(quail-translation-keymap): Declare it as
Kenichi Handa <handa@m17n.org>
parents:
22883
diff
changeset
|
2559 (if (< (window-end) (point-max)) |
00f3497854c4
(quail-translation-keymap): Declare it as
Kenichi Handa <handa@m17n.org>
parents:
22883
diff
changeset
|
2560 (scroll-up) |
00f3497854c4
(quail-translation-keymap): Declare it as
Kenichi Handa <handa@m17n.org>
parents:
22883
diff
changeset
|
2561 (if (> (window-start) (point-min)) |
00f3497854c4
(quail-translation-keymap): Declare it as
Kenichi Handa <handa@m17n.org>
parents:
22883
diff
changeset
|
2562 (set-window-start (selected-window) (point-min))))) |
00f3497854c4
(quail-translation-keymap): Declare it as
Kenichi Handa <handa@m17n.org>
parents:
22883
diff
changeset
|
2563 (setq scroll-help |
00f3497854c4
(quail-translation-keymap): Declare it as
Kenichi Handa <handa@m17n.org>
parents:
22883
diff
changeset
|
2564 (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
|
2565 "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
|
2566 (if (> (window-start) (point-min)) |
00f3497854c4
(quail-translation-keymap): Declare it as
Kenichi Handa <handa@m17n.org>
parents:
22883
diff
changeset
|
2567 "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
|
2568 (if scroll-help |
00f3497854c4
(quail-translation-keymap): Declare it as
Kenichi Handa <handa@m17n.org>
parents:
22883
diff
changeset
|
2569 (progn |
00f3497854c4
(quail-translation-keymap): Declare it as
Kenichi Handa <handa@m17n.org>
parents:
22883
diff
changeset
|
2570 (message "%s" (substitute-command-keys scroll-help)) |
00f3497854c4
(quail-translation-keymap): Declare it as
Kenichi Handa <handa@m17n.org>
parents:
22883
diff
changeset
|
2571 (sit-for 1) |
00f3497854c4
(quail-translation-keymap): Declare it as
Kenichi Handa <handa@m17n.org>
parents:
22883
diff
changeset
|
2572 (message nil) |
00f3497854c4
(quail-translation-keymap): Declare it as
Kenichi Handa <handa@m17n.org>
parents:
22883
diff
changeset
|
2573 (quail-update-guidance) |
00f3497854c4
(quail-translation-keymap): Declare it as
Kenichi Handa <handa@m17n.org>
parents:
22883
diff
changeset
|
2574 )))) |
26891
651d521c8f52
(quail-install-map): New optional arg
Kenichi Handa <handa@m17n.org>
parents:
24821
diff
changeset
|
2575 |
651d521c8f52
(quail-install-map): New optional arg
Kenichi Handa <handa@m17n.org>
parents:
24821
diff
changeset
|
2576 ;; Quail map generator from state transition table. |
651d521c8f52
(quail-install-map): New optional arg
Kenichi Handa <handa@m17n.org>
parents:
24821
diff
changeset
|
2577 |
651d521c8f52
(quail-install-map): New optional arg
Kenichi Handa <handa@m17n.org>
parents:
24821
diff
changeset
|
2578 (defun quail-map-from-table (table) |
651d521c8f52
(quail-install-map): New optional arg
Kenichi Handa <handa@m17n.org>
parents:
24821
diff
changeset
|
2579 "Make quail map from state transition table TABLE. |
651d521c8f52
(quail-install-map): New optional arg
Kenichi Handa <handa@m17n.org>
parents:
24821
diff
changeset
|
2580 |
651d521c8f52
(quail-install-map): New optional arg
Kenichi Handa <handa@m17n.org>
parents:
24821
diff
changeset
|
2581 TABLE is an alist, the form is: |
651d521c8f52
(quail-install-map): New optional arg
Kenichi Handa <handa@m17n.org>
parents:
24821
diff
changeset
|
2582 ((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
|
2583 |
651d521c8f52
(quail-install-map): New optional arg
Kenichi Handa <handa@m17n.org>
parents:
24821
diff
changeset
|
2584 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
|
2585 |
651d521c8f52
(quail-install-map): New optional arg
Kenichi Handa <handa@m17n.org>
parents:
24821
diff
changeset
|
2586 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
|
2587 \(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
|
2588 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
|
2589 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
|
2590 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
|
2591 |
651d521c8f52
(quail-install-map): New optional arg
Kenichi Handa <handa@m17n.org>
parents:
24821
diff
changeset
|
2592 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
|
2593 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
|
2594 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
|
2595 |
651d521c8f52
(quail-install-map): New optional arg
Kenichi Handa <handa@m17n.org>
parents:
24821
diff
changeset
|
2596 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
|
2597 when keys in RULES are input. |
651d521c8f52
(quail-install-map): New optional arg
Kenichi Handa <handa@m17n.org>
parents:
24821
diff
changeset
|
2598 |
651d521c8f52
(quail-install-map): New optional arg
Kenichi Handa <handa@m17n.org>
parents:
24821
diff
changeset
|
2599 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
|
2600 function `quail-install-map' (which see)." |
651d521c8f52
(quail-install-map): New optional arg
Kenichi Handa <handa@m17n.org>
parents:
24821
diff
changeset
|
2601 (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
|
2602 tail elt) |
651d521c8f52
(quail-install-map): New optional arg
Kenichi Handa <handa@m17n.org>
parents:
24821
diff
changeset
|
2603 ;; 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
|
2604 ;; 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
|
2605 ;; 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
|
2606 (while table |
651d521c8f52
(quail-install-map): New optional arg
Kenichi Handa <handa@m17n.org>
parents:
24821
diff
changeset
|
2607 (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
|
2608 (setq table (cdr table))) |
651d521c8f52
(quail-install-map): New optional arg
Kenichi Handa <handa@m17n.org>
parents:
24821
diff
changeset
|
2609 |
651d521c8f52
(quail-install-map): New optional arg
Kenichi Handa <handa@m17n.org>
parents:
24821
diff
changeset
|
2610 ;; 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
|
2611 ;; 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
|
2612 ;; 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
|
2613 ;; STATE-ALIST valid Quail maps. |
651d521c8f52
(quail-install-map): New optional arg
Kenichi Handa <handa@m17n.org>
parents:
24821
diff
changeset
|
2614 (setq tail state-alist) |
651d521c8f52
(quail-install-map): New optional arg
Kenichi Handa <handa@m17n.org>
parents:
24821
diff
changeset
|
2615 (while tail |
651d521c8f52
(quail-install-map): New optional arg
Kenichi Handa <handa@m17n.org>
parents:
24821
diff
changeset
|
2616 (setq elt (car tail) tail (cdr tail)) |
651d521c8f52
(quail-install-map): New optional arg
Kenichi Handa <handa@m17n.org>
parents:
24821
diff
changeset
|
2617 (quail-map-from-table-2 state-alist elt)) |
651d521c8f52
(quail-install-map): New optional arg
Kenichi Handa <handa@m17n.org>
parents:
24821
diff
changeset
|
2618 |
651d521c8f52
(quail-install-map): New optional arg
Kenichi Handa <handa@m17n.org>
parents:
24821
diff
changeset
|
2619 ;; Return the Quail map for the initial state. |
651d521c8f52
(quail-install-map): New optional arg
Kenichi Handa <handa@m17n.org>
parents:
24821
diff
changeset
|
2620 (car state-alist))) |
651d521c8f52
(quail-install-map): New optional arg
Kenichi Handa <handa@m17n.org>
parents:
24821
diff
changeset
|
2621 |
651d521c8f52
(quail-install-map): New optional arg
Kenichi Handa <handa@m17n.org>
parents:
24821
diff
changeset
|
2622 ;; 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
|
2623 ;; 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
|
2624 ;; STATE according to TRANSITION ... |
651d521c8f52
(quail-install-map): New optional arg
Kenichi Handa <handa@m17n.org>
parents:
24821
diff
changeset
|
2625 (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
|
2626 (let* ((state (car state-info)) |
651d521c8f52
(quail-install-map): New optional arg
Kenichi Handa <handa@m17n.org>
parents:
24821
diff
changeset
|
2627 (map (assq state state-alist)) |
651d521c8f52
(quail-install-map): New optional arg
Kenichi Handa <handa@m17n.org>
parents:
24821
diff
changeset
|
2628 (transitions (cdr state-info)) |
651d521c8f52
(quail-install-map): New optional arg
Kenichi Handa <handa@m17n.org>
parents:
24821
diff
changeset
|
2629 elt) |
651d521c8f52
(quail-install-map): New optional arg
Kenichi Handa <handa@m17n.org>
parents:
24821
diff
changeset
|
2630 (while transitions |
651d521c8f52
(quail-install-map): New optional arg
Kenichi Handa <handa@m17n.org>
parents:
24821
diff
changeset
|
2631 (setq elt (car transitions) transitions (cdr transitions)) |
651d521c8f52
(quail-install-map): New optional arg
Kenichi Handa <handa@m17n.org>
parents:
24821
diff
changeset
|
2632 (let (rules dst-state key trans) |
651d521c8f52
(quail-install-map): New optional arg
Kenichi Handa <handa@m17n.org>
parents:
24821
diff
changeset
|
2633 ;; 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
|
2634 ;; 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
|
2635 (if (consp elt) |
651d521c8f52
(quail-install-map): New optional arg
Kenichi Handa <handa@m17n.org>
parents:
24821
diff
changeset
|
2636 (setq rules (symbol-value (car elt)) |
651d521c8f52
(quail-install-map): New optional arg
Kenichi Handa <handa@m17n.org>
parents:
24821
diff
changeset
|
2637 ;; 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
|
2638 ;; 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
|
2639 ;; later in `quail-map-from-table-2'. |
651d521c8f52
(quail-install-map): New optional arg
Kenichi Handa <handa@m17n.org>
parents:
24821
diff
changeset
|
2640 dst-state (list (cdr elt))) |
651d521c8f52
(quail-install-map): New optional arg
Kenichi Handa <handa@m17n.org>
parents:
24821
diff
changeset
|
2641 (setq rules (symbol-value elt))) |
651d521c8f52
(quail-install-map): New optional arg
Kenichi Handa <handa@m17n.org>
parents:
24821
diff
changeset
|
2642 (while rules |
651d521c8f52
(quail-install-map): New optional arg
Kenichi Handa <handa@m17n.org>
parents:
24821
diff
changeset
|
2643 (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
|
2644 rules (cdr rules)) |
651d521c8f52
(quail-install-map): New optional arg
Kenichi Handa <handa@m17n.org>
parents:
24821
diff
changeset
|
2645 (if (stringp trans) |
651d521c8f52
(quail-install-map): New optional arg
Kenichi Handa <handa@m17n.org>
parents:
24821
diff
changeset
|
2646 (if (= (length trans) 1) |
651d521c8f52
(quail-install-map): New optional arg
Kenichi Handa <handa@m17n.org>
parents:
24821
diff
changeset
|
2647 (setq trans (aref trans 0)) |
651d521c8f52
(quail-install-map): New optional arg
Kenichi Handa <handa@m17n.org>
parents:
24821
diff
changeset
|
2648 (setq trans (string-to-vector trans)))) |
651d521c8f52
(quail-install-map): New optional arg
Kenichi Handa <handa@m17n.org>
parents:
24821
diff
changeset
|
2649 (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
|
2650 |
651d521c8f52
(quail-install-map): New optional arg
Kenichi Handa <handa@m17n.org>
parents:
24821
diff
changeset
|
2651 ;; 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
|
2652 ;; the form is: |
651d521c8f52
(quail-install-map): New optional arg
Kenichi Handa <handa@m17n.org>
parents:
24821
diff
changeset
|
2653 ;; (STATE (CHAR NESTED-ALIST) ...) |
651d521c8f52
(quail-install-map): New optional arg
Kenichi Handa <handa@m17n.org>
parents:
24821
diff
changeset
|
2654 ;; 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
|
2655 ;; (TRANS (CHAR NESTED-ALIST) ...) |
651d521c8f52
(quail-install-map): New optional arg
Kenichi Handa <handa@m17n.org>
parents:
24821
diff
changeset
|
2656 ;; or |
651d521c8f52
(quail-install-map): New optional arg
Kenichi Handa <handa@m17n.org>
parents:
24821
diff
changeset
|
2657 ;; (TRANS (CHAR NESTED-ALIST) ... . (STATE-x)) |
651d521c8f52
(quail-install-map): New optional arg
Kenichi Handa <handa@m17n.org>
parents:
24821
diff
changeset
|
2658 ;; 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
|
2659 ;; (cdr (assq STATE-x STATE-ALIST)) |
651d521c8f52
(quail-install-map): New optional arg
Kenichi Handa <handa@m17n.org>
parents:
24821
diff
changeset
|
2660 |
651d521c8f52
(quail-install-map): New optional arg
Kenichi Handa <handa@m17n.org>
parents:
24821
diff
changeset
|
2661 (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
|
2662 (let ((prev element) |
651d521c8f52
(quail-install-map): New optional arg
Kenichi Handa <handa@m17n.org>
parents:
24821
diff
changeset
|
2663 (tail (cdr element)) |
651d521c8f52
(quail-install-map): New optional arg
Kenichi Handa <handa@m17n.org>
parents:
24821
diff
changeset
|
2664 elt) |
651d521c8f52
(quail-install-map): New optional arg
Kenichi Handa <handa@m17n.org>
parents:
24821
diff
changeset
|
2665 (while (cdr tail) |
651d521c8f52
(quail-install-map): New optional arg
Kenichi Handa <handa@m17n.org>
parents:
24821
diff
changeset
|
2666 (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
|
2667 (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
|
2668 (setq elt (car tail)) |
651d521c8f52
(quail-install-map): New optional arg
Kenichi Handa <handa@m17n.org>
parents:
24821
diff
changeset
|
2669 (if (consp elt) |
651d521c8f52
(quail-install-map): New optional arg
Kenichi Handa <handa@m17n.org>
parents:
24821
diff
changeset
|
2670 (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
|
2671 (setcdr prev (cdr (assq elt state-alist)))))) |
651d521c8f52
(quail-install-map): New optional arg
Kenichi Handa <handa@m17n.org>
parents:
24821
diff
changeset
|
2672 |
651d521c8f52
(quail-install-map): New optional arg
Kenichi Handa <handa@m17n.org>
parents:
24821
diff
changeset
|
2673 ;; 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
|
2674 ;; 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
|
2675 ;; 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
|
2676 (defun quail-lookup-map-and-concat (key) |
651d521c8f52
(quail-install-map): New optional arg
Kenichi Handa <handa@m17n.org>
parents:
24821
diff
changeset
|
2677 (let* ((len (length key)) |
651d521c8f52
(quail-install-map): New optional arg
Kenichi Handa <handa@m17n.org>
parents:
24821
diff
changeset
|
2678 (translation-list nil) |
651d521c8f52
(quail-install-map): New optional arg
Kenichi Handa <handa@m17n.org>
parents:
24821
diff
changeset
|
2679 map) |
651d521c8f52
(quail-install-map): New optional arg
Kenichi Handa <handa@m17n.org>
parents:
24821
diff
changeset
|
2680 (while (> len 0) |
651d521c8f52
(quail-install-map): New optional arg
Kenichi Handa <handa@m17n.org>
parents:
24821
diff
changeset
|
2681 (setq map (quail-lookup-key key len) |
651d521c8f52
(quail-install-map): New optional arg
Kenichi Handa <handa@m17n.org>
parents:
24821
diff
changeset
|
2682 len (1- len)) |
651d521c8f52
(quail-install-map): New optional arg
Kenichi Handa <handa@m17n.org>
parents:
24821
diff
changeset
|
2683 (if map |
651d521c8f52
(quail-install-map): New optional arg
Kenichi Handa <handa@m17n.org>
parents:
24821
diff
changeset
|
2684 (let* ((def (quail-map-definition map)) |
651d521c8f52
(quail-install-map): New optional arg
Kenichi Handa <handa@m17n.org>
parents:
24821
diff
changeset
|
2685 (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
|
2686 def))) |
651d521c8f52
(quail-install-map): New optional arg
Kenichi Handa <handa@m17n.org>
parents:
24821
diff
changeset
|
2687 (if (integerp trans) |
651d521c8f52
(quail-install-map): New optional arg
Kenichi Handa <handa@m17n.org>
parents:
24821
diff
changeset
|
2688 (setq trans (char-to-string trans))) |
651d521c8f52
(quail-install-map): New optional arg
Kenichi Handa <handa@m17n.org>
parents:
24821
diff
changeset
|
2689 (setq translation-list (cons trans translation-list))))) |
651d521c8f52
(quail-install-map): New optional arg
Kenichi Handa <handa@m17n.org>
parents:
24821
diff
changeset
|
2690 (apply 'concat translation-list))) |
17052 | 2691 |
18297
5c8e37591da5
(quail-current-data): New variable.
Kenichi Handa <handa@m17n.org>
parents:
18201
diff
changeset
|
2692 |
5c8e37591da5
(quail-current-data): New variable.
Kenichi Handa <handa@m17n.org>
parents:
18201
diff
changeset
|
2693 (defvar quail-directory-name "quail" |
23176 | 2694 "Name of Quail directory which contains Quail packages. |
18297
5c8e37591da5
(quail-current-data): New variable.
Kenichi Handa <handa@m17n.org>
parents:
18201
diff
changeset
|
2695 This is a sub-directory of LEIM directory.") |
5c8e37591da5
(quail-current-data): New variable.
Kenichi Handa <handa@m17n.org>
parents:
18201
diff
changeset
|
2696 |
5c8e37591da5
(quail-current-data): New variable.
Kenichi Handa <handa@m17n.org>
parents:
18201
diff
changeset
|
2697 ;;;###autoload |
19605
3b700b203cfd
(quail-update-leim-list-file): Make it
Kenichi Handa <handa@m17n.org>
parents:
19519
diff
changeset
|
2698 (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
|
2699 "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
|
2700 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
|
2701 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
|
2702 of the Emacs source tree. |
3b700b203cfd
(quail-update-leim-list-file): Make it
Kenichi Handa <handa@m17n.org>
parents:
19519
diff
changeset
|
2703 |
3b700b203cfd
(quail-update-leim-list-file): Make it
Kenichi Handa <handa@m17n.org>
parents:
19519
diff
changeset
|
2704 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
|
2705 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
|
2706 |
3b700b203cfd
(quail-update-leim-list-file): Make it
Kenichi Handa <handa@m17n.org>
parents:
19519
diff
changeset
|
2707 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
|
2708 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
|
2709 of each directory." |
18297
5c8e37591da5
(quail-current-data): New variable.
Kenichi Handa <handa@m17n.org>
parents:
18201
diff
changeset
|
2710 (interactive "FDirectory of LEIM: ") |
19605
3b700b203cfd
(quail-update-leim-list-file): Make it
Kenichi Handa <handa@m17n.org>
parents:
19519
diff
changeset
|
2711 (setq dirname (expand-file-name dirname)) |
3b700b203cfd
(quail-update-leim-list-file): Make it
Kenichi Handa <handa@m17n.org>
parents:
19519
diff
changeset
|
2712 (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
|
2713 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
|
2714 (if (not (file-writable-p leim-list)) |
3b700b203cfd
(quail-update-leim-list-file): Make it
Kenichi Handa <handa@m17n.org>
parents:
19519
diff
changeset
|
2715 (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
|
2716 (message "Updating %s ..." leim-list) |
3b700b203cfd
(quail-update-leim-list-file): Make it
Kenichi Handa <handa@m17n.org>
parents:
19519
diff
changeset
|
2717 (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
|
2718 |
3b700b203cfd
(quail-update-leim-list-file): Make it
Kenichi Handa <handa@m17n.org>
parents:
19519
diff
changeset
|
2719 ;; At first, clean up the file. |
3b700b203cfd
(quail-update-leim-list-file): Make it
Kenichi Handa <handa@m17n.org>
parents:
19519
diff
changeset
|
2720 (save-excursion |
3b700b203cfd
(quail-update-leim-list-file): Make it
Kenichi Handa <handa@m17n.org>
parents:
19519
diff
changeset
|
2721 (set-buffer list-buf) |
3b700b203cfd
(quail-update-leim-list-file): Make it
Kenichi Handa <handa@m17n.org>
parents:
19519
diff
changeset
|
2722 (goto-char 1) |
18297
5c8e37591da5
(quail-current-data): New variable.
Kenichi Handa <handa@m17n.org>
parents:
18201
diff
changeset
|
2723 |
19605
3b700b203cfd
(quail-update-leim-list-file): Make it
Kenichi Handa <handa@m17n.org>
parents:
19519
diff
changeset
|
2724 ;; Insert the correct header. |
3b700b203cfd
(quail-update-leim-list-file): Make it
Kenichi Handa <handa@m17n.org>
parents:
19519
diff
changeset
|
2725 (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
|
2726 (goto-char (match-end 0)) |
3b700b203cfd
(quail-update-leim-list-file): Make it
Kenichi Handa <handa@m17n.org>
parents:
19519
diff
changeset
|
2727 (insert leim-list-header)) |
3b700b203cfd
(quail-update-leim-list-file): Make it
Kenichi Handa <handa@m17n.org>
parents:
19519
diff
changeset
|
2728 (setq pos (point)) |
3b700b203cfd
(quail-update-leim-list-file): Make it
Kenichi Handa <handa@m17n.org>
parents:
19519
diff
changeset
|
2729 (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
|
2730 nil |
3b700b203cfd
(quail-update-leim-list-file): Make it
Kenichi Handa <handa@m17n.org>
parents:
19519
diff
changeset
|
2731 |
3b700b203cfd
(quail-update-leim-list-file): Make it
Kenichi Handa <handa@m17n.org>
parents:
19519
diff
changeset
|
2732 ;; Remove garbages after the header. |
3b700b203cfd
(quail-update-leim-list-file): Make it
Kenichi Handa <handa@m17n.org>
parents:
19519
diff
changeset
|
2733 (goto-char (match-beginning 0)) |
3b700b203cfd
(quail-update-leim-list-file): Make it
Kenichi Handa <handa@m17n.org>
parents:
19519
diff
changeset
|
2734 (if (< pos (point)) |
3b700b203cfd
(quail-update-leim-list-file): Make it
Kenichi Handa <handa@m17n.org>
parents:
19519
diff
changeset
|
2735 (delete-region pos (point))) |
18297
5c8e37591da5
(quail-current-data): New variable.
Kenichi Handa <handa@m17n.org>
parents:
18201
diff
changeset
|
2736 |
19605
3b700b203cfd
(quail-update-leim-list-file): Make it
Kenichi Handa <handa@m17n.org>
parents:
19519
diff
changeset
|
2737 ;; Remove all entries for Quail. |
3b700b203cfd
(quail-update-leim-list-file): Make it
Kenichi Handa <handa@m17n.org>
parents:
19519
diff
changeset
|
2738 (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
|
2739 (goto-char (match-beginning 0)) |
3b700b203cfd
(quail-update-leim-list-file): Make it
Kenichi Handa <handa@m17n.org>
parents:
19519
diff
changeset
|
2740 (setq pos (point)) |
3b700b203cfd
(quail-update-leim-list-file): Make it
Kenichi Handa <handa@m17n.org>
parents:
19519
diff
changeset
|
2741 (condition-case nil |
3b700b203cfd
(quail-update-leim-list-file): Make it
Kenichi Handa <handa@m17n.org>
parents:
19519
diff
changeset
|
2742 (let ((form (read list-buf))) |
3b700b203cfd
(quail-update-leim-list-file): Make it
Kenichi Handa <handa@m17n.org>
parents:
19519
diff
changeset
|
2743 (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
|
2744 (if (eolp) (forward-line 1)) |
3b700b203cfd
(quail-update-leim-list-file): Make it
Kenichi Handa <handa@m17n.org>
parents:
19519
diff
changeset
|
2745 (delete-region pos (point)))) |
3b700b203cfd
(quail-update-leim-list-file): Make it
Kenichi Handa <handa@m17n.org>
parents:
19519
diff
changeset
|
2746 (error |
3b700b203cfd
(quail-update-leim-list-file): Make it
Kenichi Handa <handa@m17n.org>
parents:
19519
diff
changeset
|
2747 ;; 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
|
2748 ;; this file is broken. |
23014
ddc2fa7883d6
(quail-update-leim-list-file): Fix message syntax.
Richard M. Stallman <rms@gnu.org>
parents:
22984
diff
changeset
|
2749 (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
|
2750 (delete-region pos (point-max))))))) |
18297
5c8e37591da5
(quail-current-data): New variable.
Kenichi Handa <handa@m17n.org>
parents:
18201
diff
changeset
|
2751 |
23176 | 2752 ;; 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
|
2753 (setq dirnames (cons dirname dirnames)) |
3b700b203cfd
(quail-update-leim-list-file): Make it
Kenichi Handa <handa@m17n.org>
parents:
19519
diff
changeset
|
2754 (let ((l dirnames)) |
3b700b203cfd
(quail-update-leim-list-file): Make it
Kenichi Handa <handa@m17n.org>
parents:
19519
diff
changeset
|
2755 (while l |
3b700b203cfd
(quail-update-leim-list-file): Make it
Kenichi Handa <handa@m17n.org>
parents:
19519
diff
changeset
|
2756 (setcar l (expand-file-name (car l))) |
3b700b203cfd
(quail-update-leim-list-file): Make it
Kenichi Handa <handa@m17n.org>
parents:
19519
diff
changeset
|
2757 (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
|
2758 (if (file-readable-p dirname) |
3b700b203cfd
(quail-update-leim-list-file): Make it
Kenichi Handa <handa@m17n.org>
parents:
19519
diff
changeset
|
2759 (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
|
2760 (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
|
2761 (car l) quail-directory-name) |
3b700b203cfd
(quail-update-leim-list-file): Make it
Kenichi Handa <handa@m17n.org>
parents:
19519
diff
changeset
|
2762 (setq quail-dirs (cons nil quail-dirs))) |
3b700b203cfd
(quail-update-leim-list-file): Make it
Kenichi Handa <handa@m17n.org>
parents:
19519
diff
changeset
|
2763 (setq l (cdr l))) |
3b700b203cfd
(quail-update-leim-list-file): Make it
Kenichi Handa <handa@m17n.org>
parents:
19519
diff
changeset
|
2764 (setq quail-dirs (nreverse quail-dirs))) |
18297
5c8e37591da5
(quail-current-data): New variable.
Kenichi Handa <handa@m17n.org>
parents:
18201
diff
changeset
|
2765 |
19605
3b700b203cfd
(quail-update-leim-list-file): Make it
Kenichi Handa <handa@m17n.org>
parents:
19519
diff
changeset
|
2766 ;; Insert input method registering forms. |
3b700b203cfd
(quail-update-leim-list-file): Make it
Kenichi Handa <handa@m17n.org>
parents:
19519
diff
changeset
|
2767 (while quail-dirs |
3b700b203cfd
(quail-update-leim-list-file): Make it
Kenichi Handa <handa@m17n.org>
parents:
19519
diff
changeset
|
2768 (setq dirname (car quail-dirs)) |
3b700b203cfd
(quail-update-leim-list-file): Make it
Kenichi Handa <handa@m17n.org>
parents:
19519
diff
changeset
|
2769 (when dirname |
3b700b203cfd
(quail-update-leim-list-file): Make it
Kenichi Handa <handa@m17n.org>
parents:
19519
diff
changeset
|
2770 (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
|
2771 (while pkg-list |
3b700b203cfd
(quail-update-leim-list-file): Make it
Kenichi Handa <handa@m17n.org>
parents:
19519
diff
changeset
|
2772 (message "Checking %s ..." (car pkg-list)) |
3b700b203cfd
(quail-update-leim-list-file): Make it
Kenichi Handa <handa@m17n.org>
parents:
19519
diff
changeset
|
2773 (with-temp-buffer |
3b700b203cfd
(quail-update-leim-list-file): Make it
Kenichi Handa <handa@m17n.org>
parents:
19519
diff
changeset
|
2774 (insert-file-contents (car pkg-list)) |
3b700b203cfd
(quail-update-leim-list-file): Make it
Kenichi Handa <handa@m17n.org>
parents:
19519
diff
changeset
|
2775 (goto-char (point-min)) |
3b700b203cfd
(quail-update-leim-list-file): Make it
Kenichi Handa <handa@m17n.org>
parents:
19519
diff
changeset
|
2776 (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
|
2777 (goto-char (match-beginning 0)) |
3b700b203cfd
(quail-update-leim-list-file): Make it
Kenichi Handa <handa@m17n.org>
parents:
19519
diff
changeset
|
2778 (condition-case nil |
3b700b203cfd
(quail-update-leim-list-file): Make it
Kenichi Handa <handa@m17n.org>
parents:
19519
diff
changeset
|
2779 (let ((form (read (current-buffer)))) |
3b700b203cfd
(quail-update-leim-list-file): Make it
Kenichi Handa <handa@m17n.org>
parents:
19519
diff
changeset
|
2780 (save-excursion |
3b700b203cfd
(quail-update-leim-list-file): Make it
Kenichi Handa <handa@m17n.org>
parents:
19519
diff
changeset
|
2781 (set-buffer list-buf) |
3b700b203cfd
(quail-update-leim-list-file): Make it
Kenichi Handa <handa@m17n.org>
parents:
19519
diff
changeset
|
2782 (insert |
3b700b203cfd
(quail-update-leim-list-file): Make it
Kenichi Handa <handa@m17n.org>
parents:
19519
diff
changeset
|
2783 (format "(register-input-method |
18297
5c8e37591da5
(quail-current-data): New variable.
Kenichi Handa <handa@m17n.org>
parents:
18201
diff
changeset
|
2784 %S %S '%s |
5c8e37591da5
(quail-current-data): New variable.
Kenichi Handa <handa@m17n.org>
parents:
18201
diff
changeset
|
2785 %S %S |
19200
74ec766c0ada
(quail-update-leim-list-file):
Richard M. Stallman <rms@gnu.org>
parents:
19144
diff
changeset
|
2786 %S)\n" |
19605
3b700b203cfd
(quail-update-leim-list-file): Make it
Kenichi Handa <handa@m17n.org>
parents:
19519
diff
changeset
|
2787 (nth 1 form) ; PACKAGE-NAME |
3b700b203cfd
(quail-update-leim-list-file): Make it
Kenichi Handa <handa@m17n.org>
parents:
19519
diff
changeset
|
2788 (nth 2 form) ; LANGUAGE |
3b700b203cfd
(quail-update-leim-list-file): Make it
Kenichi Handa <handa@m17n.org>
parents:
19519
diff
changeset
|
2789 'quail-use-package ; ACTIVATE-FUNC |
3b700b203cfd
(quail-update-leim-list-file): Make it
Kenichi Handa <handa@m17n.org>
parents:
19519
diff
changeset
|
2790 (nth 3 form) ; PACKAGE-TITLE |
3b700b203cfd
(quail-update-leim-list-file): Make it
Kenichi Handa <handa@m17n.org>
parents:
19519
diff
changeset
|
2791 (progn ; PACKAGE-DESCRIPTION (one line) |
3b700b203cfd
(quail-update-leim-list-file): Make it
Kenichi Handa <handa@m17n.org>
parents:
19519
diff
changeset
|
2792 (string-match ".*" (nth 5 form)) |
3b700b203cfd
(quail-update-leim-list-file): Make it
Kenichi Handa <handa@m17n.org>
parents:
19519
diff
changeset
|
2793 (match-string 0 (nth 5 form))) |
3b700b203cfd
(quail-update-leim-list-file): Make it
Kenichi Handa <handa@m17n.org>
parents:
19519
diff
changeset
|
2794 (file-relative-name ; PACKAGE-FILENAME |
3b700b203cfd
(quail-update-leim-list-file): Make it
Kenichi Handa <handa@m17n.org>
parents:
19519
diff
changeset
|
2795 (file-name-sans-extension (car pkg-list)) |
3b700b203cfd
(quail-update-leim-list-file): Make it
Kenichi Handa <handa@m17n.org>
parents:
19519
diff
changeset
|
2796 (car dirnames)))))) |
3b700b203cfd
(quail-update-leim-list-file): Make it
Kenichi Handa <handa@m17n.org>
parents:
19519
diff
changeset
|
2797 (error |
3b700b203cfd
(quail-update-leim-list-file): Make it
Kenichi Handa <handa@m17n.org>
parents:
19519
diff
changeset
|
2798 ;; Ignore the remaining contents of this file. |
3b700b203cfd
(quail-update-leim-list-file): Make it
Kenichi Handa <handa@m17n.org>
parents:
19519
diff
changeset
|
2799 (goto-char (point-max)) |
3b700b203cfd
(quail-update-leim-list-file): Make it
Kenichi Handa <handa@m17n.org>
parents:
19519
diff
changeset
|
2800 (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
|
2801 (setq pkg-list (cdr pkg-list))) |
3b700b203cfd
(quail-update-leim-list-file): Make it
Kenichi Handa <handa@m17n.org>
parents:
19519
diff
changeset
|
2802 (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
|
2803 |
3b700b203cfd
(quail-update-leim-list-file): Make it
Kenichi Handa <handa@m17n.org>
parents:
19519
diff
changeset
|
2804 ;; At last, write out LEIM list file. |
3b700b203cfd
(quail-update-leim-list-file): Make it
Kenichi Handa <handa@m17n.org>
parents:
19519
diff
changeset
|
2805 (save-excursion |
3b700b203cfd
(quail-update-leim-list-file): Make it
Kenichi Handa <handa@m17n.org>
parents:
19519
diff
changeset
|
2806 (set-buffer list-buf) |
3b700b203cfd
(quail-update-leim-list-file): Make it
Kenichi Handa <handa@m17n.org>
parents:
19519
diff
changeset
|
2807 (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
|
2808 (save-buffer 0)) |
3b700b203cfd
(quail-update-leim-list-file): Make it
Kenichi Handa <handa@m17n.org>
parents:
19519
diff
changeset
|
2809 (kill-buffer list-buf) |
3b700b203cfd
(quail-update-leim-list-file): Make it
Kenichi Handa <handa@m17n.org>
parents:
19519
diff
changeset
|
2810 (message "Updating %s ... done" leim-list))) |
30656
321084a896d1
(quail-define-rules): Handle Quail decode
Kenichi Handa <handa@m17n.org>
parents:
29690
diff
changeset
|
2811 |
321084a896d1
(quail-define-rules): Handle Quail decode
Kenichi Handa <handa@m17n.org>
parents:
29690
diff
changeset
|
2812 (defun quail-advice (args) |
321084a896d1
(quail-define-rules): Handle Quail decode
Kenichi Handa <handa@m17n.org>
parents:
29690
diff
changeset
|
2813 "Advice users about the characters input by the current Quail package. |
321084a896d1
(quail-define-rules): Handle Quail decode
Kenichi Handa <handa@m17n.org>
parents:
29690
diff
changeset
|
2814 The argument is a parameterized event of the form: |
321084a896d1
(quail-define-rules): Handle Quail decode
Kenichi Handa <handa@m17n.org>
parents:
29690
diff
changeset
|
2815 (quail-advice STRING) |
321084a896d1
(quail-define-rules): Handle Quail decode
Kenichi Handa <handa@m17n.org>
parents:
29690
diff
changeset
|
2816 where STRING is a string containing the input characters. |
321084a896d1
(quail-define-rules): Handle Quail decode
Kenichi Handa <handa@m17n.org>
parents:
29690
diff
changeset
|
2817 If STRING has property `advice' and the value is a function, |
321084a896d1
(quail-define-rules): Handle Quail decode
Kenichi Handa <handa@m17n.org>
parents:
29690
diff
changeset
|
2818 call it with one argument STRING." |
321084a896d1
(quail-define-rules): Handle Quail decode
Kenichi Handa <handa@m17n.org>
parents:
29690
diff
changeset
|
2819 (interactive "e") |
321084a896d1
(quail-define-rules): Handle Quail decode
Kenichi Handa <handa@m17n.org>
parents:
29690
diff
changeset
|
2820 (let* ((string (nth 1 args)) |
321084a896d1
(quail-define-rules): Handle Quail decode
Kenichi Handa <handa@m17n.org>
parents:
29690
diff
changeset
|
2821 (func (get-text-property 0 'advice string))) |
321084a896d1
(quail-define-rules): Handle Quail decode
Kenichi Handa <handa@m17n.org>
parents:
29690
diff
changeset
|
2822 (if (functionp func) |
321084a896d1
(quail-define-rules): Handle Quail decode
Kenichi Handa <handa@m17n.org>
parents:
29690
diff
changeset
|
2823 (funcall func string)))) |
321084a896d1
(quail-define-rules): Handle Quail decode
Kenichi Handa <handa@m17n.org>
parents:
29690
diff
changeset
|
2824 |
321084a896d1
(quail-define-rules): Handle Quail decode
Kenichi Handa <handa@m17n.org>
parents:
29690
diff
changeset
|
2825 (global-set-key [quail-advice] 'quail-advice) |
321084a896d1
(quail-define-rules): Handle Quail decode
Kenichi Handa <handa@m17n.org>
parents:
29690
diff
changeset
|
2826 |
17052 | 2827 ;; |
2828 (provide 'quail) | |
2829 | |
2830 ;;; quail.el ends here |