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