Mercurial > emacs
annotate lisp/international/mule-cmds.el @ 18208:5b68d05ff026 gnumach-release-1-1-2 gnumach-release-1-1-3 hurd-release-0-2 libc-970610 libc-970611 libc-970612 libc-970613 libc-970614 libc-970615 libc-970616 libc-970617 libc-970618 libc-970619 libc-970620 libc-970621 libc-970622
Fix previous change.
author | Richard M. Stallman <rms@gnu.org> |
---|---|
date | Tue, 10 Jun 1997 04:18:36 +0000 |
parents | fc07ea29cd81 |
children | 13a240aa1960 |
rev | line source |
---|---|
17052 | 1 ;;; mule-cmds.el --- Commands for mulitilingual environment |
2 | |
3 ;; Copyright (C) 1995 Free Software Foundation, Inc. | |
4 ;; Copyright (C) 1995 Electrotechnical Laboratory, JAPAN. | |
5 | |
6 ;; Keywords: mule, multilingual | |
7 | |
8 ;; This file is part of GNU Emacs. | |
9 | |
10 ;; GNU Emacs is free software; you can redistribute it and/or modify | |
11 ;; it under the terms of the GNU General Public License as published by | |
12 ;; the Free Software Foundation; either version 2, or (at your option) | |
13 ;; any later version. | |
14 | |
15 ;; GNU Emacs is distributed in the hope that it will be useful, | |
16 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of | |
17 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
18 ;; GNU General Public License for more details. | |
19 | |
20 ;; You should have received a copy of the GNU General Public License | |
17071 | 21 ;; along with GNU Emacs; see the file COPYING. If not, write to the |
22 ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330, | |
23 ;; Boston, MA 02111-1307, USA. | |
17052 | 24 |
25 ;;; Code: | |
26 | |
27 ;;; MULE related key bindings and menus. | |
28 | |
17991
65407fdc4a33
Delete defining "i" in mule-keymap.
Kenichi Handa <handa@m17n.org>
parents:
17840
diff
changeset
|
29 (defvar mule-keymap nil |
17052 | 30 "Keymap for MULE (Multilingual environment) specific commands.") |
17991
65407fdc4a33
Delete defining "i" in mule-keymap.
Kenichi Handa <handa@m17n.org>
parents:
17840
diff
changeset
|
31 (define-prefix-command 'mule-keymap) |
17052 | 32 |
17294
d7ae63db9e6e
Prefix for Mule related commands is changed.
Kenichi Handa <handa@m17n.org>
parents:
17090
diff
changeset
|
33 ;; Keep "C-x C-m ..." for mule specific commands. |
17991
65407fdc4a33
Delete defining "i" in mule-keymap.
Kenichi Handa <handa@m17n.org>
parents:
17840
diff
changeset
|
34 (define-key ctl-x-map "\C-m" 'mule-keymap) |
17090
8085a8690c87
(mule-keymap): Re-arranged.
Kenichi Handa <handa@m17n.org>
parents:
17071
diff
changeset
|
35 |
17052 | 36 (define-key mule-keymap "m" 'toggle-enable-multibyte-characters) |
37 (define-key mule-keymap "f" 'set-buffer-file-coding-system) | |
38 (define-key mule-keymap "t" 'set-terminal-coding-system) | |
17991
65407fdc4a33
Delete defining "i" in mule-keymap.
Kenichi Handa <handa@m17n.org>
parents:
17840
diff
changeset
|
39 (define-key mule-keymap "k" 'set-keyboard-coding-system) |
65407fdc4a33
Delete defining "i" in mule-keymap.
Kenichi Handa <handa@m17n.org>
parents:
17840
diff
changeset
|
40 (define-key mule-keymap "p" 'set-buffer-process-coding-system) |
17526
6501aac82580
(mule-keymap): Add C-x RET C-\ for select-input-method.
Richard M. Stallman <rms@gnu.org>
parents:
17294
diff
changeset
|
41 (define-key mule-keymap "\C-\\" 'select-input-method) |
17991
65407fdc4a33
Delete defining "i" in mule-keymap.
Kenichi Handa <handa@m17n.org>
parents:
17840
diff
changeset
|
42 (define-key mule-keymap "c" 'universal-coding-system-argument) |
17052 | 43 |
18152
e184e7061c9a
(describe-language-environment):
Richard M. Stallman <rms@gnu.org>
parents:
18068
diff
changeset
|
44 (define-key help-map "\C-L" 'describe-language-environment) |
17052 | 45 (define-key help-map "\C-\\" 'describe-input-method) |
46 (define-key help-map "C" 'describe-current-coding-system) | |
47 (define-key help-map "h" 'view-hello-file) | |
48 | |
17991
65407fdc4a33
Delete defining "i" in mule-keymap.
Kenichi Handa <handa@m17n.org>
parents:
17840
diff
changeset
|
49 (defvar mule-menu-keymap nil |
65407fdc4a33
Delete defining "i" in mule-keymap.
Kenichi Handa <handa@m17n.org>
parents:
17840
diff
changeset
|
50 "Keymap for MULE (Multilingual environment) menu specific commands.") |
65407fdc4a33
Delete defining "i" in mule-keymap.
Kenichi Handa <handa@m17n.org>
parents:
17840
diff
changeset
|
51 (define-prefix-command 'mule-menu-keymap) |
65407fdc4a33
Delete defining "i" in mule-keymap.
Kenichi Handa <handa@m17n.org>
parents:
17840
diff
changeset
|
52 |
65407fdc4a33
Delete defining "i" in mule-keymap.
Kenichi Handa <handa@m17n.org>
parents:
17840
diff
changeset
|
53 (define-key global-map [menu-bar mule] (cons "Mule" mule-menu-keymap)) |
65407fdc4a33
Delete defining "i" in mule-keymap.
Kenichi Handa <handa@m17n.org>
parents:
17840
diff
changeset
|
54 |
65407fdc4a33
Delete defining "i" in mule-keymap.
Kenichi Handa <handa@m17n.org>
parents:
17840
diff
changeset
|
55 (setq menu-bar-final-items (cons 'mule menu-bar-final-items)) |
65407fdc4a33
Delete defining "i" in mule-keymap.
Kenichi Handa <handa@m17n.org>
parents:
17840
diff
changeset
|
56 |
18152
e184e7061c9a
(describe-language-environment):
Richard M. Stallman <rms@gnu.org>
parents:
18068
diff
changeset
|
57 (defvar describe-language-environment-map nil) |
e184e7061c9a
(describe-language-environment):
Richard M. Stallman <rms@gnu.org>
parents:
18068
diff
changeset
|
58 (define-prefix-command 'describe-language-environment-map) |
17991
65407fdc4a33
Delete defining "i" in mule-keymap.
Kenichi Handa <handa@m17n.org>
parents:
17840
diff
changeset
|
59 |
65407fdc4a33
Delete defining "i" in mule-keymap.
Kenichi Handa <handa@m17n.org>
parents:
17840
diff
changeset
|
60 (defvar setup-language-environment-map nil) |
65407fdc4a33
Delete defining "i" in mule-keymap.
Kenichi Handa <handa@m17n.org>
parents:
17840
diff
changeset
|
61 (define-prefix-command 'setup-language-environment-map) |
65407fdc4a33
Delete defining "i" in mule-keymap.
Kenichi Handa <handa@m17n.org>
parents:
17840
diff
changeset
|
62 |
65407fdc4a33
Delete defining "i" in mule-keymap.
Kenichi Handa <handa@m17n.org>
parents:
17840
diff
changeset
|
63 (defvar set-coding-system-map nil) |
65407fdc4a33
Delete defining "i" in mule-keymap.
Kenichi Handa <handa@m17n.org>
parents:
17840
diff
changeset
|
64 (define-prefix-command 'set-coding-system-map) |
65407fdc4a33
Delete defining "i" in mule-keymap.
Kenichi Handa <handa@m17n.org>
parents:
17840
diff
changeset
|
65 |
65407fdc4a33
Delete defining "i" in mule-keymap.
Kenichi Handa <handa@m17n.org>
parents:
17840
diff
changeset
|
66 (define-key-after mule-menu-keymap [toggle-mule] |
65407fdc4a33
Delete defining "i" in mule-keymap.
Kenichi Handa <handa@m17n.org>
parents:
17840
diff
changeset
|
67 '("Toggle MULE facility" . toggle-enable-multibyte-characters) |
65407fdc4a33
Delete defining "i" in mule-keymap.
Kenichi Handa <handa@m17n.org>
parents:
17840
diff
changeset
|
68 t) |
18152
e184e7061c9a
(describe-language-environment):
Richard M. Stallman <rms@gnu.org>
parents:
18068
diff
changeset
|
69 (define-key-after mule-menu-keymap [describe-language-environment] |
e184e7061c9a
(describe-language-environment):
Richard M. Stallman <rms@gnu.org>
parents:
18068
diff
changeset
|
70 '("Describe language environment" . describe-language-environment-map) |
17991
65407fdc4a33
Delete defining "i" in mule-keymap.
Kenichi Handa <handa@m17n.org>
parents:
17840
diff
changeset
|
71 t) |
65407fdc4a33
Delete defining "i" in mule-keymap.
Kenichi Handa <handa@m17n.org>
parents:
17840
diff
changeset
|
72 (define-key-after mule-menu-keymap [set-language-environment] |
65407fdc4a33
Delete defining "i" in mule-keymap.
Kenichi Handa <handa@m17n.org>
parents:
17840
diff
changeset
|
73 '("Set language environment" . setup-language-environment-map) |
65407fdc4a33
Delete defining "i" in mule-keymap.
Kenichi Handa <handa@m17n.org>
parents:
17840
diff
changeset
|
74 t) |
65407fdc4a33
Delete defining "i" in mule-keymap.
Kenichi Handa <handa@m17n.org>
parents:
17840
diff
changeset
|
75 (define-key-after mule-menu-keymap [separator-mule] |
65407fdc4a33
Delete defining "i" in mule-keymap.
Kenichi Handa <handa@m17n.org>
parents:
17840
diff
changeset
|
76 '("--") |
65407fdc4a33
Delete defining "i" in mule-keymap.
Kenichi Handa <handa@m17n.org>
parents:
17840
diff
changeset
|
77 t) |
65407fdc4a33
Delete defining "i" in mule-keymap.
Kenichi Handa <handa@m17n.org>
parents:
17840
diff
changeset
|
78 (define-key-after mule-menu-keymap [toggle-input-method] |
65407fdc4a33
Delete defining "i" in mule-keymap.
Kenichi Handa <handa@m17n.org>
parents:
17840
diff
changeset
|
79 '("Toggle input method" . toggle-input-method) |
65407fdc4a33
Delete defining "i" in mule-keymap.
Kenichi Handa <handa@m17n.org>
parents:
17840
diff
changeset
|
80 t) |
65407fdc4a33
Delete defining "i" in mule-keymap.
Kenichi Handa <handa@m17n.org>
parents:
17840
diff
changeset
|
81 (define-key-after mule-menu-keymap [select-input-method] |
65407fdc4a33
Delete defining "i" in mule-keymap.
Kenichi Handa <handa@m17n.org>
parents:
17840
diff
changeset
|
82 '("Select input method" . select-input-method) |
65407fdc4a33
Delete defining "i" in mule-keymap.
Kenichi Handa <handa@m17n.org>
parents:
17840
diff
changeset
|
83 t) |
65407fdc4a33
Delete defining "i" in mule-keymap.
Kenichi Handa <handa@m17n.org>
parents:
17840
diff
changeset
|
84 (define-key-after mule-menu-keymap [describe-input-method] |
65407fdc4a33
Delete defining "i" in mule-keymap.
Kenichi Handa <handa@m17n.org>
parents:
17840
diff
changeset
|
85 '("Describe input method" . describe-input-method) |
65407fdc4a33
Delete defining "i" in mule-keymap.
Kenichi Handa <handa@m17n.org>
parents:
17840
diff
changeset
|
86 t) |
65407fdc4a33
Delete defining "i" in mule-keymap.
Kenichi Handa <handa@m17n.org>
parents:
17840
diff
changeset
|
87 (define-key-after mule-menu-keymap [separator-input-method] |
65407fdc4a33
Delete defining "i" in mule-keymap.
Kenichi Handa <handa@m17n.org>
parents:
17840
diff
changeset
|
88 '("--") |
65407fdc4a33
Delete defining "i" in mule-keymap.
Kenichi Handa <handa@m17n.org>
parents:
17840
diff
changeset
|
89 t) |
65407fdc4a33
Delete defining "i" in mule-keymap.
Kenichi Handa <handa@m17n.org>
parents:
17840
diff
changeset
|
90 (define-key-after mule-menu-keymap [describe-current-coding-system] |
65407fdc4a33
Delete defining "i" in mule-keymap.
Kenichi Handa <handa@m17n.org>
parents:
17840
diff
changeset
|
91 '("Describe coding systems" . describe-current-coding-system) |
65407fdc4a33
Delete defining "i" in mule-keymap.
Kenichi Handa <handa@m17n.org>
parents:
17840
diff
changeset
|
92 t) |
65407fdc4a33
Delete defining "i" in mule-keymap.
Kenichi Handa <handa@m17n.org>
parents:
17840
diff
changeset
|
93 (define-key-after mule-menu-keymap [set-various-coding-system] |
65407fdc4a33
Delete defining "i" in mule-keymap.
Kenichi Handa <handa@m17n.org>
parents:
17840
diff
changeset
|
94 '("Set coding systems" . set-coding-system-map) |
65407fdc4a33
Delete defining "i" in mule-keymap.
Kenichi Handa <handa@m17n.org>
parents:
17840
diff
changeset
|
95 t) |
65407fdc4a33
Delete defining "i" in mule-keymap.
Kenichi Handa <handa@m17n.org>
parents:
17840
diff
changeset
|
96 (define-key-after mule-menu-keymap [separator-coding-system] |
65407fdc4a33
Delete defining "i" in mule-keymap.
Kenichi Handa <handa@m17n.org>
parents:
17840
diff
changeset
|
97 '("--") |
65407fdc4a33
Delete defining "i" in mule-keymap.
Kenichi Handa <handa@m17n.org>
parents:
17840
diff
changeset
|
98 t) |
65407fdc4a33
Delete defining "i" in mule-keymap.
Kenichi Handa <handa@m17n.org>
parents:
17840
diff
changeset
|
99 (define-key-after mule-menu-keymap [mule-diag] |
65407fdc4a33
Delete defining "i" in mule-keymap.
Kenichi Handa <handa@m17n.org>
parents:
17840
diff
changeset
|
100 '("Show diagnosis for MULE" . mule-diag) |
65407fdc4a33
Delete defining "i" in mule-keymap.
Kenichi Handa <handa@m17n.org>
parents:
17840
diff
changeset
|
101 t) |
65407fdc4a33
Delete defining "i" in mule-keymap.
Kenichi Handa <handa@m17n.org>
parents:
17840
diff
changeset
|
102 (define-key-after mule-menu-keymap [view-hello-file] |
65407fdc4a33
Delete defining "i" in mule-keymap.
Kenichi Handa <handa@m17n.org>
parents:
17840
diff
changeset
|
103 '("Show many languages" . view-hello-file) |
65407fdc4a33
Delete defining "i" in mule-keymap.
Kenichi Handa <handa@m17n.org>
parents:
17840
diff
changeset
|
104 t) |
65407fdc4a33
Delete defining "i" in mule-keymap.
Kenichi Handa <handa@m17n.org>
parents:
17840
diff
changeset
|
105 |
65407fdc4a33
Delete defining "i" in mule-keymap.
Kenichi Handa <handa@m17n.org>
parents:
17840
diff
changeset
|
106 (define-key-after set-coding-system-map [set-buffer-file-coding-system] |
65407fdc4a33
Delete defining "i" in mule-keymap.
Kenichi Handa <handa@m17n.org>
parents:
17840
diff
changeset
|
107 '("Buffer file" . set-buffer-file-coding-system) |
65407fdc4a33
Delete defining "i" in mule-keymap.
Kenichi Handa <handa@m17n.org>
parents:
17840
diff
changeset
|
108 t) |
65407fdc4a33
Delete defining "i" in mule-keymap.
Kenichi Handa <handa@m17n.org>
parents:
17840
diff
changeset
|
109 (define-key-after set-coding-system-map [set-terminal-coding-system] |
65407fdc4a33
Delete defining "i" in mule-keymap.
Kenichi Handa <handa@m17n.org>
parents:
17840
diff
changeset
|
110 '("Terminal" . set-terminal-coding-system) |
65407fdc4a33
Delete defining "i" in mule-keymap.
Kenichi Handa <handa@m17n.org>
parents:
17840
diff
changeset
|
111 t) |
65407fdc4a33
Delete defining "i" in mule-keymap.
Kenichi Handa <handa@m17n.org>
parents:
17840
diff
changeset
|
112 (define-key-after set-coding-system-map [set-keyboard-coding-system] |
65407fdc4a33
Delete defining "i" in mule-keymap.
Kenichi Handa <handa@m17n.org>
parents:
17840
diff
changeset
|
113 '("Keyboard" . set-keyboard-coding-system) |
65407fdc4a33
Delete defining "i" in mule-keymap.
Kenichi Handa <handa@m17n.org>
parents:
17840
diff
changeset
|
114 t) |
65407fdc4a33
Delete defining "i" in mule-keymap.
Kenichi Handa <handa@m17n.org>
parents:
17840
diff
changeset
|
115 (define-key-after set-coding-system-map [set-buffer-process-coding-system] |
65407fdc4a33
Delete defining "i" in mule-keymap.
Kenichi Handa <handa@m17n.org>
parents:
17840
diff
changeset
|
116 '("Buffer process" . set-buffer-process-coding-system) |
65407fdc4a33
Delete defining "i" in mule-keymap.
Kenichi Handa <handa@m17n.org>
parents:
17840
diff
changeset
|
117 t) |
65407fdc4a33
Delete defining "i" in mule-keymap.
Kenichi Handa <handa@m17n.org>
parents:
17840
diff
changeset
|
118 |
65407fdc4a33
Delete defining "i" in mule-keymap.
Kenichi Handa <handa@m17n.org>
parents:
17840
diff
changeset
|
119 (define-key setup-language-environment-map |
65407fdc4a33
Delete defining "i" in mule-keymap.
Kenichi Handa <handa@m17n.org>
parents:
17840
diff
changeset
|
120 [Default] '("Default" . setup-specified-language-environment)) |
17052 | 121 |
122 ;; These are meaningless when running under X. | |
17991
65407fdc4a33
Delete defining "i" in mule-keymap.
Kenichi Handa <handa@m17n.org>
parents:
17840
diff
changeset
|
123 (put 'set-terminal-coding-system 'menu-enable |
17052 | 124 '(null window-system)) |
17991
65407fdc4a33
Delete defining "i" in mule-keymap.
Kenichi Handa <handa@m17n.org>
parents:
17840
diff
changeset
|
125 (put 'set-keyboard-coding-system 'menu-enable |
17052 | 126 '(null window-system)) |
127 | |
128 ;; This should be a single character key binding because users use it | |
129 ;; very frequently while editing multilingual text. Now we can use | |
130 ;; only two such keys: "\C-\\" and "\C-^", but the latter is not | |
131 ;; convenient because it requires shifting on most keyboards. An | |
132 ;; alternative is "\C-\]" which is now bound to `abort-recursive-edit' | |
133 ;; but it won't be used that frequently. | |
134 (define-key global-map "\C-\\" 'toggle-input-method) | |
135 | |
136 (defun toggle-enable-multibyte-characters (&optional arg) | |
137 "Change whether this buffer enables multibyte characters. | |
138 With arg, make them enable iff arg is positive." | |
139 (interactive "P") | |
140 (setq enable-multibyte-characters | |
141 (if (null arg) (null enable-multibyte-characters) | |
142 (> (prefix-numeric-value arg) 0))) | |
143 (force-mode-line-update)) | |
144 | |
145 (defun view-hello-file () | |
146 "Display the HELLO file which list up many languages and characters." | |
147 (interactive) | |
17294
d7ae63db9e6e
Prefix for Mule related commands is changed.
Kenichi Handa <handa@m17n.org>
parents:
17090
diff
changeset
|
148 ;; We have to decode the file in any environment. |
d7ae63db9e6e
Prefix for Mule related commands is changed.
Kenichi Handa <handa@m17n.org>
parents:
17090
diff
changeset
|
149 (let ((default-enable-multibyte-characters t) |
d7ae63db9e6e
Prefix for Mule related commands is changed.
Kenichi Handa <handa@m17n.org>
parents:
17090
diff
changeset
|
150 (coding-system-for-read 'iso-2022-7)) |
d7ae63db9e6e
Prefix for Mule related commands is changed.
Kenichi Handa <handa@m17n.org>
parents:
17090
diff
changeset
|
151 (find-file-read-only (expand-file-name "HELLO" data-directory)))) |
17052 | 152 |
17991
65407fdc4a33
Delete defining "i" in mule-keymap.
Kenichi Handa <handa@m17n.org>
parents:
17840
diff
changeset
|
153 (defun universal-coding-system-argument () |
65407fdc4a33
Delete defining "i" in mule-keymap.
Kenichi Handa <handa@m17n.org>
parents:
17840
diff
changeset
|
154 "Execute an I/O command using the specified coding system." |
65407fdc4a33
Delete defining "i" in mule-keymap.
Kenichi Handa <handa@m17n.org>
parents:
17840
diff
changeset
|
155 (interactive) |
65407fdc4a33
Delete defining "i" in mule-keymap.
Kenichi Handa <handa@m17n.org>
parents:
17840
diff
changeset
|
156 (let* ((coding-system (read-coding-system "Coding system: ")) |
65407fdc4a33
Delete defining "i" in mule-keymap.
Kenichi Handa <handa@m17n.org>
parents:
17840
diff
changeset
|
157 (keyseq (read-key-sequence |
65407fdc4a33
Delete defining "i" in mule-keymap.
Kenichi Handa <handa@m17n.org>
parents:
17840
diff
changeset
|
158 (format "With coding system %s:" coding-system))) |
65407fdc4a33
Delete defining "i" in mule-keymap.
Kenichi Handa <handa@m17n.org>
parents:
17840
diff
changeset
|
159 (cmd (key-binding keyseq))) |
65407fdc4a33
Delete defining "i" in mule-keymap.
Kenichi Handa <handa@m17n.org>
parents:
17840
diff
changeset
|
160 (let ((coding-system-for-read coding-system) |
65407fdc4a33
Delete defining "i" in mule-keymap.
Kenichi Handa <handa@m17n.org>
parents:
17840
diff
changeset
|
161 (coding-system-for-write coding-system)) |
65407fdc4a33
Delete defining "i" in mule-keymap.
Kenichi Handa <handa@m17n.org>
parents:
17840
diff
changeset
|
162 (message "") |
65407fdc4a33
Delete defining "i" in mule-keymap.
Kenichi Handa <handa@m17n.org>
parents:
17840
diff
changeset
|
163 (call-interactively cmd)))) |
65407fdc4a33
Delete defining "i" in mule-keymap.
Kenichi Handa <handa@m17n.org>
parents:
17840
diff
changeset
|
164 |
17052 | 165 |
166 ;;; Language support staffs. | |
167 | |
168 (defvar primary-language "English" | |
169 "Name of a user's primary language. | |
170 Emacs provide various language supports based on this variable.") | |
171 | |
172 (defvar language-info-alist nil | |
173 "Alist of language names vs the corresponding information of various kind. | |
174 Each element looks like: | |
175 (LANGUAGE-NAME . ((KEY . INFO) ...)) | |
176 where LANGUAGE-NAME is a string, | |
177 KEY is a symbol denoting the kind of information, | |
178 INFO is any Lisp object which contains the actual information related | |
179 to KEY.") | |
180 | |
181 (defun get-language-info (language-name key) | |
182 "Return the information for LANGUAGE-NAME of the kind KEY. | |
183 LANGUAGE-NAME is a string. | |
184 KEY is a symbol denoting the kind of required information." | |
17991
65407fdc4a33
Delete defining "i" in mule-keymap.
Kenichi Handa <handa@m17n.org>
parents:
17840
diff
changeset
|
185 (let ((lang-slot (assoc-ignore-case language-name language-info-alist))) |
17052 | 186 (if lang-slot |
187 (cdr (assq key (cdr lang-slot)))))) | |
188 | |
189 (defun set-language-info (language-name key info) | |
190 "Set for LANGUAGE-NAME the information INFO under KEY. | |
191 LANGUAGE-NAME is a string | |
192 KEY is a symbol denoting the kind of information. | |
193 INFO is any Lisp object which contains the actual information. | |
194 | |
195 Currently, the following KEYs are used by Emacs: | |
18152
e184e7061c9a
(describe-language-environment):
Richard M. Stallman <rms@gnu.org>
parents:
18068
diff
changeset
|
196 |
17052 | 197 charset: list of symbols whose values are charsets specific to the language. |
18152
e184e7061c9a
(describe-language-environment):
Richard M. Stallman <rms@gnu.org>
parents:
18068
diff
changeset
|
198 |
17052 | 199 coding-system: list of coding systems specific to the langauge. |
18152
e184e7061c9a
(describe-language-environment):
Richard M. Stallman <rms@gnu.org>
parents:
18068
diff
changeset
|
200 |
17052 | 201 tutorial: a tutorial file name written in the language. |
18152
e184e7061c9a
(describe-language-environment):
Richard M. Stallman <rms@gnu.org>
parents:
18068
diff
changeset
|
202 |
17052 | 203 sample-text: one line short text containing characters of the language. |
18152
e184e7061c9a
(describe-language-environment):
Richard M. Stallman <rms@gnu.org>
parents:
18068
diff
changeset
|
204 |
17052 | 205 input-method: alist of input method names for the language vs information |
18152
e184e7061c9a
(describe-language-environment):
Richard M. Stallman <rms@gnu.org>
parents:
18068
diff
changeset
|
206 for activating them. Use `register-input-method' (which see) |
e184e7061c9a
(describe-language-environment):
Richard M. Stallman <rms@gnu.org>
parents:
18068
diff
changeset
|
207 to add a new input method to the alist. |
e184e7061c9a
(describe-language-environment):
Richard M. Stallman <rms@gnu.org>
parents:
18068
diff
changeset
|
208 |
17991
65407fdc4a33
Delete defining "i" in mule-keymap.
Kenichi Handa <handa@m17n.org>
parents:
17840
diff
changeset
|
209 documentation: t or a string describing how Emacs supports the language. |
18152
e184e7061c9a
(describe-language-environment):
Richard M. Stallman <rms@gnu.org>
parents:
18068
diff
changeset
|
210 If a string is specified, it is shown before any other information |
e184e7061c9a
(describe-language-environment):
Richard M. Stallman <rms@gnu.org>
parents:
18068
diff
changeset
|
211 of the language by the command `describe-language-environment'. |
e184e7061c9a
(describe-language-environment):
Richard M. Stallman <rms@gnu.org>
parents:
18068
diff
changeset
|
212 |
17758
8c67c2e2cc29
(build-describe-language-support-function,
Kenichi Handa <handa@m17n.org>
parents:
17526
diff
changeset
|
213 setup-function: a function to call for setting up environment |
18152
e184e7061c9a
(describe-language-environment):
Richard M. Stallman <rms@gnu.org>
parents:
18068
diff
changeset
|
214 convenient for a user of the language. |
17991
65407fdc4a33
Delete defining "i" in mule-keymap.
Kenichi Handa <handa@m17n.org>
parents:
17840
diff
changeset
|
215 |
65407fdc4a33
Delete defining "i" in mule-keymap.
Kenichi Handa <handa@m17n.org>
parents:
17840
diff
changeset
|
216 If KEY is documentation or setup-function, you can also specify |
65407fdc4a33
Delete defining "i" in mule-keymap.
Kenichi Handa <handa@m17n.org>
parents:
17840
diff
changeset
|
217 a cons cell as INFO, in which case, the car part should be |
65407fdc4a33
Delete defining "i" in mule-keymap.
Kenichi Handa <handa@m17n.org>
parents:
17840
diff
changeset
|
218 a normal value as INFO for KEY (as described above), |
65407fdc4a33
Delete defining "i" in mule-keymap.
Kenichi Handa <handa@m17n.org>
parents:
17840
diff
changeset
|
219 and the cdr part should be a symbol whose value is a menu keymap |
65407fdc4a33
Delete defining "i" in mule-keymap.
Kenichi Handa <handa@m17n.org>
parents:
17840
diff
changeset
|
220 in which an entry for the language is defined. But, only the car part |
65407fdc4a33
Delete defining "i" in mule-keymap.
Kenichi Handa <handa@m17n.org>
parents:
17840
diff
changeset
|
221 is actually set as the information. |
17052 | 222 |
18152
e184e7061c9a
(describe-language-environment):
Richard M. Stallman <rms@gnu.org>
parents:
18068
diff
changeset
|
223 We will define more KEYs in the future. To avoid conflict, |
e184e7061c9a
(describe-language-environment):
Richard M. Stallman <rms@gnu.org>
parents:
18068
diff
changeset
|
224 if you want to use your own KEY values, make them start with `user-'." |
17052 | 225 (let (lang-slot key-slot) |
226 (setq lang-slot (assoc language-name language-info-alist)) | |
227 (if (null lang-slot) ; If no slot for the language, add it. | |
228 (setq lang-slot (list language-name) | |
229 language-info-alist (cons lang-slot language-info-alist))) | |
230 (setq key-slot (assq key lang-slot)) | |
231 (if (null key-slot) ; If no slot for the key, add it. | |
232 (progn | |
233 (setq key-slot (list key)) | |
234 (setcdr lang-slot (cons key-slot (cdr lang-slot))))) | |
235 ;; Setup menu. | |
17840
2517414676ed
(set-language-info): Change the special treatment
Kenichi Handa <handa@m17n.org>
parents:
17758
diff
changeset
|
236 (cond ((eq key 'documentation) |
17991
65407fdc4a33
Delete defining "i" in mule-keymap.
Kenichi Handa <handa@m17n.org>
parents:
17840
diff
changeset
|
237 (define-key-after |
65407fdc4a33
Delete defining "i" in mule-keymap.
Kenichi Handa <handa@m17n.org>
parents:
17840
diff
changeset
|
238 (if (consp info) |
65407fdc4a33
Delete defining "i" in mule-keymap.
Kenichi Handa <handa@m17n.org>
parents:
17840
diff
changeset
|
239 (prog1 (symbol-value (cdr info)) |
65407fdc4a33
Delete defining "i" in mule-keymap.
Kenichi Handa <handa@m17n.org>
parents:
17840
diff
changeset
|
240 (setq info (car info))) |
18152
e184e7061c9a
(describe-language-environment):
Richard M. Stallman <rms@gnu.org>
parents:
18068
diff
changeset
|
241 describe-language-environment-map) |
17090
8085a8690c87
(mule-keymap): Re-arranged.
Kenichi Handa <handa@m17n.org>
parents:
17071
diff
changeset
|
242 (vector (intern language-name)) |
17840
2517414676ed
(set-language-info): Change the special treatment
Kenichi Handa <handa@m17n.org>
parents:
17758
diff
changeset
|
243 (cons language-name 'describe-specified-language-support) |
17758
8c67c2e2cc29
(build-describe-language-support-function,
Kenichi Handa <handa@m17n.org>
parents:
17526
diff
changeset
|
244 t)) |
17090
8085a8690c87
(mule-keymap): Re-arranged.
Kenichi Handa <handa@m17n.org>
parents:
17071
diff
changeset
|
245 ((eq key 'setup-function) |
17991
65407fdc4a33
Delete defining "i" in mule-keymap.
Kenichi Handa <handa@m17n.org>
parents:
17840
diff
changeset
|
246 (define-key-after |
65407fdc4a33
Delete defining "i" in mule-keymap.
Kenichi Handa <handa@m17n.org>
parents:
17840
diff
changeset
|
247 (if (consp info) |
65407fdc4a33
Delete defining "i" in mule-keymap.
Kenichi Handa <handa@m17n.org>
parents:
17840
diff
changeset
|
248 (prog1 (symbol-value (cdr info)) |
65407fdc4a33
Delete defining "i" in mule-keymap.
Kenichi Handa <handa@m17n.org>
parents:
17840
diff
changeset
|
249 (setq info (car info))) |
65407fdc4a33
Delete defining "i" in mule-keymap.
Kenichi Handa <handa@m17n.org>
parents:
17840
diff
changeset
|
250 setup-language-environment-map) |
17090
8085a8690c87
(mule-keymap): Re-arranged.
Kenichi Handa <handa@m17n.org>
parents:
17071
diff
changeset
|
251 (vector (intern language-name)) |
17991
65407fdc4a33
Delete defining "i" in mule-keymap.
Kenichi Handa <handa@m17n.org>
parents:
17840
diff
changeset
|
252 (cons language-name 'setup-specified-language-environment) |
17758
8c67c2e2cc29
(build-describe-language-support-function,
Kenichi Handa <handa@m17n.org>
parents:
17526
diff
changeset
|
253 t))) |
17991
65407fdc4a33
Delete defining "i" in mule-keymap.
Kenichi Handa <handa@m17n.org>
parents:
17840
diff
changeset
|
254 |
65407fdc4a33
Delete defining "i" in mule-keymap.
Kenichi Handa <handa@m17n.org>
parents:
17840
diff
changeset
|
255 (setcdr key-slot info) |
17052 | 256 )) |
257 | |
258 (defun set-language-info-alist (language-name alist) | |
259 "Set for LANGUAGE-NAME the information in ALIST. | |
260 ALIST is an alist of KEY and INFO. See the documentation of | |
261 `set-langauge-info' for the meanings of KEY and INFO." | |
262 (while alist | |
263 (set-language-info language-name (car (car alist)) (cdr (car alist))) | |
264 (setq alist (cdr alist)))) | |
265 | |
266 (defun read-language-name (key prompt &optional initial-input) | |
267 "Read language name which has information for KEY, prompting with PROMPT." | |
268 (let* ((completion-ignore-case t) | |
269 (name (completing-read prompt | |
270 language-info-alist | |
271 (function (lambda (elm) (assq key elm))) | |
272 t | |
273 initial-input))) | |
17758
8c67c2e2cc29
(build-describe-language-support-function,
Kenichi Handa <handa@m17n.org>
parents:
17526
diff
changeset
|
274 (if (and (> (length name) 0) |
8c67c2e2cc29
(build-describe-language-support-function,
Kenichi Handa <handa@m17n.org>
parents:
17526
diff
changeset
|
275 (get-language-info name key)) |
8c67c2e2cc29
(build-describe-language-support-function,
Kenichi Handa <handa@m17n.org>
parents:
17526
diff
changeset
|
276 name))) |
17052 | 277 |
278 ;;; Multilingual input methods. | |
279 | |
280 (defvar current-input-method nil | |
281 "The current input method for multilingual text. | |
282 The value is a cons of language name and input method name. | |
283 If nil, it means no input method is activated now.") | |
284 (make-variable-buffer-local 'current-input-method) | |
285 (put 'current-input-method 'permanent-local t) | |
286 | |
287 (defvar current-input-method-title nil | |
288 "Title string of the current input method shown in mode line. | |
17758
8c67c2e2cc29
(build-describe-language-support-function,
Kenichi Handa <handa@m17n.org>
parents:
17526
diff
changeset
|
289 Every input method should set this to an appropriate value when activated.") |
17052 | 290 (make-variable-buffer-local 'current-input-method-title) |
291 (put 'current-input-method-title 'permanent-local t) | |
292 | |
293 (defvar default-input-method nil | |
294 "Default input method. | |
295 The default input method is the one activated automatically by the command | |
296 `toggle-input-method' (\\[toggle-input-method]). | |
297 The value is a cons of language name and input method name.") | |
17991
65407fdc4a33
Delete defining "i" in mule-keymap.
Kenichi Handa <handa@m17n.org>
parents:
17840
diff
changeset
|
298 (make-variable-buffer-local 'default-input-method) |
65407fdc4a33
Delete defining "i" in mule-keymap.
Kenichi Handa <handa@m17n.org>
parents:
17840
diff
changeset
|
299 (put 'default-input-method 'permanent-local t) |
17052 | 300 |
301 (defvar default-input-method-title nil | |
302 "Title string of the default input method.") | |
17991
65407fdc4a33
Delete defining "i" in mule-keymap.
Kenichi Handa <handa@m17n.org>
parents:
17840
diff
changeset
|
303 (make-variable-buffer-local 'default-input-method-title) |
65407fdc4a33
Delete defining "i" in mule-keymap.
Kenichi Handa <handa@m17n.org>
parents:
17840
diff
changeset
|
304 (put 'default-input-method-title 'permanent-local t) |
17052 | 305 |
306 (defvar previous-input-method nil | |
307 "Input method selected previously. | |
308 This is the one selected before the current input method is selected. | |
309 See also the documentation of `default-input-method'.") | |
17991
65407fdc4a33
Delete defining "i" in mule-keymap.
Kenichi Handa <handa@m17n.org>
parents:
17840
diff
changeset
|
310 (make-variable-buffer-local 'previous-input-method) |
65407fdc4a33
Delete defining "i" in mule-keymap.
Kenichi Handa <handa@m17n.org>
parents:
17840
diff
changeset
|
311 (put 'previous-input-method 'permanent-local t) |
17052 | 312 |
313 (defvar inactivate-current-input-method-function nil | |
314 "Function to call for inactivating the current input method. | |
315 Every input method should set this to an appropriate value when activated. | |
316 This function is called with no argument.") | |
317 (make-variable-buffer-local 'inactivate-current-input-method-function) | |
318 (put 'inactivate-current-input-method-function 'permanent-local t) | |
319 | |
320 (defvar describe-current-input-method-function nil | |
321 "Function to call for describing the current input method. | |
322 This function is called with no argument.") | |
323 (make-variable-buffer-local 'describe-current-input-method-function) | |
324 (put 'describe-current-input-method-function 'permanent-local t) | |
325 | |
326 (defun register-input-method (language-name input-method) | |
327 "Register INPUT-METHOD as an input method of LANGUAGE-NAME. | |
328 LANGUAGE-NAME is a string. | |
329 INPUT-METHOD is a list of the form: | |
330 (METHOD-NAME ACTIVATE-FUNC ARG ...) | |
331 where METHOD-NAME is the name of this method, | |
332 ACTIVATE-FUNC is the function to call for activating this method. | |
333 Arguments for the function are METHOD-NAME and ARGs." | |
334 (let ((slot (get-language-info language-name 'input-method)) | |
335 method-slot) | |
336 (if (null slot) | |
337 (set-language-info language-name 'input-method (list input-method)) | |
338 (setq method-slot (assoc (car input-method) slot)) | |
339 (if method-slot | |
340 (setcdr method-slot (cdr input-method)) | |
341 (set-language-info language-name 'input-method | |
342 (cons input-method slot)))))) | |
343 | |
344 (defun read-language-and-input-method-name () | |
17991
65407fdc4a33
Delete defining "i" in mule-keymap.
Kenichi Handa <handa@m17n.org>
parents:
17840
diff
changeset
|
345 "Read a language name and the corresponding input method from a minibuffer. |
65407fdc4a33
Delete defining "i" in mule-keymap.
Kenichi Handa <handa@m17n.org>
parents:
17840
diff
changeset
|
346 Return a list of those names." |
65407fdc4a33
Delete defining "i" in mule-keymap.
Kenichi Handa <handa@m17n.org>
parents:
17840
diff
changeset
|
347 (let* ((default-val (or previous-input-method default-input-method)) |
65407fdc4a33
Delete defining "i" in mule-keymap.
Kenichi Handa <handa@m17n.org>
parents:
17840
diff
changeset
|
348 (language-name (read-language-name |
65407fdc4a33
Delete defining "i" in mule-keymap.
Kenichi Handa <handa@m17n.org>
parents:
17840
diff
changeset
|
349 'input-method "Language: " |
65407fdc4a33
Delete defining "i" in mule-keymap.
Kenichi Handa <handa@m17n.org>
parents:
17840
diff
changeset
|
350 (if default-val (cons (car default-val) 0))))) |
17052 | 351 (if (null language-name) |
352 (error "No input method for the specified language")) | |
17991
65407fdc4a33
Delete defining "i" in mule-keymap.
Kenichi Handa <handa@m17n.org>
parents:
17840
diff
changeset
|
353 (if (not (string= language-name (car default-val))) |
65407fdc4a33
Delete defining "i" in mule-keymap.
Kenichi Handa <handa@m17n.org>
parents:
17840
diff
changeset
|
354 ;; Now the default value has no meaning. |
65407fdc4a33
Delete defining "i" in mule-keymap.
Kenichi Handa <handa@m17n.org>
parents:
17840
diff
changeset
|
355 (setq default-val nil)) |
17052 | 356 (let* ((completion-ignore-case t) |
17090
8085a8690c87
(mule-keymap): Re-arranged.
Kenichi Handa <handa@m17n.org>
parents:
17071
diff
changeset
|
357 (key-slot (cdr (assq 'input-method |
8085a8690c87
(mule-keymap): Re-arranged.
Kenichi Handa <handa@m17n.org>
parents:
17071
diff
changeset
|
358 (assoc language-name language-info-alist)))) |
17052 | 359 (method-name |
17090
8085a8690c87
(mule-keymap): Re-arranged.
Kenichi Handa <handa@m17n.org>
parents:
17071
diff
changeset
|
360 (completing-read "Input method: " key-slot nil t |
17991
65407fdc4a33
Delete defining "i" in mule-keymap.
Kenichi Handa <handa@m17n.org>
parents:
17840
diff
changeset
|
361 (if default-val (cons (cdr default-val) 0))))) |
17052 | 362 (if (= (length method-name) 0) |
363 (error "No input method specified")) | |
17090
8085a8690c87
(mule-keymap): Re-arranged.
Kenichi Handa <handa@m17n.org>
parents:
17071
diff
changeset
|
364 (list language-name |
17991
65407fdc4a33
Delete defining "i" in mule-keymap.
Kenichi Handa <handa@m17n.org>
parents:
17840
diff
changeset
|
365 (car (assoc-ignore-case method-name key-slot)))))) |
17052 | 366 |
17991
65407fdc4a33
Delete defining "i" in mule-keymap.
Kenichi Handa <handa@m17n.org>
parents:
17840
diff
changeset
|
367 ;; Actvate input method METHOD-NAME for langauge LANGUAGE-NAME. |
65407fdc4a33
Delete defining "i" in mule-keymap.
Kenichi Handa <handa@m17n.org>
parents:
17840
diff
changeset
|
368 (defun activate-input-method (language-name method-name) |
65407fdc4a33
Delete defining "i" in mule-keymap.
Kenichi Handa <handa@m17n.org>
parents:
17840
diff
changeset
|
369 (if (and current-input-method |
65407fdc4a33
Delete defining "i" in mule-keymap.
Kenichi Handa <handa@m17n.org>
parents:
17840
diff
changeset
|
370 (or (not (string= (car current-input-method) language-name)) |
65407fdc4a33
Delete defining "i" in mule-keymap.
Kenichi Handa <handa@m17n.org>
parents:
17840
diff
changeset
|
371 (not (string= (cdr current-input-method) method-name)))) |
65407fdc4a33
Delete defining "i" in mule-keymap.
Kenichi Handa <handa@m17n.org>
parents:
17840
diff
changeset
|
372 (inactivate-input-method)) |
65407fdc4a33
Delete defining "i" in mule-keymap.
Kenichi Handa <handa@m17n.org>
parents:
17840
diff
changeset
|
373 (or current-input-method |
65407fdc4a33
Delete defining "i" in mule-keymap.
Kenichi Handa <handa@m17n.org>
parents:
17840
diff
changeset
|
374 (let* ((key-slot (get-language-info language-name 'input-method)) |
65407fdc4a33
Delete defining "i" in mule-keymap.
Kenichi Handa <handa@m17n.org>
parents:
17840
diff
changeset
|
375 (method-slot (cdr (assoc method-name key-slot)))) |
65407fdc4a33
Delete defining "i" in mule-keymap.
Kenichi Handa <handa@m17n.org>
parents:
17840
diff
changeset
|
376 (if (null method-slot) |
65407fdc4a33
Delete defining "i" in mule-keymap.
Kenichi Handa <handa@m17n.org>
parents:
17840
diff
changeset
|
377 (error "Invalid input method `%s' for %s" |
65407fdc4a33
Delete defining "i" in mule-keymap.
Kenichi Handa <handa@m17n.org>
parents:
17840
diff
changeset
|
378 method-name language-name)) |
65407fdc4a33
Delete defining "i" in mule-keymap.
Kenichi Handa <handa@m17n.org>
parents:
17840
diff
changeset
|
379 (apply (car method-slot) method-name (cdr method-slot)) |
65407fdc4a33
Delete defining "i" in mule-keymap.
Kenichi Handa <handa@m17n.org>
parents:
17840
diff
changeset
|
380 (setq current-input-method (cons language-name method-name)) |
65407fdc4a33
Delete defining "i" in mule-keymap.
Kenichi Handa <handa@m17n.org>
parents:
17840
diff
changeset
|
381 (if (not (equal default-input-method current-input-method)) |
65407fdc4a33
Delete defining "i" in mule-keymap.
Kenichi Handa <handa@m17n.org>
parents:
17840
diff
changeset
|
382 (progn |
65407fdc4a33
Delete defining "i" in mule-keymap.
Kenichi Handa <handa@m17n.org>
parents:
17840
diff
changeset
|
383 (setq previous-input-method default-input-method) |
65407fdc4a33
Delete defining "i" in mule-keymap.
Kenichi Handa <handa@m17n.org>
parents:
17840
diff
changeset
|
384 (setq default-input-method current-input-method) |
65407fdc4a33
Delete defining "i" in mule-keymap.
Kenichi Handa <handa@m17n.org>
parents:
17840
diff
changeset
|
385 (setq default-input-method-title current-input-method-title)))))) |
65407fdc4a33
Delete defining "i" in mule-keymap.
Kenichi Handa <handa@m17n.org>
parents:
17840
diff
changeset
|
386 |
65407fdc4a33
Delete defining "i" in mule-keymap.
Kenichi Handa <handa@m17n.org>
parents:
17840
diff
changeset
|
387 ;; Inactivate the current input method. |
65407fdc4a33
Delete defining "i" in mule-keymap.
Kenichi Handa <handa@m17n.org>
parents:
17840
diff
changeset
|
388 (defun inactivate-input-method () |
65407fdc4a33
Delete defining "i" in mule-keymap.
Kenichi Handa <handa@m17n.org>
parents:
17840
diff
changeset
|
389 (if current-input-method |
65407fdc4a33
Delete defining "i" in mule-keymap.
Kenichi Handa <handa@m17n.org>
parents:
17840
diff
changeset
|
390 (unwind-protect |
65407fdc4a33
Delete defining "i" in mule-keymap.
Kenichi Handa <handa@m17n.org>
parents:
17840
diff
changeset
|
391 (funcall inactivate-current-input-method-function) |
65407fdc4a33
Delete defining "i" in mule-keymap.
Kenichi Handa <handa@m17n.org>
parents:
17840
diff
changeset
|
392 (setq current-input-method nil)))) |
17052 | 393 |
394 (defun select-input-method (language-name method-name) | |
395 "Select and activate input method METHOD-NAME for inputting LANGUAGE-NAME. | |
17991
65407fdc4a33
Delete defining "i" in mule-keymap.
Kenichi Handa <handa@m17n.org>
parents:
17840
diff
changeset
|
396 Both the default and local values of default-input-method are |
65407fdc4a33
Delete defining "i" in mule-keymap.
Kenichi Handa <handa@m17n.org>
parents:
17840
diff
changeset
|
397 set to the selected input method. |
65407fdc4a33
Delete defining "i" in mule-keymap.
Kenichi Handa <handa@m17n.org>
parents:
17840
diff
changeset
|
398 |
17052 | 399 The information for activating METHOD-NAME is stored |
400 in `language-info-alist' under the key 'input-method. | |
401 The format of the information has the form: | |
402 ((METHOD-NAME ACTIVATE-FUNC ARG ...) ...) | |
403 where ACTIVATE-FUNC is a function to call for activating this method. | |
404 Arguments for the function are METHOD-NAME and ARGs." | |
405 (interactive (read-language-and-input-method-name)) | |
17991
65407fdc4a33
Delete defining "i" in mule-keymap.
Kenichi Handa <handa@m17n.org>
parents:
17840
diff
changeset
|
406 (activate-input-method language-name method-name) |
65407fdc4a33
Delete defining "i" in mule-keymap.
Kenichi Handa <handa@m17n.org>
parents:
17840
diff
changeset
|
407 (setq-default default-input-method default-input-method) |
65407fdc4a33
Delete defining "i" in mule-keymap.
Kenichi Handa <handa@m17n.org>
parents:
17840
diff
changeset
|
408 (setq-default default-input-method-title default-input-method-title)) |
17052 | 409 |
410 (defun toggle-input-method (&optional arg) | |
17991
65407fdc4a33
Delete defining "i" in mule-keymap.
Kenichi Handa <handa@m17n.org>
parents:
17840
diff
changeset
|
411 "Turn on or off a multilingual text input method for the current buffer. |
65407fdc4a33
Delete defining "i" in mule-keymap.
Kenichi Handa <handa@m17n.org>
parents:
17840
diff
changeset
|
412 With arg, turn on an input method specified interactively. |
65407fdc4a33
Delete defining "i" in mule-keymap.
Kenichi Handa <handa@m17n.org>
parents:
17840
diff
changeset
|
413 Without arg, if some input method is currently activated, turn it off, |
65407fdc4a33
Delete defining "i" in mule-keymap.
Kenichi Handa <handa@m17n.org>
parents:
17840
diff
changeset
|
414 else turn on default-input-method (which see). |
65407fdc4a33
Delete defining "i" in mule-keymap.
Kenichi Handa <handa@m17n.org>
parents:
17840
diff
changeset
|
415 In the latter case, if default-input-method is nil, select an input method |
65407fdc4a33
Delete defining "i" in mule-keymap.
Kenichi Handa <handa@m17n.org>
parents:
17840
diff
changeset
|
416 interactively." |
17052 | 417 (interactive "P") |
418 (if arg | |
17991
65407fdc4a33
Delete defining "i" in mule-keymap.
Kenichi Handa <handa@m17n.org>
parents:
17840
diff
changeset
|
419 (let ((input-method (read-language-and-input-method-name))) |
65407fdc4a33
Delete defining "i" in mule-keymap.
Kenichi Handa <handa@m17n.org>
parents:
17840
diff
changeset
|
420 (activate-input-method (car input-method) (nth 1 input-method))) |
65407fdc4a33
Delete defining "i" in mule-keymap.
Kenichi Handa <handa@m17n.org>
parents:
17840
diff
changeset
|
421 (if current-input-method |
65407fdc4a33
Delete defining "i" in mule-keymap.
Kenichi Handa <handa@m17n.org>
parents:
17840
diff
changeset
|
422 (inactivate-input-method) |
65407fdc4a33
Delete defining "i" in mule-keymap.
Kenichi Handa <handa@m17n.org>
parents:
17840
diff
changeset
|
423 (if default-input-method |
65407fdc4a33
Delete defining "i" in mule-keymap.
Kenichi Handa <handa@m17n.org>
parents:
17840
diff
changeset
|
424 (activate-input-method (car default-input-method) |
17052 | 425 (cdr default-input-method)) |
17991
65407fdc4a33
Delete defining "i" in mule-keymap.
Kenichi Handa <handa@m17n.org>
parents:
17840
diff
changeset
|
426 (let ((input-method (read-language-and-input-method-name))) |
65407fdc4a33
Delete defining "i" in mule-keymap.
Kenichi Handa <handa@m17n.org>
parents:
17840
diff
changeset
|
427 (activate-input-method (car input-method) (nth 1 input-method))))))) |
17052 | 428 |
429 (defun describe-input-method () | |
430 "Describe the current input method." | |
431 (interactive) | |
432 (if current-input-method | |
433 (if (and (symbolp describe-current-input-method-function) | |
434 (fboundp describe-current-input-method-function)) | |
435 (funcall describe-current-input-method-function) | |
436 (message "No way to describe the current input method `%s'" | |
437 (cdr current-input-method)) | |
438 (ding)) | |
439 (message "No input method is activated now") | |
440 (ding))) | |
441 | |
442 (defun read-multilingual-string (prompt &optional initial-input | |
443 language-name method-name) | |
444 "Read a multilingual string from minibuffer, prompting with string PROMPT. | |
445 The input method selected last time is activated in minibuffer. | |
17991
65407fdc4a33
Delete defining "i" in mule-keymap.
Kenichi Handa <handa@m17n.org>
parents:
17840
diff
changeset
|
446 If optional second arg INITIAL-INPUT is non-nil, insert it in the minibuffer |
65407fdc4a33
Delete defining "i" in mule-keymap.
Kenichi Handa <handa@m17n.org>
parents:
17840
diff
changeset
|
447 initially |
17052 | 448 Optional 3rd and 4th arguments LANGUAGE-NAME and METHOD-NAME specify |
449 the input method to be activated instead of the one selected last time." | |
17991
65407fdc4a33
Delete defining "i" in mule-keymap.
Kenichi Handa <handa@m17n.org>
parents:
17840
diff
changeset
|
450 (let ((default-input-method default-input-method)) |
17052 | 451 (if (and language-name method-name) |
17991
65407fdc4a33
Delete defining "i" in mule-keymap.
Kenichi Handa <handa@m17n.org>
parents:
17840
diff
changeset
|
452 (setq default-input-method (cons language-name method-name)) |
65407fdc4a33
Delete defining "i" in mule-keymap.
Kenichi Handa <handa@m17n.org>
parents:
17840
diff
changeset
|
453 (or default-input-method |
65407fdc4a33
Delete defining "i" in mule-keymap.
Kenichi Handa <handa@m17n.org>
parents:
17840
diff
changeset
|
454 (let ((lang-and-input-method (read-language-and-input-method-name))) |
65407fdc4a33
Delete defining "i" in mule-keymap.
Kenichi Handa <handa@m17n.org>
parents:
17840
diff
changeset
|
455 (setq default-input-method (cons (car lang-and-input-method) |
65407fdc4a33
Delete defining "i" in mule-keymap.
Kenichi Handa <handa@m17n.org>
parents:
17840
diff
changeset
|
456 (nth 1 lang-and-input-method)))))) |
65407fdc4a33
Delete defining "i" in mule-keymap.
Kenichi Handa <handa@m17n.org>
parents:
17840
diff
changeset
|
457 (let ((minibuffer-setup-hook '(toggle-input-method))) |
65407fdc4a33
Delete defining "i" in mule-keymap.
Kenichi Handa <handa@m17n.org>
parents:
17840
diff
changeset
|
458 (read-string prompt initial-input)))) |
17052 | 459 |
460 ;; Variables to control behavior of input methods. All input methods | |
461 ;; should react to these variables. | |
462 | |
463 (defvar input-method-tersely-flag nil | |
464 "*If this flag is non-nil, input method works rather tersely. | |
465 | |
466 For instance, Quail input method does not show guidance buffer while | |
467 inputting at minibuffer if this flag is t.") | |
468 | |
469 (defvar input-method-activate-hook nil | |
470 "Normal hook run just after an input method is activated.") | |
471 | |
472 (defvar input-method-inactivate-hook nil | |
473 "Normal hook run just after an input method is inactivated.") | |
474 | |
475 (defvar input-method-after-insert-chunk-hook nil | |
476 "Normal hook run just after an input method insert some chunk of text.") | |
477 | |
478 | |
17991
65407fdc4a33
Delete defining "i" in mule-keymap.
Kenichi Handa <handa@m17n.org>
parents:
17840
diff
changeset
|
479 (defun setup-specified-language-environment () |
65407fdc4a33
Delete defining "i" in mule-keymap.
Kenichi Handa <handa@m17n.org>
parents:
17840
diff
changeset
|
480 "Setup multi-lingual environment convenient for the specified language." |
65407fdc4a33
Delete defining "i" in mule-keymap.
Kenichi Handa <handa@m17n.org>
parents:
17840
diff
changeset
|
481 (interactive) |
65407fdc4a33
Delete defining "i" in mule-keymap.
Kenichi Handa <handa@m17n.org>
parents:
17840
diff
changeset
|
482 (let (language-name func) |
65407fdc4a33
Delete defining "i" in mule-keymap.
Kenichi Handa <handa@m17n.org>
parents:
17840
diff
changeset
|
483 (if (and (symbolp last-command-event) |
65407fdc4a33
Delete defining "i" in mule-keymap.
Kenichi Handa <handa@m17n.org>
parents:
17840
diff
changeset
|
484 (or (not (eq last-command-event 'Default)) |
65407fdc4a33
Delete defining "i" in mule-keymap.
Kenichi Handa <handa@m17n.org>
parents:
17840
diff
changeset
|
485 (setq last-command-event 'English)) |
65407fdc4a33
Delete defining "i" in mule-keymap.
Kenichi Handa <handa@m17n.org>
parents:
17840
diff
changeset
|
486 (setq language-name (symbol-name last-command-event)) |
65407fdc4a33
Delete defining "i" in mule-keymap.
Kenichi Handa <handa@m17n.org>
parents:
17840
diff
changeset
|
487 (setq func (get-language-info language-name 'setup-function))) |
65407fdc4a33
Delete defining "i" in mule-keymap.
Kenichi Handa <handa@m17n.org>
parents:
17840
diff
changeset
|
488 (progn |
65407fdc4a33
Delete defining "i" in mule-keymap.
Kenichi Handa <handa@m17n.org>
parents:
17840
diff
changeset
|
489 (funcall func) |
65407fdc4a33
Delete defining "i" in mule-keymap.
Kenichi Handa <handa@m17n.org>
parents:
17840
diff
changeset
|
490 (force-mode-line-update t)) |
65407fdc4a33
Delete defining "i" in mule-keymap.
Kenichi Handa <handa@m17n.org>
parents:
17840
diff
changeset
|
491 (error "Bogus calling sequence")))) |
17052 | 492 |
18066
eecd891e2b63
(set-language-environment): Add autoload cookie.
Richard M. Stallman <rms@gnu.org>
parents:
17991
diff
changeset
|
493 ;;;###autoload |
eecd891e2b63
(set-language-environment): Add autoload cookie.
Richard M. Stallman <rms@gnu.org>
parents:
17991
diff
changeset
|
494 (defun set-language-environment (language-name) |
18068
317f57f07b14
Doc fix for previous change.
Richard M. Stallman <rms@gnu.org>
parents:
18066
diff
changeset
|
495 "Set up multi-lingual environment for using LANGUAGE-NAME. |
317f57f07b14
Doc fix for previous change.
Richard M. Stallman <rms@gnu.org>
parents:
18066
diff
changeset
|
496 This sets the coding system priority and the default input method |
317f57f07b14
Doc fix for previous change.
Richard M. Stallman <rms@gnu.org>
parents:
18066
diff
changeset
|
497 and sometimes other things." |
17052 | 498 (interactive (list (read-language-name 'setup-function "Language: "))) |
17991
65407fdc4a33
Delete defining "i" in mule-keymap.
Kenichi Handa <handa@m17n.org>
parents:
17840
diff
changeset
|
499 (if (or (null language-name) |
65407fdc4a33
Delete defining "i" in mule-keymap.
Kenichi Handa <handa@m17n.org>
parents:
17840
diff
changeset
|
500 (null (get-language-info language-name 'setup-function))) |
65407fdc4a33
Delete defining "i" in mule-keymap.
Kenichi Handa <handa@m17n.org>
parents:
17840
diff
changeset
|
501 (error "No way to setup environment for the specified language")) |
65407fdc4a33
Delete defining "i" in mule-keymap.
Kenichi Handa <handa@m17n.org>
parents:
17840
diff
changeset
|
502 (let ((last-command-event (intern language-name))) |
65407fdc4a33
Delete defining "i" in mule-keymap.
Kenichi Handa <handa@m17n.org>
parents:
17840
diff
changeset
|
503 (setup-specified-language-environment))) |
17052 | 504 |
505 ;; Print all arguments with `princ', then print "\n". | |
506 (defsubst princ-list (&rest args) | |
507 (while args (princ (car args)) (setq args (cdr args))) | |
508 (princ "\n")) | |
509 | |
17840
2517414676ed
(set-language-info): Change the special treatment
Kenichi Handa <handa@m17n.org>
parents:
17758
diff
changeset
|
510 ;; Print a language specific information such as input methods, |
17758
8c67c2e2cc29
(build-describe-language-support-function,
Kenichi Handa <handa@m17n.org>
parents:
17526
diff
changeset
|
511 ;; charsets, and coding systems. This function is intended to be |
17840
2517414676ed
(set-language-info): Change the special treatment
Kenichi Handa <handa@m17n.org>
parents:
17758
diff
changeset
|
512 ;; called from the menu: |
18152
e184e7061c9a
(describe-language-environment):
Richard M. Stallman <rms@gnu.org>
parents:
18068
diff
changeset
|
513 ;; [menu-bar mule describe-language-environment LANGUAGE] |
17840
2517414676ed
(set-language-info): Change the special treatment
Kenichi Handa <handa@m17n.org>
parents:
17758
diff
changeset
|
514 ;; and should not run it by `M-x describe-current-input-method-function'. |
2517414676ed
(set-language-info): Change the special treatment
Kenichi Handa <handa@m17n.org>
parents:
17758
diff
changeset
|
515 (defun describe-specified-language-support () |
2517414676ed
(set-language-info): Change the special treatment
Kenichi Handa <handa@m17n.org>
parents:
17758
diff
changeset
|
516 "Describe how Emacs supports the specified langugage." |
2517414676ed
(set-language-info): Change the special treatment
Kenichi Handa <handa@m17n.org>
parents:
17758
diff
changeset
|
517 (interactive) |
18152
e184e7061c9a
(describe-language-environment):
Richard M. Stallman <rms@gnu.org>
parents:
18068
diff
changeset
|
518 (let (language-name) |
17840
2517414676ed
(set-language-info): Change the special treatment
Kenichi Handa <handa@m17n.org>
parents:
17758
diff
changeset
|
519 (if (not (and (symbolp last-command-event) |
18152
e184e7061c9a
(describe-language-environment):
Richard M. Stallman <rms@gnu.org>
parents:
18068
diff
changeset
|
520 (setq language-name (symbol-name last-command-event)))) |
17840
2517414676ed
(set-language-info): Change the special treatment
Kenichi Handa <handa@m17n.org>
parents:
17758
diff
changeset
|
521 (error "Bogus calling sequence")) |
18152
e184e7061c9a
(describe-language-environment):
Richard M. Stallman <rms@gnu.org>
parents:
18068
diff
changeset
|
522 (describe-language-environment language-name))) |
e184e7061c9a
(describe-language-environment):
Richard M. Stallman <rms@gnu.org>
parents:
18068
diff
changeset
|
523 |
e184e7061c9a
(describe-language-environment):
Richard M. Stallman <rms@gnu.org>
parents:
18068
diff
changeset
|
524 (defun describe-language-environment (language-name) |
e184e7061c9a
(describe-language-environment):
Richard M. Stallman <rms@gnu.org>
parents:
18068
diff
changeset
|
525 "Describe how Emacs supports language environment LANGUAGE-NAME." |
e184e7061c9a
(describe-language-environment):
Richard M. Stallman <rms@gnu.org>
parents:
18068
diff
changeset
|
526 (interactive (list (read-language-name 'documentation "Language: "))) |
e184e7061c9a
(describe-language-environment):
Richard M. Stallman <rms@gnu.org>
parents:
18068
diff
changeset
|
527 (if (or (null language-name) |
e184e7061c9a
(describe-language-environment):
Richard M. Stallman <rms@gnu.org>
parents:
18068
diff
changeset
|
528 (null (get-language-info language-name 'documentation))) |
e184e7061c9a
(describe-language-environment):
Richard M. Stallman <rms@gnu.org>
parents:
18068
diff
changeset
|
529 (error "No documentation for the specified language")) |
e184e7061c9a
(describe-language-environment):
Richard M. Stallman <rms@gnu.org>
parents:
18068
diff
changeset
|
530 (let ((doc (get-language-info language-name 'documentation))) |
17840
2517414676ed
(set-language-info): Change the special treatment
Kenichi Handa <handa@m17n.org>
parents:
17758
diff
changeset
|
531 (with-output-to-temp-buffer "*Help*" |
17758
8c67c2e2cc29
(build-describe-language-support-function,
Kenichi Handa <handa@m17n.org>
parents:
17526
diff
changeset
|
532 (if (stringp doc) |
17991
65407fdc4a33
Delete defining "i" in mule-keymap.
Kenichi Handa <handa@m17n.org>
parents:
17840
diff
changeset
|
533 (princ-list doc)) |
18152
e184e7061c9a
(describe-language-environment):
Richard M. Stallman <rms@gnu.org>
parents:
18068
diff
changeset
|
534 (terpri) |
17991
65407fdc4a33
Delete defining "i" in mule-keymap.
Kenichi Handa <handa@m17n.org>
parents:
17840
diff
changeset
|
535 (let ((str (get-language-info language-name 'sample-text))) |
65407fdc4a33
Delete defining "i" in mule-keymap.
Kenichi Handa <handa@m17n.org>
parents:
17840
diff
changeset
|
536 (if (stringp str) |
65407fdc4a33
Delete defining "i" in mule-keymap.
Kenichi Handa <handa@m17n.org>
parents:
17840
diff
changeset
|
537 (progn |
18152
e184e7061c9a
(describe-language-environment):
Richard M. Stallman <rms@gnu.org>
parents:
18068
diff
changeset
|
538 (princ "Sample text:\n") |
17991
65407fdc4a33
Delete defining "i" in mule-keymap.
Kenichi Handa <handa@m17n.org>
parents:
17840
diff
changeset
|
539 (princ-list " " str)))) |
18152
e184e7061c9a
(describe-language-environment):
Richard M. Stallman <rms@gnu.org>
parents:
18068
diff
changeset
|
540 (terpri) |
e184e7061c9a
(describe-language-environment):
Richard M. Stallman <rms@gnu.org>
parents:
18068
diff
changeset
|
541 (princ "Input methods:\n") |
17991
65407fdc4a33
Delete defining "i" in mule-keymap.
Kenichi Handa <handa@m17n.org>
parents:
17840
diff
changeset
|
542 (let ((l (get-language-info language-name 'input-method))) |
65407fdc4a33
Delete defining "i" in mule-keymap.
Kenichi Handa <handa@m17n.org>
parents:
17840
diff
changeset
|
543 (while l |
65407fdc4a33
Delete defining "i" in mule-keymap.
Kenichi Handa <handa@m17n.org>
parents:
17840
diff
changeset
|
544 (princ-list " " (car (car l))) |
65407fdc4a33
Delete defining "i" in mule-keymap.
Kenichi Handa <handa@m17n.org>
parents:
17840
diff
changeset
|
545 (setq l (cdr l)))) |
18152
e184e7061c9a
(describe-language-environment):
Richard M. Stallman <rms@gnu.org>
parents:
18068
diff
changeset
|
546 (terpri) |
e184e7061c9a
(describe-language-environment):
Richard M. Stallman <rms@gnu.org>
parents:
18068
diff
changeset
|
547 (princ "Character sets:\n") |
17991
65407fdc4a33
Delete defining "i" in mule-keymap.
Kenichi Handa <handa@m17n.org>
parents:
17840
diff
changeset
|
548 (let ((l (get-language-info language-name 'charset))) |
65407fdc4a33
Delete defining "i" in mule-keymap.
Kenichi Handa <handa@m17n.org>
parents:
17840
diff
changeset
|
549 (if (null l) |
65407fdc4a33
Delete defining "i" in mule-keymap.
Kenichi Handa <handa@m17n.org>
parents:
17840
diff
changeset
|
550 (princ-list " nothing specific to " language-name) |
17840
2517414676ed
(set-language-info): Change the special treatment
Kenichi Handa <handa@m17n.org>
parents:
17758
diff
changeset
|
551 (while l |
17991
65407fdc4a33
Delete defining "i" in mule-keymap.
Kenichi Handa <handa@m17n.org>
parents:
17840
diff
changeset
|
552 (princ-list " " (car l) ": " |
65407fdc4a33
Delete defining "i" in mule-keymap.
Kenichi Handa <handa@m17n.org>
parents:
17840
diff
changeset
|
553 (charset-description (car l))) |
65407fdc4a33
Delete defining "i" in mule-keymap.
Kenichi Handa <handa@m17n.org>
parents:
17840
diff
changeset
|
554 (setq l (cdr l))))) |
18152
e184e7061c9a
(describe-language-environment):
Richard M. Stallman <rms@gnu.org>
parents:
18068
diff
changeset
|
555 (terpri) |
e184e7061c9a
(describe-language-environment):
Richard M. Stallman <rms@gnu.org>
parents:
18068
diff
changeset
|
556 (princ "Coding systems:\n") |
17991
65407fdc4a33
Delete defining "i" in mule-keymap.
Kenichi Handa <handa@m17n.org>
parents:
17840
diff
changeset
|
557 (let ((l (get-language-info language-name 'coding-system))) |
65407fdc4a33
Delete defining "i" in mule-keymap.
Kenichi Handa <handa@m17n.org>
parents:
17840
diff
changeset
|
558 (if (null l) |
65407fdc4a33
Delete defining "i" in mule-keymap.
Kenichi Handa <handa@m17n.org>
parents:
17840
diff
changeset
|
559 (princ-list " nothing specific to " language-name) |
65407fdc4a33
Delete defining "i" in mule-keymap.
Kenichi Handa <handa@m17n.org>
parents:
17840
diff
changeset
|
560 (while l |
18152
e184e7061c9a
(describe-language-environment):
Richard M. Stallman <rms@gnu.org>
parents:
18068
diff
changeset
|
561 (princ (format " %s (`%c' in mode line):\n\t%s\n" |
e184e7061c9a
(describe-language-environment):
Richard M. Stallman <rms@gnu.org>
parents:
18068
diff
changeset
|
562 (car l) |
e184e7061c9a
(describe-language-environment):
Richard M. Stallman <rms@gnu.org>
parents:
18068
diff
changeset
|
563 (coding-system-mnemonic (car l)) |
18176
fc07ea29cd81
Define mouse-set-font in mule-menu-keymap.
Kenichi Handa <handa@m17n.org>
parents:
18152
diff
changeset
|
564 (coding-system-doc-string (car l)))) |
17991
65407fdc4a33
Delete defining "i" in mule-keymap.
Kenichi Handa <handa@m17n.org>
parents:
17840
diff
changeset
|
565 (setq l (cdr l)))))))) |
17052 | 566 |
567 ;;; Charset property | |
568 | |
569 (defsubst get-charset-property (charset propname) | |
570 "Return the value of CHARSET's PROPNAME property. | |
571 This is the last value stored with | |
572 `(put-charset-property CHARSET PROPNAME VALUE)'." | |
573 (plist-get (charset-plist charset) propname)) | |
574 | |
575 (defsubst put-charset-property (charset propname value) | |
576 "Store CHARSETS's PROPNAME property with value VALUE. | |
577 It can be retrieved with `(get-charset-property CHARSET PROPNAME)'." | |
578 (set-charset-plist charset | |
579 (plist-put (charset-plist charset) propname value))) | |
580 | |
581 ;;; Character code property | |
582 (put 'char-code-property-table 'char-table-extra-slots 0) | |
583 | |
584 (defvar char-code-property-table | |
585 (make-char-table 'char-code-property-table) | |
586 "Char-table containing a property list of each character code. | |
587 | |
588 See also the documentation of `get-char-code-property' and | |
589 `put-char-code-property'") | |
590 | |
591 (defun get-char-code-property (char propname) | |
592 "Return the value of CHAR's PROPNAME property in `char-code-property-table'." | |
593 (let ((plist (aref char-code-property-table char))) | |
594 (if (listp plist) | |
595 (car (cdr (memq propname plist)))))) | |
596 | |
597 (defun put-char-code-property (char propname value) | |
598 "Store CHAR's PROPNAME property with VALUE in `char-code-property-table'. | |
599 It can be retrieved with `(get-char-code-property CHAR PROPNAME)'." | |
600 (let ((plist (aref char-code-property-table char))) | |
601 (if plist | |
602 (let ((slot (memq propname plist))) | |
603 (if slot | |
604 (setcar (cdr slot) value) | |
605 (nconc plist (list propname value)))) | |
606 (aset char-code-property-table char (list propname value))))) | |
607 | |
608 ;;; mule-cmds.el ends here |