annotate lisp/international/quail.el @ 36587:d9bb01d5dbbb

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