annotate lisp/international/quail.el @ 19944:e274dc2d61f1

(quail-completion-list-translations): Fix and simplify generation of translation list.
author Richard M. Stallman <rms@gnu.org>
date Tue, 16 Sep 1997 07:04:03 +0000
parents 486a8046bbf5
children ad6d3d0b2cb4
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)
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
290 (define-key map "\C-i" 'quail-completion)
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
291 (define-key map "\C-@" 'quail-select-current)
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
292 (define-key map "\C-h" 'quail-translation-help)
19844
1e682aef0ce0 (quail-translation-keymap)
Richard M. Stallman <rms@gnu.org>
parents: 19811
diff changeset
293 ;;; 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
294 ;;; (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
295 (define-key map [?\C-\ ] 'quail-select-current)
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
296 (define-key map [tab] 'quail-completion)
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
297 (define-key map [delete] 'quail-delete-last-char)
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
298 (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
299 (let ((meta-map (make-sparse-keymap)))
a69ae37e6932 (quail-update-translation): Fix previous change.
Richard M. Stallman <rms@gnu.org>
parents: 19849
diff changeset
300 (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
301 (define-key map [escape] meta-map))
a69ae37e6932 (quail-update-translation): Fix previous change.
Richard M. Stallman <rms@gnu.org>
parents: 19849
diff changeset
302 (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
303 'quail-execute-non-quail-command)
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
304 ;; At last, define default key binding.
19878
a69ae37e6932 (quail-update-translation): Fix previous change.
Richard M. Stallman <rms@gnu.org>
parents: 19849
diff changeset
305 (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
306 map)
19619
b033d0b34c71 (quail-define-package): New arg SIMPLE.
Richard M. Stallman <rms@gnu.org>
parents: 19605
diff changeset
307 "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
308 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
309 most use `quail-simple-translation-keymap' instead.
b033d0b34c71 (quail-define-package): New arg SIMPLE.
Richard M. Stallman <rms@gnu.org>
parents: 19605
diff changeset
310 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
311
b033d0b34c71 (quail-define-package): New arg SIMPLE.
Richard M. Stallman <rms@gnu.org>
parents: 19605
diff changeset
312 (defvar quail-simple-translation-keymap
b033d0b34c71 (quail-define-package): New arg SIMPLE.
Richard M. Stallman <rms@gnu.org>
parents: 19605
diff changeset
313 (let ((map (make-keymap))
b033d0b34c71 (quail-define-package): New arg SIMPLE.
Richard M. Stallman <rms@gnu.org>
parents: 19605
diff changeset
314 (i 0))
b033d0b34c71 (quail-define-package): New arg SIMPLE.
Richard M. Stallman <rms@gnu.org>
parents: 19605
diff changeset
315 (while (< i ?\ )
b033d0b34c71 (quail-define-package): New arg SIMPLE.
Richard M. Stallman <rms@gnu.org>
parents: 19605
diff changeset
316 (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
317 (setq i (1+ i)))
b033d0b34c71 (quail-define-package): New arg SIMPLE.
Richard M. Stallman <rms@gnu.org>
parents: 19605
diff changeset
318 (while (< i 127)
b033d0b34c71 (quail-define-package): New arg SIMPLE.
Richard M. Stallman <rms@gnu.org>
parents: 19605
diff changeset
319 (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
320 (setq i (1+ i)))
b033d0b34c71 (quail-define-package): New arg SIMPLE.
Richard M. Stallman <rms@gnu.org>
parents: 19605
diff changeset
321 (define-key map "\177" 'quail-delete-last-char)
19844
1e682aef0ce0 (quail-translation-keymap)
Richard M. Stallman <rms@gnu.org>
parents: 19811
diff changeset
322 ;;; 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
323 ;;; (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
324 (let ((meta-map (make-sparse-keymap)))
a69ae37e6932 (quail-update-translation): Fix previous change.
Richard M. Stallman <rms@gnu.org>
parents: 19849
diff changeset
325 (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
326 (define-key map [escape] meta-map))
a69ae37e6932 (quail-update-translation): Fix previous change.
Richard M. Stallman <rms@gnu.org>
parents: 19849
diff changeset
327 (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
328 'quail-execute-non-quail-command)
19619
b033d0b34c71 (quail-define-package): New arg SIMPLE.
Richard M. Stallman <rms@gnu.org>
parents: 19605
diff changeset
329 ;; 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
330 (define-key map [t]
19878
a69ae37e6932 (quail-update-translation): Fix previous change.
Richard M. Stallman <rms@gnu.org>
parents: 19849
diff changeset
331 'quail-execute-non-quail-command)
a69ae37e6932 (quail-update-translation): Fix previous change.
Richard M. Stallman <rms@gnu.org>
parents: 19849
diff changeset
332 map)
19619
b033d0b34c71 (quail-define-package): New arg SIMPLE.
Richard M. Stallman <rms@gnu.org>
parents: 19605
diff changeset
333 "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
334 A few especially complex input methods use `quail--translation-keymap' instead.
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
335 This map is activated while translation region is active.")
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
336
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
337 (defvar quail-conversion-keymap
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
338 (let ((map (make-keymap))
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
339 (i 0))
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
340 (while (< i ?\ )
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
341 (define-key map (char-to-string i) 'quail-execute-non-quail-command)
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
342 (setq i (1+ i)))
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
343 (while (< i 127)
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
344 (define-key map (char-to-string i)
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
345 'quail-start-translation-in-conversion-mode)
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
346 (setq i (1+ i)))
19647
9b9af28bee8d (quail-translation-keymap): Do not bind
Kenichi Handa <handa@m17n.org>
parents: 19619
diff changeset
347 (setq i 128)
19655
47d11f4bbc6c (quail-translation-keymap): Fix previous
Kenichi Handa <handa@m17n.org>
parents: 19647
diff changeset
348 (while (< i 256)
19647
9b9af28bee8d (quail-translation-keymap): Do not bind
Kenichi Handa <handa@m17n.org>
parents: 19619
diff changeset
349 (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
350 (setq i (1+ i)))
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
351 (define-key map "\C-b" 'quail-conversion-backward-char)
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
352 (define-key map "\C-f" 'quail-conversion-forward-char)
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
353 (define-key map "\C-a" 'quail-conversion-beginning-of-region)
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
354 (define-key map "\C-e" 'quail-conversion-end-of-region)
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
355 (define-key map "\C-d" 'quail-conversion-delete-char)
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
356 (define-key map "\C-h" 'quail-conversion-help)
19844
1e682aef0ce0 (quail-translation-keymap)
Richard M. Stallman <rms@gnu.org>
parents: 19811
diff changeset
357 ;;; 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
358 ;;; (define-key map "\e" '(keymap (t . quail-execute-non-quail-command)))
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
359 (define-key map "\177" 'quail-conversion-backward-delete-char)
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
360 (define-key map [delete] 'quail-conversion-backward-delete-char)
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
361 (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
362 (let ((meta-map (make-sparse-keymap)))
a69ae37e6932 (quail-update-translation): Fix previous change.
Richard M. Stallman <rms@gnu.org>
parents: 19849
diff changeset
363 (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
364 (define-key map [escape] meta-map))
a69ae37e6932 (quail-update-translation): Fix previous change.
Richard M. Stallman <rms@gnu.org>
parents: 19849
diff changeset
365 (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
366 'quail-execute-non-quail-command)
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
367 ;; At last, define default key binding.
19878
a69ae37e6932 (quail-update-translation): Fix previous change.
Richard M. Stallman <rms@gnu.org>
parents: 19849
diff changeset
368 (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
369 map)
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
370 "Keymap used for processing conversion in Quail mode.
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
371 This map is activated while convesion region is active but translation
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
372 region is not active.")
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
373
18297
5c8e37591da5 (quail-current-data): New variable.
Kenichi Handa <handa@m17n.org>
parents: 18201
diff changeset
374 ;;;###autoload
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
375 (defun quail-define-package (name language title
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
376 &optional guidance docstring translation-keys
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
377 forget-last-selection deterministic
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
378 kbd-translate show-layout create-decode-map
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
379 maximum-shortest overlay-plist
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
380 update-translation-function
19619
b033d0b34c71 (quail-define-package): New arg SIMPLE.
Richard M. Stallman <rms@gnu.org>
parents: 19605
diff changeset
381 conversion-keys simple)
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
382 "Define NAME as a new Quail package for input LANGUAGE.
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
383 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
384 Optional arguments are GUIDANCE, DOCSTRING, TRANLSATION-KEYS,
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
385 FORGET-LAST-SELECTION, DETERMINISTIC, KBD-TRANSLATE, SHOW-LAYOUT,
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
386 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
387 UPDATE-TRANSLATION-FUNCTION, CONVERSION-KEYS and SIMPLE.
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
388
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
389 GUIDANCE specifies how a guidance string is shown in echo area.
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
390 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
391 with the currently selected translation being highlighted.
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
392 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
393 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
394 shown.
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
395 If it is nil, the current key is shown.
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
396
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
397 DOCSTRING is the documentation string of this package.
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
398
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
399 TRANSLATION-KEYS specifies additional key bindings used while translation
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
400 region is active. It is an alist of single key character vs. corresponding
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
401 command to be called.
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
402
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
403 FORGET-LAST-SELECTION non-nil means a selected translation is not kept
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
404 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
405 translation selected for a key is remembered so that it can be the
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
406 first candidate when the same key is entered later.
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
407
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
408 DETERMINISTIC non-nil means the first candidate of translation is
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
409 selected automatically without allowing users to select another
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
410 translation for a key. In this case, unselected translations are of
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
411 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
412 programs. If this flag is non-nil, FORGET-LAST-SELECTION is also set
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
413 to t.
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
414
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
415 KBD-TRANSLATE non-nil means input characters are translated from a
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
416 user's keyboard layout to the standard keyboard layout. See the
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
417 documentation of `quail-keyboard-layout' and
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
418 `quail-keyboard-layout-standard' for more detail.
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
419
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
420 SHOW-LAYOUT non-nil means the `quail-help' command should show
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
421 the user's keyboard layout visually with translated characters.
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
422 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
423 this package defines no translations for single character keys.
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
424
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
425 CREATE-DECODE-MAP non-nil means decode map is also created. A decode
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
426 map is an alist of translations and corresponding original keys.
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
427 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
428 other programs. For instance, Vietnamese supporting needs this map to
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
429 convert Vietnamese text to VIQR format which uses only ASCII
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
430 characters to represent Vietnamese characters.
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
431
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
432 MAXIMUM-SHORTEST non-nil means break key sequence to get maximum
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
433 length of the shortest sequence. When we don't have a translation of
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
434 key \"..ABCD\" but have translations of \"..AB\" and \"CD..\", break
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
435 the key at \"..AB\" and start translation of \"CD..\". Hangul
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
436 packages, for instance, use this facility. If this flag is nil, we
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
437 break the key just at \"..ABC\" and start translation of \"D..\".
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
438
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
439 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
440 covers Quail translation region.
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
441
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
442 UPDATE-TRANSLATION-FUNCTION if non-nil is a function to call to update
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
443 the current translation region accoding to a new translation data. By
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
444 default, a tranlated text or a user's key sequence (if no transltion
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
445 for it) is inserted.
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
446
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
447 CONVERSION-KEYS specifies additional key bindings used while
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
448 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
449 vs. corresponding command to be called.
b033d0b34c71 (quail-define-package): New arg SIMPLE.
Richard M. Stallman <rms@gnu.org>
parents: 19605
diff changeset
450
b033d0b34c71 (quail-define-package): New arg SIMPLE.
Richard M. Stallman <rms@gnu.org>
parents: 19605
diff changeset
451 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
452 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
453 non-Quail commands."
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
454 (let (translation-keymap conversion-keymap)
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
455 (if deterministic (setq forget-last-selection t))
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
456 (if translation-keys
19404
8901359ae445 (quail-inactivate): Turn Quail mode off
Kenichi Handa <handa@m17n.org>
parents: 19391
diff changeset
457 (progn
19619
b033d0b34c71 (quail-define-package): New arg SIMPLE.
Richard M. Stallman <rms@gnu.org>
parents: 19605
diff changeset
458 (setq translation-keymap (copy-keymap
b033d0b34c71 (quail-define-package): New arg SIMPLE.
Richard M. Stallman <rms@gnu.org>
parents: 19605
diff changeset
459 (if simple quail-simple-translation-keymap
b033d0b34c71 (quail-define-package): New arg SIMPLE.
Richard M. Stallman <rms@gnu.org>
parents: 19605
diff changeset
460 quail-translation-keymap)))
19404
8901359ae445 (quail-inactivate): Turn Quail mode off
Kenichi Handa <handa@m17n.org>
parents: 19391
diff changeset
461 (while translation-keys
8901359ae445 (quail-inactivate): Turn Quail mode off
Kenichi Handa <handa@m17n.org>
parents: 19391
diff changeset
462 (define-key translation-keymap
8901359ae445 (quail-inactivate): Turn Quail mode off
Kenichi Handa <handa@m17n.org>
parents: 19391
diff changeset
463 (car (car translation-keys)) (cdr (car translation-keys)))
8901359ae445 (quail-inactivate): Turn Quail mode off
Kenichi Handa <handa@m17n.org>
parents: 19391
diff changeset
464 (setq translation-keys (cdr translation-keys))))
19619
b033d0b34c71 (quail-define-package): New arg SIMPLE.
Richard M. Stallman <rms@gnu.org>
parents: 19605
diff changeset
465 (setq translation-keymap
b033d0b34c71 (quail-define-package): New arg SIMPLE.
Richard M. Stallman <rms@gnu.org>
parents: 19605
diff changeset
466 (if simple quail-simple-translation-keymap
b033d0b34c71 (quail-define-package): New arg SIMPLE.
Richard M. Stallman <rms@gnu.org>
parents: 19605
diff changeset
467 quail-translation-keymap)))
19404
8901359ae445 (quail-inactivate): Turn Quail mode off
Kenichi Handa <handa@m17n.org>
parents: 19391
diff changeset
468 (when conversion-keys
8901359ae445 (quail-inactivate): Turn Quail mode off
Kenichi Handa <handa@m17n.org>
parents: 19391
diff changeset
469 (setq conversion-keymap (copy-keymap quail-conversion-keymap))
8901359ae445 (quail-inactivate): Turn Quail mode off
Kenichi Handa <handa@m17n.org>
parents: 19391
diff changeset
470 (while conversion-keys
8901359ae445 (quail-inactivate): Turn Quail mode off
Kenichi Handa <handa@m17n.org>
parents: 19391
diff changeset
471 (define-key conversion-keymap
8901359ae445 (quail-inactivate): Turn Quail mode off
Kenichi Handa <handa@m17n.org>
parents: 19391
diff changeset
472 (car (car conversion-keys)) (cdr (car conversion-keys)))
8901359ae445 (quail-inactivate): Turn Quail mode off
Kenichi Handa <handa@m17n.org>
parents: 19391
diff changeset
473 (setq conversion-keys (cdr conversion-keys))))
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
474 (quail-add-package
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
475 (list name title (list nil) guidance (or docstring "")
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
476 translation-keymap
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
477 forget-last-selection deterministic kbd-translate show-layout
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
478 (if create-decode-map (list 'decode-map) nil)
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
479 maximum-shortest overlay-plist update-translation-function
19849
1c5164d81426 (quail-simple): New function.
Kenichi Handa <handa@m17n.org>
parents: 19844
diff changeset
480 conversion-keymap simple))
18556
99e8ae18137f (quail-guidance-buf): Make it buffer
Kenichi Handa <handa@m17n.org>
parents: 18377
diff changeset
481
99e8ae18137f (quail-guidance-buf): Make it buffer
Kenichi Handa <handa@m17n.org>
parents: 18377
diff changeset
482 ;; Update input-method-alist.
99e8ae18137f (quail-guidance-buf): Make it buffer
Kenichi Handa <handa@m17n.org>
parents: 18377
diff changeset
483 (let ((slot (assoc name input-method-alist))
99e8ae18137f (quail-guidance-buf): Make it buffer
Kenichi Handa <handa@m17n.org>
parents: 18377
diff changeset
484 (val (list language 'quail-use-package title docstring)))
99e8ae18137f (quail-guidance-buf): Make it buffer
Kenichi Handa <handa@m17n.org>
parents: 18377
diff changeset
485 (if slot (setcdr slot val)
99e8ae18137f (quail-guidance-buf): Make it buffer
Kenichi Handa <handa@m17n.org>
parents: 18377
diff changeset
486 (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
487
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
488 (quail-select-package name))
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
489
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
490 ;; Quail minor mode handlers.
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
491
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
492 ;; Setup overlays used in Quail mode.
19404
8901359ae445 (quail-inactivate): Turn Quail mode off
Kenichi Handa <handa@m17n.org>
parents: 19391
diff changeset
493 (defun quail-setup-overlays (conversion-mode)
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
494 (let ((pos (point)))
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
495 (if (overlayp quail-overlay)
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
496 (move-overlay quail-overlay pos pos)
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
497 (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
498 (if input-method-highlight-flag
8901359ae445 (quail-inactivate): Turn Quail mode off
Kenichi Handa <handa@m17n.org>
parents: 19391
diff changeset
499 (overlay-put quail-overlay 'face 'underline))
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
500 (let ((l (quail-overlay-plist)))
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
501 (while l
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
502 (overlay-put quail-overlay (car l) (car (cdr l)))
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
503 (setq l (cdr (cdr l))))))
19404
8901359ae445 (quail-inactivate): Turn Quail mode off
Kenichi Handa <handa@m17n.org>
parents: 19391
diff changeset
504 (if conversion-mode
8901359ae445 (quail-inactivate): Turn Quail mode off
Kenichi Handa <handa@m17n.org>
parents: 19391
diff changeset
505 (if (overlayp quail-conv-overlay)
8901359ae445 (quail-inactivate): Turn Quail mode off
Kenichi Handa <handa@m17n.org>
parents: 19391
diff changeset
506 (if (not (overlay-start quail-conv-overlay))
8901359ae445 (quail-inactivate): Turn Quail mode off
Kenichi Handa <handa@m17n.org>
parents: 19391
diff changeset
507 (move-overlay quail-conv-overlay pos pos))
8901359ae445 (quail-inactivate): Turn Quail mode off
Kenichi Handa <handa@m17n.org>
parents: 19391
diff changeset
508 (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
509 (if input-method-highlight-flag
8901359ae445 (quail-inactivate): Turn Quail mode off
Kenichi Handa <handa@m17n.org>
parents: 19391
diff changeset
510 (overlay-put quail-conv-overlay 'face 'underline))))))
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
511
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
512 ;; Delete overlays used in Quail mode.
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
513 (defun quail-delete-overlays ()
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
514 (if (overlayp quail-overlay)
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
515 (delete-overlay quail-overlay))
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
516 (if (overlayp quail-conv-overlay)
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
517 (delete-overlay quail-conv-overlay)))
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
518
19432
4492653b04e8 (quail-exit-from-minibuffer): Call
Kenichi Handa <handa@m17n.org>
parents: 19404
diff changeset
519 ;; Kill Quail guidance buffer. Set in kill-buffer-hook.
4492653b04e8 (quail-exit-from-minibuffer): Call
Kenichi Handa <handa@m17n.org>
parents: 19404
diff changeset
520 (defun quail-kill-guidance-buf ()
4492653b04e8 (quail-exit-from-minibuffer): Call
Kenichi Handa <handa@m17n.org>
parents: 19404
diff changeset
521 (if (buffer-live-p quail-guidance-buf)
4492653b04e8 (quail-exit-from-minibuffer): Call
Kenichi Handa <handa@m17n.org>
parents: 19404
diff changeset
522 (kill-buffer quail-guidance-buf)))
4492653b04e8 (quail-exit-from-minibuffer): Call
Kenichi Handa <handa@m17n.org>
parents: 19404
diff changeset
523
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
524 (defun quail-mode (&optional arg)
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
525 "Toggle Quail minor mode.
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
526 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
527
4492653b04e8 (quail-exit-from-minibuffer): Call
Kenichi Handa <handa@m17n.org>
parents: 19404
diff changeset
528 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
529 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
530 see). They automatically turn on or off this mode.
4492653b04e8 (quail-exit-from-minibuffer): Call
Kenichi Handa <handa@m17n.org>
parents: 19404
diff changeset
531
4492653b04e8 (quail-exit-from-minibuffer): Call
Kenichi Handa <handa@m17n.org>
parents: 19404
diff changeset
532 Try \\[describe-bindings] in Quail mode to see the available key bindings.
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
533 The command \\[describe-input-method] describes the current Quail package."
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
534 (setq quail-mode
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
535 (if (null arg) (null quail-mode)
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
536 (> (prefix-numeric-value arg) 0)))
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
537 (if (null quail-mode)
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
538 ;; Let's turn off Quail mode.
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
539 (progn
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
540 (quail-hide-guidance-buf)
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
541 (quail-delete-overlays)
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
542 (setq describe-current-input-method-function nil)
19404
8901359ae445 (quail-inactivate): Turn Quail mode off
Kenichi Handa <handa@m17n.org>
parents: 19391
diff changeset
543 (run-hooks 'quail-mode-exit-hook))
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
544 ;; Let's turn on Quail mode.
17764
561a8476368f (use-quail-package): Error message added.
Kenichi Handa <handa@m17n.org>
parents: 17315
diff changeset
545 ;; 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
546 ;; minor-mode-map-alist.
561a8476368f (use-quail-package): Error message added.
Kenichi Handa <handa@m17n.org>
parents: 17315
diff changeset
547 (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
548 (let ((l minor-mode-map-alist))
561a8476368f (use-quail-package): Error message added.
Kenichi Handa <handa@m17n.org>
parents: 17315
diff changeset
549 (while (cdr l)
561a8476368f (use-quail-package): Error message added.
Kenichi Handa <handa@m17n.org>
parents: 17315
diff changeset
550 (if (eq (car (cdr l)) 'quail-mode)
561a8476368f (use-quail-package): Error message added.
Kenichi Handa <handa@m17n.org>
parents: 17315
diff changeset
551 (progn
561a8476368f (use-quail-package): Error message added.
Kenichi Handa <handa@m17n.org>
parents: 17315
diff changeset
552 (setcdr l (cdr (cdr l)))
561a8476368f (use-quail-package): Error message added.
Kenichi Handa <handa@m17n.org>
parents: 17315
diff changeset
553 (setq l nil))
561a8476368f (use-quail-package): Error message added.
Kenichi Handa <handa@m17n.org>
parents: 17315
diff changeset
554 (setq l (cdr l))))
561a8476368f (use-quail-package): Error message added.
Kenichi Handa <handa@m17n.org>
parents: 17315
diff changeset
555 (setq minor-mode-map-alist (cons 'quail-mode minor-mode-map-alist))))
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
556 (if (null quail-current-package)
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
557 ;; Quail package is not yet selected. Select one now.
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
558 (let (name)
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
559 (if quail-package-alist
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
560 (setq name (car (car quail-package-alist)))
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
561 (setq quail-mode nil)
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
562 (error "No Quail package loaded"))
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
563 (quail-select-package name)))
19404
8901359ae445 (quail-inactivate): Turn Quail mode off
Kenichi Handa <handa@m17n.org>
parents: 19391
diff changeset
564 (setq inactivate-current-input-method-function 'quail-inactivate)
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
565 (setq describe-current-input-method-function 'quail-help)
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
566 (quail-delete-overlays)
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
567 (quail-show-guidance-buf)
19432
4492653b04e8 (quail-exit-from-minibuffer): Call
Kenichi Handa <handa@m17n.org>
parents: 19404
diff changeset
568 ;; 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
569 ;; before exiting.
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
570 (if (eq (selected-window) (minibuffer-window))
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
571 (add-hook 'minibuffer-exit-hook 'quail-exit-from-minibuffer))
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
572 (make-local-hook 'post-command-hook)
19432
4492653b04e8 (quail-exit-from-minibuffer): Call
Kenichi Handa <handa@m17n.org>
parents: 19404
diff changeset
573 (make-local-hook 'kill-buffer-hook)
4492653b04e8 (quail-exit-from-minibuffer): Call
Kenichi Handa <handa@m17n.org>
parents: 19404
diff changeset
574 (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
575 (run-hooks 'quail-mode-hook))
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
576 (force-mode-line-update))
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
577
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
578 (defun quail-exit-from-minibuffer ()
19432
4492653b04e8 (quail-exit-from-minibuffer): Call
Kenichi Handa <handa@m17n.org>
parents: 19404
diff changeset
579 (inactivate-input-method)
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
580 (if (<= (minibuffer-depth) 1)
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
581 (remove-hook 'minibuffer-exit-hook 'quail-exit-from-minibuffer)))
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
582
19404
8901359ae445 (quail-inactivate): Turn Quail mode off
Kenichi Handa <handa@m17n.org>
parents: 19391
diff changeset
583 (defvar quail-saved-current-map nil)
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
584 (defvar quail-saved-current-buffer nil)
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
585
19404
8901359ae445 (quail-inactivate): Turn Quail mode off
Kenichi Handa <handa@m17n.org>
parents: 19391
diff changeset
586 ;; 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
587 ;; 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
588 ;; one non-Quail command.
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
589 (defun quail-toggle-mode-temporarily ()
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
590 (if quail-mode
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
591 ;; 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
592 (setq quail-saved-current-buffer (current-buffer)
8901359ae445 (quail-inactivate): Turn Quail mode off
Kenichi Handa <handa@m17n.org>
parents: 19391
diff changeset
593 quail-saved-current-map overriding-terminal-local-map
8901359ae445 (quail-inactivate): Turn Quail mode off
Kenichi Handa <handa@m17n.org>
parents: 19391
diff changeset
594 quail-mode nil
8901359ae445 (quail-inactivate): Turn Quail mode off
Kenichi Handa <handa@m17n.org>
parents: 19391
diff changeset
595 overriding-terminal-local-map nil)
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
596 ;; We have just executed one non-Quail command. We don't need
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
597 ;; this hook any more.
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
598 (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
599 (if (eq (current-buffer) quail-saved-current-buffer)
8901359ae445 (quail-inactivate): Turn Quail mode off
Kenichi Handa <handa@m17n.org>
parents: 19391
diff changeset
600 ;; 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
601 ;; 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
602 (when current-input-method
8901359ae445 (quail-inactivate): Turn Quail mode off
Kenichi Handa <handa@m17n.org>
parents: 19391
diff changeset
603 (setq quail-mode t
8901359ae445 (quail-inactivate): Turn Quail mode off
Kenichi Handa <handa@m17n.org>
parents: 19391
diff changeset
604 overriding-terminal-local-map quail-saved-current-map)
8901359ae445 (quail-inactivate): Turn Quail mode off
Kenichi Handa <handa@m17n.org>
parents: 19391
diff changeset
605 (if input-method-exit-on-invalid-key
8901359ae445 (quail-inactivate): Turn Quail mode off
Kenichi Handa <handa@m17n.org>
parents: 19391
diff changeset
606 (inactivate-input-method)))
8901359ae445 (quail-inactivate): Turn Quail mode off
Kenichi Handa <handa@m17n.org>
parents: 19391
diff changeset
607 ;; 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
608 ;; 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
609 ;; Quail mode in the original buffer.
8901359ae445 (quail-inactivate): Turn Quail mode off
Kenichi Handa <handa@m17n.org>
parents: 19391
diff changeset
610 (save-excursion
8901359ae445 (quail-inactivate): Turn Quail mode off
Kenichi Handa <handa@m17n.org>
parents: 19391
diff changeset
611 (set-buffer quail-saved-current-buffer)
8901359ae445 (quail-inactivate): Turn Quail mode off
Kenichi Handa <handa@m17n.org>
parents: 19391
diff changeset
612 (setq quail-mode t)
8901359ae445 (quail-inactivate): Turn Quail mode off
Kenichi Handa <handa@m17n.org>
parents: 19391
diff changeset
613 (quail-delete-overlays)))))
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
614
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
615 (defun quail-execute-non-quail-command ()
19404
8901359ae445 (quail-inactivate): Turn Quail mode off
Kenichi Handa <handa@m17n.org>
parents: 19391
diff changeset
616 "Execute one non-Quail command out of Quail mode.
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
617 The current translation and conversion are terminated."
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
618 (interactive)
19878
a69ae37e6932 (quail-update-translation): Fix previous change.
Richard M. Stallman <rms@gnu.org>
parents: 19849
diff changeset
619 (let* ((key (this-command-keys))
a69ae37e6932 (quail-update-translation): Fix previous change.
Richard M. Stallman <rms@gnu.org>
parents: 19849
diff changeset
620 (keylist (listify-key-sequence key)))
a69ae37e6932 (quail-update-translation): Fix previous change.
Richard M. Stallman <rms@gnu.org>
parents: 19849
diff changeset
621 (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
622 (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
623 (quail-terminate-translation)
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
624 (quail-delete-overlays)
19404
8901359ae445 (quail-inactivate): Turn Quail mode off
Kenichi Handa <handa@m17n.org>
parents: 19391
diff changeset
625 (setq overriding-terminal-local-map nil)
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
626 (if (buffer-live-p quail-guidance-buf)
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
627 (save-excursion
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
628 (set-buffer quail-guidance-buf)
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
629 (erase-buffer)))
19404
8901359ae445 (quail-inactivate): Turn Quail mode off
Kenichi Handa <handa@m17n.org>
parents: 19391
diff changeset
630 (add-hook 'post-command-hook 'quail-toggle-mode-temporarily nil t))
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
631
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
632 ;; Keyboard layout translation handlers.
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
633
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
634 ;; Some Quail packages provide localized keyboard simulation which
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
635 ;; requires a particular keyboard layout. In this case, what we need
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
636 ;; is locations of keys the user entered, not character codes
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
637 ;; generated by those keys. However, for the moment, there's no
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
638 ;; common way to get such information. So, we ask a user to give
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
639 ;; information of his own keyboard layout, then translate it to the
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
640 ;; standard layout which we defined so that all Quail packages depend
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
641 ;; just on it.
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
642
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
643 (defconst quail-keyboard-layout-standard
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
644 "\
17174
9c1191812679 (quail-translation-keymap): Add entry for escape key.
Kenichi Handa <handa@m17n.org>
parents: 17095
diff changeset
645 \
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
646 1!2@3#4$5%6^7&8*9(0)-_=+`~ \
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
647 qQwWeErRtTyYuUiIoOpP[{]} \
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
648 aAsSdDfFgGhHjJkKlL;:'\"\\| \
17174
9c1191812679 (quail-translation-keymap): Add entry for escape key.
Kenichi Handa <handa@m17n.org>
parents: 17095
diff changeset
649 zZxXcCvVbBnNmM,<.>/? \
9c1191812679 (quail-translation-keymap): Add entry for escape key.
Kenichi Handa <handa@m17n.org>
parents: 17095
diff changeset
650 "
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
651 "Standard keyboard layout of printable characters Quail assumes.
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
652 See the documentation of `quail-keyboard-layout' for this format.
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
653 This layout is almost the same as that of VT100,
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
654 but the location of key \\ (backslash) is just right of key ' (single-quote),
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
655 not right of RETURN key.")
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
656
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
657 (defvar quail-keyboard-layout quail-keyboard-layout-standard
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
658 "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
659 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
660 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
661 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
662 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
663 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
664 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
665 the sixth row is below the `z' - `/' row.
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
666 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
667 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
668 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
669 The command `quail-set-keyboard-layout' usually sets this variable.")
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
670
17174
9c1191812679 (quail-translation-keymap): Add entry for escape key.
Kenichi Handa <handa@m17n.org>
parents: 17095
diff changeset
671 (defconst quail-keyboard-layout-len 180)
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
672
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
673 ;; Here we provide several examples of famous keyboard layouts.
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
674
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
675 (defvar quail-keyboard-layout-alist
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
676 (list
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
677 '("sun-type3" . "\
17174
9c1191812679 (quail-translation-keymap): Add entry for escape key.
Kenichi Handa <handa@m17n.org>
parents: 17095
diff changeset
678 \
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
679 1!2@3#4$5%6^7&8*9(0)-_=+\\|`~\
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
680 qQwWeErRtTyYuUiIoOpP[{]} \
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
681 aAsSdDfFgGhHjJkKlL;:'\" \
17174
9c1191812679 (quail-translation-keymap): Add entry for escape key.
Kenichi Handa <handa@m17n.org>
parents: 17095
diff changeset
682 zZxXcCvVbBnNmM,<.>/? \
9c1191812679 (quail-translation-keymap): Add entry for escape key.
Kenichi Handa <handa@m17n.org>
parents: 17095
diff changeset
683 ")
19675
32c3f7d9ef10 (quail-keyboard-layout-alist): Add an
Kenichi Handa <handa@m17n.org>
parents: 19655
diff changeset
684 '("atari-german" . "\
32c3f7d9ef10 (quail-keyboard-layout-alist): Add an
Kenichi Handa <handa@m17n.org>
parents: 19655
diff changeset
685 \
32c3f7d9ef10 (quail-keyboard-layout-alist): Add an
Kenichi Handa <handa@m17n.org>
parents: 19655
diff changeset
686 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
687 qQwWeErRtTzZuUiIoOpP\374\334+* \
32c3f7d9ef10 (quail-keyboard-layout-alist): Add an
Kenichi Handa <handa@m17n.org>
parents: 19655
diff changeset
688 aAsSdDfFgGhHjJkKlL\366\326\344\304~| \
32c3f7d9ef10 (quail-keyboard-layout-alist): Add an
Kenichi Handa <handa@m17n.org>
parents: 19655
diff changeset
689 <>yYxXcCvVbBnNmM,;.:-_ \
32c3f7d9ef10 (quail-keyboard-layout-alist): Add an
Kenichi Handa <handa@m17n.org>
parents: 19655
diff changeset
690 ")
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
691 (cons "standard" quail-keyboard-layout-standard))
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
692 "Alist of keyboard names and corresponding layout strings.
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
693 See the documentation of `quail-keyboard-layout' for the format of
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
694 the layout string.")
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
695
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
696 (defun quail-set-keyboard-layout (kbd-type)
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
697 "Set the current keyboard layout to the same as keyboard KBD-TYPE.
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
698
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
699 Since some Quail packages depends on a physical layout of keys (not
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
700 characters generated by them), those are created by assuming the
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
701 standard layout defined in `quail-keyboard-layout-standard'. This
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
702 function tells Quail system the layout of your keyboard so that what
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
703 you type is correctly handled."
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
704 (interactive
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
705 (let* ((completing-ignore-case t)
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
706 (type (completing-read "Keyboard type: "
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
707 quail-keyboard-layout-alist)))
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
708 (list type)))
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
709 (let ((layout (assoc kbd-type quail-keyboard-layout-alist)))
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
710 (if (null layout)
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
711 ;; Here, we had better ask a user to define his own keyboard
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
712 ;; layout interactively.
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
713 (error "Unknown keyboard type `%s'" kbd-type))
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
714 (setq quail-keyboard-layout (cdr layout))))
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
715
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
716 (defun quail-keyboard-translate (ch)
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
717 "Translate CHAR according to `quail-keyboard-layout' and return the result."
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
718 (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
719 ;; All Quail packages are designed based on
32c3f7d9ef10 (quail-keyboard-layout-alist): Add an
Kenichi Handa <handa@m17n.org>
parents: 19655
diff changeset
720 ;; `quail-keyboard-layout-standard'.
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
721 ch
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
722 (let ((i 0))
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
723 (while (and (< i quail-keyboard-layout-len)
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
724 (/= ch (aref quail-keyboard-layout i)))
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
725 (setq i (1+ i)))
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
726 (if (= i quail-keyboard-layout-len)
19675
32c3f7d9ef10 (quail-keyboard-layout-alist): Add an
Kenichi Handa <handa@m17n.org>
parents: 19655
diff changeset
727 ;; 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
728 ;; 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
729 ;; 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
730 ;; quail-execute-non-quail-command handle it correctly.
32c3f7d9ef10 (quail-keyboard-layout-alist): Add an
Kenichi Handa <handa@m17n.org>
parents: 19655
diff changeset
731 ch
32c3f7d9ef10 (quail-keyboard-layout-alist): Add an
Kenichi Handa <handa@m17n.org>
parents: 19655
diff changeset
732 (let ((char (aref quail-keyboard-layout-standard i)))
32c3f7d9ef10 (quail-keyboard-layout-alist): Add an
Kenichi Handa <handa@m17n.org>
parents: 19655
diff changeset
733 (if (= char ?\ )
32c3f7d9ef10 (quail-keyboard-layout-alist): Add an
Kenichi Handa <handa@m17n.org>
parents: 19655
diff changeset
734 ;; 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
735 ;; quail-keyboard-layout-standard. Just return CH as
32c3f7d9ef10 (quail-keyboard-layout-alist): Add an
Kenichi Handa <handa@m17n.org>
parents: 19655
diff changeset
736 ;; well as above.
32c3f7d9ef10 (quail-keyboard-layout-alist): Add an
Kenichi Handa <handa@m17n.org>
parents: 19655
diff changeset
737 ch
32c3f7d9ef10 (quail-keyboard-layout-alist): Add an
Kenichi Handa <handa@m17n.org>
parents: 19655
diff changeset
738 char))))))
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
739
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
740 ;; Quail map
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
741
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
742 (defsubst quail-map-p (object)
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
743 "Return t if OBJECT is a Quail map.
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
744
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
745 A Quail map holds information how a particular key should be translated.
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
746 Its format is (TRANSLATION . ALIST).
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
747 TRANSLATION is either a character, or a cons (INDEX . VECTOR).
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
748 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
749 and INDEX points the currently selected translation.
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
750
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
751 ALIST is normally a list of elements that look like (CHAR . DEFN),
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
752 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
753 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
754 alist of the above format.
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
755
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
756 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
757 vector. Then each element of the string or vector is a candidate for
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
758 the translation. These objects are transformed to cons cells in the
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
759 format \(INDEX . VECTOR), as described above."
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
760 (and (consp object)
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
761 (let ((translation (car object)))
18297
5c8e37591da5 (quail-current-data): New variable.
Kenichi Handa <handa@m17n.org>
parents: 18201
diff changeset
762 (or (integerp translation) (null translation)
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
763 (vectorp translation) (stringp translation)
18297
5c8e37591da5 (quail-current-data): New variable.
Kenichi Handa <handa@m17n.org>
parents: 18201
diff changeset
764 (symbolp translation)
5c8e37591da5 (quail-current-data): New variable.
Kenichi Handa <handa@m17n.org>
parents: 18201
diff changeset
765 (and (consp translation) (not (vectorp (cdr translation))))))
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
766 (let ((alist (cdr object)))
18297
5c8e37591da5 (quail-current-data): New variable.
Kenichi Handa <handa@m17n.org>
parents: 18201
diff changeset
767 (or (and (listp alist) (consp (car alist)))
5c8e37591da5 (quail-current-data): New variable.
Kenichi Handa <handa@m17n.org>
parents: 18201
diff changeset
768 (symbolp alist)))))
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
769
18297
5c8e37591da5 (quail-current-data): New variable.
Kenichi Handa <handa@m17n.org>
parents: 18201
diff changeset
770 ;;;###autoload
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
771 (defmacro quail-define-rules (&rest rules)
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
772 "Define translation rules of the current Quail package.
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
773 Each argument is a list of KEY and TRANSLATION.
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
774 KEY is a string meaning a sequence of keystrokes to be translated.
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
775 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
776 It it is a character, it is the sole translation of KEY.
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
777 If it is a string, each character is a candidate for the translation.
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
778 If it is a vector, each element (string or character) is a candidate
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
779 for the translation.
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
780 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
781
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
782 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
783 it is used to handle KEY."
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
784 `(quail-install-map
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
785 ',(let ((l rules)
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
786 (map (list nil)))
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
787 (while l
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
788 (quail-defrule-internal (car (car l)) (car (cdr (car l))) map)
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
789 (setq l (cdr l)))
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
790 map)))
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
791
18297
5c8e37591da5 (quail-current-data): New variable.
Kenichi Handa <handa@m17n.org>
parents: 18201
diff changeset
792 ;;;###autoload
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
793 (defun quail-install-map (map)
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
794 "Install the Quail map MAP in the current Quail package.
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
795 The installed map can be referred by the function `quail-map'."
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
796 (if (null quail-current-package)
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
797 (error "No current Quail package"))
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
798 (if (null (quail-map-p map))
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
799 (error "Invalid Quail map `%s'" map))
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
800 (setcar (cdr (cdr quail-current-package)) map))
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
801
18297
5c8e37591da5 (quail-current-data): New variable.
Kenichi Handa <handa@m17n.org>
parents: 18201
diff changeset
802 ;;;###autoload
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
803 (defun quail-defrule (key translation &optional name)
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
804 "Add one translation rule, KEY to TRANSLATION, in the current Quail package.
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
805 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
806 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
807 a function, or a cons.
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
808 It it is a character, it is the sole translation of KEY.
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
809 If it is a string, each character is a candidate for the translation.
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
810 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
811 for the translation.
18297
5c8e37591da5 (quail-current-data): New variable.
Kenichi Handa <handa@m17n.org>
parents: 18201
diff changeset
812 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
813 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
814 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
815 the value itself is assigned to `quail-current-data'.
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
816 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
817
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
818 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
819 it is used to handle KEY.
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
820 Optional argument NAME, if specified, says which Quail package
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
821 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
822 current Quail package."
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
823 (if name
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
824 (let ((package (quail-package name)))
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
825 (if (null package)
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
826 (error "No Quail package `%s'" name))
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
827 (setq quail-current-package package)))
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
828 (quail-defrule-internal key translation (quail-map)))
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
829
18297
5c8e37591da5 (quail-current-data): New variable.
Kenichi Handa <handa@m17n.org>
parents: 18201
diff changeset
830 ;;;###autoload
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
831 (defun quail-defrule-internal (key trans map)
18556
99e8ae18137f (quail-guidance-buf): Make it buffer
Kenichi Handa <handa@m17n.org>
parents: 18377
diff changeset
832 "Define KEY as TRANS in a Quail map MAP."
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
833 (if (null (stringp key))
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
834 "Invalid Quail key `%s'" key)
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
835 (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
836 (consp trans)
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
837 (symbolp trans)
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
838 (quail-map-p trans)))
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
839 (error "Invalid Quail translation `%s'" trans))
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
840 (if (null (quail-map-p map))
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
841 (error "Invalid Quail map `%s'" map))
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
842 (let ((len (length key))
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
843 (idx 0)
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
844 ch entry)
18297
5c8e37591da5 (quail-current-data): New variable.
Kenichi Handa <handa@m17n.org>
parents: 18201
diff changeset
845 ;; Make a map for registering TRANS if necessary.
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
846 (while (< idx len)
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
847 (if (null (consp map))
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
848 ;; We come here, for example, when we try to define a rule
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
849 ;; for "ABC" but a rule for "AB" is already defined as a
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
850 ;; symbol.
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
851 (error "Quail key %s is too long" key))
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
852 (setq ch (aref key idx)
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
853 entry (assq ch (cdr map)))
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
854 (if (null entry)
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
855 (progn
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
856 (setq entry (cons ch (list nil)))
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
857 (setcdr map (cons entry (cdr map)))))
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
858 (setq map (cdr entry))
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
859 (setq idx (1+ idx)))
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
860 (if (symbolp trans)
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
861 (if (cdr map)
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
862 ;; We come here, for example, when we try to define a rule
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
863 ;; for "AB" as a symbol but a rule for "ABC" is already
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
864 ;; defined.
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
865 (error "Quail key %s is too short" key)
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
866 (setcdr entry trans))
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
867 (if (quail-map-p trans)
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
868 (if (not (listp (cdr map)))
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
869 ;; We come here, for example, when we try to define a rule
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
870 ;; for "AB" as a symbol but a rule for "ABC" is already
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
871 ;; defined.
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
872 (error "Quail key %s is too short" key)
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
873 (if (not (listp (cdr 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
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
876 ;; define a rule for "AB" as a symbol but a rule
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
877 ;; for "ABC" is already 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 (setcdr entry (append trans (cdr map)))))
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
881 (setcar map trans)))))
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
882
18297
5c8e37591da5 (quail-current-data): New variable.
Kenichi Handa <handa@m17n.org>
parents: 18201
diff changeset
883 (defun quail-get-translation (def key len)
5c8e37591da5 (quail-current-data): New variable.
Kenichi Handa <handa@m17n.org>
parents: 18201
diff changeset
884 "Return the translation specified as DEF for KEY of length LEN.
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
885 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
886 where VECTOR is a vector of candidates (character or string) for
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
887 the translation, and INDEX points into VECTOR to specify the currently
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
888 selected translation."
18297
5c8e37591da5 (quail-current-data): New variable.
Kenichi Handa <handa@m17n.org>
parents: 18201
diff changeset
889 (if (and def (symbolp def))
5c8e37591da5 (quail-current-data): New variable.
Kenichi Handa <handa@m17n.org>
parents: 18201
diff changeset
890 ;; 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
891 (setq def (funcall def key len)))
5c8e37591da5 (quail-current-data): New variable.
Kenichi Handa <handa@m17n.org>
parents: 18201
diff changeset
892 (if (and (consp def) (not (vectorp (cdr def))))
5c8e37591da5 (quail-current-data): New variable.
Kenichi Handa <handa@m17n.org>
parents: 18201
diff changeset
893 (setq def (car def)))
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
894
18297
5c8e37591da5 (quail-current-data): New variable.
Kenichi Handa <handa@m17n.org>
parents: 18201
diff changeset
895 (cond
5c8e37591da5 (quail-current-data): New variable.
Kenichi Handa <handa@m17n.org>
parents: 18201
diff changeset
896 ((or (integerp def) (consp def))
5c8e37591da5 (quail-current-data): New variable.
Kenichi Handa <handa@m17n.org>
parents: 18201
diff changeset
897 def)
5c8e37591da5 (quail-current-data): New variable.
Kenichi Handa <handa@m17n.org>
parents: 18201
diff changeset
898
5c8e37591da5 (quail-current-data): New variable.
Kenichi Handa <handa@m17n.org>
parents: 18201
diff changeset
899 ((null def)
5c8e37591da5 (quail-current-data): New variable.
Kenichi Handa <handa@m17n.org>
parents: 18201
diff changeset
900 ;; No translation.
5c8e37591da5 (quail-current-data): New variable.
Kenichi Handa <handa@m17n.org>
parents: 18201
diff changeset
901 nil)
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
902
18297
5c8e37591da5 (quail-current-data): New variable.
Kenichi Handa <handa@m17n.org>
parents: 18201
diff changeset
903 ((stringp def)
5c8e37591da5 (quail-current-data): New variable.
Kenichi Handa <handa@m17n.org>
parents: 18201
diff changeset
904 ;; 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
905 ;; it as (INDICES . VECTOR).
18297
5c8e37591da5 (quail-current-data): New variable.
Kenichi Handa <handa@m17n.org>
parents: 18201
diff changeset
906 (setq def (string-to-vector def))
5c8e37591da5 (quail-current-data): New variable.
Kenichi Handa <handa@m17n.org>
parents: 18201
diff changeset
907 ;; 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
908 ;; candidate as the translation.
5c8e37591da5 (quail-current-data): New variable.
Kenichi Handa <handa@m17n.org>
parents: 18201
diff changeset
909 (if (= (length def) 1)
5c8e37591da5 (quail-current-data): New variable.
Kenichi Handa <handa@m17n.org>
parents: 18201
diff changeset
910 (aref def 0)
18556
99e8ae18137f (quail-guidance-buf): Make it buffer
Kenichi Handa <handa@m17n.org>
parents: 18377
diff changeset
911 (cons (list 0 0 0 0 nil) def)))
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
912
18297
5c8e37591da5 (quail-current-data): New variable.
Kenichi Handa <handa@m17n.org>
parents: 18201
diff changeset
913 ((vectorp def)
5c8e37591da5 (quail-current-data): New variable.
Kenichi Handa <handa@m17n.org>
parents: 18201
diff changeset
914 ;; 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
915 ;; translation. Reform it as (INDICES . VECTOR).
99e8ae18137f (quail-guidance-buf): Make it buffer
Kenichi Handa <handa@m17n.org>
parents: 18377
diff changeset
916 (cons (list 0 0 0 0 nil) def))
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
917
18297
5c8e37591da5 (quail-current-data): New variable.
Kenichi Handa <handa@m17n.org>
parents: 18201
diff changeset
918 (t
5c8e37591da5 (quail-current-data): New variable.
Kenichi Handa <handa@m17n.org>
parents: 18201
diff changeset
919 (error "Invalid object in Quail map: %s" def))))
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
920
18556
99e8ae18137f (quail-guidance-buf): Make it buffer
Kenichi Handa <handa@m17n.org>
parents: 18377
diff changeset
921 (defun quail-lookup-key (key &optional len)
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
922 "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
923 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
924 (or len
99e8ae18137f (quail-guidance-buf): Make it buffer
Kenichi Handa <handa@m17n.org>
parents: 18377
diff changeset
925 (setq len (length key)))
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
926 (let ((idx 0)
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
927 (map (quail-map))
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
928 (kbd-translate (quail-kbd-translate))
18297
5c8e37591da5 (quail-current-data): New variable.
Kenichi Handa <handa@m17n.org>
parents: 18201
diff changeset
929 slot ch translation def)
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
930 (while (and map (< idx len))
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
931 (setq ch (if kbd-translate (quail-keyboard-translate (aref key idx))
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
932 (aref key idx)))
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
933 (setq idx (1+ idx))
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
934 (if (and (cdr map) (symbolp (cdr map)))
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
935 (setcdr map (funcall (cdr map) key idx)))
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
936 (setq slot (assq ch (cdr map)))
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
937 (if (and (cdr slot) (symbolp (cdr slot)))
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
938 (setcdr slot (funcall (cdr slot) key idx)))
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
939 (setq map (cdr slot)))
18297
5c8e37591da5 (quail-current-data): New variable.
Kenichi Handa <handa@m17n.org>
parents: 18201
diff changeset
940 (setq def (car map))
18556
99e8ae18137f (quail-guidance-buf): Make it buffer
Kenichi Handa <handa@m17n.org>
parents: 18377
diff changeset
941 (setq quail-current-translations nil)
18297
5c8e37591da5 (quail-current-data): New variable.
Kenichi Handa <handa@m17n.org>
parents: 18201
diff changeset
942 (if (and map (setq translation (quail-get-translation def key len)))
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
943 (progn
18297
5c8e37591da5 (quail-current-data): New variable.
Kenichi Handa <handa@m17n.org>
parents: 18201
diff changeset
944 (if (and (consp def) (not (vectorp (cdr def))))
5c8e37591da5 (quail-current-data): New variable.
Kenichi Handa <handa@m17n.org>
parents: 18201
diff changeset
945 (progn
5c8e37591da5 (quail-current-data): New variable.
Kenichi Handa <handa@m17n.org>
parents: 18201
diff changeset
946 (if (not (equal (car def) translation))
5c8e37591da5 (quail-current-data): New variable.
Kenichi Handa <handa@m17n.org>
parents: 18201
diff changeset
947 ;; We must reflect TRANSLATION to car part of DEF.
5c8e37591da5 (quail-current-data): New variable.
Kenichi Handa <handa@m17n.org>
parents: 18201
diff changeset
948 (setcar def translation))
5c8e37591da5 (quail-current-data): New variable.
Kenichi Handa <handa@m17n.org>
parents: 18201
diff changeset
949 (setq quail-current-data
5c8e37591da5 (quail-current-data): New variable.
Kenichi Handa <handa@m17n.org>
parents: 18201
diff changeset
950 (if (functionp (cdr def))
5c8e37591da5 (quail-current-data): New variable.
Kenichi Handa <handa@m17n.org>
parents: 18201
diff changeset
951 (funcall (cdr def))
5c8e37591da5 (quail-current-data): New variable.
Kenichi Handa <handa@m17n.org>
parents: 18201
diff changeset
952 (cdr def))))
5c8e37591da5 (quail-current-data): New variable.
Kenichi Handa <handa@m17n.org>
parents: 18201
diff changeset
953 (if (not (equal def translation))
5c8e37591da5 (quail-current-data): New variable.
Kenichi Handa <handa@m17n.org>
parents: 18201
diff changeset
954 ;; We must reflect TRANSLATION to car part of MAP.
5c8e37591da5 (quail-current-data): New variable.
Kenichi Handa <handa@m17n.org>
parents: 18201
diff changeset
955 (setcar map translation)))
5c8e37591da5 (quail-current-data): New variable.
Kenichi Handa <handa@m17n.org>
parents: 18201
diff changeset
956 (if (and (consp translation) (vectorp (cdr translation)))
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
957 (progn
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
958 (setq quail-current-translations translation)
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
959 (if (quail-forget-last-selection)
18556
99e8ae18137f (quail-guidance-buf): Make it buffer
Kenichi Handa <handa@m17n.org>
parents: 18377
diff changeset
960 (setcar (car quail-current-translations) 0))))
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
961 ;; We may have to reform cdr part of MAP.
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
962 (if (and (cdr map) (symbolp (cdr map)))
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
963 (progn
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
964 (setcdr map (funcall (cdr map) key len))))
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
965 ))
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
966 map))
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
967
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
968 ;; If set to non-nil, exit conversion mode before starting new translation.
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
969 (defvar quail-exit-conversion-mode nil)
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
970
18201
feea31893155 (quail-prefix-arg): New variable.
Kenichi Handa <handa@m17n.org>
parents: 17764
diff changeset
971 (defvar quail-prefix-arg nil)
feea31893155 (quail-prefix-arg): New variable.
Kenichi Handa <handa@m17n.org>
parents: 17764
diff changeset
972
feea31893155 (quail-prefix-arg): New variable.
Kenichi Handa <handa@m17n.org>
parents: 17764
diff changeset
973 (defun quail-start-translation (arg)
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
974 "Start translating the typed character in Quail mode."
18201
feea31893155 (quail-prefix-arg): New variable.
Kenichi Handa <handa@m17n.org>
parents: 17764
diff changeset
975 (interactive "*p")
feea31893155 (quail-prefix-arg): New variable.
Kenichi Handa <handa@m17n.org>
parents: 17764
diff changeset
976 (setq prefix-arg arg)
feea31893155 (quail-prefix-arg): New variable.
Kenichi Handa <handa@m17n.org>
parents: 17764
diff changeset
977 (setq quail-prefix-arg arg)
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
978 (setq unread-command-events
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
979 (cons last-command-event unread-command-events))
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
980 ;; Check the possibility of translating the last key.
19432
4492653b04e8 (quail-exit-from-minibuffer): Call
Kenichi Handa <handa@m17n.org>
parents: 19404
diff changeset
981 (if (and (integerp last-command-event)
4492653b04e8 (quail-exit-from-minibuffer): Call
Kenichi Handa <handa@m17n.org>
parents: 19404
diff changeset
982 (assq (if (quail-kbd-translate)
4492653b04e8 (quail-exit-from-minibuffer): Call
Kenichi Handa <handa@m17n.org>
parents: 19404
diff changeset
983 (quail-keyboard-translate last-command-event)
4492653b04e8 (quail-exit-from-minibuffer): Call
Kenichi Handa <handa@m17n.org>
parents: 19404
diff changeset
984 last-command-event)
4492653b04e8 (quail-exit-from-minibuffer): Call
Kenichi Handa <handa@m17n.org>
parents: 19404
diff changeset
985 (cdr (quail-map))))
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
986 ;; Ok, we can start translation.
19404
8901359ae445 (quail-inactivate): Turn Quail mode off
Kenichi Handa <handa@m17n.org>
parents: 19391
diff changeset
987 (if (quail-conversion-keymap)
8901359ae445 (quail-inactivate): Turn Quail mode off
Kenichi Handa <handa@m17n.org>
parents: 19391
diff changeset
988 ;; We must start translation in conversion mode.
8901359ae445 (quail-inactivate): Turn Quail mode off
Kenichi Handa <handa@m17n.org>
parents: 19391
diff changeset
989 (setq quail-exit-conversion-mode nil
8901359ae445 (quail-inactivate): Turn Quail mode off
Kenichi Handa <handa@m17n.org>
parents: 19391
diff changeset
990 overriding-terminal-local-map (quail-conversion-keymap))
8901359ae445 (quail-inactivate): Turn Quail mode off
Kenichi Handa <handa@m17n.org>
parents: 19391
diff changeset
991 (quail-setup-overlays nil)
8901359ae445 (quail-inactivate): Turn Quail mode off
Kenichi Handa <handa@m17n.org>
parents: 19391
diff changeset
992 (setq quail-current-key "")
8901359ae445 (quail-inactivate): Turn Quail mode off
Kenichi Handa <handa@m17n.org>
parents: 19391
diff changeset
993 (setq overriding-terminal-local-map (quail-translation-keymap)))
8901359ae445 (quail-inactivate): Turn Quail mode off
Kenichi Handa <handa@m17n.org>
parents: 19391
diff changeset
994 ;; 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
995 ;; 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
996 ;; function `quail-toggle-mode-temporarily' in
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
997 ;; `post-command-hook'.
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
998 (add-hook 'post-command-hook 'quail-toggle-mode-temporarily nil t)))
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
999
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1000 (defsubst quail-point-in-conversion-region ()
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1001 "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
1002 (let (start pos)
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1003 (and (setq start (overlay-start quail-conv-overlay))
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1004 (>= (setq pos (point)) start)
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1005 (<= pos (overlay-end quail-conv-overlay)))))
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1006
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1007 (defun quail-start-translation-in-conversion-mode ()
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1008 "Start translating the typed character in conversion mode of Quail mode."
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1009 (interactive "*")
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1010 (setq unread-command-events
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1011 (cons last-command-event unread-command-events))
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1012 ;; Check the possibility of translating the last key.
19432
4492653b04e8 (quail-exit-from-minibuffer): Call
Kenichi Handa <handa@m17n.org>
parents: 19404
diff changeset
1013 (if (and (integerp last-command-event)
4492653b04e8 (quail-exit-from-minibuffer): Call
Kenichi Handa <handa@m17n.org>
parents: 19404
diff changeset
1014 (assq (if (quail-kbd-translate)
4492653b04e8 (quail-exit-from-minibuffer): Call
Kenichi Handa <handa@m17n.org>
parents: 19404
diff changeset
1015 (quail-keyboard-translate last-command-event)
4492653b04e8 (quail-exit-from-minibuffer): Call
Kenichi Handa <handa@m17n.org>
parents: 19404
diff changeset
1016 last-command-event)
4492653b04e8 (quail-exit-from-minibuffer): Call
Kenichi Handa <handa@m17n.org>
parents: 19404
diff changeset
1017 (cdr (quail-map))))
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1018 ;; Ok, we can start translation.
19404
8901359ae445 (quail-inactivate): Turn Quail mode off
Kenichi Handa <handa@m17n.org>
parents: 19391
diff changeset
1019 (progn
8901359ae445 (quail-inactivate): Turn Quail mode off
Kenichi Handa <handa@m17n.org>
parents: 19391
diff changeset
1020 (quail-setup-overlays t)
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1021 (setq quail-current-key "")
19404
8901359ae445 (quail-inactivate): Turn Quail mode off
Kenichi Handa <handa@m17n.org>
parents: 19391
diff changeset
1022 (setq overriding-terminal-local-map (quail-translation-keymap))
8901359ae445 (quail-inactivate): Turn Quail mode off
Kenichi Handa <handa@m17n.org>
parents: 19391
diff changeset
1023 (move-overlay quail-overlay (point) (point)))
8901359ae445 (quail-inactivate): Turn Quail mode off
Kenichi Handa <handa@m17n.org>
parents: 19391
diff changeset
1024 ;; 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
1025 ;; 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
1026 ;; function `quail-toggle-mode-temporarily' in
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1027 ;; `post-command-hook'.
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1028 (add-hook 'post-command-hook 'quail-toggle-mode-temporarily nil t)))
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1029
18201
feea31893155 (quail-prefix-arg): New variable.
Kenichi Handa <handa@m17n.org>
parents: 17764
diff changeset
1030 (defsubst quail-delete-region ()
feea31893155 (quail-prefix-arg): New variable.
Kenichi Handa <handa@m17n.org>
parents: 17764
diff changeset
1031 "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
1032 (if (overlay-start quail-overlay)
8901359ae445 (quail-inactivate): Turn Quail mode off
Kenichi Handa <handa@m17n.org>
parents: 19391
diff changeset
1033 (delete-region (overlay-start quail-overlay)
8901359ae445 (quail-inactivate): Turn Quail mode off
Kenichi Handa <handa@m17n.org>
parents: 19391
diff changeset
1034 (overlay-end quail-overlay))))
18201
feea31893155 (quail-prefix-arg): New variable.
Kenichi Handa <handa@m17n.org>
parents: 17764
diff changeset
1035
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1036 (defun quail-terminate-translation ()
19519
1c0ecc266e38 (quail-terminate-translation): Doc-string
Kenichi Handa <handa@m17n.org>
parents: 19453
diff changeset
1037 "Terminate the translation of the current key."
19933
e135dd522e64 (quail-terminate-translation):
Richard M. Stallman <rms@gnu.org>
parents: 19881
diff changeset
1038 (when (overlayp quail-overlay)
e135dd522e64 (quail-terminate-translation):
Richard M. Stallman <rms@gnu.org>
parents: 19881
diff changeset
1039 (let ((start (overlay-start quail-overlay)))
e135dd522e64 (quail-terminate-translation):
Richard M. Stallman <rms@gnu.org>
parents: 19881
diff changeset
1040 (if (and start
e135dd522e64 (quail-terminate-translation):
Richard M. Stallman <rms@gnu.org>
parents: 19881
diff changeset
1041 (< start (overlay-end quail-overlay)))
e135dd522e64 (quail-terminate-translation):
Richard M. Stallman <rms@gnu.org>
parents: 19881
diff changeset
1042 ;; Here we simulate self-insert-command.
e135dd522e64 (quail-terminate-translation):
Richard M. Stallman <rms@gnu.org>
parents: 19881
diff changeset
1043 (let ((seq (string-to-sequence
e135dd522e64 (quail-terminate-translation):
Richard M. Stallman <rms@gnu.org>
parents: 19881
diff changeset
1044 (buffer-substring (overlay-start quail-overlay)
e135dd522e64 (quail-terminate-translation):
Richard M. Stallman <rms@gnu.org>
parents: 19881
diff changeset
1045 (overlay-end quail-overlay))
e135dd522e64 (quail-terminate-translation):
Richard M. Stallman <rms@gnu.org>
parents: 19881
diff changeset
1046 'list))
e135dd522e64 (quail-terminate-translation):
Richard M. Stallman <rms@gnu.org>
parents: 19881
diff changeset
1047 last-command-char)
e135dd522e64 (quail-terminate-translation):
Richard M. Stallman <rms@gnu.org>
parents: 19881
diff changeset
1048 (goto-char start)
e135dd522e64 (quail-terminate-translation):
Richard M. Stallman <rms@gnu.org>
parents: 19881
diff changeset
1049 (quail-delete-region)
18201
feea31893155 (quail-prefix-arg): New variable.
Kenichi Handa <handa@m17n.org>
parents: 17764
diff changeset
1050 (setq last-command-char (car seq))
19933
e135dd522e64 (quail-terminate-translation):
Richard M. Stallman <rms@gnu.org>
parents: 19881
diff changeset
1051 (self-insert-command (or quail-prefix-arg 1))
e135dd522e64 (quail-terminate-translation):
Richard M. Stallman <rms@gnu.org>
parents: 19881
diff changeset
1052 (setq quail-prefix-arg nil)
e135dd522e64 (quail-terminate-translation):
Richard M. Stallman <rms@gnu.org>
parents: 19881
diff changeset
1053 (setq seq (cdr seq))
e135dd522e64 (quail-terminate-translation):
Richard M. Stallman <rms@gnu.org>
parents: 19881
diff changeset
1054 (while seq
e135dd522e64 (quail-terminate-translation):
Richard M. Stallman <rms@gnu.org>
parents: 19881
diff changeset
1055 (setq last-command-char (car seq))
e135dd522e64 (quail-terminate-translation):
Richard M. Stallman <rms@gnu.org>
parents: 19881
diff changeset
1056 (self-insert-command 1)
e135dd522e64 (quail-terminate-translation):
Richard M. Stallman <rms@gnu.org>
parents: 19881
diff changeset
1057 (setq seq (cdr seq))))))
e135dd522e64 (quail-terminate-translation):
Richard M. Stallman <rms@gnu.org>
parents: 19881
diff changeset
1058 (delete-overlay quail-overlay))
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1059 (if (buffer-live-p quail-guidance-buf)
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1060 (save-excursion
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1061 (set-buffer quail-guidance-buf)
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1062 (erase-buffer)))
19404
8901359ae445 (quail-inactivate): Turn Quail mode off
Kenichi Handa <handa@m17n.org>
parents: 19391
diff changeset
1063 (setq overriding-terminal-local-map
19453
e6134c179b4c (quail-terminate-translation): Run
Kenichi Handa <handa@m17n.org>
parents: 19432
diff changeset
1064 (quail-conversion-keymap))
e6134c179b4c (quail-terminate-translation): Run
Kenichi Handa <handa@m17n.org>
parents: 19432
diff changeset
1065 ;; 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
1066 ;; conversion. When conversion is required, the conversion function
1c0ecc266e38 (quail-terminate-translation): Doc-string
Kenichi Handa <handa@m17n.org>
parents: 19453
diff changeset
1067 ;; should run this hook at a proper timing.
19453
e6134c179b4c (quail-terminate-translation): Run
Kenichi Handa <handa@m17n.org>
parents: 19432
diff changeset
1068 (unless (quail-conversion-keymap)
e6134c179b4c (quail-terminate-translation): Run
Kenichi Handa <handa@m17n.org>
parents: 19432
diff changeset
1069 (run-hooks 'input-method-after-insert-chunk-hook)))
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1070
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1071 (defun quail-select-current ()
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1072 "Select the current text shown in Quail translation region."
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1073 (interactive)
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1074 (quail-terminate-translation))
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1075
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1076 ;; Update the current translation status according to CONTROL-FLAG.
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1077 ;; 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
1078 ;; head quail-current-key which can be translated. The remaining keys
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1079 ;; are put back to unread-command-events to be handled again.
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1080 ;; If CONTROL-FLAG is t, terminate the translation for the whole keys
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1081 ;; in quail-current-key.
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1082 ;; If CONTROL-FLAG is nil, proceed the translation with more keys.
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-update-translation (control-flag)
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1085 (quail-delete-region)
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1086 (let ((func (quail-update-translation-function)))
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1087 (if func
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1088 (funcall func control-flag)
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1089 (if (numberp control-flag)
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1090 (let ((len (length quail-current-key)))
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1091 (while (> len control-flag)
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1092 (setq len (1- len))
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1093 (setq unread-command-events
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1094 (cons (aref quail-current-key len)
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1095 unread-command-events)))
19744
b1774d359a3d (quail-update-translation):
Richard M. Stallman <rms@gnu.org>
parents: 19723
diff changeset
1096 ;; Insert the translated sequence.
b1774d359a3d (quail-update-translation):
Richard M. Stallman <rms@gnu.org>
parents: 19723
diff changeset
1097 ;; It is a string containing multibyte characters.
b1774d359a3d (quail-update-translation):
Richard M. Stallman <rms@gnu.org>
parents: 19723
diff changeset
1098 ;; If enable-multibyte-characters, just insert it.
b1774d359a3d (quail-update-translation):
Richard M. Stallman <rms@gnu.org>
parents: 19723
diff changeset
1099 (if enable-multibyte-characters
b1774d359a3d (quail-update-translation):
Richard M. Stallman <rms@gnu.org>
parents: 19723
diff changeset
1100 (insert (or quail-current-str
b1774d359a3d (quail-update-translation):
Richard M. Stallman <rms@gnu.org>
parents: 19723
diff changeset
1101 (substring quail-current-key 0 len)))
b1774d359a3d (quail-update-translation):
Richard M. Stallman <rms@gnu.org>
parents: 19723
diff changeset
1102 ;; Otherwise, in case the user is using a single-byte
b1774d359a3d (quail-update-translation):
Richard M. Stallman <rms@gnu.org>
parents: 19723
diff changeset
1103 ;; extended-ASCII character set,
b1774d359a3d (quail-update-translation):
Richard M. Stallman <rms@gnu.org>
parents: 19723
diff changeset
1104 ;; try inserting the translated character.
19878
a69ae37e6932 (quail-update-translation): Fix previous change.
Richard M. Stallman <rms@gnu.org>
parents: 19849
diff changeset
1105 (let ((char (or quail-current-str
a69ae37e6932 (quail-update-translation): Fix previous change.
Richard M. Stallman <rms@gnu.org>
parents: 19849
diff changeset
1106 (substring quail-current-key 0 len))))
a69ae37e6932 (quail-update-translation): Fix previous change.
Richard M. Stallman <rms@gnu.org>
parents: 19849
diff changeset
1107 (if (stringp char)
a69ae37e6932 (quail-update-translation): Fix previous change.
Richard M. Stallman <rms@gnu.org>
parents: 19849
diff changeset
1108 (setq char (sref char 0)))
19744
b1774d359a3d (quail-update-translation):
Richard M. Stallman <rms@gnu.org>
parents: 19723
diff changeset
1109 (if (= (length (split-char char)) 2)
19878
a69ae37e6932 (quail-update-translation): Fix previous change.
Richard M. Stallman <rms@gnu.org>
parents: 19849
diff changeset
1110 (insert-char (logand char 255) 1)
a69ae37e6932 (quail-update-translation): Fix previous change.
Richard M. Stallman <rms@gnu.org>
parents: 19849
diff changeset
1111 (error "Three-byte characters require enabling multibyte characters")))))
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1112 (insert (or quail-current-str quail-current-key)))))
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1113 (quail-update-guidance)
19432
4492653b04e8 (quail-exit-from-minibuffer): Call
Kenichi Handa <handa@m17n.org>
parents: 19404
diff changeset
1114 (if control-flag
4492653b04e8 (quail-exit-from-minibuffer): Call
Kenichi Handa <handa@m17n.org>
parents: 19404
diff changeset
1115 (quail-terminate-translation)))
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1116
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1117 (defun quail-self-insert-command ()
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1118 "Add the typed character to the key for translation."
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1119 (interactive "*")
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1120 (setq quail-current-key
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1121 (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
1122 (unless (catch 'quail-tag
1c0ecc266e38 (quail-terminate-translation): Doc-string
Kenichi Handa <handa@m17n.org>
parents: 19453
diff changeset
1123 (quail-update-translation (quail-translate-key))
1c0ecc266e38 (quail-terminate-translation): Doc-string
Kenichi Handa <handa@m17n.org>
parents: 19453
diff changeset
1124 t)
1c0ecc266e38 (quail-terminate-translation): Doc-string
Kenichi Handa <handa@m17n.org>
parents: 19453
diff changeset
1125 ;; 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
1126 ;; translation mode.
1c0ecc266e38 (quail-terminate-translation): Doc-string
Kenichi Handa <handa@m17n.org>
parents: 19453
diff changeset
1127 (setq overriding-terminal-local-map nil)))
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1128
18556
99e8ae18137f (quail-guidance-buf): Make it buffer
Kenichi Handa <handa@m17n.org>
parents: 18377
diff changeset
1129 ;; 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
1130 (defun quail-map-definition (map)
99e8ae18137f (quail-guidance-buf): Make it buffer
Kenichi Handa <handa@m17n.org>
parents: 18377
diff changeset
1131 (let ((def (car map)))
99e8ae18137f (quail-guidance-buf): Make it buffer
Kenichi Handa <handa@m17n.org>
parents: 18377
diff changeset
1132 (if (and (consp def) (not (vectorp (cdr def))))
99e8ae18137f (quail-guidance-buf): Make it buffer
Kenichi Handa <handa@m17n.org>
parents: 18377
diff changeset
1133 (setq def (car def)))
99e8ae18137f (quail-guidance-buf): Make it buffer
Kenichi Handa <handa@m17n.org>
parents: 18377
diff changeset
1134 def))
99e8ae18137f (quail-guidance-buf): Make it buffer
Kenichi Handa <handa@m17n.org>
parents: 18377
diff changeset
1135
99e8ae18137f (quail-guidance-buf): Make it buffer
Kenichi Handa <handa@m17n.org>
parents: 18377
diff changeset
1136 ;; 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
1137 ;; 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
1138 ;; the sequence.
99e8ae18137f (quail-guidance-buf): Make it buffer
Kenichi Handa <handa@m17n.org>
parents: 18377
diff changeset
1139 (defun quail-get-current-str (len def)
99e8ae18137f (quail-guidance-buf): Make it buffer
Kenichi Handa <handa@m17n.org>
parents: 18377
diff changeset
1140 (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
1141 def
99e8ae18137f (quail-guidance-buf): Make it buffer
Kenichi Handa <handa@m17n.org>
parents: 18377
diff changeset
1142 (and (> len 1)
99e8ae18137f (quail-guidance-buf): Make it buffer
Kenichi Handa <handa@m17n.org>
parents: 18377
diff changeset
1143 (let ((str (quail-get-current-str
99e8ae18137f (quail-guidance-buf): Make it buffer
Kenichi Handa <handa@m17n.org>
parents: 18377
diff changeset
1144 (1- len)
99e8ae18137f (quail-guidance-buf): Make it buffer
Kenichi Handa <handa@m17n.org>
parents: 18377
diff changeset
1145 (quail-map-definition (quail-lookup-key
99e8ae18137f (quail-guidance-buf): Make it buffer
Kenichi Handa <handa@m17n.org>
parents: 18377
diff changeset
1146 quail-current-key (1- len))))))
99e8ae18137f (quail-guidance-buf): Make it buffer
Kenichi Handa <handa@m17n.org>
parents: 18377
diff changeset
1147 (if str
99e8ae18137f (quail-guidance-buf): Make it buffer
Kenichi Handa <handa@m17n.org>
parents: 18377
diff changeset
1148 (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
1149 (substring quail-current-key (1- len) len)))))))
99e8ae18137f (quail-guidance-buf): Make it buffer
Kenichi Handa <handa@m17n.org>
parents: 18377
diff changeset
1150
99e8ae18137f (quail-guidance-buf): Make it buffer
Kenichi Handa <handa@m17n.org>
parents: 18377
diff changeset
1151 (defvar quail-guidance-translations-starting-column 20)
99e8ae18137f (quail-guidance-buf): Make it buffer
Kenichi Handa <handa@m17n.org>
parents: 18377
diff changeset
1152
99e8ae18137f (quail-guidance-buf): Make it buffer
Kenichi Handa <handa@m17n.org>
parents: 18377
diff changeset
1153 ;; 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
1154 ;; current translation.
99e8ae18137f (quail-guidance-buf): Make it buffer
Kenichi Handa <handa@m17n.org>
parents: 18377
diff changeset
1155 (defun quail-update-current-translations (&optional relative-index)
99e8ae18137f (quail-guidance-buf): Make it buffer
Kenichi Handa <handa@m17n.org>
parents: 18377
diff changeset
1156 (let* ((indices (car quail-current-translations))
99e8ae18137f (quail-guidance-buf): Make it buffer
Kenichi Handa <handa@m17n.org>
parents: 18377
diff changeset
1157 (cur (car indices))
99e8ae18137f (quail-guidance-buf): Make it buffer
Kenichi Handa <handa@m17n.org>
parents: 18377
diff changeset
1158 (start (nth 1 indices))
99e8ae18137f (quail-guidance-buf): Make it buffer
Kenichi Handa <handa@m17n.org>
parents: 18377
diff changeset
1159 (end (nth 2 indices)))
99e8ae18137f (quail-guidance-buf): Make it buffer
Kenichi Handa <handa@m17n.org>
parents: 18377
diff changeset
1160 ;; Validate the index number of current translation.
99e8ae18137f (quail-guidance-buf): Make it buffer
Kenichi Handa <handa@m17n.org>
parents: 18377
diff changeset
1161 (if (< cur 0)
99e8ae18137f (quail-guidance-buf): Make it buffer
Kenichi Handa <handa@m17n.org>
parents: 18377
diff changeset
1162 (setcar indices (setq cur 0))
99e8ae18137f (quail-guidance-buf): Make it buffer
Kenichi Handa <handa@m17n.org>
parents: 18377
diff changeset
1163 (if (>= cur (length (cdr quail-current-translations)))
99e8ae18137f (quail-guidance-buf): Make it buffer
Kenichi Handa <handa@m17n.org>
parents: 18377
diff changeset
1164 (setcar indices
99e8ae18137f (quail-guidance-buf): Make it buffer
Kenichi Handa <handa@m17n.org>
parents: 18377
diff changeset
1165 (setq cur (1- (length (cdr quail-current-translations)))))))
99e8ae18137f (quail-guidance-buf): Make it buffer
Kenichi Handa <handa@m17n.org>
parents: 18377
diff changeset
1166
99e8ae18137f (quail-guidance-buf): Make it buffer
Kenichi Handa <handa@m17n.org>
parents: 18377
diff changeset
1167 (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
1168 (< cur start) ; We moved to the previous block.
99e8ae18137f (quail-guidance-buf): Make it buffer
Kenichi Handa <handa@m17n.org>
parents: 18377
diff changeset
1169 (>= cur end)) ; We moved to the next block.
99e8ae18137f (quail-guidance-buf): Make it buffer
Kenichi Handa <handa@m17n.org>
parents: 18377
diff changeset
1170 (let ((len (length (cdr quail-current-translations)))
99e8ae18137f (quail-guidance-buf): Make it buffer
Kenichi Handa <handa@m17n.org>
parents: 18377
diff changeset
1171 (maxcol (- (window-width quail-guidance-win)
99e8ae18137f (quail-guidance-buf): Make it buffer
Kenichi Handa <handa@m17n.org>
parents: 18377
diff changeset
1172 quail-guidance-translations-starting-column))
99e8ae18137f (quail-guidance-buf): Make it buffer
Kenichi Handa <handa@m17n.org>
parents: 18377
diff changeset
1173 (block (nth 3 indices))
99e8ae18137f (quail-guidance-buf): Make it buffer
Kenichi Handa <handa@m17n.org>
parents: 18377
diff changeset
1174 col idx width trans num-items blocks)
99e8ae18137f (quail-guidance-buf): Make it buffer
Kenichi Handa <handa@m17n.org>
parents: 18377
diff changeset
1175 (if (< cur start)
99e8ae18137f (quail-guidance-buf): Make it buffer
Kenichi Handa <handa@m17n.org>
parents: 18377
diff changeset
1176 ;; We must calculate from the head.
99e8ae18137f (quail-guidance-buf): Make it buffer
Kenichi Handa <handa@m17n.org>
parents: 18377
diff changeset
1177 (setq start 0 block 0)
99e8ae18137f (quail-guidance-buf): Make it buffer
Kenichi Handa <handa@m17n.org>
parents: 18377
diff changeset
1178 (if end ; i.e. (>= cur end)
99e8ae18137f (quail-guidance-buf): Make it buffer
Kenichi Handa <handa@m17n.org>
parents: 18377
diff changeset
1179 (setq start end)))
99e8ae18137f (quail-guidance-buf): Make it buffer
Kenichi Handa <handa@m17n.org>
parents: 18377
diff changeset
1180 (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
1181 ;; 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
1182 (while (and (< idx len) (>= cur end))
99e8ae18137f (quail-guidance-buf): Make it buffer
Kenichi Handa <handa@m17n.org>
parents: 18377
diff changeset
1183 (if (= num-items 0)
99e8ae18137f (quail-guidance-buf): Make it buffer
Kenichi Handa <handa@m17n.org>
parents: 18377
diff changeset
1184 (setq start idx col 0 block (1+ block)))
99e8ae18137f (quail-guidance-buf): Make it buffer
Kenichi Handa <handa@m17n.org>
parents: 18377
diff changeset
1185 (setq trans (aref (cdr quail-current-translations) idx))
99e8ae18137f (quail-guidance-buf): Make it buffer
Kenichi Handa <handa@m17n.org>
parents: 18377
diff changeset
1186 (setq width (if (integerp trans) (char-width trans)
99e8ae18137f (quail-guidance-buf): Make it buffer
Kenichi Handa <handa@m17n.org>
parents: 18377
diff changeset
1187 (string-width trans)))
99e8ae18137f (quail-guidance-buf): Make it buffer
Kenichi Handa <handa@m17n.org>
parents: 18377
diff changeset
1188 (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
1189 (if (and (> num-items 0)
99e8ae18137f (quail-guidance-buf): Make it buffer
Kenichi Handa <handa@m17n.org>
parents: 18377
diff changeset
1190 (or (>= col maxcol) (> num-items 10)))
99e8ae18137f (quail-guidance-buf): Make it buffer
Kenichi Handa <handa@m17n.org>
parents: 18377
diff changeset
1191 (setq end idx num-items 0)
99e8ae18137f (quail-guidance-buf): Make it buffer
Kenichi Handa <handa@m17n.org>
parents: 18377
diff changeset
1192 (setq idx (1+ idx))))
99e8ae18137f (quail-guidance-buf): Make it buffer
Kenichi Handa <handa@m17n.org>
parents: 18377
diff changeset
1193 (setcar (nthcdr 3 indices) block)
99e8ae18137f (quail-guidance-buf): Make it buffer
Kenichi Handa <handa@m17n.org>
parents: 18377
diff changeset
1194 (if (>= idx len)
99e8ae18137f (quail-guidance-buf): Make it buffer
Kenichi Handa <handa@m17n.org>
parents: 18377
diff changeset
1195 (progn
99e8ae18137f (quail-guidance-buf): Make it buffer
Kenichi Handa <handa@m17n.org>
parents: 18377
diff changeset
1196 ;; We hit the tail before reaching MAXCOL.
99e8ae18137f (quail-guidance-buf): Make it buffer
Kenichi Handa <handa@m17n.org>
parents: 18377
diff changeset
1197 (setq end idx)
99e8ae18137f (quail-guidance-buf): Make it buffer
Kenichi Handa <handa@m17n.org>
parents: 18377
diff changeset
1198 (setcar (nthcdr 4 indices) block)))
99e8ae18137f (quail-guidance-buf): Make it buffer
Kenichi Handa <handa@m17n.org>
parents: 18377
diff changeset
1199 (setcar (cdr indices) start)
99e8ae18137f (quail-guidance-buf): Make it buffer
Kenichi Handa <handa@m17n.org>
parents: 18377
diff changeset
1200 (setcar (nthcdr 2 indices) end)))
99e8ae18137f (quail-guidance-buf): Make it buffer
Kenichi Handa <handa@m17n.org>
parents: 18377
diff changeset
1201 (if relative-index
99e8ae18137f (quail-guidance-buf): Make it buffer
Kenichi Handa <handa@m17n.org>
parents: 18377
diff changeset
1202 (if (>= (+ start relative-index) end)
99e8ae18137f (quail-guidance-buf): Make it buffer
Kenichi Handa <handa@m17n.org>
parents: 18377
diff changeset
1203 (setcar indices end)
99e8ae18137f (quail-guidance-buf): Make it buffer
Kenichi Handa <handa@m17n.org>
parents: 18377
diff changeset
1204 (setcar indices (+ start relative-index))))
99e8ae18137f (quail-guidance-buf): Make it buffer
Kenichi Handa <handa@m17n.org>
parents: 18377
diff changeset
1205 (setq quail-current-str
99e8ae18137f (quail-guidance-buf): Make it buffer
Kenichi Handa <handa@m17n.org>
parents: 18377
diff changeset
1206 (aref (cdr quail-current-translations) (car indices)))))
99e8ae18137f (quail-guidance-buf): Make it buffer
Kenichi Handa <handa@m17n.org>
parents: 18377
diff changeset
1207
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1208 (defun quail-translate-key ()
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1209 "Translate the current key sequence according to the current Quail map.
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1210 Return t if we can terminate the translation.
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1211 Return nil if the current key sequence may be followed by more keys.
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1212 Return number if we can't find any translation for the current key
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1213 sequence. The number is the count of valid keys in the current
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1214 sequence counting from the head."
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1215 (let* ((len (length quail-current-key))
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1216 (map (quail-lookup-key quail-current-key len))
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1217 def ch)
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1218 (if map
18556
99e8ae18137f (quail-guidance-buf): Make it buffer
Kenichi Handa <handa@m17n.org>
parents: 18377
diff changeset
1219 (let ((def (quail-map-definition map)))
99e8ae18137f (quail-guidance-buf): Make it buffer
Kenichi Handa <handa@m17n.org>
parents: 18377
diff changeset
1220 (setq quail-current-str (quail-get-current-str len def))
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1221 ;; Return t only if we can terminate the current translation.
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1222 (and
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1223 ;; No alternative translations.
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1224 (or (null (consp def)) (= (length (cdr def)) 1))
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1225 ;; No translation for the longer key.
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1226 (null (cdr map))
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1227 ;; No shorter breaking point.
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1228 (or (null (quail-maximum-shortest))
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1229 (< len 3)
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1230 (null (quail-lookup-key quail-current-key (1- len)))
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1231 (null (quail-lookup-key
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1232 (substring quail-current-key -2 -1) 1)))))
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1233
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1234 ;; There's no translation for the current key sequence. Before
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1235 ;; giving up, we must check two possibilities.
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1236 (cond ((and
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1237 (quail-maximum-shortest)
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1238 (>= len 4)
18556
99e8ae18137f (quail-guidance-buf): Make it buffer
Kenichi Handa <handa@m17n.org>
parents: 18377
diff changeset
1239 (setq def (quail-map-definition
99e8ae18137f (quail-guidance-buf): Make it buffer
Kenichi Handa <handa@m17n.org>
parents: 18377
diff changeset
1240 (quail-lookup-key quail-current-key (- len 2))))
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1241 (quail-lookup-key (substring quail-current-key -2) 2))
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1242 ;; Now the sequence is "...ABCD", which can be split into
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1243 ;; "...AB" and "CD..." to get valid translation.
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1244 ;; At first, get translation of "...AB".
18556
99e8ae18137f (quail-guidance-buf): Make it buffer
Kenichi Handa <handa@m17n.org>
parents: 18377
diff changeset
1245 (setq quail-current-str (quail-get-current-str (- len 2) def))
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1246 ;; Then, return the length of "...AB".
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1247 (- len 2))
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1248
18797
e9aa787f0154 (quail-translate-key): Fix previous change.
Kenichi Handa <handa@m17n.org>
parents: 18642
diff changeset
1249 ((and (> len 0)
e9aa787f0154 (quail-translate-key): Fix previous change.
Kenichi Handa <handa@m17n.org>
parents: 18642
diff changeset
1250 (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
1251 quail-current-translations
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1252 (not (quail-deterministic))
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1253 (setq ch (aref quail-current-key (1- len)))
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1254 (>= ch ?0) (<= ch ?9))
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1255 ;; A numeric key is entered to select a desirable translation.
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1256 (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
1257 ;; 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
1258 (setq ch (if (= ch ?0) 9 (- ch ?1)))
99e8ae18137f (quail-guidance-buf): Make it buffer
Kenichi Handa <handa@m17n.org>
parents: 18377
diff changeset
1259 (quail-update-current-translations ch)
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1260 ;; And, we can terminate the current translation.
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1261 t)
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1262
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1263 (t
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1264 ;; No way to handle the last character in this context.
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1265 (1- len))))))
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1266
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1267 (defun quail-next-translation ()
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1268 "Select next translation in the current batch of candidates."
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1269 (interactive)
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1270 (if quail-current-translations
18556
99e8ae18137f (quail-guidance-buf): Make it buffer
Kenichi Handa <handa@m17n.org>
parents: 18377
diff changeset
1271 (let ((indices (car quail-current-translations)))
99e8ae18137f (quail-guidance-buf): Make it buffer
Kenichi Handa <handa@m17n.org>
parents: 18377
diff changeset
1272 (if (= (1+ (car indices)) (length (cdr quail-current-translations)))
19084
9f4b95f30c4f (quail-next-translation): Call
Kenichi Handa <handa@m17n.org>
parents: 18983
diff changeset
1273 ;; We are already at the tail.
18556
99e8ae18137f (quail-guidance-buf): Make it buffer
Kenichi Handa <handa@m17n.org>
parents: 18377
diff changeset
1274 (beep)
99e8ae18137f (quail-guidance-buf): Make it buffer
Kenichi Handa <handa@m17n.org>
parents: 18377
diff changeset
1275 (setcar indices (1+ (car indices)))
99e8ae18137f (quail-guidance-buf): Make it buffer
Kenichi Handa <handa@m17n.org>
parents: 18377
diff changeset
1276 (quail-update-current-translations)
99e8ae18137f (quail-guidance-buf): Make it buffer
Kenichi Handa <handa@m17n.org>
parents: 18377
diff changeset
1277 (quail-update-translation nil)))
19084
9f4b95f30c4f (quail-next-translation): Call
Kenichi Handa <handa@m17n.org>
parents: 18983
diff changeset
1278 (quail-execute-non-quail-command)))
17052
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-prev-translation ()
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1281 "Select previous 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 (= (car indices) 0)
99e8ae18137f (quail-guidance-buf): Make it buffer
Kenichi Handa <handa@m17n.org>
parents: 18377
diff changeset
1286 ;; We are already at the head.
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-next-translation-block ()
18556
99e8ae18137f (quail-guidance-buf): Make it buffer
Kenichi Handa <handa@m17n.org>
parents: 18377
diff changeset
1294 "Select from the next block of translations."
17052
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 (offset (- (car indices) (nth 1 indices))))
99e8ae18137f (quail-guidance-buf): Make it buffer
Kenichi Handa <handa@m17n.org>
parents: 18377
diff changeset
1299 (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
1300 ;; We are already at the last block.
99e8ae18137f (quail-guidance-buf): Make it buffer
Kenichi Handa <handa@m17n.org>
parents: 18377
diff changeset
1301 (beep)
99e8ae18137f (quail-guidance-buf): Make it buffer
Kenichi Handa <handa@m17n.org>
parents: 18377
diff changeset
1302 (setcar indices (+ (nth 2 indices) offset))
99e8ae18137f (quail-guidance-buf): Make it buffer
Kenichi Handa <handa@m17n.org>
parents: 18377
diff changeset
1303 (quail-update-current-translations)
99e8ae18137f (quail-guidance-buf): Make it buffer
Kenichi Handa <handa@m17n.org>
parents: 18377
diff changeset
1304 (quail-update-translation nil)))
19084
9f4b95f30c4f (quail-next-translation): Call
Kenichi Handa <handa@m17n.org>
parents: 18983
diff changeset
1305 (quail-execute-non-quail-command)))
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1306
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1307 (defun quail-prev-translation-block ()
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1308 "Select the previous batch of 10 translation candidates."
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1309 (interactive)
18556
99e8ae18137f (quail-guidance-buf): Make it buffer
Kenichi Handa <handa@m17n.org>
parents: 18377
diff changeset
1310 (if quail-current-translations
99e8ae18137f (quail-guidance-buf): Make it buffer
Kenichi Handa <handa@m17n.org>
parents: 18377
diff changeset
1311 (let* ((indices (car quail-current-translations))
99e8ae18137f (quail-guidance-buf): Make it buffer
Kenichi Handa <handa@m17n.org>
parents: 18377
diff changeset
1312 (offset (- (car indices) (nth 1 indices))))
99e8ae18137f (quail-guidance-buf): Make it buffer
Kenichi Handa <handa@m17n.org>
parents: 18377
diff changeset
1313 (if (= (nth 1 indices) 0)
99e8ae18137f (quail-guidance-buf): Make it buffer
Kenichi Handa <handa@m17n.org>
parents: 18377
diff changeset
1314 ;; We are already at the first block.
99e8ae18137f (quail-guidance-buf): Make it buffer
Kenichi Handa <handa@m17n.org>
parents: 18377
diff changeset
1315 (beep)
99e8ae18137f (quail-guidance-buf): Make it buffer
Kenichi Handa <handa@m17n.org>
parents: 18377
diff changeset
1316 (setcar indices (1- (nth 1 indices)))
99e8ae18137f (quail-guidance-buf): Make it buffer
Kenichi Handa <handa@m17n.org>
parents: 18377
diff changeset
1317 (quail-update-current-translations)
99e8ae18137f (quail-guidance-buf): Make it buffer
Kenichi Handa <handa@m17n.org>
parents: 18377
diff changeset
1318 (if (< (+ (nth 1 indices) offset) (nth 2 indices))
99e8ae18137f (quail-guidance-buf): Make it buffer
Kenichi Handa <handa@m17n.org>
parents: 18377
diff changeset
1319 (progn
99e8ae18137f (quail-guidance-buf): Make it buffer
Kenichi Handa <handa@m17n.org>
parents: 18377
diff changeset
1320 (setcar indices (+ (nth 1 indices) offset))
99e8ae18137f (quail-guidance-buf): Make it buffer
Kenichi Handa <handa@m17n.org>
parents: 18377
diff changeset
1321 (quail-update-current-translations)))
99e8ae18137f (quail-guidance-buf): Make it buffer
Kenichi Handa <handa@m17n.org>
parents: 18377
diff changeset
1322 (quail-update-translation nil)))
19084
9f4b95f30c4f (quail-next-translation): Call
Kenichi Handa <handa@m17n.org>
parents: 18983
diff changeset
1323 (quail-execute-non-quail-command)))
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1324
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1325 (defun quail-abort-translation ()
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1326 "Abort translation and delete the current Quail key sequence."
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1327 (interactive)
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1328 (quail-delete-region)
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1329 (quail-terminate-translation))
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1330
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1331 (defun quail-delete-last-char ()
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1332 "Delete the last input character from the current Quail key sequence."
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1333 (interactive)
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1334 (if (= (length quail-current-key) 1)
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1335 (quail-abort-translation)
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1336 (setq quail-current-key (substring quail-current-key 0 -1))
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1337 (quail-update-translation (quail-translate-key))))
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1338
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1339 ;; For conversion mode.
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1340
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1341 (defun quail-conversion-backward-char ()
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1342 (interactive)
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1343 (if (<= (point) (overlay-start quail-conv-overlay))
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1344 (error "Beginning of conversion region"))
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1345 (forward-char -1))
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1346
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1347 (defun quail-conversion-forward-char ()
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1348 (interactive)
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1349 (if (>= (point) (overlay-end quail-conv-overlay))
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1350 (error "End of conversion region"))
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1351 (forward-char 1))
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1352
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1353 (defun quail-conversion-beginning-of-region ()
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1354 (interactive)
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1355 (goto-char (overlay-start quail-conv-overlay)))
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1356
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1357 (defun quail-conversion-end-of-region ()
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1358 (interactive)
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1359 (goto-char (overlay-end quail-conv-overlay)))
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1360
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1361 (defun quail-conversion-delete-char ()
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1362 (interactive)
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1363 (if (>= (point) (overlay-end quail-conv-overlay))
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1364 (error "End of conversion region"))
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1365 (delete-char 1)
19404
8901359ae445 (quail-inactivate): Turn Quail mode off
Kenichi Handa <handa@m17n.org>
parents: 19391
diff changeset
1366 (when (= (overlay-start quail-conv-overlay)
8901359ae445 (quail-inactivate): Turn Quail mode off
Kenichi Handa <handa@m17n.org>
parents: 19391
diff changeset
1367 (overlay-end quail-conv-overlay))
8901359ae445 (quail-inactivate): Turn Quail mode off
Kenichi Handa <handa@m17n.org>
parents: 19391
diff changeset
1368 (quail-delete-overlays)
8901359ae445 (quail-inactivate): Turn Quail mode off
Kenichi Handa <handa@m17n.org>
parents: 19391
diff changeset
1369 (setq overriding-terminal-local-map nil)))
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1370
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1371 (defun quail-conversion-backward-delete-char ()
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1372 (interactive)
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1373 (if (<= (point) (overlay-start quail-conv-overlay))
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1374 (error "Beginning of conversion region"))
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1375 (delete-char -1)
19404
8901359ae445 (quail-inactivate): Turn Quail mode off
Kenichi Handa <handa@m17n.org>
parents: 19391
diff changeset
1376 (when (= (overlay-start quail-conv-overlay)
8901359ae445 (quail-inactivate): Turn Quail mode off
Kenichi Handa <handa@m17n.org>
parents: 19391
diff changeset
1377 (overlay-end quail-conv-overlay))
8901359ae445 (quail-inactivate): Turn Quail mode off
Kenichi Handa <handa@m17n.org>
parents: 19391
diff changeset
1378 (quail-delete-overlays)
8901359ae445 (quail-inactivate): Turn Quail mode off
Kenichi Handa <handa@m17n.org>
parents: 19391
diff changeset
1379 (setq overriding-terminal-local-map nil)))
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1380
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1381 (defun quail-do-conversion (func &rest args)
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1382 "Call FUNC to convert text in the current conversion region of Quail.
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1383 Remaining args are for FUNC."
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1384 (delete-overlay quail-overlay)
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1385 (apply func args))
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1386
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1387 (defun quail-no-conversion ()
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1388 "Do no conversion of the current conversion region of Quail."
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1389 (interactive)
19404
8901359ae445 (quail-inactivate): Turn Quail mode off
Kenichi Handa <handa@m17n.org>
parents: 19391
diff changeset
1390 (quail-delete-overlays)
19453
e6134c179b4c (quail-terminate-translation): Run
Kenichi Handa <handa@m17n.org>
parents: 19432
diff changeset
1391 (setq overriding-terminal-local-map nil)
e6134c179b4c (quail-terminate-translation): Run
Kenichi Handa <handa@m17n.org>
parents: 19432
diff changeset
1392 (run-hooks 'input-method-after-insert-chunk-hook))
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 ;; Guidance, Completion, and Help buffer handlers.
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1395
18556
99e8ae18137f (quail-guidance-buf): Make it buffer
Kenichi Handa <handa@m17n.org>
parents: 18377
diff changeset
1396 ;; 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
1397 (defun quail-make-guidance-frame (buf)
99e8ae18137f (quail-guidance-buf): Make it buffer
Kenichi Handa <handa@m17n.org>
parents: 18377
diff changeset
1398 (let* ((fparam (frame-parameters))
99e8ae18137f (quail-guidance-buf): Make it buffer
Kenichi Handa <handa@m17n.org>
parents: 18377
diff changeset
1399 (top (cdr (assq 'top fparam)))
99e8ae18137f (quail-guidance-buf): Make it buffer
Kenichi Handa <handa@m17n.org>
parents: 18377
diff changeset
1400 (border (cdr (assq 'border-width fparam)))
99e8ae18137f (quail-guidance-buf): Make it buffer
Kenichi Handa <handa@m17n.org>
parents: 18377
diff changeset
1401 (internal-border (cdr (assq 'internal-border-width fparam)))
99e8ae18137f (quail-guidance-buf): Make it buffer
Kenichi Handa <handa@m17n.org>
parents: 18377
diff changeset
1402 (newtop (- top
99e8ae18137f (quail-guidance-buf): Make it buffer
Kenichi Handa <handa@m17n.org>
parents: 18377
diff changeset
1403 (frame-char-height) (* internal-border 2) (* border 2))))
99e8ae18137f (quail-guidance-buf): Make it buffer
Kenichi Handa <handa@m17n.org>
parents: 18377
diff changeset
1404 (if (< newtop 0)
99e8ae18137f (quail-guidance-buf): Make it buffer
Kenichi Handa <handa@m17n.org>
parents: 18377
diff changeset
1405 (setq newtop (+ top (frame-pixel-height))))
99e8ae18137f (quail-guidance-buf): Make it buffer
Kenichi Handa <handa@m17n.org>
parents: 18377
diff changeset
1406 (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
1407 (minibuffer) (menu-bar-lines . 0))
99e8ae18137f (quail-guidance-buf): Make it buffer
Kenichi Handa <handa@m17n.org>
parents: 18377
diff changeset
1408 (cons (cons 'top newtop) fparam))))
99e8ae18137f (quail-guidance-buf): Make it buffer
Kenichi Handa <handa@m17n.org>
parents: 18377
diff changeset
1409 (win (frame-first-window frame)))
99e8ae18137f (quail-guidance-buf): Make it buffer
Kenichi Handa <handa@m17n.org>
parents: 18377
diff changeset
1410 (set-window-buffer win buf)
19878
a69ae37e6932 (quail-update-translation): Fix previous change.
Richard M. Stallman <rms@gnu.org>
parents: 19849
diff changeset
1411 ;;(set-window-dedicated-p win t)
a69ae37e6932 (quail-update-translation): Fix previous change.
Richard M. Stallman <rms@gnu.org>
parents: 19849
diff changeset
1412 )))
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1413
19432
4492653b04e8 (quail-exit-from-minibuffer): Call
Kenichi Handa <handa@m17n.org>
parents: 19404
diff changeset
1414 ;; Setup Quail completion buffer.
4492653b04e8 (quail-exit-from-minibuffer): Call
Kenichi Handa <handa@m17n.org>
parents: 19404
diff changeset
1415 (defun quail-setup-completion-buf ()
4492653b04e8 (quail-exit-from-minibuffer): Call
Kenichi Handa <handa@m17n.org>
parents: 19404
diff changeset
1416 (unless (buffer-live-p quail-completion-buf)
4492653b04e8 (quail-exit-from-minibuffer): Call
Kenichi Handa <handa@m17n.org>
parents: 19404
diff changeset
1417 (setq quail-completion-buf (get-buffer-create "*Quail Completions*"))
4492653b04e8 (quail-exit-from-minibuffer): Call
Kenichi Handa <handa@m17n.org>
parents: 19404
diff changeset
1418 (save-excursion
4492653b04e8 (quail-exit-from-minibuffer): Call
Kenichi Handa <handa@m17n.org>
parents: 19404
diff changeset
1419 (set-buffer quail-completion-buf)
4492653b04e8 (quail-exit-from-minibuffer): Call
Kenichi Handa <handa@m17n.org>
parents: 19404
diff changeset
1420 (setq quail-overlay (make-overlay 1 1))
4492653b04e8 (quail-exit-from-minibuffer): Call
Kenichi Handa <handa@m17n.org>
parents: 19404
diff changeset
1421 (overlay-put quail-overlay 'face 'highlight))))
4492653b04e8 (quail-exit-from-minibuffer): Call
Kenichi Handa <handa@m17n.org>
parents: 19404
diff changeset
1422
19849
1c5164d81426 (quail-simple): New function.
Kenichi Handa <handa@m17n.org>
parents: 19844
diff changeset
1423 ;; Return t iff the current Quail package requires showing guidance
1c5164d81426 (quail-simple): New function.
Kenichi Handa <handa@m17n.org>
parents: 19844
diff changeset
1424 ;; buffer.
1c5164d81426 (quail-simple): New function.
Kenichi Handa <handa@m17n.org>
parents: 19844
diff changeset
1425 (defun quail-require-guidance-buf ()
1c5164d81426 (quail-simple): New function.
Kenichi Handa <handa@m17n.org>
parents: 19844
diff changeset
1426 (and input-method-verbose-flag
1c5164d81426 (quail-simple): New function.
Kenichi Handa <handa@m17n.org>
parents: 19844
diff changeset
1427 (not (and (eq (selected-window) (minibuffer-window))
1c5164d81426 (quail-simple): New function.
Kenichi Handa <handa@m17n.org>
parents: 19844
diff changeset
1428 (quail-simple)))))
1c5164d81426 (quail-simple): New function.
Kenichi Handa <handa@m17n.org>
parents: 19844
diff changeset
1429
18556
99e8ae18137f (quail-guidance-buf): Make it buffer
Kenichi Handa <handa@m17n.org>
parents: 18377
diff changeset
1430 (defun quail-show-guidance-buf ()
99e8ae18137f (quail-guidance-buf): Make it buffer
Kenichi Handa <handa@m17n.org>
parents: 18377
diff changeset
1431 "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
1432 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
1433 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
1434 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
1435 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
1436 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
1437 (when (quail-require-guidance-buf)
18556
99e8ae18137f (quail-guidance-buf): Make it buffer
Kenichi Handa <handa@m17n.org>
parents: 18377
diff changeset
1438 ;; At first, setup a guidance buffer.
99e8ae18137f (quail-guidance-buf): Make it buffer
Kenichi Handa <handa@m17n.org>
parents: 18377
diff changeset
1439 (or (buffer-live-p quail-guidance-buf)
99e8ae18137f (quail-guidance-buf): Make it buffer
Kenichi Handa <handa@m17n.org>
parents: 18377
diff changeset
1440 (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
1441 (let ((title (quail-title)))
99e8ae18137f (quail-guidance-buf): Make it buffer
Kenichi Handa <handa@m17n.org>
parents: 18377
diff changeset
1442 (save-excursion
99e8ae18137f (quail-guidance-buf): Make it buffer
Kenichi Handa <handa@m17n.org>
parents: 18377
diff changeset
1443 (set-buffer quail-guidance-buf)
99e8ae18137f (quail-guidance-buf): Make it buffer
Kenichi Handa <handa@m17n.org>
parents: 18377
diff changeset
1444 ;; To show the title of Quail package.
99e8ae18137f (quail-guidance-buf): Make it buffer
Kenichi Handa <handa@m17n.org>
parents: 18377
diff changeset
1445 (setq current-input-method t
99e8ae18137f (quail-guidance-buf): Make it buffer
Kenichi Handa <handa@m17n.org>
parents: 18377
diff changeset
1446 current-input-method-title title)
99e8ae18137f (quail-guidance-buf): Make it buffer
Kenichi Handa <handa@m17n.org>
parents: 18377
diff changeset
1447 (erase-buffer)
99e8ae18137f (quail-guidance-buf): Make it buffer
Kenichi Handa <handa@m17n.org>
parents: 18377
diff changeset
1448 (or (overlayp quail-overlay)
99e8ae18137f (quail-guidance-buf): Make it buffer
Kenichi Handa <handa@m17n.org>
parents: 18377
diff changeset
1449 (progn
99e8ae18137f (quail-guidance-buf): Make it buffer
Kenichi Handa <handa@m17n.org>
parents: 18377
diff changeset
1450 (setq quail-overlay (make-overlay 1 1))
99e8ae18137f (quail-guidance-buf): Make it buffer
Kenichi Handa <handa@m17n.org>
parents: 18377
diff changeset
1451 (overlay-put quail-overlay 'face 'highlight)))
99e8ae18137f (quail-guidance-buf): Make it buffer
Kenichi Handa <handa@m17n.org>
parents: 18377
diff changeset
1452 (delete-overlay quail-overlay)
99e8ae18137f (quail-guidance-buf): Make it buffer
Kenichi Handa <handa@m17n.org>
parents: 18377
diff changeset
1453 (set-buffer-modified-p nil)))
99e8ae18137f (quail-guidance-buf): Make it buffer
Kenichi Handa <handa@m17n.org>
parents: 18377
diff changeset
1454 (bury-buffer quail-guidance-buf)
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1455
18556
99e8ae18137f (quail-guidance-buf): Make it buffer
Kenichi Handa <handa@m17n.org>
parents: 18377
diff changeset
1456 ;; Then, display it in an appropriate window.
99e8ae18137f (quail-guidance-buf): Make it buffer
Kenichi Handa <handa@m17n.org>
parents: 18377
diff changeset
1457 (let ((win (minibuffer-window)))
99e8ae18137f (quail-guidance-buf): Make it buffer
Kenichi Handa <handa@m17n.org>
parents: 18377
diff changeset
1458 (if (eq (selected-window) win)
99e8ae18137f (quail-guidance-buf): Make it buffer
Kenichi Handa <handa@m17n.org>
parents: 18377
diff changeset
1459 ;; 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
1460 (if (eq win (frame-root-window))
99e8ae18137f (quail-guidance-buf): Make it buffer
Kenichi Handa <handa@m17n.org>
parents: 18377
diff changeset
1461 ;; 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
1462 ;; window system.
99e8ae18137f (quail-guidance-buf): Make it buffer
Kenichi Handa <handa@m17n.org>
parents: 18377
diff changeset
1463 (quail-make-guidance-frame quail-guidance-buf)
99e8ae18137f (quail-guidance-buf): Make it buffer
Kenichi Handa <handa@m17n.org>
parents: 18377
diff changeset
1464 ;; 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
1465 (let (height)
99e8ae18137f (quail-guidance-buf): Make it buffer
Kenichi Handa <handa@m17n.org>
parents: 18377
diff changeset
1466 (setq win (window-at 0 (- (frame-height) 2)))
99e8ae18137f (quail-guidance-buf): Make it buffer
Kenichi Handa <handa@m17n.org>
parents: 18377
diff changeset
1467 (setq height (window-height win))
99e8ae18137f (quail-guidance-buf): Make it buffer
Kenichi Handa <handa@m17n.org>
parents: 18377
diff changeset
1468 ;; 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
1469 ;; the lower one.
99e8ae18137f (quail-guidance-buf): Make it buffer
Kenichi Handa <handa@m17n.org>
parents: 18377
diff changeset
1470 (if (>= height 4)
99e8ae18137f (quail-guidance-buf): Make it buffer
Kenichi Handa <handa@m17n.org>
parents: 18377
diff changeset
1471 (let ((window-min-height 2))
99e8ae18137f (quail-guidance-buf): Make it buffer
Kenichi Handa <handa@m17n.org>
parents: 18377
diff changeset
1472 ;; Here, `split-window' returns a lower window
99e8ae18137f (quail-guidance-buf): Make it buffer
Kenichi Handa <handa@m17n.org>
parents: 18377
diff changeset
1473 ;; which is what we wanted.
99e8ae18137f (quail-guidance-buf): Make it buffer
Kenichi Handa <handa@m17n.org>
parents: 18377
diff changeset
1474 (setq win (split-window win (- height 2)))))
99e8ae18137f (quail-guidance-buf): Make it buffer
Kenichi Handa <handa@m17n.org>
parents: 18377
diff changeset
1475 (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
1476 ;;(set-window-dedicated-p win t)
a69ae37e6932 (quail-update-translation): Fix previous change.
Richard M. Stallman <rms@gnu.org>
parents: 19849
diff changeset
1477 ))
18556
99e8ae18137f (quail-guidance-buf): Make it buffer
Kenichi Handa <handa@m17n.org>
parents: 18377
diff changeset
1478 (set-window-buffer win quail-guidance-buf))
99e8ae18137f (quail-guidance-buf): Make it buffer
Kenichi Handa <handa@m17n.org>
parents: 18377
diff changeset
1479 (setq quail-guidance-win win)))
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1480
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1481 ;; And, create a buffer for completion.
19432
4492653b04e8 (quail-exit-from-minibuffer): Call
Kenichi Handa <handa@m17n.org>
parents: 19404
diff changeset
1482 (quail-setup-completion-buf)
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1483 (bury-buffer quail-completion-buf))
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1484
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1485 (defun quail-hide-guidance-buf ()
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1486 "Hide the Quail guidance buffer."
18556
99e8ae18137f (quail-guidance-buf): Make it buffer
Kenichi Handa <handa@m17n.org>
parents: 18377
diff changeset
1487 (if (buffer-live-p quail-guidance-buf)
99e8ae18137f (quail-guidance-buf): Make it buffer
Kenichi Handa <handa@m17n.org>
parents: 18377
diff changeset
1488 (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
1489 win)
99e8ae18137f (quail-guidance-buf): Make it buffer
Kenichi Handa <handa@m17n.org>
parents: 18377
diff changeset
1490 (while win-list
99e8ae18137f (quail-guidance-buf): Make it buffer
Kenichi Handa <handa@m17n.org>
parents: 18377
diff changeset
1491 (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
1492 (if (eq win (minibuffer-window))
99e8ae18137f (quail-guidance-buf): Make it buffer
Kenichi Handa <handa@m17n.org>
parents: 18377
diff changeset
1493 ;; 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
1494 ;; Vacate it to the deepest minibuffer.
99e8ae18137f (quail-guidance-buf): Make it buffer
Kenichi Handa <handa@m17n.org>
parents: 18377
diff changeset
1495 (set-window-buffer win
99e8ae18137f (quail-guidance-buf): Make it buffer
Kenichi Handa <handa@m17n.org>
parents: 18377
diff changeset
1496 (format " *Minibuf-%d*" (minibuffer-depth)))
99e8ae18137f (quail-guidance-buf): Make it buffer
Kenichi Handa <handa@m17n.org>
parents: 18377
diff changeset
1497 (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
1498 (progn
99e8ae18137f (quail-guidance-buf): Make it buffer
Kenichi Handa <handa@m17n.org>
parents: 18377
diff changeset
1499 ;; 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
1500 ;;(set-window-dedicated-p win nil)
99e8ae18137f (quail-guidance-buf): Make it buffer
Kenichi Handa <handa@m17n.org>
parents: 18377
diff changeset
1501 (delete-frame (window-frame win)))
19878
a69ae37e6932 (quail-update-translation): Fix previous change.
Richard M. Stallman <rms@gnu.org>
parents: 19849
diff changeset
1502 ;;(set-window-dedicated-p win nil)
18556
99e8ae18137f (quail-guidance-buf): Make it buffer
Kenichi Handa <handa@m17n.org>
parents: 18377
diff changeset
1503 (delete-window win)))))))
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1504
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1505 (defun quail-update-guidance ()
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1506 "Update the Quail guidance buffer and completion buffer (if displayed now)."
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1507 ;; Update guidance buffer.
19849
1c5164d81426 (quail-simple): New function.
Kenichi Handa <handa@m17n.org>
parents: 19844
diff changeset
1508 (if (quail-require-guidance-buf)
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1509 (let ((guidance (quail-guidance)))
19723
3ada64a43911 (quail-update-guidance): If PROMPTKEY is
Kenichi Handa <handa@m17n.org>
parents: 19675
diff changeset
1510 (cond ((or (eq guidance t)
3ada64a43911 (quail-update-guidance): If PROMPTKEY is
Kenichi Handa <handa@m17n.org>
parents: 19675
diff changeset
1511 (listp guidance))
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1512 ;; Show the current possible translations.
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1513 (quail-show-translations))
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1514 ((null guidance)
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1515 ;; Show the current input keys.
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1516 (let ((key quail-current-key))
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1517 (save-excursion
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1518 (set-buffer quail-guidance-buf)
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1519 (erase-buffer)
19723
3ada64a43911 (quail-update-guidance): If PROMPTKEY is
Kenichi Handa <handa@m17n.org>
parents: 19675
diff changeset
1520 (insert key)))))))
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 ;; Update completion buffer if displayed now. We highlight the
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1523 ;; selected candidate string in *Completion* buffer if any.
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1524 (let ((win (get-buffer-window quail-completion-buf))
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1525 key str pos)
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1526 (if win
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1527 (save-excursion
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1528 (setq str (if (stringp quail-current-str)
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1529 quail-current-str
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1530 (if (numberp quail-current-str)
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1531 (char-to-string quail-current-str)))
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1532 key quail-current-key)
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1533 (set-buffer quail-completion-buf)
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1534 (goto-char (point-min))
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1535 (if (null (search-forward (concat " " key ":") nil t))
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1536 (delete-overlay quail-overlay)
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1537 (setq pos (point))
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1538 (if (and str (search-forward (concat "." str) nil t))
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1539 (move-overlay quail-overlay (1+ (match-beginning 0)) (point))
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1540 (move-overlay quail-overlay (match-beginning 0) (point)))
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1541 ;; Now POS points end of KEY and (point) points end of STR.
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1542 (if (pos-visible-in-window-p (point) win)
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1543 ;; STR is already visible.
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1544 nil
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1545 ;; We want to make both KEY and STR visible, but if the
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1546 ;; window is too short, make at least STR visible.
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1547 (setq pos (progn (point) (goto-char pos)))
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1548 (beginning-of-line)
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1549 (set-window-start win (point))
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1550 (if (not (pos-visible-in-window-p pos win))
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1551 (set-window-start win pos))
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1552 ))))))
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1553
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1554 (defun quail-show-translations ()
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1555 "Show the current possible translations."
18297
5c8e37591da5 (quail-current-data): New variable.
Kenichi Handa <handa@m17n.org>
parents: 18201
diff changeset
1556 (let* ((key quail-current-key)
18556
99e8ae18137f (quail-guidance-buf): Make it buffer
Kenichi Handa <handa@m17n.org>
parents: 18377
diff changeset
1557 (map (quail-lookup-key quail-current-key)))
99e8ae18137f (quail-guidance-buf): Make it buffer
Kenichi Handa <handa@m17n.org>
parents: 18377
diff changeset
1558 (if quail-current-translations
99e8ae18137f (quail-guidance-buf): Make it buffer
Kenichi Handa <handa@m17n.org>
parents: 18377
diff changeset
1559 (quail-update-current-translations))
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1560 (save-excursion
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1561 (set-buffer quail-guidance-buf)
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1562 (erase-buffer)
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1563
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1564 ;; Show the current key.
19723
3ada64a43911 (quail-update-guidance): If PROMPTKEY is
Kenichi Handa <handa@m17n.org>
parents: 19675
diff changeset
1565 (let ((guidance (quail-guidance)))
3ada64a43911 (quail-update-guidance): If PROMPTKEY is
Kenichi Handa <handa@m17n.org>
parents: 19675
diff changeset
1566 (if (listp guidance)
3ada64a43911 (quail-update-guidance): If PROMPTKEY is
Kenichi Handa <handa@m17n.org>
parents: 19675
diff changeset
1567 ;; 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
1568 ;; actual typed keys.
3ada64a43911 (quail-update-guidance): If PROMPTKEY is
Kenichi Handa <handa@m17n.org>
parents: 19675
diff changeset
1569 (let ((i 0)
3ada64a43911 (quail-update-guidance): If PROMPTKEY is
Kenichi Handa <handa@m17n.org>
parents: 19675
diff changeset
1570 (len (length key))
3ada64a43911 (quail-update-guidance): If PROMPTKEY is
Kenichi Handa <handa@m17n.org>
parents: 19675
diff changeset
1571 prompt-key)
3ada64a43911 (quail-update-guidance): If PROMPTKEY is
Kenichi Handa <handa@m17n.org>
parents: 19675
diff changeset
1572 (while (< i len)
3ada64a43911 (quail-update-guidance): If PROMPTKEY is
Kenichi Handa <handa@m17n.org>
parents: 19675
diff changeset
1573 (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
1574 (insert (or prompt-key (aref key i)))
3ada64a43911 (quail-update-guidance): If PROMPTKEY is
Kenichi Handa <handa@m17n.org>
parents: 19675
diff changeset
1575 (setq i (1+ i))))
3ada64a43911 (quail-update-guidance): If PROMPTKEY is
Kenichi Handa <handa@m17n.org>
parents: 19675
diff changeset
1576 (insert key)))
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1577
18556
99e8ae18137f (quail-guidance-buf): Make it buffer
Kenichi Handa <handa@m17n.org>
parents: 18377
diff changeset
1578 ;; Show followable keys.
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1579 (if (cdr map)
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1580 (let ((l (cdr map)))
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1581 (insert "[")
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1582 (while l
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1583 (insert (car (car l)))
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1584 (setq l (cdr l)))
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1585 (insert "]")))
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1586
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1587 ;; Show list of translations.
18556
99e8ae18137f (quail-guidance-buf): Make it buffer
Kenichi Handa <handa@m17n.org>
parents: 18377
diff changeset
1588 (if quail-current-translations
99e8ae18137f (quail-guidance-buf): Make it buffer
Kenichi Handa <handa@m17n.org>
parents: 18377
diff changeset
1589 (let* ((indices (car quail-current-translations))
99e8ae18137f (quail-guidance-buf): Make it buffer
Kenichi Handa <handa@m17n.org>
parents: 18377
diff changeset
1590 (cur (car indices))
99e8ae18137f (quail-guidance-buf): Make it buffer
Kenichi Handa <handa@m17n.org>
parents: 18377
diff changeset
1591 (start (nth 1 indices))
99e8ae18137f (quail-guidance-buf): Make it buffer
Kenichi Handa <handa@m17n.org>
parents: 18377
diff changeset
1592 (end (nth 2 indices))
99e8ae18137f (quail-guidance-buf): Make it buffer
Kenichi Handa <handa@m17n.org>
parents: 18377
diff changeset
1593 (idx start))
99e8ae18137f (quail-guidance-buf): Make it buffer
Kenichi Handa <handa@m17n.org>
parents: 18377
diff changeset
1594 (indent-to (- quail-guidance-translations-starting-column 7))
99e8ae18137f (quail-guidance-buf): Make it buffer
Kenichi Handa <handa@m17n.org>
parents: 18377
diff changeset
1595 (insert (format "(%02d/"(nth 3 indices))
99e8ae18137f (quail-guidance-buf): Make it buffer
Kenichi Handa <handa@m17n.org>
parents: 18377
diff changeset
1596 (if (nth 4 indices)
99e8ae18137f (quail-guidance-buf): Make it buffer
Kenichi Handa <handa@m17n.org>
parents: 18377
diff changeset
1597 (format "%02d)" (nth 4 indices))
99e8ae18137f (quail-guidance-buf): Make it buffer
Kenichi Handa <handa@m17n.org>
parents: 18377
diff changeset
1598 "??)"))
99e8ae18137f (quail-guidance-buf): Make it buffer
Kenichi Handa <handa@m17n.org>
parents: 18377
diff changeset
1599 (while (< idx end)
99e8ae18137f (quail-guidance-buf): Make it buffer
Kenichi Handa <handa@m17n.org>
parents: 18377
diff changeset
1600 (insert (format " %d." (if (= (- idx start) 9) 0
99e8ae18137f (quail-guidance-buf): Make it buffer
Kenichi Handa <handa@m17n.org>
parents: 18377
diff changeset
1601 (1+ (- idx start)))))
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1602 (let ((pos (point)))
18556
99e8ae18137f (quail-guidance-buf): Make it buffer
Kenichi Handa <handa@m17n.org>
parents: 18377
diff changeset
1603 (insert (aref (cdr quail-current-translations) idx))
99e8ae18137f (quail-guidance-buf): Make it buffer
Kenichi Handa <handa@m17n.org>
parents: 18377
diff changeset
1604 (if (= idx cur)
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1605 (move-overlay quail-overlay pos (point))))
18556
99e8ae18137f (quail-guidance-buf): Make it buffer
Kenichi Handa <handa@m17n.org>
parents: 18377
diff changeset
1606 (setq idx (1+ idx)))))
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1607 )))
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1608
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1609 (defun quail-completion ()
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1610 "List all completions for the current key.
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1611 All possible translations of the current key and whole possible longer keys
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1612 are shown."
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1613 (interactive)
19432
4492653b04e8 (quail-exit-from-minibuffer): Call
Kenichi Handa <handa@m17n.org>
parents: 19404
diff changeset
1614 (quail-setup-completion-buf)
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1615 (let ((key quail-current-key)
18556
99e8ae18137f (quail-guidance-buf): Make it buffer
Kenichi Handa <handa@m17n.org>
parents: 18377
diff changeset
1616 (map (quail-lookup-key quail-current-key)))
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1617 (save-excursion
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1618 (set-buffer quail-completion-buf)
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1619 (erase-buffer)
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1620 (insert "Possible completion and corresponding translations are:\n")
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1621 (quail-completion-1 key map 1)
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1622 (goto-char (point-min))
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1623 (display-buffer (current-buffer)))
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1624 (quail-update-guidance)))
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1625
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1626 ;; List all completions of KEY in MAP with indentation INDENT.
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1627 (defun quail-completion-1 (key map indent)
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1628 (let ((len (length key)))
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1629 (indent-to indent)
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1630 (insert key ":")
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1631 (if (and (symbolp map) (fboundp map))
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1632 (setq map (funcall map key len)))
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1633 (if (car map)
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1634 (quail-completion-list-translations map key (+ indent len 1))
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1635 (insert " -\n"))
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1636 (setq indent (+ indent 2))
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1637 (if (cdr map)
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1638 (let ((l (cdr map))
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1639 (newkey (make-string (1+ len) 0))
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1640 (i 0))
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1641 ;; Set KEY in the first LEN characters of NEWKEY.
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1642 (while (< i len)
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1643 (aset newkey i (aref key i))
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1644 (setq i (1+ i)))
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1645 (while l ; L = ((CHAR . DEFN) ....) ;
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1646 (aset newkey len (car (car l)))
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1647 (quail-completion-1 newkey (cdr (car l)) indent)
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1648 (setq l (cdr l)))))))
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1649
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1650 ;; 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
1651 ;; indentation INDENT.
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1652 (defun quail-completion-list-translations (map key indent)
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1653 (let ((translations
18297
5c8e37591da5 (quail-current-data): New variable.
Kenichi Handa <handa@m17n.org>
parents: 18201
diff changeset
1654 (quail-get-translation (car map) key (length key))))
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1655 (if (integerp translations)
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1656 (insert "(1/1) 1." translations "\n")
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1657 ;; We need only vector part.
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1658 (setq translations (cdr translations))
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1659 ;; Insert every 10 elements with indices in a line.
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1660 (let ((len (length translations))
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1661 (i 0)
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1662 num)
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1663 (while (< i len)
19944
e274dc2d61f1 (quail-completion-list-translations): Fix
Richard M. Stallman <rms@gnu.org>
parents: 19934
diff changeset
1664 (when (zerop (% i 10))
e274dc2d61f1 (quail-completion-list-translations): Fix
Richard M. Stallman <rms@gnu.org>
parents: 19934
diff changeset
1665 (when (>= i 10)
e274dc2d61f1 (quail-completion-list-translations): Fix
Richard M. Stallman <rms@gnu.org>
parents: 19934
diff changeset
1666 (newline)
e274dc2d61f1 (quail-completion-list-translations): Fix
Richard M. Stallman <rms@gnu.org>
parents: 19934
diff changeset
1667 (indent-to indent))
e274dc2d61f1 (quail-completion-list-translations): Fix
Richard M. Stallman <rms@gnu.org>
parents: 19934
diff changeset
1668 (insert (format "(%d/%d)" (1+ (/ i 10)) (1+ (/ len 10)))))
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1669 ;; We show the last digit of FROM while converting
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1670 ;; 0,1,..,9 to 1,2,..,0.
19944
e274dc2d61f1 (quail-completion-list-translations): Fix
Richard M. Stallman <rms@gnu.org>
parents: 19934
diff changeset
1671 (insert (format " %d." (% (1+ i) 10)))
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1672 (insert (aref translations i))
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1673 (setq i (1+ i)))
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1674 (newline)))))
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1675
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1676 (defun quail-help ()
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1677 "Show brief description of the current Quail package."
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1678 (interactive)
18349
f468344dd2bd (quail-help): Use with-output-to-temp-buffer.
Kenichi Handa <handa@m17n.org>
parents: 18297
diff changeset
1679 (let ((package quail-current-package))
f468344dd2bd (quail-help): Use with-output-to-temp-buffer.
Kenichi Handa <handa@m17n.org>
parents: 18297
diff changeset
1680 (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
1681 (save-excursion
f468344dd2bd (quail-help): Use with-output-to-temp-buffer.
Kenichi Handa <handa@m17n.org>
parents: 18297
diff changeset
1682 (set-buffer standard-output)
f468344dd2bd (quail-help): Use with-output-to-temp-buffer.
Kenichi Handa <handa@m17n.org>
parents: 18297
diff changeset
1683 (let ((quail-current-package package))
f468344dd2bd (quail-help): Use with-output-to-temp-buffer.
Kenichi Handa <handa@m17n.org>
parents: 18297
diff changeset
1684 (insert "Quail input method (name:"
f468344dd2bd (quail-help): Use with-output-to-temp-buffer.
Kenichi Handa <handa@m17n.org>
parents: 18297
diff changeset
1685 (quail-name)
f468344dd2bd (quail-help): Use with-output-to-temp-buffer.
Kenichi Handa <handa@m17n.org>
parents: 18297
diff changeset
1686 ", mode line indicator:["
f468344dd2bd (quail-help): Use with-output-to-temp-buffer.
Kenichi Handa <handa@m17n.org>
parents: 18297
diff changeset
1687 (quail-title)
f468344dd2bd (quail-help): Use with-output-to-temp-buffer.
Kenichi Handa <handa@m17n.org>
parents: 18297
diff changeset
1688 "])\n---- Documentation ----\n"
f468344dd2bd (quail-help): Use with-output-to-temp-buffer.
Kenichi Handa <handa@m17n.org>
parents: 18297
diff changeset
1689 (quail-docstring))
f468344dd2bd (quail-help): Use with-output-to-temp-buffer.
Kenichi Handa <handa@m17n.org>
parents: 18297
diff changeset
1690 (newline)
f468344dd2bd (quail-help): Use with-output-to-temp-buffer.
Kenichi Handa <handa@m17n.org>
parents: 18297
diff changeset
1691 (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
1692 (quail-help-insert-keymap-description
f468344dd2bd (quail-help): Use with-output-to-temp-buffer.
Kenichi Handa <handa@m17n.org>
parents: 18297
diff changeset
1693 quail-mode-map
f468344dd2bd (quail-help): Use with-output-to-temp-buffer.
Kenichi Handa <handa@m17n.org>
parents: 18297
diff changeset
1694 "---- Key bindings (before starting translation) ----
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1695 key binding
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1696 --- -------\n")
18349
f468344dd2bd (quail-help): Use with-output-to-temp-buffer.
Kenichi Handa <handa@m17n.org>
parents: 18297
diff changeset
1697 (quail-help-insert-keymap-description
f468344dd2bd (quail-help): Use with-output-to-temp-buffer.
Kenichi Handa <handa@m17n.org>
parents: 18297
diff changeset
1698 (quail-translation-keymap)
f468344dd2bd (quail-help): Use with-output-to-temp-buffer.
Kenichi Handa <handa@m17n.org>
parents: 18297
diff changeset
1699 "--- Key bindings (while translating) ---
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1700 key binding
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1701 --- -------\n")
18349
f468344dd2bd (quail-help): Use with-output-to-temp-buffer.
Kenichi Handa <handa@m17n.org>
parents: 18297
diff changeset
1702 (if (quail-conversion-keymap)
f468344dd2bd (quail-help): Use with-output-to-temp-buffer.
Kenichi Handa <handa@m17n.org>
parents: 18297
diff changeset
1703 (quail-help-insert-keymap-description
f468344dd2bd (quail-help): Use with-output-to-temp-buffer.
Kenichi Handa <handa@m17n.org>
parents: 18297
diff changeset
1704 (quail-conversion-keymap)
f468344dd2bd (quail-help): Use with-output-to-temp-buffer.
Kenichi Handa <handa@m17n.org>
parents: 18297
diff changeset
1705 "--- Key bindings (while converting) ---
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1706 key binding
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1707 --- -------\n"))
18349
f468344dd2bd (quail-help): Use with-output-to-temp-buffer.
Kenichi Handa <handa@m17n.org>
parents: 18297
diff changeset
1708 (help-mode))))))
f468344dd2bd (quail-help): Use with-output-to-temp-buffer.
Kenichi Handa <handa@m17n.org>
parents: 18297
diff changeset
1709
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1710 (defun quail-help-insert-keymap-description (keymap &optional header)
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1711 (let (from to)
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1712 (if header
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1713 (insert header))
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1714 (save-excursion
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1715 (save-window-excursion
19404
8901359ae445 (quail-inactivate): Turn Quail mode off
Kenichi Handa <handa@m17n.org>
parents: 19391
diff changeset
1716 (let ((overriding-terminal-local-map keymap))
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1717 (describe-bindings))
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1718 (set-buffer "*Help*")
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1719 (goto-char (point-min))
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1720 (forward-line 4)
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1721 (setq from (point))
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1722 (search-forward "Global Bindings:" nil 'move)
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1723 (beginning-of-line)
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1724 (setq to (point))))
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1725 (insert-buffer-substring "*Help*" from to)))
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1726
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1727 (defun quail-show-kbd-layout ()
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1728 "Show keyboard layout with key tops of multilingual characters."
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1729 (insert "--- Keyboard layout ---\n")
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1730 (let* ((i 0) ch)
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1731 (while (< i quail-keyboard-layout-len)
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1732 (if (= (% i 30) 0)
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1733 (progn
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1734 (newline)
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1735 (indent-to (/ i 30)))
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1736 (if (= (% i 2) 0)
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1737 (insert " ")))
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1738 (setq ch (aref quail-keyboard-layout i))
19675
32c3f7d9ef10 (quail-keyboard-layout-alist): Add an
Kenichi Handa <handa@m17n.org>
parents: 19655
diff changeset
1739 (when (and (quail-kbd-translate)
32c3f7d9ef10 (quail-keyboard-layout-alist): Add an
Kenichi Handa <handa@m17n.org>
parents: 19655
diff changeset
1740 (/= ch ?\ ))
32c3f7d9ef10 (quail-keyboard-layout-alist): Add an
Kenichi Handa <handa@m17n.org>
parents: 19655
diff changeset
1741 ;; 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
1742 ;; some keyboard layout (which means it requires keyboard
32c3f7d9ef10 (quail-keyboard-layout-alist): Add an
Kenichi Handa <handa@m17n.org>
parents: 19655
diff changeset
1743 ;; 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
1744 ;; keyboard. We must translate that key by
32c3f7d9ef10 (quail-keyboard-layout-alist): Add an
Kenichi Handa <handa@m17n.org>
parents: 19655
diff changeset
1745 ;; `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
1746 ;; 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
1747 ;; 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
1748 ;; minus value.
32c3f7d9ef10 (quail-keyboard-layout-alist): Add an
Kenichi Handa <handa@m17n.org>
parents: 19655
diff changeset
1749 (setq ch (aref quail-keyboard-layout-standard i))
32c3f7d9ef10 (quail-keyboard-layout-alist): Add an
Kenichi Handa <handa@m17n.org>
parents: 19655
diff changeset
1750 (if (= ch ?\ )
32c3f7d9ef10 (quail-keyboard-layout-alist): Add an
Kenichi Handa <handa@m17n.org>
parents: 19655
diff changeset
1751 (setq ch (- (aref quail-keyboard-layout i)))))
32c3f7d9ef10 (quail-keyboard-layout-alist): Add an
Kenichi Handa <handa@m17n.org>
parents: 19655
diff changeset
1752 (if (< ch 0)
32c3f7d9ef10 (quail-keyboard-layout-alist): Add an
Kenichi Handa <handa@m17n.org>
parents: 19655
diff changeset
1753 (let ((last-command-event (- ch)))
32c3f7d9ef10 (quail-keyboard-layout-alist): Add an
Kenichi Handa <handa@m17n.org>
parents: 19655
diff changeset
1754 (self-insert-command 1))
32c3f7d9ef10 (quail-keyboard-layout-alist): Add an
Kenichi Handa <handa@m17n.org>
parents: 19655
diff changeset
1755 (if (= ch ?\ )
32c3f7d9ef10 (quail-keyboard-layout-alist): Add an
Kenichi Handa <handa@m17n.org>
parents: 19655
diff changeset
1756 (insert ch)
32c3f7d9ef10 (quail-keyboard-layout-alist): Add an
Kenichi Handa <handa@m17n.org>
parents: 19655
diff changeset
1757 (let* ((map (cdr (assq ch (cdr (quail-map)))))
32c3f7d9ef10 (quail-keyboard-layout-alist): Add an
Kenichi Handa <handa@m17n.org>
parents: 19655
diff changeset
1758 (translation (and map (quail-get-translation
32c3f7d9ef10 (quail-keyboard-layout-alist): Add an
Kenichi Handa <handa@m17n.org>
parents: 19655
diff changeset
1759 (car map) (char-to-string ch) 1))))
32c3f7d9ef10 (quail-keyboard-layout-alist): Add an
Kenichi Handa <handa@m17n.org>
parents: 19655
diff changeset
1760 (if (integerp translation)
32c3f7d9ef10 (quail-keyboard-layout-alist): Add an
Kenichi Handa <handa@m17n.org>
parents: 19655
diff changeset
1761 (insert translation)
32c3f7d9ef10 (quail-keyboard-layout-alist): Add an
Kenichi Handa <handa@m17n.org>
parents: 19655
diff changeset
1762 (if (consp translation)
32c3f7d9ef10 (quail-keyboard-layout-alist): Add an
Kenichi Handa <handa@m17n.org>
parents: 19655
diff changeset
1763 (insert (aref (cdr translation) (car translation)))
32c3f7d9ef10 (quail-keyboard-layout-alist): Add an
Kenichi Handa <handa@m17n.org>
parents: 19655
diff changeset
1764 (let ((last-command-event ch))
32c3f7d9ef10 (quail-keyboard-layout-alist): Add an
Kenichi Handa <handa@m17n.org>
parents: 19655
diff changeset
1765 (self-insert-command 1)))))))
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1766 (setq i (1+ i))))
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1767 (newline))
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1768
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1769 (defun quail-translation-help ()
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1770 "Show help message while translating in Quail mode."
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1771 (interactive)
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1772 (let ((package quail-current-package)
18349
f468344dd2bd (quail-help): Use with-output-to-temp-buffer.
Kenichi Handa <handa@m17n.org>
parents: 18297
diff changeset
1773 (current-key quail-current-key))
f468344dd2bd (quail-help): Use with-output-to-temp-buffer.
Kenichi Handa <handa@m17n.org>
parents: 18297
diff changeset
1774 (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
1775 (save-excursion
f468344dd2bd (quail-help): Use with-output-to-temp-buffer.
Kenichi Handa <handa@m17n.org>
parents: 18297
diff changeset
1776 (set-buffer standard-output)
f468344dd2bd (quail-help): Use with-output-to-temp-buffer.
Kenichi Handa <handa@m17n.org>
parents: 18297
diff changeset
1777 (let ((quail-current-package package))
f468344dd2bd (quail-help): Use with-output-to-temp-buffer.
Kenichi Handa <handa@m17n.org>
parents: 18297
diff changeset
1778 (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
1779 (prin1 quail-current-key)
f468344dd2bd (quail-help): Use with-output-to-temp-buffer.
Kenichi Handa <handa@m17n.org>
parents: 18297
diff changeset
1780 (princ" in Quail mode.\n")
f468344dd2bd (quail-help): Use with-output-to-temp-buffer.
Kenichi Handa <handa@m17n.org>
parents: 18297
diff changeset
1781 (quail-help-insert-keymap-description
f468344dd2bd (quail-help): Use with-output-to-temp-buffer.
Kenichi Handa <handa@m17n.org>
parents: 18297
diff changeset
1782 (quail-translation-keymap)
f468344dd2bd (quail-help): Use with-output-to-temp-buffer.
Kenichi Handa <handa@m17n.org>
parents: 18297
diff changeset
1783 "-----------------------
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1784 key binding
18349
f468344dd2bd (quail-help): Use with-output-to-temp-buffer.
Kenichi Handa <handa@m17n.org>
parents: 18297
diff changeset
1785 --- -------\n"))
f468344dd2bd (quail-help): Use with-output-to-temp-buffer.
Kenichi Handa <handa@m17n.org>
parents: 18297
diff changeset
1786 (help-mode)))))
f468344dd2bd (quail-help): Use with-output-to-temp-buffer.
Kenichi Handa <handa@m17n.org>
parents: 18297
diff changeset
1787
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1788 (defun quail-conversion-help ()
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1789 "Show help message while converting in Quail mode."
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1790 (interactive)
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1791 (let ((package quail-current-package)
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1792 (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
1793 (overlay-end quail-conv-overlay))))
18349
f468344dd2bd (quail-help): Use with-output-to-temp-buffer.
Kenichi Handa <handa@m17n.org>
parents: 18297
diff changeset
1794 (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
1795 (save-excursion
f468344dd2bd (quail-help): Use with-output-to-temp-buffer.
Kenichi Handa <handa@m17n.org>
parents: 18297
diff changeset
1796 (set-buffer standard-output)
f468344dd2bd (quail-help): Use with-output-to-temp-buffer.
Kenichi Handa <handa@m17n.org>
parents: 18297
diff changeset
1797 (let ((quail-current-package package))
f468344dd2bd (quail-help): Use with-output-to-temp-buffer.
Kenichi Handa <handa@m17n.org>
parents: 18297
diff changeset
1798 (princ "You are converting the string ")
f468344dd2bd (quail-help): Use with-output-to-temp-buffer.
Kenichi Handa <handa@m17n.org>
parents: 18297
diff changeset
1799 (prin1 str)
f468344dd2bd (quail-help): Use with-output-to-temp-buffer.
Kenichi Handa <handa@m17n.org>
parents: 18297
diff changeset
1800 (princ " in Quail mode.\n")
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-conversion-keymap)
18642
0fc832264117 (quail-conversion-help): Source code indentation changed.
Kenichi Handa <handa@m17n.org>
parents: 18556
diff changeset
1803 "-----------------------
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1804 key binding
18349
f468344dd2bd (quail-help): Use with-output-to-temp-buffer.
Kenichi Handa <handa@m17n.org>
parents: 18297
diff changeset
1805 --- -------\n"))
f468344dd2bd (quail-help): Use with-output-to-temp-buffer.
Kenichi Handa <handa@m17n.org>
parents: 18297
diff changeset
1806 (help-mode)))))
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1807
18297
5c8e37591da5 (quail-current-data): New variable.
Kenichi Handa <handa@m17n.org>
parents: 18201
diff changeset
1808
5c8e37591da5 (quail-current-data): New variable.
Kenichi Handa <handa@m17n.org>
parents: 18201
diff changeset
1809 (defvar quail-directory-name "quail"
5c8e37591da5 (quail-current-data): New variable.
Kenichi Handa <handa@m17n.org>
parents: 18201
diff changeset
1810 "Name of Quail directory which cotains Quail packages.
5c8e37591da5 (quail-current-data): New variable.
Kenichi Handa <handa@m17n.org>
parents: 18201
diff changeset
1811 This is a sub-directory of LEIM directory.")
5c8e37591da5 (quail-current-data): New variable.
Kenichi Handa <handa@m17n.org>
parents: 18201
diff changeset
1812
5c8e37591da5 (quail-current-data): New variable.
Kenichi Handa <handa@m17n.org>
parents: 18201
diff changeset
1813 ;;;###autoload
19605
3b700b203cfd (quail-update-leim-list-file): Make it
Kenichi Handa <handa@m17n.org>
parents: 19519
diff changeset
1814 (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
1815 "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
1816 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
1817 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
1818 of the Emacs source tree.
3b700b203cfd (quail-update-leim-list-file): Make it
Kenichi Handa <handa@m17n.org>
parents: 19519
diff changeset
1819
3b700b203cfd (quail-update-leim-list-file): Make it
Kenichi Handa <handa@m17n.org>
parents: 19519
diff changeset
1820 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
1821 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
1822
3b700b203cfd (quail-update-leim-list-file): Make it
Kenichi Handa <handa@m17n.org>
parents: 19519
diff changeset
1823 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
1824 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
1825 of each directory."
18297
5c8e37591da5 (quail-current-data): New variable.
Kenichi Handa <handa@m17n.org>
parents: 18201
diff changeset
1826 (interactive "FDirectory of LEIM: ")
19605
3b700b203cfd (quail-update-leim-list-file): Make it
Kenichi Handa <handa@m17n.org>
parents: 19519
diff changeset
1827 (setq dirname (expand-file-name dirname))
3b700b203cfd (quail-update-leim-list-file): Make it
Kenichi Handa <handa@m17n.org>
parents: 19519
diff changeset
1828 (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
1829 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
1830 (if (not (file-writable-p leim-list))
3b700b203cfd (quail-update-leim-list-file): Make it
Kenichi Handa <handa@m17n.org>
parents: 19519
diff changeset
1831 (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
1832 (message "Updating %s ..." leim-list)
3b700b203cfd (quail-update-leim-list-file): Make it
Kenichi Handa <handa@m17n.org>
parents: 19519
diff changeset
1833 (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
1834
3b700b203cfd (quail-update-leim-list-file): Make it
Kenichi Handa <handa@m17n.org>
parents: 19519
diff changeset
1835 ;; At first, clean up the file.
3b700b203cfd (quail-update-leim-list-file): Make it
Kenichi Handa <handa@m17n.org>
parents: 19519
diff changeset
1836 (save-excursion
3b700b203cfd (quail-update-leim-list-file): Make it
Kenichi Handa <handa@m17n.org>
parents: 19519
diff changeset
1837 (set-buffer list-buf)
3b700b203cfd (quail-update-leim-list-file): Make it
Kenichi Handa <handa@m17n.org>
parents: 19519
diff changeset
1838 (goto-char 1)
18297
5c8e37591da5 (quail-current-data): New variable.
Kenichi Handa <handa@m17n.org>
parents: 18201
diff changeset
1839
19605
3b700b203cfd (quail-update-leim-list-file): Make it
Kenichi Handa <handa@m17n.org>
parents: 19519
diff changeset
1840 ;; Insert the correct header.
3b700b203cfd (quail-update-leim-list-file): Make it
Kenichi Handa <handa@m17n.org>
parents: 19519
diff changeset
1841 (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
1842 (goto-char (match-end 0))
3b700b203cfd (quail-update-leim-list-file): Make it
Kenichi Handa <handa@m17n.org>
parents: 19519
diff changeset
1843 (insert leim-list-header))
3b700b203cfd (quail-update-leim-list-file): Make it
Kenichi Handa <handa@m17n.org>
parents: 19519
diff changeset
1844 (setq pos (point))
3b700b203cfd (quail-update-leim-list-file): Make it
Kenichi Handa <handa@m17n.org>
parents: 19519
diff changeset
1845 (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
1846 nil
3b700b203cfd (quail-update-leim-list-file): Make it
Kenichi Handa <handa@m17n.org>
parents: 19519
diff changeset
1847
3b700b203cfd (quail-update-leim-list-file): Make it
Kenichi Handa <handa@m17n.org>
parents: 19519
diff changeset
1848 ;; Remove garbages after the header.
3b700b203cfd (quail-update-leim-list-file): Make it
Kenichi Handa <handa@m17n.org>
parents: 19519
diff changeset
1849 (goto-char (match-beginning 0))
3b700b203cfd (quail-update-leim-list-file): Make it
Kenichi Handa <handa@m17n.org>
parents: 19519
diff changeset
1850 (if (< pos (point))
3b700b203cfd (quail-update-leim-list-file): Make it
Kenichi Handa <handa@m17n.org>
parents: 19519
diff changeset
1851 (delete-region pos (point)))
18297
5c8e37591da5 (quail-current-data): New variable.
Kenichi Handa <handa@m17n.org>
parents: 18201
diff changeset
1852
19605
3b700b203cfd (quail-update-leim-list-file): Make it
Kenichi Handa <handa@m17n.org>
parents: 19519
diff changeset
1853 ;; Remove all entries for Quail.
3b700b203cfd (quail-update-leim-list-file): Make it
Kenichi Handa <handa@m17n.org>
parents: 19519
diff changeset
1854 (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
1855 (goto-char (match-beginning 0))
3b700b203cfd (quail-update-leim-list-file): Make it
Kenichi Handa <handa@m17n.org>
parents: 19519
diff changeset
1856 (setq pos (point))
3b700b203cfd (quail-update-leim-list-file): Make it
Kenichi Handa <handa@m17n.org>
parents: 19519
diff changeset
1857 (condition-case nil
3b700b203cfd (quail-update-leim-list-file): Make it
Kenichi Handa <handa@m17n.org>
parents: 19519
diff changeset
1858 (let ((form (read list-buf)))
3b700b203cfd (quail-update-leim-list-file): Make it
Kenichi Handa <handa@m17n.org>
parents: 19519
diff changeset
1859 (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
1860 (if (eolp) (forward-line 1))
3b700b203cfd (quail-update-leim-list-file): Make it
Kenichi Handa <handa@m17n.org>
parents: 19519
diff changeset
1861 (delete-region pos (point))))
3b700b203cfd (quail-update-leim-list-file): Make it
Kenichi Handa <handa@m17n.org>
parents: 19519
diff changeset
1862 (error
3b700b203cfd (quail-update-leim-list-file): Make it
Kenichi Handa <handa@m17n.org>
parents: 19519
diff changeset
1863 ;; 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
1864 ;; this file is broken.
3b700b203cfd (quail-update-leim-list-file): Make it
Kenichi Handa <handa@m17n.org>
parents: 19519
diff changeset
1865 (message "Garbages in %s deleted" leim-list)
3b700b203cfd (quail-update-leim-list-file): Make it
Kenichi Handa <handa@m17n.org>
parents: 19519
diff changeset
1866 (delete-region pos (point-max)))))))
18297
5c8e37591da5 (quail-current-data): New variable.
Kenichi Handa <handa@m17n.org>
parents: 18201
diff changeset
1867
19605
3b700b203cfd (quail-update-leim-list-file): Make it
Kenichi Handa <handa@m17n.org>
parents: 19519
diff changeset
1868 ;; Search for `quail' subdirector under each DIRNAMES.
3b700b203cfd (quail-update-leim-list-file): Make it
Kenichi Handa <handa@m17n.org>
parents: 19519
diff changeset
1869 (setq dirnames (cons dirname dirnames))
3b700b203cfd (quail-update-leim-list-file): Make it
Kenichi Handa <handa@m17n.org>
parents: 19519
diff changeset
1870 (let ((l dirnames))
3b700b203cfd (quail-update-leim-list-file): Make it
Kenichi Handa <handa@m17n.org>
parents: 19519
diff changeset
1871 (while l
3b700b203cfd (quail-update-leim-list-file): Make it
Kenichi Handa <handa@m17n.org>
parents: 19519
diff changeset
1872 (setcar l (expand-file-name (car l)))
3b700b203cfd (quail-update-leim-list-file): Make it
Kenichi Handa <handa@m17n.org>
parents: 19519
diff changeset
1873 (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
1874 (if (file-readable-p dirname)
3b700b203cfd (quail-update-leim-list-file): Make it
Kenichi Handa <handa@m17n.org>
parents: 19519
diff changeset
1875 (setq quail-dirs (cons dirname quail-dirs))
3b700b203cfd (quail-update-leim-list-file): Make it
Kenichi Handa <handa@m17n.org>
parents: 19519
diff changeset
1876 (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
1877 (car l) quail-directory-name)
3b700b203cfd (quail-update-leim-list-file): Make it
Kenichi Handa <handa@m17n.org>
parents: 19519
diff changeset
1878 (setq quail-dirs (cons nil quail-dirs)))
3b700b203cfd (quail-update-leim-list-file): Make it
Kenichi Handa <handa@m17n.org>
parents: 19519
diff changeset
1879 (setq l (cdr l)))
3b700b203cfd (quail-update-leim-list-file): Make it
Kenichi Handa <handa@m17n.org>
parents: 19519
diff changeset
1880 (setq quail-dirs (nreverse quail-dirs)))
18297
5c8e37591da5 (quail-current-data): New variable.
Kenichi Handa <handa@m17n.org>
parents: 18201
diff changeset
1881
19605
3b700b203cfd (quail-update-leim-list-file): Make it
Kenichi Handa <handa@m17n.org>
parents: 19519
diff changeset
1882 ;; Insert input method registering forms.
3b700b203cfd (quail-update-leim-list-file): Make it
Kenichi Handa <handa@m17n.org>
parents: 19519
diff changeset
1883 (while quail-dirs
3b700b203cfd (quail-update-leim-list-file): Make it
Kenichi Handa <handa@m17n.org>
parents: 19519
diff changeset
1884 (setq dirname (car quail-dirs))
3b700b203cfd (quail-update-leim-list-file): Make it
Kenichi Handa <handa@m17n.org>
parents: 19519
diff changeset
1885 (when dirname
3b700b203cfd (quail-update-leim-list-file): Make it
Kenichi Handa <handa@m17n.org>
parents: 19519
diff changeset
1886 (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
1887 (while pkg-list
3b700b203cfd (quail-update-leim-list-file): Make it
Kenichi Handa <handa@m17n.org>
parents: 19519
diff changeset
1888 (message "Checking %s ..." (car pkg-list))
3b700b203cfd (quail-update-leim-list-file): Make it
Kenichi Handa <handa@m17n.org>
parents: 19519
diff changeset
1889 (with-temp-buffer
3b700b203cfd (quail-update-leim-list-file): Make it
Kenichi Handa <handa@m17n.org>
parents: 19519
diff changeset
1890 (insert-file-contents (car pkg-list))
3b700b203cfd (quail-update-leim-list-file): Make it
Kenichi Handa <handa@m17n.org>
parents: 19519
diff changeset
1891 (goto-char (point-min))
3b700b203cfd (quail-update-leim-list-file): Make it
Kenichi Handa <handa@m17n.org>
parents: 19519
diff changeset
1892 (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
1893 (goto-char (match-beginning 0))
3b700b203cfd (quail-update-leim-list-file): Make it
Kenichi Handa <handa@m17n.org>
parents: 19519
diff changeset
1894 (condition-case nil
3b700b203cfd (quail-update-leim-list-file): Make it
Kenichi Handa <handa@m17n.org>
parents: 19519
diff changeset
1895 (let ((form (read (current-buffer))))
3b700b203cfd (quail-update-leim-list-file): Make it
Kenichi Handa <handa@m17n.org>
parents: 19519
diff changeset
1896 (save-excursion
3b700b203cfd (quail-update-leim-list-file): Make it
Kenichi Handa <handa@m17n.org>
parents: 19519
diff changeset
1897 (set-buffer list-buf)
3b700b203cfd (quail-update-leim-list-file): Make it
Kenichi Handa <handa@m17n.org>
parents: 19519
diff changeset
1898 (insert
3b700b203cfd (quail-update-leim-list-file): Make it
Kenichi Handa <handa@m17n.org>
parents: 19519
diff changeset
1899 (format "(register-input-method
18297
5c8e37591da5 (quail-current-data): New variable.
Kenichi Handa <handa@m17n.org>
parents: 18201
diff changeset
1900 %S %S '%s
5c8e37591da5 (quail-current-data): New variable.
Kenichi Handa <handa@m17n.org>
parents: 18201
diff changeset
1901 %S %S
19200
74ec766c0ada (quail-update-leim-list-file):
Richard M. Stallman <rms@gnu.org>
parents: 19144
diff changeset
1902 %S)\n"
19605
3b700b203cfd (quail-update-leim-list-file): Make it
Kenichi Handa <handa@m17n.org>
parents: 19519
diff changeset
1903 (nth 1 form) ; PACKAGE-NAME
3b700b203cfd (quail-update-leim-list-file): Make it
Kenichi Handa <handa@m17n.org>
parents: 19519
diff changeset
1904 (nth 2 form) ; LANGUAGE
3b700b203cfd (quail-update-leim-list-file): Make it
Kenichi Handa <handa@m17n.org>
parents: 19519
diff changeset
1905 'quail-use-package ; ACTIVATE-FUNC
3b700b203cfd (quail-update-leim-list-file): Make it
Kenichi Handa <handa@m17n.org>
parents: 19519
diff changeset
1906 (nth 3 form) ; PACKAGE-TITLE
3b700b203cfd (quail-update-leim-list-file): Make it
Kenichi Handa <handa@m17n.org>
parents: 19519
diff changeset
1907 (progn ; PACKAGE-DESCRIPTION (one line)
3b700b203cfd (quail-update-leim-list-file): Make it
Kenichi Handa <handa@m17n.org>
parents: 19519
diff changeset
1908 (string-match ".*" (nth 5 form))
3b700b203cfd (quail-update-leim-list-file): Make it
Kenichi Handa <handa@m17n.org>
parents: 19519
diff changeset
1909 (match-string 0 (nth 5 form)))
3b700b203cfd (quail-update-leim-list-file): Make it
Kenichi Handa <handa@m17n.org>
parents: 19519
diff changeset
1910 (file-relative-name ; PACKAGE-FILENAME
3b700b203cfd (quail-update-leim-list-file): Make it
Kenichi Handa <handa@m17n.org>
parents: 19519
diff changeset
1911 (file-name-sans-extension (car pkg-list))
3b700b203cfd (quail-update-leim-list-file): Make it
Kenichi Handa <handa@m17n.org>
parents: 19519
diff changeset
1912 (car dirnames))))))
3b700b203cfd (quail-update-leim-list-file): Make it
Kenichi Handa <handa@m17n.org>
parents: 19519
diff changeset
1913 (error
3b700b203cfd (quail-update-leim-list-file): Make it
Kenichi Handa <handa@m17n.org>
parents: 19519
diff changeset
1914 ;; Ignore the remaining contents of this file.
3b700b203cfd (quail-update-leim-list-file): Make it
Kenichi Handa <handa@m17n.org>
parents: 19519
diff changeset
1915 (goto-char (point-max))
3b700b203cfd (quail-update-leim-list-file): Make it
Kenichi Handa <handa@m17n.org>
parents: 19519
diff changeset
1916 (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
1917 (setq pkg-list (cdr pkg-list)))
3b700b203cfd (quail-update-leim-list-file): Make it
Kenichi Handa <handa@m17n.org>
parents: 19519
diff changeset
1918 (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
1919
3b700b203cfd (quail-update-leim-list-file): Make it
Kenichi Handa <handa@m17n.org>
parents: 19519
diff changeset
1920 ;; At last, write out LEIM list file.
3b700b203cfd (quail-update-leim-list-file): Make it
Kenichi Handa <handa@m17n.org>
parents: 19519
diff changeset
1921 (save-excursion
3b700b203cfd (quail-update-leim-list-file): Make it
Kenichi Handa <handa@m17n.org>
parents: 19519
diff changeset
1922 (set-buffer list-buf)
3b700b203cfd (quail-update-leim-list-file): Make it
Kenichi Handa <handa@m17n.org>
parents: 19519
diff changeset
1923 (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
1924 (save-buffer 0))
3b700b203cfd (quail-update-leim-list-file): Make it
Kenichi Handa <handa@m17n.org>
parents: 19519
diff changeset
1925 (kill-buffer list-buf)
3b700b203cfd (quail-update-leim-list-file): Make it
Kenichi Handa <handa@m17n.org>
parents: 19519
diff changeset
1926 (message "Updating %s ... done" leim-list)))
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1927 ;;
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1928 (provide 'quail)
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1929
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1930 ;;; quail.el ends here