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