annotate lisp/international/quail.el @ 20218:84d1bec9ac4b

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