annotate lisp/international/mule-cmds.el @ 21038:9b33c6a5b4dc

(Vnonascii_translate_table, Qcharset): New variable decls. (Fstring_make_multibyte, Fstring_make_unibyte): New function decl. (Fstring_as_multibyte, Fstring_as_unibyte): New function decl. (list2, list3, list4, list5): New function decl. (Fwrite_region): Add an argument. (compare_window_configurations): New function decl.
author Richard M. Stallman <rms@gnu.org>
date Tue, 03 Mar 1998 01:31:11 +0000
parents 588dae3ae7cc
children b6530c2add6a
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1 ;;; mule-cmds.el --- Commands for mulitilingual environment
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3 ;; Copyright (C) 1995 Electrotechnical Laboratory, JAPAN.
18377
8b4a66c66dd6 Change copyright notice.
Richard M. Stallman <rms@gnu.org>
parents: 18351
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 ;; Keywords: mule, multilingual
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
7
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
8 ;; This file is part of GNU Emacs.
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
9
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
10 ;; GNU Emacs is free software; you can redistribute it and/or modify
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
11 ;; it under the terms of the GNU General Public License as published by
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
12 ;; the Free Software Foundation; either version 2, or (at your option)
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
13 ;; any later version.
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
14
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
15 ;; GNU Emacs is distributed in the hope that it will be useful,
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
16 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
17 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
18 ;; GNU General Public License for more details.
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
19
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
20 ;; 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
21 ;; 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
22 ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
70194012fb3a Fix FSF address in comment.
Karl Heuer <kwzh@gnu.org>
parents: 17052
diff changeset
23 ;; Boston, MA 02111-1307, USA.
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
24
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
25 ;;; Code:
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
26
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
27 ;;; MULE related key bindings and menus.
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
28
19725
1b5169b9c5be (mule-menu-keymap):
Richard M. Stallman <rms@gnu.org>
parents: 19673
diff changeset
29 (defvar mule-keymap (make-sparse-keymap)
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
30 "Keymap for MULE (Multilingual environment) specific commands.")
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
31
17294
d7ae63db9e6e Prefix for Mule related commands is changed.
Kenichi Handa <handa@m17n.org>
parents: 17090
diff changeset
32 ;; Keep "C-x C-m ..." for mule specific commands.
19725
1b5169b9c5be (mule-menu-keymap):
Richard M. Stallman <rms@gnu.org>
parents: 19673
diff changeset
33 (define-key ctl-x-map "\C-m" mule-keymap)
17090
8085a8690c87 (mule-keymap): Re-arranged.
Kenichi Handa <handa@m17n.org>
parents: 17071
diff changeset
34
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
35 (define-key mule-keymap "f" 'set-buffer-file-coding-system)
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
36 (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
37 (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
38 (define-key mule-keymap "p" 'set-buffer-process-coding-system)
20295
27ae44142cfd (set-input-method): Renamed from select-input-method.
Karl Heuer <kwzh@gnu.org>
parents: 20231
diff changeset
39 (define-key mule-keymap "\C-\\" 'set-input-method)
17991
65407fdc4a33 Delete defining "i" in mule-keymap.
Kenichi Handa <handa@m17n.org>
parents: 17840
diff changeset
40 (define-key mule-keymap "c" 'universal-coding-system-argument)
18801
f60dbf4f7d7c (mule-keymap): Bind l to set-language-environment.
Kenichi Handa <handa@m17n.org>
parents: 18712
diff changeset
41 (define-key mule-keymap "l" 'set-language-environment)
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
42
18152
e184e7061c9a (describe-language-environment):
Richard M. Stallman <rms@gnu.org>
parents: 18068
diff changeset
43 (define-key help-map "\C-L" 'describe-language-environment)
18633
c8cbbd038612 (help-map): Bind I to describe-input-method.
Richard M. Stallman <rms@gnu.org>
parents: 18377
diff changeset
44 (define-key help-map "L" 'describe-language-environment)
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
45 (define-key help-map "\C-\\" 'describe-input-method)
18633
c8cbbd038612 (help-map): Bind I to describe-input-method.
Richard M. Stallman <rms@gnu.org>
parents: 18377
diff changeset
46 (define-key help-map "I" 'describe-input-method)
18301
a4da36c7bb08 Define describe-coding-system instead of
Kenichi Handa <handa@m17n.org>
parents: 18217
diff changeset
47 (define-key help-map "C" 'describe-coding-system)
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
48 (define-key help-map "h" 'view-hello-file)
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
49
19725
1b5169b9c5be (mule-menu-keymap):
Richard M. Stallman <rms@gnu.org>
parents: 19673
diff changeset
50 (defvar mule-menu-keymap (make-sparse-keymap "Mule")
17991
65407fdc4a33 Delete defining "i" in mule-keymap.
Kenichi Handa <handa@m17n.org>
parents: 17840
diff changeset
51 "Keymap for MULE (Multilingual environment) menu specific commands.")
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
18152
e184e7061c9a (describe-language-environment):
Richard M. Stallman <rms@gnu.org>
parents: 18068
diff changeset
66 (define-key-after mule-menu-keymap [describe-language-environment]
19036
6ed970c33b7d (mule-menu-keymap): Fix menu item names.
Richard M. Stallman <rms@gnu.org>
parents: 18982
diff changeset
67 '("Describe Language Environment" . describe-language-environment-map)
17991
65407fdc4a33 Delete defining "i" in mule-keymap.
Kenichi Handa <handa@m17n.org>
parents: 17840
diff changeset
68 t)
65407fdc4a33 Delete defining "i" in mule-keymap.
Kenichi Handa <handa@m17n.org>
parents: 17840
diff changeset
69 (define-key-after mule-menu-keymap [set-language-environment]
19036
6ed970c33b7d (mule-menu-keymap): Fix menu item names.
Richard M. Stallman <rms@gnu.org>
parents: 18982
diff changeset
70 '("Set Language Environment" . setup-language-environment-map)
17991
65407fdc4a33 Delete defining "i" in mule-keymap.
Kenichi Handa <handa@m17n.org>
parents: 17840
diff changeset
71 t)
18351
8cc30b266976 Define mouse-set-font in mule-menu-keymap agian.
Kenichi Handa <handa@m17n.org>
parents: 18301
diff changeset
72 (define-key-after mule-menu-keymap [mouse-set-font]
19036
6ed970c33b7d (mule-menu-keymap): Fix menu item names.
Richard M. Stallman <rms@gnu.org>
parents: 18982
diff changeset
73 '("Set Font/Fontset" . mouse-set-font)
18351
8cc30b266976 Define mouse-set-font in mule-menu-keymap agian.
Kenichi Handa <handa@m17n.org>
parents: 18301
diff changeset
74 t)
17991
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]
19036
6ed970c33b7d (mule-menu-keymap): Fix menu item names.
Richard M. Stallman <rms@gnu.org>
parents: 18982
diff changeset
79 '("Toggle Input Method" . toggle-input-method)
17991
65407fdc4a33 Delete defining "i" in mule-keymap.
Kenichi Handa <handa@m17n.org>
parents: 17840
diff changeset
80 t)
20295
27ae44142cfd (set-input-method): Renamed from select-input-method.
Karl Heuer <kwzh@gnu.org>
parents: 20231
diff changeset
81 (define-key-after mule-menu-keymap [set-input-method]
27ae44142cfd (set-input-method): Renamed from select-input-method.
Karl Heuer <kwzh@gnu.org>
parents: 20231
diff changeset
82 '("Select Input Method" . set-input-method)
17991
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]
19036
6ed970c33b7d (mule-menu-keymap): Fix menu item names.
Richard M. Stallman <rms@gnu.org>
parents: 18982
diff changeset
85 '("Describe Input Method" . describe-input-method)
17991
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)
18301
a4da36c7bb08 Define describe-coding-system instead of
Kenichi Handa <handa@m17n.org>
parents: 18217
diff changeset
90 (define-key-after mule-menu-keymap [describe-coding-system]
19036
6ed970c33b7d (mule-menu-keymap): Fix menu item names.
Richard M. Stallman <rms@gnu.org>
parents: 18982
diff changeset
91 '("Describe Coding Systems" . describe-coding-system)
17991
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]
19036
6ed970c33b7d (mule-menu-keymap): Fix menu item names.
Richard M. Stallman <rms@gnu.org>
parents: 18982
diff changeset
94 '("Set Coding System" . set-coding-system-map)
17991
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]
19036
6ed970c33b7d (mule-menu-keymap): Fix menu item names.
Richard M. Stallman <rms@gnu.org>
parents: 18982
diff changeset
100 '("Show All of MULE Status" . mule-diag)
17991
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]
19036
6ed970c33b7d (mule-menu-keymap): Fix menu item names.
Richard M. Stallman <rms@gnu.org>
parents: 18982
diff changeset
103 '("Show Script Examples" . view-hello-file)
17991
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]
19036
6ed970c33b7d (mule-menu-keymap): Fix menu item names.
Richard M. Stallman <rms@gnu.org>
parents: 18982
diff changeset
107 '("Buffer File" . set-buffer-file-coding-system)
17991
65407fdc4a33 Delete defining "i" in mule-keymap.
Kenichi Handa <handa@m17n.org>
parents: 17840
diff changeset
108 t)
19673
da7f50da6773 (set-coding-system-map):
Richard M. Stallman <rms@gnu.org>
parents: 19654
diff changeset
109 (define-key-after set-coding-system-map [universal-coding-system-argument]
da7f50da6773 (set-coding-system-map):
Richard M. Stallman <rms@gnu.org>
parents: 19654
diff changeset
110 '("Next Command" . universal-coding-system-argument)
da7f50da6773 (set-coding-system-map):
Richard M. Stallman <rms@gnu.org>
parents: 19654
diff changeset
111 t)
17991
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-terminal-coding-system]
65407fdc4a33 Delete defining "i" in mule-keymap.
Kenichi Handa <handa@m17n.org>
parents: 17840
diff changeset
113 '("Terminal" . set-terminal-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-keyboard-coding-system]
65407fdc4a33 Delete defining "i" in mule-keymap.
Kenichi Handa <handa@m17n.org>
parents: 17840
diff changeset
116 '("Keyboard" . set-keyboard-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 (define-key-after set-coding-system-map [set-buffer-process-coding-system]
19036
6ed970c33b7d (mule-menu-keymap): Fix menu item names.
Richard M. Stallman <rms@gnu.org>
parents: 18982
diff changeset
119 '("Buffer Process" . set-buffer-process-coding-system)
17991
65407fdc4a33 Delete defining "i" in mule-keymap.
Kenichi Handa <handa@m17n.org>
parents: 17840
diff changeset
120 t)
65407fdc4a33 Delete defining "i" in mule-keymap.
Kenichi Handa <handa@m17n.org>
parents: 17840
diff changeset
121
65407fdc4a33 Delete defining "i" in mule-keymap.
Kenichi Handa <handa@m17n.org>
parents: 17840
diff changeset
122 (define-key setup-language-environment-map
65407fdc4a33 Delete defining "i" in mule-keymap.
Kenichi Handa <handa@m17n.org>
parents: 17840
diff changeset
123 [Default] '("Default" . setup-specified-language-environment))
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
124
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
125 ;; These are meaningless when running under X.
17991
65407fdc4a33 Delete defining "i" in mule-keymap.
Kenichi Handa <handa@m17n.org>
parents: 17840
diff changeset
126 (put 'set-terminal-coding-system 'menu-enable
19614
a0db11a32775 (set-terminal-coding-system):
Richard M. Stallman <rms@gnu.org>
parents: 19555
diff changeset
127 '(not (eq window-system 'x)))
17991
65407fdc4a33 Delete defining "i" in mule-keymap.
Kenichi Handa <handa@m17n.org>
parents: 17840
diff changeset
128 (put 'set-keyboard-coding-system 'menu-enable
19614
a0db11a32775 (set-terminal-coding-system):
Richard M. Stallman <rms@gnu.org>
parents: 19555
diff changeset
129 '(not (eq window-system 'x)))
18301
a4da36c7bb08 Define describe-coding-system instead of
Kenichi Handa <handa@m17n.org>
parents: 18217
diff changeset
130 ;; This is meaningless when the current buffer has no process.
a4da36c7bb08 Define describe-coding-system instead of
Kenichi Handa <handa@m17n.org>
parents: 18217
diff changeset
131 (put 'set-buffer-process-coding-system 'menu-enable
a4da36c7bb08 Define describe-coding-system instead of
Kenichi Handa <handa@m17n.org>
parents: 18217
diff changeset
132 '(get-buffer-process (current-buffer)))
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
133
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
134 ;; This should be a single character key binding because users use it
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
135 ;; very frequently while editing multilingual text. Now we can use
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
136 ;; only two such keys: "\C-\\" and "\C-^", but the latter is not
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
137 ;; convenient because it requires shifting on most keyboards. An
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
138 ;; alternative is "\C-\]" which is now bound to `abort-recursive-edit'
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
139 ;; but it won't be used that frequently.
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
140 (define-key global-map "\C-\\" 'toggle-input-method)
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
141
18807
75b2e402c45d (global-map): Turn off the S-SPC binding.
Richard M. Stallman <rms@gnu.org>
parents: 18801
diff changeset
142 ;;; This is no good because people often type Shift-SPC
75b2e402c45d (global-map): Turn off the S-SPC binding.
Richard M. Stallman <rms@gnu.org>
parents: 18801
diff changeset
143 ;;; meaning to type SPC. -- rms.
75b2e402c45d (global-map): Turn off the S-SPC binding.
Richard M. Stallman <rms@gnu.org>
parents: 18801
diff changeset
144 ;;; ;; Here's an alternative key binding for X users (Shift-SPACE).
75b2e402c45d (global-map): Turn off the S-SPC binding.
Richard M. Stallman <rms@gnu.org>
parents: 18801
diff changeset
145 ;;; (define-key global-map [?\S- ] 'toggle-input-method)
18801
f60dbf4f7d7c (mule-keymap): Bind l to set-language-environment.
Kenichi Handa <handa@m17n.org>
parents: 18712
diff changeset
146
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
147 (defun toggle-enable-multibyte-characters (&optional arg)
20483
141c2d41d39c (toggle-enable-multibyte-characters): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents: 20467
diff changeset
148 "Change whether this buffer uses multibyte characters.
141c2d41d39c (toggle-enable-multibyte-characters): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents: 20467
diff changeset
149 With arg, use multibyte characters if the arg is positive.
141c2d41d39c (toggle-enable-multibyte-characters): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents: 20467
diff changeset
150
141c2d41d39c (toggle-enable-multibyte-characters): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents: 20467
diff changeset
151 Note that this command does not convert the byte contents of
141c2d41d39c (toggle-enable-multibyte-characters): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents: 20467
diff changeset
152 the buffer; it only changes the way those bytes are interpreted.
141c2d41d39c (toggle-enable-multibyte-characters): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents: 20467
diff changeset
153 In general, therefore, this command *changes* the sequence of
141c2d41d39c (toggle-enable-multibyte-characters): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents: 20467
diff changeset
154 characters that the current buffer contains.
141c2d41d39c (toggle-enable-multibyte-characters): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents: 20467
diff changeset
155
141c2d41d39c (toggle-enable-multibyte-characters): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents: 20467
diff changeset
156 We suggest you avoid using use this command unless you know what you
141c2d41d39c (toggle-enable-multibyte-characters): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents: 20467
diff changeset
157 are doing. If you use it by mistake, and the buffer is now displayed
141c2d41d39c (toggle-enable-multibyte-characters): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents: 20467
diff changeset
158 wrong, use this command again to toggle back to the right mode."
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
159 (interactive "P")
20830
237a0f70c61d (toggle-enable-multibyte-characters): Use set-buffer-multibyte.
Richard M. Stallman <rms@gnu.org>
parents: 20733
diff changeset
160 (let ((new-flag
237a0f70c61d (toggle-enable-multibyte-characters): Use set-buffer-multibyte.
Richard M. Stallman <rms@gnu.org>
parents: 20733
diff changeset
161 (if (null arg) (null enable-multibyte-characters)
237a0f70c61d (toggle-enable-multibyte-characters): Use set-buffer-multibyte.
Richard M. Stallman <rms@gnu.org>
parents: 20733
diff changeset
162 (> (prefix-numeric-value arg) 0))))
237a0f70c61d (toggle-enable-multibyte-characters): Use set-buffer-multibyte.
Richard M. Stallman <rms@gnu.org>
parents: 20733
diff changeset
163 (set-buffer-multibyte new-flag))
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
164 (force-mode-line-update))
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
165
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
166 (defun view-hello-file ()
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
167 "Display the HELLO file which list up many languages and characters."
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
168 (interactive)
17294
d7ae63db9e6e Prefix for Mule related commands is changed.
Kenichi Handa <handa@m17n.org>
parents: 17090
diff changeset
169 ;; 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
170 (let ((default-enable-multibyte-characters t)
18217
13a240aa1960 (view-hello-file): Adjusted for the changes of
Kenichi Handa <handa@m17n.org>
parents: 18176
diff changeset
171 (coding-system-for-read 'iso-2022-7bit))
17294
d7ae63db9e6e Prefix for Mule related commands is changed.
Kenichi Handa <handa@m17n.org>
parents: 17090
diff changeset
172 (find-file-read-only (expand-file-name "HELLO" data-directory))))
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
173
17991
65407fdc4a33 Delete defining "i" in mule-keymap.
Kenichi Handa <handa@m17n.org>
parents: 17840
diff changeset
174 (defun universal-coding-system-argument ()
65407fdc4a33 Delete defining "i" in mule-keymap.
Kenichi Handa <handa@m17n.org>
parents: 17840
diff changeset
175 "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
176 (interactive)
19798
054497f70932 (universal-coding-system-argument): Improve prompt strings.
Richard M. Stallman <rms@gnu.org>
parents: 19784
diff changeset
177 (let* ((coding-system (read-coding-system "Coding system for following command: "))
17991
65407fdc4a33 Delete defining "i" in mule-keymap.
Kenichi Handa <handa@m17n.org>
parents: 17840
diff changeset
178 (keyseq (read-key-sequence
19798
054497f70932 (universal-coding-system-argument): Improve prompt strings.
Richard M. Stallman <rms@gnu.org>
parents: 19784
diff changeset
179 (format "Command to execute with %s:" coding-system)))
17991
65407fdc4a33 Delete defining "i" in mule-keymap.
Kenichi Handa <handa@m17n.org>
parents: 17840
diff changeset
180 (cmd (key-binding keyseq)))
65407fdc4a33 Delete defining "i" in mule-keymap.
Kenichi Handa <handa@m17n.org>
parents: 17840
diff changeset
181 (let ((coding-system-for-read coding-system)
65407fdc4a33 Delete defining "i" in mule-keymap.
Kenichi Handa <handa@m17n.org>
parents: 17840
diff changeset
182 (coding-system-for-write coding-system))
65407fdc4a33 Delete defining "i" in mule-keymap.
Kenichi Handa <handa@m17n.org>
parents: 17840
diff changeset
183 (message "")
65407fdc4a33 Delete defining "i" in mule-keymap.
Kenichi Handa <handa@m17n.org>
parents: 17840
diff changeset
184 (call-interactively cmd))))
65407fdc4a33 Delete defining "i" in mule-keymap.
Kenichi Handa <handa@m17n.org>
parents: 17840
diff changeset
185
19141
9e0468e59b5f (set-default-coding-systems): New function.
Kenichi Handa <handa@m17n.org>
parents: 19083
diff changeset
186 (defun set-default-coding-systems (coding-system)
19267
6e152439176f (set-default-coding-systems):
Kenichi Handa <handa@m17n.org>
parents: 19141
diff changeset
187 "Set default value of various coding systems to CODING-SYSTEM.
20165
2d0abf12009b (set-default-coding-systems):
Kenichi Handa <handa@m17n.org>
parents: 20116
diff changeset
188 This sets the follwing coding systems:
19267
6e152439176f (set-default-coding-systems):
Kenichi Handa <handa@m17n.org>
parents: 19141
diff changeset
189 o coding system of a newly created buffer
20165
2d0abf12009b (set-default-coding-systems):
Kenichi Handa <handa@m17n.org>
parents: 20116
diff changeset
190 o default coding system for subprocess I/O
2d0abf12009b (set-default-coding-systems):
Kenichi Handa <handa@m17n.org>
parents: 20116
diff changeset
191 This also sets the following values:
2d0abf12009b (set-default-coding-systems):
Kenichi Handa <handa@m17n.org>
parents: 20116
diff changeset
192 o default value for the command `set-terminal-coding-system'
2d0abf12009b (set-default-coding-systems):
Kenichi Handa <handa@m17n.org>
parents: 20116
diff changeset
193 o default value for the command `set-keyboard-coding-system'"
19141
9e0468e59b5f (set-default-coding-systems): New function.
Kenichi Handa <handa@m17n.org>
parents: 19083
diff changeset
194 (check-coding-system coding-system)
9e0468e59b5f (set-default-coding-systems): New function.
Kenichi Handa <handa@m17n.org>
parents: 19083
diff changeset
195 (setq-default buffer-file-coding-system coding-system)
9e0468e59b5f (set-default-coding-systems): New function.
Kenichi Handa <handa@m17n.org>
parents: 19083
diff changeset
196 (setq default-terminal-coding-system coding-system)
9e0468e59b5f (set-default-coding-systems): New function.
Kenichi Handa <handa@m17n.org>
parents: 19083
diff changeset
197 (setq default-keyboard-coding-system coding-system)
9e0468e59b5f (set-default-coding-systems): New function.
Kenichi Handa <handa@m17n.org>
parents: 19083
diff changeset
198 (setq default-process-coding-system (cons coding-system coding-system)))
9e0468e59b5f (set-default-coding-systems): New function.
Kenichi Handa <handa@m17n.org>
parents: 19083
diff changeset
199
19267
6e152439176f (set-default-coding-systems):
Kenichi Handa <handa@m17n.org>
parents: 19141
diff changeset
200 (defun prefer-coding-system (coding-system)
6e152439176f (set-default-coding-systems):
Kenichi Handa <handa@m17n.org>
parents: 19141
diff changeset
201 "Add CODING-SYSTEM at the front of the priority list for automatic detection.
20165
2d0abf12009b (set-default-coding-systems):
Kenichi Handa <handa@m17n.org>
parents: 20116
diff changeset
202 This also sets the follwing coding systems:
19267
6e152439176f (set-default-coding-systems):
Kenichi Handa <handa@m17n.org>
parents: 19141
diff changeset
203 o coding system of a newly created buffer
20165
2d0abf12009b (set-default-coding-systems):
Kenichi Handa <handa@m17n.org>
parents: 20116
diff changeset
204 o default coding system for subprocess I/O
2d0abf12009b (set-default-coding-systems):
Kenichi Handa <handa@m17n.org>
parents: 20116
diff changeset
205 This also sets the following values:
2d0abf12009b (set-default-coding-systems):
Kenichi Handa <handa@m17n.org>
parents: 20116
diff changeset
206 o default value for the command `set-terminal-coding-system'
2d0abf12009b (set-default-coding-systems):
Kenichi Handa <handa@m17n.org>
parents: 20116
diff changeset
207 o default value for the command `set-keyboard-coding-system'"
19267
6e152439176f (set-default-coding-systems):
Kenichi Handa <handa@m17n.org>
parents: 19141
diff changeset
208 (interactive "zPrefer coding system: ")
6e152439176f (set-default-coding-systems):
Kenichi Handa <handa@m17n.org>
parents: 19141
diff changeset
209 (if (not (and coding-system (coding-system-p coding-system)))
6e152439176f (set-default-coding-systems):
Kenichi Handa <handa@m17n.org>
parents: 19141
diff changeset
210 (error "Invalid coding system `%s'" coding-system))
6e152439176f (set-default-coding-systems):
Kenichi Handa <handa@m17n.org>
parents: 19141
diff changeset
211 (let ((coding-category (coding-system-category coding-system))
20165
2d0abf12009b (set-default-coding-systems):
Kenichi Handa <handa@m17n.org>
parents: 20116
diff changeset
212 (base (coding-system-base coding-system)))
19267
6e152439176f (set-default-coding-systems):
Kenichi Handa <handa@m17n.org>
parents: 19141
diff changeset
213 (if (not coding-category)
6e152439176f (set-default-coding-systems):
Kenichi Handa <handa@m17n.org>
parents: 19141
diff changeset
214 ;; CODING-SYSTEM is no-conversion or undecided.
6e152439176f (set-default-coding-systems):
Kenichi Handa <handa@m17n.org>
parents: 19141
diff changeset
215 (error "Can't prefer the coding system `%s'" coding-system))
20165
2d0abf12009b (set-default-coding-systems):
Kenichi Handa <handa@m17n.org>
parents: 20116
diff changeset
216 (set coding-category (or base coding-system))
20733
079907c59fb2 (set-language-info): Doc-string
Kenichi Handa <handa@m17n.org>
parents: 20485
diff changeset
217 (update-iso-coding-systems)
19267
6e152439176f (set-default-coding-systems):
Kenichi Handa <handa@m17n.org>
parents: 19141
diff changeset
218 (if (not (eq coding-category (car coding-category-list)))
6e152439176f (set-default-coding-systems):
Kenichi Handa <handa@m17n.org>
parents: 19141
diff changeset
219 ;; We must change the order.
6e152439176f (set-default-coding-systems):
Kenichi Handa <handa@m17n.org>
parents: 19141
diff changeset
220 (setq coding-category-list
6e152439176f (set-default-coding-systems):
Kenichi Handa <handa@m17n.org>
parents: 19141
diff changeset
221 (cons coding-category
6e152439176f (set-default-coding-systems):
Kenichi Handa <handa@m17n.org>
parents: 19141
diff changeset
222 (delq coding-category coding-category-list))))
20165
2d0abf12009b (set-default-coding-systems):
Kenichi Handa <handa@m17n.org>
parents: 20116
diff changeset
223 (if (and base (interactive-p))
2d0abf12009b (set-default-coding-systems):
Kenichi Handa <handa@m17n.org>
parents: 20116
diff changeset
224 (message "Highest priority is set to %s (base of %s)"
2d0abf12009b (set-default-coding-systems):
Kenichi Handa <handa@m17n.org>
parents: 20116
diff changeset
225 base coding-system))
2d0abf12009b (set-default-coding-systems):
Kenichi Handa <handa@m17n.org>
parents: 20116
diff changeset
226 (set-default-coding-systems (or base coding-system))))
19267
6e152439176f (set-default-coding-systems):
Kenichi Handa <handa@m17n.org>
parents: 19141
diff changeset
227
20830
237a0f70c61d (toggle-enable-multibyte-characters): Use set-buffer-multibyte.
Richard M. Stallman <rms@gnu.org>
parents: 20733
diff changeset
228 (defun find-safe-coding-system-list-subset-p (list1 list2)
20733
079907c59fb2 (set-language-info): Doc-string
Kenichi Handa <handa@m17n.org>
parents: 20485
diff changeset
229 "Return non-nil if all elements in LIST1 are included in LIST2.
079907c59fb2 (set-language-info): Doc-string
Kenichi Handa <handa@m17n.org>
parents: 20485
diff changeset
230 Comparison done with EQ."
079907c59fb2 (set-language-info): Doc-string
Kenichi Handa <handa@m17n.org>
parents: 20485
diff changeset
231 (catch 'tag
079907c59fb2 (set-language-info): Doc-string
Kenichi Handa <handa@m17n.org>
parents: 20485
diff changeset
232 (while list1
079907c59fb2 (set-language-info): Doc-string
Kenichi Handa <handa@m17n.org>
parents: 20485
diff changeset
233 (or (memq (car list1) list2)
079907c59fb2 (set-language-info): Doc-string
Kenichi Handa <handa@m17n.org>
parents: 20485
diff changeset
234 (throw 'tag nil))
079907c59fb2 (set-language-info): Doc-string
Kenichi Handa <handa@m17n.org>
parents: 20485
diff changeset
235 (setq list1 (cdr list1)))
079907c59fb2 (set-language-info): Doc-string
Kenichi Handa <handa@m17n.org>
parents: 20485
diff changeset
236 t))
079907c59fb2 (set-language-info): Doc-string
Kenichi Handa <handa@m17n.org>
parents: 20485
diff changeset
237
079907c59fb2 (set-language-info): Doc-string
Kenichi Handa <handa@m17n.org>
parents: 20485
diff changeset
238 (defun find-safe-coding-system (from to)
079907c59fb2 (set-language-info): Doc-string
Kenichi Handa <handa@m17n.org>
parents: 20485
diff changeset
239 "Return a list of proper coding systems to encode a text between FROM and TO.
079907c59fb2 (set-language-info): Doc-string
Kenichi Handa <handa@m17n.org>
parents: 20485
diff changeset
240 All coding systems in the list can safely encode any multibyte characters
079907c59fb2 (set-language-info): Doc-string
Kenichi Handa <handa@m17n.org>
parents: 20485
diff changeset
241 in the text.
079907c59fb2 (set-language-info): Doc-string
Kenichi Handa <handa@m17n.org>
parents: 20485
diff changeset
242
079907c59fb2 (set-language-info): Doc-string
Kenichi Handa <handa@m17n.org>
parents: 20485
diff changeset
243 If the text contains no multibyte charcters, return a list of a single
079907c59fb2 (set-language-info): Doc-string
Kenichi Handa <handa@m17n.org>
parents: 20485
diff changeset
244 element `undecided'.
079907c59fb2 (set-language-info): Doc-string
Kenichi Handa <handa@m17n.org>
parents: 20485
diff changeset
245
079907c59fb2 (set-language-info): Doc-string
Kenichi Handa <handa@m17n.org>
parents: 20485
diff changeset
246 Kludgy feature: if FROM is a string, the string is the target text,
079907c59fb2 (set-language-info): Doc-string
Kenichi Handa <handa@m17n.org>
parents: 20485
diff changeset
247 and TO is ignored."
079907c59fb2 (set-language-info): Doc-string
Kenichi Handa <handa@m17n.org>
parents: 20485
diff changeset
248 (let ((charset-list (if (stringp from) (find-charset-string from)
079907c59fb2 (set-language-info): Doc-string
Kenichi Handa <handa@m17n.org>
parents: 20485
diff changeset
249 (find-charset-region from to))))
20842
428831a6f4d1 (find-safe-coding-system): Return
Kenichi Handa <handa@m17n.org>
parents: 20830
diff changeset
250 (if (or (null charset-list)
428831a6f4d1 (find-safe-coding-system): Return
Kenichi Handa <handa@m17n.org>
parents: 20830
diff changeset
251 (and (= (length charset-list) 1)
428831a6f4d1 (find-safe-coding-system): Return
Kenichi Handa <handa@m17n.org>
parents: 20830
diff changeset
252 (eq 'ascii (car charset-list))))
20733
079907c59fb2 (set-language-info): Doc-string
Kenichi Handa <handa@m17n.org>
parents: 20485
diff changeset
253 '(undecided)
079907c59fb2 (set-language-info): Doc-string
Kenichi Handa <handa@m17n.org>
parents: 20485
diff changeset
254 (let ((l coding-system-list)
079907c59fb2 (set-language-info): Doc-string
Kenichi Handa <handa@m17n.org>
parents: 20485
diff changeset
255 (prefered-codings
079907c59fb2 (set-language-info): Doc-string
Kenichi Handa <handa@m17n.org>
parents: 20485
diff changeset
256 (mapcar (function
079907c59fb2 (set-language-info): Doc-string
Kenichi Handa <handa@m17n.org>
parents: 20485
diff changeset
257 (lambda (x)
079907c59fb2 (set-language-info): Doc-string
Kenichi Handa <handa@m17n.org>
parents: 20485
diff changeset
258 (get-charset-property x 'prefered-coding-system)))
079907c59fb2 (set-language-info): Doc-string
Kenichi Handa <handa@m17n.org>
parents: 20485
diff changeset
259 charset-list))
079907c59fb2 (set-language-info): Doc-string
Kenichi Handa <handa@m17n.org>
parents: 20485
diff changeset
260 codings coding safe)
079907c59fb2 (set-language-info): Doc-string
Kenichi Handa <handa@m17n.org>
parents: 20485
diff changeset
261 (while l
079907c59fb2 (set-language-info): Doc-string
Kenichi Handa <handa@m17n.org>
parents: 20485
diff changeset
262 (setq coding (car l) l (cdr l))
079907c59fb2 (set-language-info): Doc-string
Kenichi Handa <handa@m17n.org>
parents: 20485
diff changeset
263 (if (and (eq coding (coding-system-base coding))
079907c59fb2 (set-language-info): Doc-string
Kenichi Handa <handa@m17n.org>
parents: 20485
diff changeset
264 (setq safe (coding-system-get coding 'safe-charsets))
079907c59fb2 (set-language-info): Doc-string
Kenichi Handa <handa@m17n.org>
parents: 20485
diff changeset
265 (or (eq safe t)
20830
237a0f70c61d (toggle-enable-multibyte-characters): Use set-buffer-multibyte.
Richard M. Stallman <rms@gnu.org>
parents: 20733
diff changeset
266 (find-safe-coding-system-list-subset-p
237a0f70c61d (toggle-enable-multibyte-characters): Use set-buffer-multibyte.
Richard M. Stallman <rms@gnu.org>
parents: 20733
diff changeset
267 charset-list safe)))
20733
079907c59fb2 (set-language-info): Doc-string
Kenichi Handa <handa@m17n.org>
parents: 20485
diff changeset
268 ;; We put the higher priority to coding systems included
079907c59fb2 (set-language-info): Doc-string
Kenichi Handa <handa@m17n.org>
parents: 20485
diff changeset
269 ;; in PREFERED-CODINGS, and within them, put the higher
079907c59fb2 (set-language-info): Doc-string
Kenichi Handa <handa@m17n.org>
parents: 20485
diff changeset
270 ;; priority to coding systems which support smaller
079907c59fb2 (set-language-info): Doc-string
Kenichi Handa <handa@m17n.org>
parents: 20485
diff changeset
271 ;; number of charsets.
079907c59fb2 (set-language-info): Doc-string
Kenichi Handa <handa@m17n.org>
parents: 20485
diff changeset
272 (let ((priority
079907c59fb2 (set-language-info): Doc-string
Kenichi Handa <handa@m17n.org>
parents: 20485
diff changeset
273 (logior (if (coding-system-get coding 'mime-charset)
079907c59fb2 (set-language-info): Doc-string
Kenichi Handa <handa@m17n.org>
parents: 20485
diff changeset
274 256 0)
079907c59fb2 (set-language-info): Doc-string
Kenichi Handa <handa@m17n.org>
parents: 20485
diff changeset
275 (if (memq coding prefered-codings) 128 0)
079907c59fb2 (set-language-info): Doc-string
Kenichi Handa <handa@m17n.org>
parents: 20485
diff changeset
276 (if (> (coding-system-type coding) 0) 64 0)
079907c59fb2 (set-language-info): Doc-string
Kenichi Handa <handa@m17n.org>
parents: 20485
diff changeset
277 (if (consp safe) (- 64 (length safe)) 0))))
079907c59fb2 (set-language-info): Doc-string
Kenichi Handa <handa@m17n.org>
parents: 20485
diff changeset
278 (setq codings (cons (cons priority coding) codings)))))
079907c59fb2 (set-language-info): Doc-string
Kenichi Handa <handa@m17n.org>
parents: 20485
diff changeset
279 (mapcar 'cdr
079907c59fb2 (set-language-info): Doc-string
Kenichi Handa <handa@m17n.org>
parents: 20485
diff changeset
280 (sort codings (function (lambda (x y) (> (car x) (car y))))))
079907c59fb2 (set-language-info): Doc-string
Kenichi Handa <handa@m17n.org>
parents: 20485
diff changeset
281 ))))
079907c59fb2 (set-language-info): Doc-string
Kenichi Handa <handa@m17n.org>
parents: 20485
diff changeset
282
079907c59fb2 (set-language-info): Doc-string
Kenichi Handa <handa@m17n.org>
parents: 20485
diff changeset
283 (defun select-safe-coding-system (from to &optional default-coding-system)
20842
428831a6f4d1 (find-safe-coding-system): Return
Kenichi Handa <handa@m17n.org>
parents: 20830
diff changeset
284 "Ask a user to select a safe coding system from candidates.
428831a6f4d1 (find-safe-coding-system): Return
Kenichi Handa <handa@m17n.org>
parents: 20830
diff changeset
285 The candidates of coding systems which can safely encode a text
428831a6f4d1 (find-safe-coding-system): Return
Kenichi Handa <handa@m17n.org>
parents: 20830
diff changeset
286 between FROM and TO are shown in a popup window.
20733
079907c59fb2 (set-language-info): Doc-string
Kenichi Handa <handa@m17n.org>
parents: 20485
diff changeset
287
079907c59fb2 (set-language-info): Doc-string
Kenichi Handa <handa@m17n.org>
parents: 20485
diff changeset
288 Optional arg DEFAULT-CODING-SYSTEM specifies a coding system to be
079907c59fb2 (set-language-info): Doc-string
Kenichi Handa <handa@m17n.org>
parents: 20485
diff changeset
289 checked at first. If omitted, buffer-file-coding-system of the
079907c59fb2 (set-language-info): Doc-string
Kenichi Handa <handa@m17n.org>
parents: 20485
diff changeset
290 current buffer is used.
079907c59fb2 (set-language-info): Doc-string
Kenichi Handa <handa@m17n.org>
parents: 20485
diff changeset
291
20842
428831a6f4d1 (find-safe-coding-system): Return
Kenichi Handa <handa@m17n.org>
parents: 20830
diff changeset
292 If the text can be encoded safely by DEFAULT-CODING-SYSTEM, it is
428831a6f4d1 (find-safe-coding-system): Return
Kenichi Handa <handa@m17n.org>
parents: 20830
diff changeset
293 returned without any user interaction.
20733
079907c59fb2 (set-language-info): Doc-string
Kenichi Handa <handa@m17n.org>
parents: 20485
diff changeset
294
079907c59fb2 (set-language-info): Doc-string
Kenichi Handa <handa@m17n.org>
parents: 20485
diff changeset
295 Kludgy feature: if FROM is a string, the string is the target text,
079907c59fb2 (set-language-info): Doc-string
Kenichi Handa <handa@m17n.org>
parents: 20485
diff changeset
296 and TO is ignored."
079907c59fb2 (set-language-info): Doc-string
Kenichi Handa <handa@m17n.org>
parents: 20485
diff changeset
297 (or default-coding-system
079907c59fb2 (set-language-info): Doc-string
Kenichi Handa <handa@m17n.org>
parents: 20485
diff changeset
298 (setq default-coding-system buffer-file-coding-system))
079907c59fb2 (set-language-info): Doc-string
Kenichi Handa <handa@m17n.org>
parents: 20485
diff changeset
299 (let ((safe-coding-systems (find-safe-coding-system from to)))
079907c59fb2 (set-language-info): Doc-string
Kenichi Handa <handa@m17n.org>
parents: 20485
diff changeset
300 (if (or (eq (car safe-coding-systems) 'undecided)
079907c59fb2 (set-language-info): Doc-string
Kenichi Handa <handa@m17n.org>
parents: 20485
diff changeset
301 (and default-coding-system
079907c59fb2 (set-language-info): Doc-string
Kenichi Handa <handa@m17n.org>
parents: 20485
diff changeset
302 (memq (coding-system-base default-coding-system)
079907c59fb2 (set-language-info): Doc-string
Kenichi Handa <handa@m17n.org>
parents: 20485
diff changeset
303 safe-coding-systems)))
079907c59fb2 (set-language-info): Doc-string
Kenichi Handa <handa@m17n.org>
parents: 20485
diff changeset
304 default-coding-system
079907c59fb2 (set-language-info): Doc-string
Kenichi Handa <handa@m17n.org>
parents: 20485
diff changeset
305
079907c59fb2 (set-language-info): Doc-string
Kenichi Handa <handa@m17n.org>
parents: 20485
diff changeset
306 ;; Ask a user to select a proper coding system.
079907c59fb2 (set-language-info): Doc-string
Kenichi Handa <handa@m17n.org>
parents: 20485
diff changeset
307 (save-window-excursion
079907c59fb2 (set-language-info): Doc-string
Kenichi Handa <handa@m17n.org>
parents: 20485
diff changeset
308 ;; At first, show a helpful message.
079907c59fb2 (set-language-info): Doc-string
Kenichi Handa <handa@m17n.org>
parents: 20485
diff changeset
309 (with-output-to-temp-buffer "*Warning*"
079907c59fb2 (set-language-info): Doc-string
Kenichi Handa <handa@m17n.org>
parents: 20485
diff changeset
310 (save-excursion
079907c59fb2 (set-language-info): Doc-string
Kenichi Handa <handa@m17n.org>
parents: 20485
diff changeset
311 (set-buffer standard-output)
079907c59fb2 (set-language-info): Doc-string
Kenichi Handa <handa@m17n.org>
parents: 20485
diff changeset
312 (insert (format "\
079907c59fb2 (set-language-info): Doc-string
Kenichi Handa <handa@m17n.org>
parents: 20485
diff changeset
313 The target text contains a multibyte character which can't be
079907c59fb2 (set-language-info): Doc-string
Kenichi Handa <handa@m17n.org>
parents: 20485
diff changeset
314 encoded safely by the coding system %s.
079907c59fb2 (set-language-info): Doc-string
Kenichi Handa <handa@m17n.org>
parents: 20485
diff changeset
315
079907c59fb2 (set-language-info): Doc-string
Kenichi Handa <handa@m17n.org>
parents: 20485
diff changeset
316 Please select one from the following safe coding systems:\n"
079907c59fb2 (set-language-info): Doc-string
Kenichi Handa <handa@m17n.org>
parents: 20485
diff changeset
317 default-coding-system))
079907c59fb2 (set-language-info): Doc-string
Kenichi Handa <handa@m17n.org>
parents: 20485
diff changeset
318 (let ((pos (point))
079907c59fb2 (set-language-info): Doc-string
Kenichi Handa <handa@m17n.org>
parents: 20485
diff changeset
319 (fill-prefix " "))
079907c59fb2 (set-language-info): Doc-string
Kenichi Handa <handa@m17n.org>
parents: 20485
diff changeset
320 (mapcar (function (lambda (x) (princ " ") (princ x)))
079907c59fb2 (set-language-info): Doc-string
Kenichi Handa <handa@m17n.org>
parents: 20485
diff changeset
321 safe-coding-systems)
079907c59fb2 (set-language-info): Doc-string
Kenichi Handa <handa@m17n.org>
parents: 20485
diff changeset
322 (fill-region-as-paragraph pos (point)))))
079907c59fb2 (set-language-info): Doc-string
Kenichi Handa <handa@m17n.org>
parents: 20485
diff changeset
323
079907c59fb2 (set-language-info): Doc-string
Kenichi Handa <handa@m17n.org>
parents: 20485
diff changeset
324 ;; Read a coding system.
079907c59fb2 (set-language-info): Doc-string
Kenichi Handa <handa@m17n.org>
parents: 20485
diff changeset
325 (let* ((safe-names (mapcar (lambda (x) (list (symbol-name x)))
079907c59fb2 (set-language-info): Doc-string
Kenichi Handa <handa@m17n.org>
parents: 20485
diff changeset
326 safe-coding-systems))
079907c59fb2 (set-language-info): Doc-string
Kenichi Handa <handa@m17n.org>
parents: 20485
diff changeset
327 (name (completing-read
079907c59fb2 (set-language-info): Doc-string
Kenichi Handa <handa@m17n.org>
parents: 20485
diff changeset
328 (format "Select coding system (default %s): "
079907c59fb2 (set-language-info): Doc-string
Kenichi Handa <handa@m17n.org>
parents: 20485
diff changeset
329 (car safe-coding-systems))
079907c59fb2 (set-language-info): Doc-string
Kenichi Handa <handa@m17n.org>
parents: 20485
diff changeset
330 safe-names nil t nil nil (car (car safe-names)))))
20941
588dae3ae7cc (select-safe-coding-system): Kill the
Kenichi Handa <handa@m17n.org>
parents: 20842
diff changeset
331 (kill-buffer "*Warning*")
20733
079907c59fb2 (set-language-info): Doc-string
Kenichi Handa <handa@m17n.org>
parents: 20485
diff changeset
332 (intern name))))))
079907c59fb2 (set-language-info): Doc-string
Kenichi Handa <handa@m17n.org>
parents: 20485
diff changeset
333
079907c59fb2 (set-language-info): Doc-string
Kenichi Handa <handa@m17n.org>
parents: 20485
diff changeset
334 (setq select-safe-coding-system-function 'select-safe-coding-system)
079907c59fb2 (set-language-info): Doc-string
Kenichi Handa <handa@m17n.org>
parents: 20485
diff changeset
335
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
336
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
337 ;;; Language support staffs.
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
338
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
339 (defvar language-info-alist nil
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
340 "Alist of language names vs the corresponding information of various kind.
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
341 Each element looks like:
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
342 (LANGUAGE-NAME . ((KEY . INFO) ...))
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
343 where LANGUAGE-NAME is a string,
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
344 KEY is a symbol denoting the kind of information,
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
345 INFO is any Lisp object which contains the actual information related
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
346 to KEY.")
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
347
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
348 (defun get-language-info (language-name key)
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
349 "Return the information for LANGUAGE-NAME of the kind KEY.
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
350 KEY is a symbol denoting the kind of required information."
19649
b2bf3c43c86a (get-language-info): Accept a symbol
Kenichi Handa <handa@m17n.org>
parents: 19615
diff changeset
351 (if (symbolp language-name)
b2bf3c43c86a (get-language-info): Accept a symbol
Kenichi Handa <handa@m17n.org>
parents: 19615
diff changeset
352 (setq language-name (symbol-name language-name)))
17991
65407fdc4a33 Delete defining "i" in mule-keymap.
Kenichi Handa <handa@m17n.org>
parents: 17840
diff changeset
353 (let ((lang-slot (assoc-ignore-case language-name language-info-alist)))
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
354 (if lang-slot
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
355 (cdr (assq key (cdr lang-slot))))))
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
356
20733
079907c59fb2 (set-language-info): Doc-string
Kenichi Handa <handa@m17n.org>
parents: 20485
diff changeset
357 (defun set-language-info (language-name key info
079907c59fb2 (set-language-info): Doc-string
Kenichi Handa <handa@m17n.org>
parents: 20485
diff changeset
358 &optional describe-map setup-map)
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
359 "Set for LANGUAGE-NAME the information INFO under KEY.
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
360 KEY is a symbol denoting the kind of information.
20733
079907c59fb2 (set-language-info): Doc-string
Kenichi Handa <handa@m17n.org>
parents: 20485
diff changeset
361 INFO is any Lisp object which contains the actual information specific
079907c59fb2 (set-language-info): Doc-string
Kenichi Handa <handa@m17n.org>
parents: 20485
diff changeset
362 to LANGUAGE-NAME.
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
363
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
364 Currently, the following KEYs are used by Emacs:
18152
e184e7061c9a (describe-language-environment):
Richard M. Stallman <rms@gnu.org>
parents: 18068
diff changeset
365
20733
079907c59fb2 (set-language-info): Doc-string
Kenichi Handa <handa@m17n.org>
parents: 20485
diff changeset
366 charset: list of charsets.
18152
e184e7061c9a (describe-language-environment):
Richard M. Stallman <rms@gnu.org>
parents: 18068
diff changeset
367
20733
079907c59fb2 (set-language-info): Doc-string
Kenichi Handa <handa@m17n.org>
parents: 20485
diff changeset
368 coding-system: list of coding systems.
079907c59fb2 (set-language-info): Doc-string
Kenichi Handa <handa@m17n.org>
parents: 20485
diff changeset
369
079907c59fb2 (set-language-info): Doc-string
Kenichi Handa <handa@m17n.org>
parents: 20485
diff changeset
370 coding-priority: list of coding systems ordered by priority.
18152
e184e7061c9a (describe-language-environment):
Richard M. Stallman <rms@gnu.org>
parents: 18068
diff changeset
371
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
372 tutorial: a tutorial file name written in the language.
18152
e184e7061c9a (describe-language-environment):
Richard M. Stallman <rms@gnu.org>
parents: 18068
diff changeset
373
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
374 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
375
17991
65407fdc4a33 Delete defining "i" in mule-keymap.
Kenichi Handa <handa@m17n.org>
parents: 17840
diff changeset
376 documentation: t or a string describing how Emacs supports the language.
20733
079907c59fb2 (set-language-info): Doc-string
Kenichi Handa <handa@m17n.org>
parents: 20485
diff changeset
377 If a string is specified, it is shown before any other information
079907c59fb2 (set-language-info): Doc-string
Kenichi Handa <handa@m17n.org>
parents: 20485
diff changeset
378 of the language by the command `describe-language-environment'.
18152
e184e7061c9a (describe-language-environment):
Richard M. Stallman <rms@gnu.org>
parents: 18068
diff changeset
379
17758
8c67c2e2cc29 (build-describe-language-support-function,
Kenichi Handa <handa@m17n.org>
parents: 17526
diff changeset
380 setup-function: a function to call for setting up environment
20733
079907c59fb2 (set-language-info): Doc-string
Kenichi Handa <handa@m17n.org>
parents: 20485
diff changeset
381 convenient for a user of the language.
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
382
18152
e184e7061c9a (describe-language-environment):
Richard M. Stallman <rms@gnu.org>
parents: 18068
diff changeset
383 We will define more KEYs in the future. To avoid conflict,
20733
079907c59fb2 (set-language-info): Doc-string
Kenichi Handa <handa@m17n.org>
parents: 20485
diff changeset
384 if you want to use your own KEY values, make them start with `user-'.
079907c59fb2 (set-language-info): Doc-string
Kenichi Handa <handa@m17n.org>
parents: 20485
diff changeset
385
079907c59fb2 (set-language-info): Doc-string
Kenichi Handa <handa@m17n.org>
parents: 20485
diff changeset
386 Optional 4th and 5th args DESCRIBE-MAP and SETUP-MAP are keymaps to
079907c59fb2 (set-language-info): Doc-string
Kenichi Handa <handa@m17n.org>
parents: 20485
diff changeset
387 register LANGUAGE-NAME in the menu of `Mule'->`Describe Language
079907c59fb2 (set-language-info): Doc-string
Kenichi Handa <handa@m17n.org>
parents: 20485
diff changeset
388 Environment' and `Mule'->`Setup Language Environment' respectively."
19649
b2bf3c43c86a (get-language-info): Accept a symbol
Kenichi Handa <handa@m17n.org>
parents: 19615
diff changeset
389 (if (symbolp language-name)
b2bf3c43c86a (get-language-info): Accept a symbol
Kenichi Handa <handa@m17n.org>
parents: 19615
diff changeset
390 (setq language-name (symbol-name language-name)))
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
391 (let (lang-slot key-slot)
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
392 (setq lang-slot (assoc language-name language-info-alist))
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
393 (if (null lang-slot) ; If no slot for the language, add it.
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
394 (setq lang-slot (list language-name)
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
395 language-info-alist (cons lang-slot language-info-alist)))
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
396 (setq key-slot (assq key lang-slot))
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
397 (if (null key-slot) ; If no slot for the key, add it.
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
398 (progn
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
399 (setq key-slot (list key))
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
400 (setcdr lang-slot (cons key-slot (cdr lang-slot)))))
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
401 ;; Setup menu.
17840
2517414676ed (set-language-info): Change the special treatment
Kenichi Handa <handa@m17n.org>
parents: 17758
diff changeset
402 (cond ((eq key 'documentation)
20733
079907c59fb2 (set-language-info): Doc-string
Kenichi Handa <handa@m17n.org>
parents: 20485
diff changeset
403 (define-key-after describe-map (vector (intern language-name))
079907c59fb2 (set-language-info): Doc-string
Kenichi Handa <handa@m17n.org>
parents: 20485
diff changeset
404 (cons language-name 'describe-specified-language-support) t))
17090
8085a8690c87 (mule-keymap): Re-arranged.
Kenichi Handa <handa@m17n.org>
parents: 17071
diff changeset
405 ((eq key 'setup-function)
20733
079907c59fb2 (set-language-info): Doc-string
Kenichi Handa <handa@m17n.org>
parents: 20485
diff changeset
406 (define-key-after setup-map (vector (intern language-name))
079907c59fb2 (set-language-info): Doc-string
Kenichi Handa <handa@m17n.org>
parents: 20485
diff changeset
407 (cons language-name 'setup-specified-language-environment) t)))
17991
65407fdc4a33 Delete defining "i" in mule-keymap.
Kenichi Handa <handa@m17n.org>
parents: 17840
diff changeset
408
65407fdc4a33 Delete defining "i" in mule-keymap.
Kenichi Handa <handa@m17n.org>
parents: 17840
diff changeset
409 (setcdr key-slot info)
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
410 ))
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
411
20733
079907c59fb2 (set-language-info): Doc-string
Kenichi Handa <handa@m17n.org>
parents: 20485
diff changeset
412 (defun set-language-info-alist (language-name alist &optional parents)
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
413 "Set for LANGUAGE-NAME the information in ALIST.
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
414 ALIST is an alist of KEY and INFO. See the documentation of
20733
079907c59fb2 (set-language-info): Doc-string
Kenichi Handa <handa@m17n.org>
parents: 20485
diff changeset
415 `set-langauge-info' for the meanings of KEY and INFO.
079907c59fb2 (set-language-info): Doc-string
Kenichi Handa <handa@m17n.org>
parents: 20485
diff changeset
416
079907c59fb2 (set-language-info): Doc-string
Kenichi Handa <handa@m17n.org>
parents: 20485
diff changeset
417 Optional arg PARENTS is a list of parent language environments ordered
079907c59fb2 (set-language-info): Doc-string
Kenichi Handa <handa@m17n.org>
parents: 20485
diff changeset
418 from the highest to the lower. If it is nil, we make LANGUAGE-NAME
079907c59fb2 (set-language-info): Doc-string
Kenichi Handa <handa@m17n.org>
parents: 20485
diff changeset
419 the top level language environment."
19649
b2bf3c43c86a (get-language-info): Accept a symbol
Kenichi Handa <handa@m17n.org>
parents: 19615
diff changeset
420 (if (symbolp language-name)
b2bf3c43c86a (get-language-info): Accept a symbol
Kenichi Handa <handa@m17n.org>
parents: 19615
diff changeset
421 (setq language-name (symbol-name language-name)))
20733
079907c59fb2 (set-language-info): Doc-string
Kenichi Handa <handa@m17n.org>
parents: 20485
diff changeset
422 (let ((describe-map describe-language-environment-map)
079907c59fb2 (set-language-info): Doc-string
Kenichi Handa <handa@m17n.org>
parents: 20485
diff changeset
423 (setup-map setup-language-environment-map))
079907c59fb2 (set-language-info): Doc-string
Kenichi Handa <handa@m17n.org>
parents: 20485
diff changeset
424 (if parents
079907c59fb2 (set-language-info): Doc-string
Kenichi Handa <handa@m17n.org>
parents: 20485
diff changeset
425 (let ((l parents)
079907c59fb2 (set-language-info): Doc-string
Kenichi Handa <handa@m17n.org>
parents: 20485
diff changeset
426 map parent-symbol parent)
079907c59fb2 (set-language-info): Doc-string
Kenichi Handa <handa@m17n.org>
parents: 20485
diff changeset
427 (while l
079907c59fb2 (set-language-info): Doc-string
Kenichi Handa <handa@m17n.org>
parents: 20485
diff changeset
428 (if (symbolp (setq parent-symbol (car l)))
079907c59fb2 (set-language-info): Doc-string
Kenichi Handa <handa@m17n.org>
parents: 20485
diff changeset
429 (setq parent (symbol-name parent))
079907c59fb2 (set-language-info): Doc-string
Kenichi Handa <handa@m17n.org>
parents: 20485
diff changeset
430 (setq parent parent-symbol parent-symbol (intern parent)))
079907c59fb2 (set-language-info): Doc-string
Kenichi Handa <handa@m17n.org>
parents: 20485
diff changeset
431 (setq map (lookup-key describe-map (vector parent-symbol)))
079907c59fb2 (set-language-info): Doc-string
Kenichi Handa <handa@m17n.org>
parents: 20485
diff changeset
432 (if (not map)
079907c59fb2 (set-language-info): Doc-string
Kenichi Handa <handa@m17n.org>
parents: 20485
diff changeset
433 (progn
079907c59fb2 (set-language-info): Doc-string
Kenichi Handa <handa@m17n.org>
parents: 20485
diff changeset
434 (setq map (intern (format "describe-%s-environment-map"
079907c59fb2 (set-language-info): Doc-string
Kenichi Handa <handa@m17n.org>
parents: 20485
diff changeset
435 (downcase parent))))
079907c59fb2 (set-language-info): Doc-string
Kenichi Handa <handa@m17n.org>
parents: 20485
diff changeset
436 (define-prefix-command map)
079907c59fb2 (set-language-info): Doc-string
Kenichi Handa <handa@m17n.org>
parents: 20485
diff changeset
437 (define-key-after describe-map (vector parent-symbol)
079907c59fb2 (set-language-info): Doc-string
Kenichi Handa <handa@m17n.org>
parents: 20485
diff changeset
438 (cons parent map) t)))
079907c59fb2 (set-language-info): Doc-string
Kenichi Handa <handa@m17n.org>
parents: 20485
diff changeset
439 (setq describe-map (symbol-value map))
079907c59fb2 (set-language-info): Doc-string
Kenichi Handa <handa@m17n.org>
parents: 20485
diff changeset
440 (setq map (lookup-key setup-map (vector parent-symbol)))
079907c59fb2 (set-language-info): Doc-string
Kenichi Handa <handa@m17n.org>
parents: 20485
diff changeset
441 (if (not map)
079907c59fb2 (set-language-info): Doc-string
Kenichi Handa <handa@m17n.org>
parents: 20485
diff changeset
442 (progn
079907c59fb2 (set-language-info): Doc-string
Kenichi Handa <handa@m17n.org>
parents: 20485
diff changeset
443 (setq map (intern (format "setup-%s-environment-map"
079907c59fb2 (set-language-info): Doc-string
Kenichi Handa <handa@m17n.org>
parents: 20485
diff changeset
444 (downcase parent))))
079907c59fb2 (set-language-info): Doc-string
Kenichi Handa <handa@m17n.org>
parents: 20485
diff changeset
445 (define-prefix-command map)
079907c59fb2 (set-language-info): Doc-string
Kenichi Handa <handa@m17n.org>
parents: 20485
diff changeset
446 (define-key-after setup-map (vector parent-symbol)
079907c59fb2 (set-language-info): Doc-string
Kenichi Handa <handa@m17n.org>
parents: 20485
diff changeset
447 (cons parent map) t)))
079907c59fb2 (set-language-info): Doc-string
Kenichi Handa <handa@m17n.org>
parents: 20485
diff changeset
448 (setq setup-map (symbol-value map))
079907c59fb2 (set-language-info): Doc-string
Kenichi Handa <handa@m17n.org>
parents: 20485
diff changeset
449 (setq l (cdr l)))))
079907c59fb2 (set-language-info): Doc-string
Kenichi Handa <handa@m17n.org>
parents: 20485
diff changeset
450 (while alist
079907c59fb2 (set-language-info): Doc-string
Kenichi Handa <handa@m17n.org>
parents: 20485
diff changeset
451 (set-language-info language-name (car (car alist)) (cdr (car alist))
079907c59fb2 (set-language-info): Doc-string
Kenichi Handa <handa@m17n.org>
parents: 20485
diff changeset
452 describe-map setup-map)
079907c59fb2 (set-language-info): Doc-string
Kenichi Handa <handa@m17n.org>
parents: 20485
diff changeset
453 (setq alist (cdr alist)))))
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
454
19734
c4894d8a3310 (read-language-name): Use a default, not an initial input.
Richard M. Stallman <rms@gnu.org>
parents: 19725
diff changeset
455 (defun read-language-name (key prompt &optional default)
19649
b2bf3c43c86a (get-language-info): Accept a symbol
Kenichi Handa <handa@m17n.org>
parents: 19615
diff changeset
456 "Read language name which has information for KEY, prompting with PROMPT.
19734
c4894d8a3310 (read-language-name): Use a default, not an initial input.
Richard M. Stallman <rms@gnu.org>
parents: 19725
diff changeset
457 DEFAULT is the default choice of language.
19784
da913efb39cf (read-language-name): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents: 19748
diff changeset
458 This returns a language name as a string."
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
459 (let* ((completion-ignore-case t)
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
460 (name (completing-read prompt
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
461 language-info-alist
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
462 (function (lambda (elm) (assq key elm)))
19734
c4894d8a3310 (read-language-name): Use a default, not an initial input.
Richard M. Stallman <rms@gnu.org>
parents: 19725
diff changeset
463 t nil nil default)))
17758
8c67c2e2cc29 (build-describe-language-support-function,
Kenichi Handa <handa@m17n.org>
parents: 17526
diff changeset
464 (if (and (> (length name) 0)
8c67c2e2cc29 (build-describe-language-support-function,
Kenichi Handa <handa@m17n.org>
parents: 17526
diff changeset
465 (get-language-info name key))
8c67c2e2cc29 (build-describe-language-support-function,
Kenichi Handa <handa@m17n.org>
parents: 17526
diff changeset
466 name)))
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
467
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
468 ;;; Multilingual input methods.
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
469
18301
a4da36c7bb08 Define describe-coding-system instead of
Kenichi Handa <handa@m17n.org>
parents: 18217
diff changeset
470 (defconst leim-list-file-name "leim-list.el"
a4da36c7bb08 Define describe-coding-system instead of
Kenichi Handa <handa@m17n.org>
parents: 18217
diff changeset
471 "Name of LEIM list file.
a4da36c7bb08 Define describe-coding-system instead of
Kenichi Handa <handa@m17n.org>
parents: 18217
diff changeset
472 This file contains a list of libraries of Emacs input methods (LEIM)
a4da36c7bb08 Define describe-coding-system instead of
Kenichi Handa <handa@m17n.org>
parents: 18217
diff changeset
473 in the format of Lisp expression for registering each input method.
a4da36c7bb08 Define describe-coding-system instead of
Kenichi Handa <handa@m17n.org>
parents: 18217
diff changeset
474 Emacs loads this file at startup time.")
a4da36c7bb08 Define describe-coding-system instead of
Kenichi Handa <handa@m17n.org>
parents: 18217
diff changeset
475
a4da36c7bb08 Define describe-coding-system instead of
Kenichi Handa <handa@m17n.org>
parents: 18217
diff changeset
476 (defvar leim-list-header (format "\
a4da36c7bb08 Define describe-coding-system instead of
Kenichi Handa <handa@m17n.org>
parents: 18217
diff changeset
477 ;;; %s -- list of LEIM (Library of Emacs Input Method)
a4da36c7bb08 Define describe-coding-system instead of
Kenichi Handa <handa@m17n.org>
parents: 18217
diff changeset
478 ;;
a4da36c7bb08 Define describe-coding-system instead of
Kenichi Handa <handa@m17n.org>
parents: 18217
diff changeset
479 ;; This file contains a list of LEIM (Library of Emacs Input Method)
a4da36c7bb08 Define describe-coding-system instead of
Kenichi Handa <handa@m17n.org>
parents: 18217
diff changeset
480 ;; in the same directory as this file. Loading this file registeres
a4da36c7bb08 Define describe-coding-system instead of
Kenichi Handa <handa@m17n.org>
parents: 18217
diff changeset
481 ;; the whole input methods in Emacs.
a4da36c7bb08 Define describe-coding-system instead of
Kenichi Handa <handa@m17n.org>
parents: 18217
diff changeset
482 ;;
18969
c33e6f7947ed Typo in comment fixed.
Kenichi Handa <handa@m17n.org>
parents: 18933
diff changeset
483 ;; Each entry has the form:
18301
a4da36c7bb08 Define describe-coding-system instead of
Kenichi Handa <handa@m17n.org>
parents: 18217
diff changeset
484 ;; (register-input-method
a4da36c7bb08 Define describe-coding-system instead of
Kenichi Handa <handa@m17n.org>
parents: 18217
diff changeset
485 ;; INPUT-METHOD LANGUAGE-NAME ACTIVATE-FUNC
a4da36c7bb08 Define describe-coding-system instead of
Kenichi Handa <handa@m17n.org>
parents: 18217
diff changeset
486 ;; TITLE DESCRIPTION
a4da36c7bb08 Define describe-coding-system instead of
Kenichi Handa <handa@m17n.org>
parents: 18217
diff changeset
487 ;; ARG ...)
a4da36c7bb08 Define describe-coding-system instead of
Kenichi Handa <handa@m17n.org>
parents: 18217
diff changeset
488 ;; See the function `register-input-method' for the meanings of arguments.
a4da36c7bb08 Define describe-coding-system instead of
Kenichi Handa <handa@m17n.org>
parents: 18217
diff changeset
489 ;;
a4da36c7bb08 Define describe-coding-system instead of
Kenichi Handa <handa@m17n.org>
parents: 18217
diff changeset
490 ;; If this directory is included in load-path, Emacs automatically
a4da36c7bb08 Define describe-coding-system instead of
Kenichi Handa <handa@m17n.org>
parents: 18217
diff changeset
491 ;; loads this file at startup time.
a4da36c7bb08 Define describe-coding-system instead of
Kenichi Handa <handa@m17n.org>
parents: 18217
diff changeset
492
a4da36c7bb08 Define describe-coding-system instead of
Kenichi Handa <handa@m17n.org>
parents: 18217
diff changeset
493 "
a4da36c7bb08 Define describe-coding-system instead of
Kenichi Handa <handa@m17n.org>
parents: 18217
diff changeset
494 leim-list-file-name)
a4da36c7bb08 Define describe-coding-system instead of
Kenichi Handa <handa@m17n.org>
parents: 18217
diff changeset
495 "Header to be inserted in LEIM list file.")
a4da36c7bb08 Define describe-coding-system instead of
Kenichi Handa <handa@m17n.org>
parents: 18217
diff changeset
496
18982
2297a2cb909d (leim-list-entry-regexp): Make this match only at beginning of line.
Kenichi Handa <handa@m17n.org>
parents: 18978
diff changeset
497 (defvar leim-list-entry-regexp "^(register-input-method"
18301
a4da36c7bb08 Define describe-coding-system instead of
Kenichi Handa <handa@m17n.org>
parents: 18217
diff changeset
498 "Regexp matching head of each entry in LEIM list file.
a4da36c7bb08 Define describe-coding-system instead of
Kenichi Handa <handa@m17n.org>
parents: 18217
diff changeset
499 See also the variable `leim-list-header'")
a4da36c7bb08 Define describe-coding-system instead of
Kenichi Handa <handa@m17n.org>
parents: 18217
diff changeset
500
a4da36c7bb08 Define describe-coding-system instead of
Kenichi Handa <handa@m17n.org>
parents: 18217
diff changeset
501 (defvar update-leim-list-functions
a4da36c7bb08 Define describe-coding-system instead of
Kenichi Handa <handa@m17n.org>
parents: 18217
diff changeset
502 '(quail-update-leim-list-file)
a4da36c7bb08 Define describe-coding-system instead of
Kenichi Handa <handa@m17n.org>
parents: 18217
diff changeset
503 "List of functions to call to update LEIM list file.
a4da36c7bb08 Define describe-coding-system instead of
Kenichi Handa <handa@m17n.org>
parents: 18217
diff changeset
504 Each function is called with one arg, LEIM directory name.")
a4da36c7bb08 Define describe-coding-system instead of
Kenichi Handa <handa@m17n.org>
parents: 18217
diff changeset
505
19615
4cdef838afb0 (update-leim-list-file): Make it handle multiple directories.
Richard M. Stallman <rms@gnu.org>
parents: 19614
diff changeset
506 (defun update-leim-list-file (&rest dirs)
4cdef838afb0 (update-leim-list-file): Make it handle multiple directories.
Richard M. Stallman <rms@gnu.org>
parents: 19614
diff changeset
507 "Update LEIM list file in directories DIRS."
18301
a4da36c7bb08 Define describe-coding-system instead of
Kenichi Handa <handa@m17n.org>
parents: 18217
diff changeset
508 (let ((functions update-leim-list-functions))
a4da36c7bb08 Define describe-coding-system instead of
Kenichi Handa <handa@m17n.org>
parents: 18217
diff changeset
509 (while functions
19615
4cdef838afb0 (update-leim-list-file): Make it handle multiple directories.
Richard M. Stallman <rms@gnu.org>
parents: 19614
diff changeset
510 (apply (car functions) dirs)
18301
a4da36c7bb08 Define describe-coding-system instead of
Kenichi Handa <handa@m17n.org>
parents: 18217
diff changeset
511 (setq functions (cdr functions)))))
a4da36c7bb08 Define describe-coding-system instead of
Kenichi Handa <handa@m17n.org>
parents: 18217
diff changeset
512
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
513 (defvar current-input-method nil
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
514 "The current input method for multilingual text.
19083
8fdb29b769ed Doc fixes; fix error message text.
Richard M. Stallman <rms@gnu.org>
parents: 19036
diff changeset
515 If nil, that means no input method is activated now.")
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
516 (make-variable-buffer-local 'current-input-method)
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
517 (put 'current-input-method 'permanent-local t)
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
518
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
519 (defvar current-input-method-title nil
18301
a4da36c7bb08 Define describe-coding-system instead of
Kenichi Handa <handa@m17n.org>
parents: 18217
diff changeset
520 "Title string of the current input method shown in mode line.")
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
521 (make-variable-buffer-local 'current-input-method-title)
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
522 (put 'current-input-method-title 'permanent-local t)
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
523
18801
f60dbf4f7d7c (mule-keymap): Bind l to set-language-environment.
Kenichi Handa <handa@m17n.org>
parents: 18712
diff changeset
524 (defcustom default-input-method nil
f60dbf4f7d7c (mule-keymap): Bind l to set-language-environment.
Kenichi Handa <handa@m17n.org>
parents: 18712
diff changeset
525 "*Default input method for multilingual text.
f60dbf4f7d7c (mule-keymap): Bind l to set-language-environment.
Kenichi Handa <handa@m17n.org>
parents: 18712
diff changeset
526 This is the input method activated automatically by the command
19329
249631cebee0 (default-input-method):
Richard M. Stallman <rms@gnu.org>
parents: 19328
diff changeset
527 `toggle-input-method' (\\[toggle-input-method])."
18801
f60dbf4f7d7c (mule-keymap): Bind l to set-language-environment.
Kenichi Handa <handa@m17n.org>
parents: 18712
diff changeset
528 :group 'mule)
f60dbf4f7d7c (mule-keymap): Bind l to set-language-environment.
Kenichi Handa <handa@m17n.org>
parents: 18712
diff changeset
529
19405
7ef4af7505f2 (previous-input-method): This
Kenichi Handa <handa@m17n.org>
parents: 19402
diff changeset
530 (defvar input-method-history nil
7ef4af7505f2 (previous-input-method): This
Kenichi Handa <handa@m17n.org>
parents: 19402
diff changeset
531 "History list for some commands that read input methods.")
7ef4af7505f2 (previous-input-method): This
Kenichi Handa <handa@m17n.org>
parents: 19402
diff changeset
532 (make-variable-buffer-local 'input-method-history)
7ef4af7505f2 (previous-input-method): This
Kenichi Handa <handa@m17n.org>
parents: 19402
diff changeset
533 (put 'input-method-history 'permanent-local t)
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
534
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
535 (defvar inactivate-current-input-method-function nil
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
536 "Function to call for inactivating the current input method.
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
537 Every input method should set this to an appropriate value when activated.
19555
df2996f7fdc3 (inactivate-current-input-method-function): Doc-string modified.
Kenichi Handa <handa@m17n.org>
parents: 19424
diff changeset
538 This function is called with no argument.
df2996f7fdc3 (inactivate-current-input-method-function): Doc-string modified.
Kenichi Handa <handa@m17n.org>
parents: 19424
diff changeset
539
df2996f7fdc3 (inactivate-current-input-method-function): Doc-string modified.
Kenichi Handa <handa@m17n.org>
parents: 19424
diff changeset
540 This function should never change the value of `current-input-method'.
df2996f7fdc3 (inactivate-current-input-method-function): Doc-string modified.
Kenichi Handa <handa@m17n.org>
parents: 19424
diff changeset
541 It is set to nil by the function `inactivate-input-method'.")
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
542 (make-variable-buffer-local 'inactivate-current-input-method-function)
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
543 (put 'inactivate-current-input-method-function 'permanent-local t)
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
544
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
545 (defvar describe-current-input-method-function nil
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
546 "Function to call for describing the current input method.
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
547 This function is called with no argument.")
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
548 (make-variable-buffer-local 'describe-current-input-method-function)
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
549 (put 'describe-current-input-method-function 'permanent-local t)
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
550
18301
a4da36c7bb08 Define describe-coding-system instead of
Kenichi Handa <handa@m17n.org>
parents: 18217
diff changeset
551 (defvar input-method-alist nil
a4da36c7bb08 Define describe-coding-system instead of
Kenichi Handa <handa@m17n.org>
parents: 18217
diff changeset
552 "Alist of input method names vs the corresponding information to use it.
a4da36c7bb08 Define describe-coding-system instead of
Kenichi Handa <handa@m17n.org>
parents: 18217
diff changeset
553 Each element has the form:
a4da36c7bb08 Define describe-coding-system instead of
Kenichi Handa <handa@m17n.org>
parents: 18217
diff changeset
554 (INPUT-METHOD LANGUAGE-NAME ACTIVATE-FUNC TITLE DESCRIPTION ...)
a4da36c7bb08 Define describe-coding-system instead of
Kenichi Handa <handa@m17n.org>
parents: 18217
diff changeset
555 See the function `register-input-method' for the meanings of each elements.")
a4da36c7bb08 Define describe-coding-system instead of
Kenichi Handa <handa@m17n.org>
parents: 18217
diff changeset
556
a4da36c7bb08 Define describe-coding-system instead of
Kenichi Handa <handa@m17n.org>
parents: 18217
diff changeset
557 (defun register-input-method (input-method language-name &rest args)
a4da36c7bb08 Define describe-coding-system instead of
Kenichi Handa <handa@m17n.org>
parents: 18217
diff changeset
558 "Register INPUT-METHOD as an input method for LANGUAGE-NAME.
19649
b2bf3c43c86a (get-language-info): Accept a symbol
Kenichi Handa <handa@m17n.org>
parents: 19615
diff changeset
559 INPUT-METHOD and LANGUAGE-NAME are symbols or strings.
18301
a4da36c7bb08 Define describe-coding-system instead of
Kenichi Handa <handa@m17n.org>
parents: 18217
diff changeset
560 The remaining arguments are:
a4da36c7bb08 Define describe-coding-system instead of
Kenichi Handa <handa@m17n.org>
parents: 18217
diff changeset
561 ACTIVATE-FUNC, TITLE, DESCRIPTION, and ARG ...
a4da36c7bb08 Define describe-coding-system instead of
Kenichi Handa <handa@m17n.org>
parents: 18217
diff changeset
562 where,
a4da36c7bb08 Define describe-coding-system instead of
Kenichi Handa <handa@m17n.org>
parents: 18217
diff changeset
563 ACTIVATE-FUNC is a function to call for activating this method.
a4da36c7bb08 Define describe-coding-system instead of
Kenichi Handa <handa@m17n.org>
parents: 18217
diff changeset
564 TITLE is a string shown in mode-line while this method is active,
a4da36c7bb08 Define describe-coding-system instead of
Kenichi Handa <handa@m17n.org>
parents: 18217
diff changeset
565 DESCRIPTION is a string describing about this method,
a4da36c7bb08 Define describe-coding-system instead of
Kenichi Handa <handa@m17n.org>
parents: 18217
diff changeset
566 Arguments to ACTIVATE-FUNC are INPUT-METHOD and ARGs."
19649
b2bf3c43c86a (get-language-info): Accept a symbol
Kenichi Handa <handa@m17n.org>
parents: 19615
diff changeset
567 (if (symbolp language-name)
b2bf3c43c86a (get-language-info): Accept a symbol
Kenichi Handa <handa@m17n.org>
parents: 19615
diff changeset
568 (setq language-name (symbol-name language-name)))
b2bf3c43c86a (get-language-info): Accept a symbol
Kenichi Handa <handa@m17n.org>
parents: 19615
diff changeset
569 (if (symbolp input-method)
b2bf3c43c86a (get-language-info): Accept a symbol
Kenichi Handa <handa@m17n.org>
parents: 19615
diff changeset
570 (setq input-method (symbol-name input-method)))
18301
a4da36c7bb08 Define describe-coding-system instead of
Kenichi Handa <handa@m17n.org>
parents: 18217
diff changeset
571 (let ((info (cons language-name args))
a4da36c7bb08 Define describe-coding-system instead of
Kenichi Handa <handa@m17n.org>
parents: 18217
diff changeset
572 (slot (assoc input-method input-method-alist)))
a4da36c7bb08 Define describe-coding-system instead of
Kenichi Handa <handa@m17n.org>
parents: 18217
diff changeset
573 (if slot
a4da36c7bb08 Define describe-coding-system instead of
Kenichi Handa <handa@m17n.org>
parents: 18217
diff changeset
574 (setcdr slot info)
a4da36c7bb08 Define describe-coding-system instead of
Kenichi Handa <handa@m17n.org>
parents: 18217
diff changeset
575 (setq slot (cons input-method info))
a4da36c7bb08 Define describe-coding-system instead of
Kenichi Handa <handa@m17n.org>
parents: 18217
diff changeset
576 (setq input-method-alist (cons slot input-method-alist)))))
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
577
19328
a616b45ffa31 (read-input-method-name): Replace INITIAL-INPUT arg with DEFAULT arg.
Richard M. Stallman <rms@gnu.org>
parents: 19267
diff changeset
578 (defun read-input-method-name (prompt &optional default inhibit-null)
18301
a4da36c7bb08 Define describe-coding-system instead of
Kenichi Handa <handa@m17n.org>
parents: 18217
diff changeset
579 "Read a name of input method from a minibuffer prompting with PROMPT.
19328
a616b45ffa31 (read-input-method-name): Replace INITIAL-INPUT arg with DEFAULT arg.
Richard M. Stallman <rms@gnu.org>
parents: 19267
diff changeset
580 If DEFAULT is non-nil, use that as the default,
a616b45ffa31 (read-input-method-name): Replace INITIAL-INPUT arg with DEFAULT arg.
Richard M. Stallman <rms@gnu.org>
parents: 19267
diff changeset
581 and substitute it into PROMPT at the first `%s'.
19649
b2bf3c43c86a (get-language-info): Accept a symbol
Kenichi Handa <handa@m17n.org>
parents: 19615
diff changeset
582 If INHIBIT-NULL is non-nil, null input signals an error.
b2bf3c43c86a (get-language-info): Accept a symbol
Kenichi Handa <handa@m17n.org>
parents: 19615
diff changeset
583
b2bf3c43c86a (get-language-info): Accept a symbol
Kenichi Handa <handa@m17n.org>
parents: 19615
diff changeset
584 The return value is a string."
19328
a616b45ffa31 (read-input-method-name): Replace INITIAL-INPUT arg with DEFAULT arg.
Richard M. Stallman <rms@gnu.org>
parents: 19267
diff changeset
585 (if default
a616b45ffa31 (read-input-method-name): Replace INITIAL-INPUT arg with DEFAULT arg.
Richard M. Stallman <rms@gnu.org>
parents: 19267
diff changeset
586 (setq prompt (format prompt default)))
18301
a4da36c7bb08 Define describe-coding-system instead of
Kenichi Handa <handa@m17n.org>
parents: 18217
diff changeset
587 (let* ((completion-ignore-case t)
19405
7ef4af7505f2 (previous-input-method): This
Kenichi Handa <handa@m17n.org>
parents: 19402
diff changeset
588 ;; This binding is necessary because input-method-history is
7ef4af7505f2 (previous-input-method): This
Kenichi Handa <handa@m17n.org>
parents: 19402
diff changeset
589 ;; buffer local.
18301
a4da36c7bb08 Define describe-coding-system instead of
Kenichi Handa <handa@m17n.org>
parents: 18217
diff changeset
590 (input-method (completing-read prompt input-method-alist
19748
06cbad2e806a (read-input-method-name): Specify the input history properly.
Richard M. Stallman <rms@gnu.org>
parents: 19746
diff changeset
591 nil t nil 'input-method-history
06cbad2e806a (read-input-method-name): Specify the input history properly.
Richard M. Stallman <rms@gnu.org>
parents: 19746
diff changeset
592 default)))
18301
a4da36c7bb08 Define describe-coding-system instead of
Kenichi Handa <handa@m17n.org>
parents: 18217
diff changeset
593 (if (> (length input-method) 0)
a4da36c7bb08 Define describe-coding-system instead of
Kenichi Handa <handa@m17n.org>
parents: 18217
diff changeset
594 input-method
a4da36c7bb08 Define describe-coding-system instead of
Kenichi Handa <handa@m17n.org>
parents: 18217
diff changeset
595 (if inhibit-null
18978
0f01c27a9756 (read-input-method-name): Show more appropriate error message.
Kenichi Handa <handa@m17n.org>
parents: 18969
diff changeset
596 (error "No valid input method is specified")))))
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
597
18301
a4da36c7bb08 Define describe-coding-system instead of
Kenichi Handa <handa@m17n.org>
parents: 18217
diff changeset
598 (defun activate-input-method (input-method)
19555
df2996f7fdc3 (inactivate-current-input-method-function): Doc-string modified.
Kenichi Handa <handa@m17n.org>
parents: 19424
diff changeset
599 "Turn INPUT-METHOD on.
df2996f7fdc3 (inactivate-current-input-method-function): Doc-string modified.
Kenichi Handa <handa@m17n.org>
parents: 19424
diff changeset
600 If some input method is already on, turn it off at first."
19649
b2bf3c43c86a (get-language-info): Accept a symbol
Kenichi Handa <handa@m17n.org>
parents: 19615
diff changeset
601 (if (symbolp input-method)
b2bf3c43c86a (get-language-info): Accept a symbol
Kenichi Handa <handa@m17n.org>
parents: 19615
diff changeset
602 (setq input-method (symbol-name input-method)))
19405
7ef4af7505f2 (previous-input-method): This
Kenichi Handa <handa@m17n.org>
parents: 19402
diff changeset
603 (if (and current-input-method
7ef4af7505f2 (previous-input-method): This
Kenichi Handa <handa@m17n.org>
parents: 19402
diff changeset
604 (not (string= current-input-method input-method)))
19402
b904f6547598 (toggle-input-method)
Richard M. Stallman <rms@gnu.org>
parents: 19329
diff changeset
605 (inactivate-input-method))
b904f6547598 (toggle-input-method)
Richard M. Stallman <rms@gnu.org>
parents: 19329
diff changeset
606 (unless current-input-method
18301
a4da36c7bb08 Define describe-coding-system instead of
Kenichi Handa <handa@m17n.org>
parents: 18217
diff changeset
607 (let ((slot (assoc input-method input-method-alist)))
a4da36c7bb08 Define describe-coding-system instead of
Kenichi Handa <handa@m17n.org>
parents: 18217
diff changeset
608 (if (null slot)
19405
7ef4af7505f2 (previous-input-method): This
Kenichi Handa <handa@m17n.org>
parents: 19402
diff changeset
609 (error "Can't activate input method `%s'" input-method))
20165
2d0abf12009b (set-default-coding-systems):
Kenichi Handa <handa@m17n.org>
parents: 20116
diff changeset
610 (let ((func (nth 2 slot)))
2d0abf12009b (set-default-coding-systems):
Kenichi Handa <handa@m17n.org>
parents: 20116
diff changeset
611 (if (functionp func)
2d0abf12009b (set-default-coding-systems):
Kenichi Handa <handa@m17n.org>
parents: 20116
diff changeset
612 (apply (nth 2 slot) input-method (nthcdr 5 slot))
2d0abf12009b (set-default-coding-systems):
Kenichi Handa <handa@m17n.org>
parents: 20116
diff changeset
613 (if (and (consp func) (symbolp (car func)) (symbolp (cdr func)))
2d0abf12009b (set-default-coding-systems):
Kenichi Handa <handa@m17n.org>
parents: 20116
diff changeset
614 (progn
2d0abf12009b (set-default-coding-systems):
Kenichi Handa <handa@m17n.org>
parents: 20116
diff changeset
615 (require (cdr func))
2d0abf12009b (set-default-coding-systems):
Kenichi Handa <handa@m17n.org>
parents: 20116
diff changeset
616 (apply (car func) input-method (nthcdr 5 slot)))
2d0abf12009b (set-default-coding-systems):
Kenichi Handa <handa@m17n.org>
parents: 20116
diff changeset
617 (error "Can't activate input method `%s'" input-method))))
18301
a4da36c7bb08 Define describe-coding-system instead of
Kenichi Handa <handa@m17n.org>
parents: 18217
diff changeset
618 (setq current-input-method input-method)
19405
7ef4af7505f2 (previous-input-method): This
Kenichi Handa <handa@m17n.org>
parents: 19402
diff changeset
619 (setq current-input-method-title (nth 3 slot))
7ef4af7505f2 (previous-input-method): This
Kenichi Handa <handa@m17n.org>
parents: 19402
diff changeset
620 (run-hooks 'input-method-activate-hook))))
17991
65407fdc4a33 Delete defining "i" in mule-keymap.
Kenichi Handa <handa@m17n.org>
parents: 17840
diff changeset
621
65407fdc4a33 Delete defining "i" in mule-keymap.
Kenichi Handa <handa@m17n.org>
parents: 17840
diff changeset
622 (defun inactivate-input-method ()
19555
df2996f7fdc3 (inactivate-current-input-method-function): Doc-string modified.
Kenichi Handa <handa@m17n.org>
parents: 19424
diff changeset
623 "Turn off the current input method."
19405
7ef4af7505f2 (previous-input-method): This
Kenichi Handa <handa@m17n.org>
parents: 19402
diff changeset
624 (when current-input-method
7ef4af7505f2 (previous-input-method): This
Kenichi Handa <handa@m17n.org>
parents: 19402
diff changeset
625 (if input-method-history
7ef4af7505f2 (previous-input-method): This
Kenichi Handa <handa@m17n.org>
parents: 19402
diff changeset
626 (unless (string= current-input-method (car input-method-history))
7ef4af7505f2 (previous-input-method): This
Kenichi Handa <handa@m17n.org>
parents: 19402
diff changeset
627 (setq input-method-history
7ef4af7505f2 (previous-input-method): This
Kenichi Handa <handa@m17n.org>
parents: 19402
diff changeset
628 (cons current-input-method
7ef4af7505f2 (previous-input-method): This
Kenichi Handa <handa@m17n.org>
parents: 19402
diff changeset
629 (delete current-input-method input-method-history))))
7ef4af7505f2 (previous-input-method): This
Kenichi Handa <handa@m17n.org>
parents: 19402
diff changeset
630 (setq input-method-history (list current-input-method)))
7ef4af7505f2 (previous-input-method): This
Kenichi Handa <handa@m17n.org>
parents: 19402
diff changeset
631 (unwind-protect
7ef4af7505f2 (previous-input-method): This
Kenichi Handa <handa@m17n.org>
parents: 19402
diff changeset
632 (funcall inactivate-current-input-method-function)
17991
65407fdc4a33 Delete defining "i" in mule-keymap.
Kenichi Handa <handa@m17n.org>
parents: 17840
diff changeset
633 (unwind-protect
19405
7ef4af7505f2 (previous-input-method): This
Kenichi Handa <handa@m17n.org>
parents: 19402
diff changeset
634 (run-hooks 'input-method-inactivate-hook)
7ef4af7505f2 (previous-input-method): This
Kenichi Handa <handa@m17n.org>
parents: 19402
diff changeset
635 (setq current-input-method nil
7ef4af7505f2 (previous-input-method): This
Kenichi Handa <handa@m17n.org>
parents: 19402
diff changeset
636 current-input-method-title nil)))))
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
637
20295
27ae44142cfd (set-input-method): Renamed from select-input-method.
Karl Heuer <kwzh@gnu.org>
parents: 20231
diff changeset
638 (defun set-input-method (input-method)
19405
7ef4af7505f2 (previous-input-method): This
Kenichi Handa <handa@m17n.org>
parents: 19402
diff changeset
639 "Select and turn on INPUT-METHOD.
7ef4af7505f2 (previous-input-method): This
Kenichi Handa <handa@m17n.org>
parents: 19402
diff changeset
640 This sets the default input method to what you specify,
7ef4af7505f2 (previous-input-method): This
Kenichi Handa <handa@m17n.org>
parents: 19402
diff changeset
641 and turn it on for the current buffer."
18301
a4da36c7bb08 Define describe-coding-system instead of
Kenichi Handa <handa@m17n.org>
parents: 18217
diff changeset
642 (interactive
19405
7ef4af7505f2 (previous-input-method): This
Kenichi Handa <handa@m17n.org>
parents: 19402
diff changeset
643 (let* ((default (or (car input-method-history) default-input-method)))
19402
b904f6547598 (toggle-input-method)
Richard M. Stallman <rms@gnu.org>
parents: 19329
diff changeset
644 (list (read-input-method-name
19748
06cbad2e806a (read-input-method-name): Specify the input history properly.
Richard M. Stallman <rms@gnu.org>
parents: 19746
diff changeset
645 (if default "Select input method (default %s): " "Select input method: ")
19402
b904f6547598 (toggle-input-method)
Richard M. Stallman <rms@gnu.org>
parents: 19329
diff changeset
646 default t))))
18301
a4da36c7bb08 Define describe-coding-system instead of
Kenichi Handa <handa@m17n.org>
parents: 18217
diff changeset
647 (activate-input-method input-method)
19402
b904f6547598 (toggle-input-method)
Richard M. Stallman <rms@gnu.org>
parents: 19329
diff changeset
648 (setq default-input-method input-method))
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
649
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
650 (defun toggle-input-method (&optional arg)
17991
65407fdc4a33 Delete defining "i" in mule-keymap.
Kenichi Handa <handa@m17n.org>
parents: 17840
diff changeset
651 "Turn on or off a multilingual text input method for the current buffer.
19405
7ef4af7505f2 (previous-input-method): This
Kenichi Handa <handa@m17n.org>
parents: 19402
diff changeset
652
18301
a4da36c7bb08 Define describe-coding-system instead of
Kenichi Handa <handa@m17n.org>
parents: 18217
diff changeset
653 With arg, read an input method from minibuffer and turn it on.
19405
7ef4af7505f2 (previous-input-method): This
Kenichi Handa <handa@m17n.org>
parents: 19402
diff changeset
654
17991
65407fdc4a33 Delete defining "i" in mule-keymap.
Kenichi Handa <handa@m17n.org>
parents: 17840
diff changeset
655 Without arg, if some input method is currently activated, turn it off,
19405
7ef4af7505f2 (previous-input-method): This
Kenichi Handa <handa@m17n.org>
parents: 19402
diff changeset
656 else turn on an input method selected last time
7ef4af7505f2 (previous-input-method): This
Kenichi Handa <handa@m17n.org>
parents: 19402
diff changeset
657 or the default input method (see `default-input-method').
7ef4af7505f2 (previous-input-method): This
Kenichi Handa <handa@m17n.org>
parents: 19402
diff changeset
658
7ef4af7505f2 (previous-input-method): This
Kenichi Handa <handa@m17n.org>
parents: 19402
diff changeset
659 When there's no input method to turn on, turn on what read from minibuffer."
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
660 (interactive "P")
19405
7ef4af7505f2 (previous-input-method): This
Kenichi Handa <handa@m17n.org>
parents: 19402
diff changeset
661 (let* ((default (or (car input-method-history) default-input-method)))
18801
f60dbf4f7d7c (mule-keymap): Bind l to set-language-environment.
Kenichi Handa <handa@m17n.org>
parents: 18712
diff changeset
662 (if (and current-input-method (not arg))
f60dbf4f7d7c (mule-keymap): Bind l to set-language-environment.
Kenichi Handa <handa@m17n.org>
parents: 18712
diff changeset
663 (inactivate-input-method)
19405
7ef4af7505f2 (previous-input-method): This
Kenichi Handa <handa@m17n.org>
parents: 19402
diff changeset
664 (activate-input-method
7ef4af7505f2 (previous-input-method): This
Kenichi Handa <handa@m17n.org>
parents: 19402
diff changeset
665 (if (or arg (not default))
7ef4af7505f2 (previous-input-method): This
Kenichi Handa <handa@m17n.org>
parents: 19402
diff changeset
666 (read-input-method-name
7ef4af7505f2 (previous-input-method): This
Kenichi Handa <handa@m17n.org>
parents: 19402
diff changeset
667 (if default "Input method (default %s): " "Input method: " )
7ef4af7505f2 (previous-input-method): This
Kenichi Handa <handa@m17n.org>
parents: 19402
diff changeset
668 default t)
7ef4af7505f2 (previous-input-method): This
Kenichi Handa <handa@m17n.org>
parents: 19402
diff changeset
669 default))
7ef4af7505f2 (previous-input-method): This
Kenichi Handa <handa@m17n.org>
parents: 19402
diff changeset
670 (or default-input-method
7ef4af7505f2 (previous-input-method): This
Kenichi Handa <handa@m17n.org>
parents: 19402
diff changeset
671 (setq default-input-method current-input-method)))))
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
672
18301
a4da36c7bb08 Define describe-coding-system instead of
Kenichi Handa <handa@m17n.org>
parents: 18217
diff changeset
673 (defun describe-input-method (input-method)
19649
b2bf3c43c86a (get-language-info): Accept a symbol
Kenichi Handa <handa@m17n.org>
parents: 19615
diff changeset
674 "Describe input method INPUT-METHOD."
18301
a4da36c7bb08 Define describe-coding-system instead of
Kenichi Handa <handa@m17n.org>
parents: 18217
diff changeset
675 (interactive
a4da36c7bb08 Define describe-coding-system instead of
Kenichi Handa <handa@m17n.org>
parents: 18217
diff changeset
676 (list (read-input-method-name
a4da36c7bb08 Define describe-coding-system instead of
Kenichi Handa <handa@m17n.org>
parents: 18217
diff changeset
677 "Describe input method (default, current choice): ")))
19653
431753f747ea (describe-input-method): Fix previous
Kenichi Handa <handa@m17n.org>
parents: 19649
diff changeset
678 (if (and input-method (symbolp input-method))
19649
b2bf3c43c86a (get-language-info): Accept a symbol
Kenichi Handa <handa@m17n.org>
parents: 19615
diff changeset
679 (setq input-method (symbol-name input-method)))
18301
a4da36c7bb08 Define describe-coding-system instead of
Kenichi Handa <handa@m17n.org>
parents: 18217
diff changeset
680 (if (null input-method)
a4da36c7bb08 Define describe-coding-system instead of
Kenichi Handa <handa@m17n.org>
parents: 18217
diff changeset
681 (describe-current-input-method)
a4da36c7bb08 Define describe-coding-system instead of
Kenichi Handa <handa@m17n.org>
parents: 18217
diff changeset
682 (with-output-to-temp-buffer "*Help*"
a4da36c7bb08 Define describe-coding-system instead of
Kenichi Handa <handa@m17n.org>
parents: 18217
diff changeset
683 (let ((elt (assoc input-method input-method-alist)))
a4da36c7bb08 Define describe-coding-system instead of
Kenichi Handa <handa@m17n.org>
parents: 18217
diff changeset
684 (princ (format "Input method: %s (`%s' in mode line) for %s\n %s\n"
a4da36c7bb08 Define describe-coding-system instead of
Kenichi Handa <handa@m17n.org>
parents: 18217
diff changeset
685 input-method (nth 3 elt) (nth 1 elt) (nth 4 elt)))))))
a4da36c7bb08 Define describe-coding-system instead of
Kenichi Handa <handa@m17n.org>
parents: 18217
diff changeset
686
a4da36c7bb08 Define describe-coding-system instead of
Kenichi Handa <handa@m17n.org>
parents: 18217
diff changeset
687 (defun describe-current-input-method ()
19083
8fdb29b769ed Doc fixes; fix error message text.
Richard M. Stallman <rms@gnu.org>
parents: 19036
diff changeset
688 "Describe the input method currently in use."
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
689 (if current-input-method
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
690 (if (and (symbolp describe-current-input-method-function)
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
691 (fboundp describe-current-input-method-function))
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
692 (funcall describe-current-input-method-function)
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
693 (message "No way to describe the current input method `%s'"
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
694 (cdr current-input-method))
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
695 (ding))
18301
a4da36c7bb08 Define describe-coding-system instead of
Kenichi Handa <handa@m17n.org>
parents: 18217
diff changeset
696 (error "No input method is activated now")))
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
697
20116
8c1995cc7702 (read-multilingual-string): Use
Kenichi Handa <handa@m17n.org>
parents: 20091
diff changeset
698 (defun read-multilingual-string (prompt &optional initial-input input-method)
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
699 "Read a multilingual string from minibuffer, prompting with string PROMPT.
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
700 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
701 If optional second arg INITIAL-INPUT is non-nil, insert it in the minibuffer
18301
a4da36c7bb08 Define describe-coding-system instead of
Kenichi Handa <handa@m17n.org>
parents: 18217
diff changeset
702 initially.
a4da36c7bb08 Define describe-coding-system instead of
Kenichi Handa <handa@m17n.org>
parents: 18217
diff changeset
703 Optional 3rd argument INPUT-METHOD specifies the input method
19649
b2bf3c43c86a (get-language-info): Accept a symbol
Kenichi Handa <handa@m17n.org>
parents: 19615
diff changeset
704 to be activated instead of the one selected last time. It is a symbol
b2bf3c43c86a (get-language-info): Accept a symbol
Kenichi Handa <handa@m17n.org>
parents: 19615
diff changeset
705 or a string."
18712
7366898bee9e (read-multilingual-string): Adjusted
Kenichi Handa <handa@m17n.org>
parents: 18634
diff changeset
706 (setq input-method
7366898bee9e (read-multilingual-string): Adjusted
Kenichi Handa <handa@m17n.org>
parents: 18634
diff changeset
707 (or input-method
20116
8c1995cc7702 (read-multilingual-string): Use
Kenichi Handa <handa@m17n.org>
parents: 20091
diff changeset
708 current-input-method
18712
7366898bee9e (read-multilingual-string): Adjusted
Kenichi Handa <handa@m17n.org>
parents: 18634
diff changeset
709 default-input-method
7366898bee9e (read-multilingual-string): Adjusted
Kenichi Handa <handa@m17n.org>
parents: 18634
diff changeset
710 (read-input-method-name "Input method: " nil t)))
19654
4c0174fcf26c (read-multilingual-string): Fix previous change.
Kenichi Handa <handa@m17n.org>
parents: 19653
diff changeset
711 (if (and input-method (symbolp input-method))
19649
b2bf3c43c86a (get-language-info): Accept a symbol
Kenichi Handa <handa@m17n.org>
parents: 19615
diff changeset
712 (setq input-method (symbol-name input-method)))
20116
8c1995cc7702 (read-multilingual-string): Use
Kenichi Handa <handa@m17n.org>
parents: 20091
diff changeset
713 (let ((previous-input-method current-input-method))
8c1995cc7702 (read-multilingual-string): Use
Kenichi Handa <handa@m17n.org>
parents: 20091
diff changeset
714 (unwind-protect
8c1995cc7702 (read-multilingual-string): Use
Kenichi Handa <handa@m17n.org>
parents: 20091
diff changeset
715 (progn
8c1995cc7702 (read-multilingual-string): Use
Kenichi Handa <handa@m17n.org>
parents: 20091
diff changeset
716 (activate-input-method input-method)
8c1995cc7702 (read-multilingual-string): Use
Kenichi Handa <handa@m17n.org>
parents: 20091
diff changeset
717 (read-string prompt initial-input nil nil t))
8c1995cc7702 (read-multilingual-string): Use
Kenichi Handa <handa@m17n.org>
parents: 20091
diff changeset
718 (if previous-input-method
8c1995cc7702 (read-multilingual-string): Use
Kenichi Handa <handa@m17n.org>
parents: 20091
diff changeset
719 (activate-input-method previous-input-method)
8c1995cc7702 (read-multilingual-string): Use
Kenichi Handa <handa@m17n.org>
parents: 20091
diff changeset
720 (inactivate-input-method)))))
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
721
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
722 ;; Variables to control behavior of input methods. All input methods
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
723 ;; should react to these variables.
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
724
20165
2d0abf12009b (set-default-coding-systems):
Kenichi Handa <handa@m17n.org>
parents: 20116
diff changeset
725 (defcustom input-method-verbose-flag 'default
2d0abf12009b (set-default-coding-systems):
Kenichi Handa <handa@m17n.org>
parents: 20116
diff changeset
726 "*A flag to control extra guidance given by input methods.
2d0abf12009b (set-default-coding-systems):
Kenichi Handa <handa@m17n.org>
parents: 20116
diff changeset
727 The value should be nil, t, `complex-only', or `default'.
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
728
19917
834c629f9220 (select-input-method): No error if enable-multibyte-characters is nil.
Richard M. Stallman <rms@gnu.org>
parents: 19848
diff changeset
729 The extra guidance is done by showing list of available keys in echo
20165
2d0abf12009b (set-default-coding-systems):
Kenichi Handa <handa@m17n.org>
parents: 20116
diff changeset
730 area. When you use the input method in the minibuffer, the guidance
2d0abf12009b (set-default-coding-systems):
Kenichi Handa <handa@m17n.org>
parents: 20116
diff changeset
731 is shown at the bottom short window (split from the existing window).
2d0abf12009b (set-default-coding-systems):
Kenichi Handa <handa@m17n.org>
parents: 20116
diff changeset
732
2d0abf12009b (set-default-coding-systems):
Kenichi Handa <handa@m17n.org>
parents: 20116
diff changeset
733 If the value is t, extra guidance is always given, if the value is
2d0abf12009b (set-default-coding-systems):
Kenichi Handa <handa@m17n.org>
parents: 20116
diff changeset
734 nil, extra guidance is always suppressed.
19848
68c5c0b3ed0d (input-method-verbose-flag):
Kenichi Handa <handa@m17n.org>
parents: 19798
diff changeset
735
20165
2d0abf12009b (set-default-coding-systems):
Kenichi Handa <handa@m17n.org>
parents: 20116
diff changeset
736 If the value is `complex-only', only complex input methods such as
2d0abf12009b (set-default-coding-systems):
Kenichi Handa <handa@m17n.org>
parents: 20116
diff changeset
737 `chinese-py' and `japanese' give extra guidance.
2d0abf12009b (set-default-coding-systems):
Kenichi Handa <handa@m17n.org>
parents: 20116
diff changeset
738
2d0abf12009b (set-default-coding-systems):
Kenichi Handa <handa@m17n.org>
parents: 20116
diff changeset
739 If the value is `default', complex input methods always give extra
2d0abf12009b (set-default-coding-systems):
Kenichi Handa <handa@m17n.org>
parents: 20116
diff changeset
740 guidance, but simple input methods give it only when you are not in
2d0abf12009b (set-default-coding-systems):
Kenichi Handa <handa@m17n.org>
parents: 20116
diff changeset
741 the minibuffer.
2d0abf12009b (set-default-coding-systems):
Kenichi Handa <handa@m17n.org>
parents: 20116
diff changeset
742
2d0abf12009b (set-default-coding-systems):
Kenichi Handa <handa@m17n.org>
parents: 20116
diff changeset
743 See also the variable `input-method-highlight-flag'."
2d0abf12009b (set-default-coding-systems):
Kenichi Handa <handa@m17n.org>
parents: 20116
diff changeset
744 :type '(choice (const t) (const nil) (const complex-only) (const default))
19402
b904f6547598 (toggle-input-method)
Richard M. Stallman <rms@gnu.org>
parents: 19329
diff changeset
745 :group 'mule)
b904f6547598 (toggle-input-method)
Richard M. Stallman <rms@gnu.org>
parents: 19329
diff changeset
746
b904f6547598 (toggle-input-method)
Richard M. Stallman <rms@gnu.org>
parents: 19329
diff changeset
747 (defcustom input-method-highlight-flag t
b904f6547598 (toggle-input-method)
Richard M. Stallman <rms@gnu.org>
parents: 19329
diff changeset
748 "*If this flag is non-nil, input methods highlight partially-entered text.
b904f6547598 (toggle-input-method)
Richard M. Stallman <rms@gnu.org>
parents: 19329
diff changeset
749 For instance, while you are in the middle of a Quail input method sequence,
b904f6547598 (toggle-input-method)
Richard M. Stallman <rms@gnu.org>
parents: 19329
diff changeset
750 the text inserted so far is temporarily underlined.
20165
2d0abf12009b (set-default-coding-systems):
Kenichi Handa <handa@m17n.org>
parents: 20116
diff changeset
751 The underlining goes away when you finish or abort the input method sequence.
2d0abf12009b (set-default-coding-systems):
Kenichi Handa <handa@m17n.org>
parents: 20116
diff changeset
752 See also the variable `input-method-verbose-flag'."
19402
b904f6547598 (toggle-input-method)
Richard M. Stallman <rms@gnu.org>
parents: 19329
diff changeset
753 :type 'boolean
b904f6547598 (toggle-input-method)
Richard M. Stallman <rms@gnu.org>
parents: 19329
diff changeset
754 :group 'mule)
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
755
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
756 (defvar input-method-activate-hook nil
19555
df2996f7fdc3 (inactivate-current-input-method-function): Doc-string modified.
Kenichi Handa <handa@m17n.org>
parents: 19424
diff changeset
757 "Normal hook run just after an input method is activated.
df2996f7fdc3 (inactivate-current-input-method-function): Doc-string modified.
Kenichi Handa <handa@m17n.org>
parents: 19424
diff changeset
758
df2996f7fdc3 (inactivate-current-input-method-function): Doc-string modified.
Kenichi Handa <handa@m17n.org>
parents: 19424
diff changeset
759 The variable `current-input-method' keeps the input method name
df2996f7fdc3 (inactivate-current-input-method-function): Doc-string modified.
Kenichi Handa <handa@m17n.org>
parents: 19424
diff changeset
760 just activated.")
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
761
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
762 (defvar input-method-inactivate-hook nil
19555
df2996f7fdc3 (inactivate-current-input-method-function): Doc-string modified.
Kenichi Handa <handa@m17n.org>
parents: 19424
diff changeset
763 "Normal hook run just after an input method is inactivated.
df2996f7fdc3 (inactivate-current-input-method-function): Doc-string modified.
Kenichi Handa <handa@m17n.org>
parents: 19424
diff changeset
764
df2996f7fdc3 (inactivate-current-input-method-function): Doc-string modified.
Kenichi Handa <handa@m17n.org>
parents: 19424
diff changeset
765 The variable `current-input-method' still keeps the input method name
20467
813cabaafefb (set-language-info): Doc fix.
Karl Heuer <kwzh@gnu.org>
parents: 20295
diff changeset
766 just inactivated.")
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
767
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
768 (defvar input-method-after-insert-chunk-hook nil
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
769 "Normal hook run just after an input method insert some chunk of text.")
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
770
19405
7ef4af7505f2 (previous-input-method): This
Kenichi Handa <handa@m17n.org>
parents: 19402
diff changeset
771 (defvar input-method-exit-on-invalid-key nil
7ef4af7505f2 (previous-input-method): This
Kenichi Handa <handa@m17n.org>
parents: 19402
diff changeset
772 "This flag controls the behaviour of an input method on invalid key input.
7ef4af7505f2 (previous-input-method): This
Kenichi Handa <handa@m17n.org>
parents: 19402
diff changeset
773 Usually, when a user types a key which doesn't start any character
7ef4af7505f2 (previous-input-method): This
Kenichi Handa <handa@m17n.org>
parents: 19402
diff changeset
774 handled by the input method, the key is handled by turning off the
7ef4af7505f2 (previous-input-method): This
Kenichi Handa <handa@m17n.org>
parents: 19402
diff changeset
775 input method temporalily. After the key is handled, the input method is
7ef4af7505f2 (previous-input-method): This
Kenichi Handa <handa@m17n.org>
parents: 19402
diff changeset
776 back on.
7ef4af7505f2 (previous-input-method): This
Kenichi Handa <handa@m17n.org>
parents: 19402
diff changeset
777 But, if this flag is non-nil, the input method is never back on.")
7ef4af7505f2 (previous-input-method): This
Kenichi Handa <handa@m17n.org>
parents: 19402
diff changeset
778
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
779
20165
2d0abf12009b (set-default-coding-systems):
Kenichi Handa <handa@m17n.org>
parents: 20116
diff changeset
780 (defvar set-language-environment-hook nil
2d0abf12009b (set-default-coding-systems):
Kenichi Handa <handa@m17n.org>
parents: 20116
diff changeset
781 "Normal hook run after some language environment is set.
2d0abf12009b (set-default-coding-systems):
Kenichi Handa <handa@m17n.org>
parents: 20116
diff changeset
782
2d0abf12009b (set-default-coding-systems):
Kenichi Handa <handa@m17n.org>
parents: 20116
diff changeset
783 When you set some hook function here, that effect usually should not
2d0abf12009b (set-default-coding-systems):
Kenichi Handa <handa@m17n.org>
parents: 20116
diff changeset
784 be inherited to another language environment. So, you had better set
2d0abf12009b (set-default-coding-systems):
Kenichi Handa <handa@m17n.org>
parents: 20116
diff changeset
785 another function in `exit-language-environment-hook' (which see) to
2d0abf12009b (set-default-coding-systems):
Kenichi Handa <handa@m17n.org>
parents: 20116
diff changeset
786 cancel the effect.")
2d0abf12009b (set-default-coding-systems):
Kenichi Handa <handa@m17n.org>
parents: 20116
diff changeset
787
2d0abf12009b (set-default-coding-systems):
Kenichi Handa <handa@m17n.org>
parents: 20116
diff changeset
788 (defvar exit-language-environment-hook nil
2d0abf12009b (set-default-coding-systems):
Kenichi Handa <handa@m17n.org>
parents: 20116
diff changeset
789 "Normal hook run after exiting from some language environment.
2d0abf12009b (set-default-coding-systems):
Kenichi Handa <handa@m17n.org>
parents: 20116
diff changeset
790 When this hook is run, the variable `current-language-environment'
2d0abf12009b (set-default-coding-systems):
Kenichi Handa <handa@m17n.org>
parents: 20116
diff changeset
791 is still bound to the language environment being exited.
2d0abf12009b (set-default-coding-systems):
Kenichi Handa <handa@m17n.org>
parents: 20116
diff changeset
792
2d0abf12009b (set-default-coding-systems):
Kenichi Handa <handa@m17n.org>
parents: 20116
diff changeset
793 This hook is mainly used for cancelling the effect of
2d0abf12009b (set-default-coding-systems):
Kenichi Handa <handa@m17n.org>
parents: 20116
diff changeset
794 `set-language-environment-hook' (which-see).")
2d0abf12009b (set-default-coding-systems):
Kenichi Handa <handa@m17n.org>
parents: 20116
diff changeset
795
17991
65407fdc4a33 Delete defining "i" in mule-keymap.
Kenichi Handa <handa@m17n.org>
parents: 17840
diff changeset
796 (defun setup-specified-language-environment ()
18634
8b309d07a95e (set-language-environment): Do the real work here.
Richard M. Stallman <rms@gnu.org>
parents: 18633
diff changeset
797 "Set up multi-lingual environment convenient for the specified language."
17991
65407fdc4a33 Delete defining "i" in mule-keymap.
Kenichi Handa <handa@m17n.org>
parents: 17840
diff changeset
798 (interactive)
18634
8b309d07a95e (set-language-environment): Do the real work here.
Richard M. Stallman <rms@gnu.org>
parents: 18633
diff changeset
799 (let (language-name)
17991
65407fdc4a33 Delete defining "i" in mule-keymap.
Kenichi Handa <handa@m17n.org>
parents: 17840
diff changeset
800 (if (and (symbolp last-command-event)
65407fdc4a33 Delete defining "i" in mule-keymap.
Kenichi Handa <handa@m17n.org>
parents: 17840
diff changeset
801 (or (not (eq last-command-event 'Default))
65407fdc4a33 Delete defining "i" in mule-keymap.
Kenichi Handa <handa@m17n.org>
parents: 17840
diff changeset
802 (setq last-command-event 'English))
18634
8b309d07a95e (set-language-environment): Do the real work here.
Richard M. Stallman <rms@gnu.org>
parents: 18633
diff changeset
803 (setq language-name (symbol-name last-command-event)))
8b309d07a95e (set-language-environment): Do the real work here.
Richard M. Stallman <rms@gnu.org>
parents: 18633
diff changeset
804 (set-language-environment language-name)
17991
65407fdc4a33 Delete defining "i" in mule-keymap.
Kenichi Handa <handa@m17n.org>
parents: 17840
diff changeset
805 (error "Bogus calling sequence"))))
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
806
18634
8b309d07a95e (set-language-environment): Do the real work here.
Richard M. Stallman <rms@gnu.org>
parents: 18633
diff changeset
807 (defvar current-language-environment "English"
8b309d07a95e (set-language-environment): Do the real work here.
Richard M. Stallman <rms@gnu.org>
parents: 18633
diff changeset
808 "The last language environment specified with `set-language-environment'.")
8b309d07a95e (set-language-environment): Do the real work here.
Richard M. Stallman <rms@gnu.org>
parents: 18633
diff changeset
809
18066
eecd891e2b63 (set-language-environment): Add autoload cookie.
Richard M. Stallman <rms@gnu.org>
parents: 17991
diff changeset
810 (defun set-language-environment (language-name)
18068
317f57f07b14 Doc fix for previous change.
Richard M. Stallman <rms@gnu.org>
parents: 18066
diff changeset
811 "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
812 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
813 and sometimes other things."
20165
2d0abf12009b (set-default-coding-systems):
Kenichi Handa <handa@m17n.org>
parents: 20116
diff changeset
814 (interactive (list (read-language-name
2d0abf12009b (set-default-coding-systems):
Kenichi Handa <handa@m17n.org>
parents: 20116
diff changeset
815 'setup-function
2d0abf12009b (set-default-coding-systems):
Kenichi Handa <handa@m17n.org>
parents: 20116
diff changeset
816 "Set language environment (default, English): ")))
19649
b2bf3c43c86a (get-language-info): Accept a symbol
Kenichi Handa <handa@m17n.org>
parents: 19615
diff changeset
817 (if language-name
b2bf3c43c86a (get-language-info): Accept a symbol
Kenichi Handa <handa@m17n.org>
parents: 19615
diff changeset
818 (if (symbolp language-name)
b2bf3c43c86a (get-language-info): Accept a symbol
Kenichi Handa <handa@m17n.org>
parents: 19615
diff changeset
819 (setq language-name (symbol-name language-name)))
b2bf3c43c86a (get-language-info): Accept a symbol
Kenichi Handa <handa@m17n.org>
parents: 19615
diff changeset
820 (setq language-name "English"))
18801
f60dbf4f7d7c (mule-keymap): Bind l to set-language-environment.
Kenichi Handa <handa@m17n.org>
parents: 18712
diff changeset
821 (if (null (get-language-info language-name 'setup-function))
18634
8b309d07a95e (set-language-environment): Do the real work here.
Richard M. Stallman <rms@gnu.org>
parents: 18633
diff changeset
822 (error "Language environment not defined: %S" language-name))
20165
2d0abf12009b (set-default-coding-systems):
Kenichi Handa <handa@m17n.org>
parents: 20116
diff changeset
823 (if current-language-environment
2d0abf12009b (set-default-coding-systems):
Kenichi Handa <handa@m17n.org>
parents: 20116
diff changeset
824 (let ((func (get-language-info current-language-environment
2d0abf12009b (set-default-coding-systems):
Kenichi Handa <handa@m17n.org>
parents: 20116
diff changeset
825 'exit-function)))
20231
7f0ea4977b32 (set-language-environment): Run
Kenichi Handa <handa@m17n.org>
parents: 20165
diff changeset
826 (run-hooks 'exit-language-environment-hook)
7f0ea4977b32 (set-language-environment): Run
Kenichi Handa <handa@m17n.org>
parents: 20165
diff changeset
827 (if (fboundp func) (funcall func))))
20165
2d0abf12009b (set-default-coding-systems):
Kenichi Handa <handa@m17n.org>
parents: 20116
diff changeset
828 (setq current-language-environment language-name)
18634
8b309d07a95e (set-language-environment): Do the real work here.
Richard M. Stallman <rms@gnu.org>
parents: 18633
diff changeset
829 (funcall (get-language-info language-name 'setup-function))
20165
2d0abf12009b (set-default-coding-systems):
Kenichi Handa <handa@m17n.org>
parents: 20116
diff changeset
830 (run-hooks 'set-language-environment-hook)
18634
8b309d07a95e (set-language-environment): Do the real work here.
Richard M. Stallman <rms@gnu.org>
parents: 18633
diff changeset
831 (force-mode-line-update t))
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
832
20733
079907c59fb2 (set-language-info): Doc-string
Kenichi Handa <handa@m17n.org>
parents: 20485
diff changeset
833 (defun set-language-environment-coding-systems (language-name)
079907c59fb2 (set-language-info): Doc-string
Kenichi Handa <handa@m17n.org>
parents: 20485
diff changeset
834 "Do various coding system setups for language environment LANGUAGE-NAME."
079907c59fb2 (set-language-info): Doc-string
Kenichi Handa <handa@m17n.org>
parents: 20485
diff changeset
835 (let* ((priority (get-language-info language-name 'coding-priority))
079907c59fb2 (set-language-info): Doc-string
Kenichi Handa <handa@m17n.org>
parents: 20485
diff changeset
836 (default-coding (car priority)))
079907c59fb2 (set-language-info): Doc-string
Kenichi Handa <handa@m17n.org>
parents: 20485
diff changeset
837 (if priority
079907c59fb2 (set-language-info): Doc-string
Kenichi Handa <handa@m17n.org>
parents: 20485
diff changeset
838 (let ((categories (mapcar 'coding-system-category priority)))
079907c59fb2 (set-language-info): Doc-string
Kenichi Handa <handa@m17n.org>
parents: 20485
diff changeset
839 (set-default-coding-systems default-coding)
079907c59fb2 (set-language-info): Doc-string
Kenichi Handa <handa@m17n.org>
parents: 20485
diff changeset
840 (set-coding-priority categories)
079907c59fb2 (set-language-info): Doc-string
Kenichi Handa <handa@m17n.org>
parents: 20485
diff changeset
841 (while priority
079907c59fb2 (set-language-info): Doc-string
Kenichi Handa <handa@m17n.org>
parents: 20485
diff changeset
842 (set (car categories) (car priority))
079907c59fb2 (set-language-info): Doc-string
Kenichi Handa <handa@m17n.org>
parents: 20485
diff changeset
843 (setq priority (cdr priority) categories (cdr categories)))
079907c59fb2 (set-language-info): Doc-string
Kenichi Handa <handa@m17n.org>
parents: 20485
diff changeset
844 (update-iso-coding-systems)))))
079907c59fb2 (set-language-info): Doc-string
Kenichi Handa <handa@m17n.org>
parents: 20485
diff changeset
845
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
846 ;; Print all arguments with `princ', then print "\n".
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
847 (defsubst princ-list (&rest args)
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
848 (while args (princ (car args)) (setq args (cdr args)))
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
849 (princ "\n"))
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
850
17840
2517414676ed (set-language-info): Change the special treatment
Kenichi Handa <handa@m17n.org>
parents: 17758
diff changeset
851 ;; 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
852 ;; 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
853 ;; called from the menu:
18152
e184e7061c9a (describe-language-environment):
Richard M. Stallman <rms@gnu.org>
parents: 18068
diff changeset
854 ;; [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
855 ;; 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
856 (defun describe-specified-language-support ()
19083
8fdb29b769ed Doc fixes; fix error message text.
Richard M. Stallman <rms@gnu.org>
parents: 19036
diff changeset
857 "Describe how Emacs supports the specified language environment."
17840
2517414676ed (set-language-info): Change the special treatment
Kenichi Handa <handa@m17n.org>
parents: 17758
diff changeset
858 (interactive)
18152
e184e7061c9a (describe-language-environment):
Richard M. Stallman <rms@gnu.org>
parents: 18068
diff changeset
859 (let (language-name)
17840
2517414676ed (set-language-info): Change the special treatment
Kenichi Handa <handa@m17n.org>
parents: 17758
diff changeset
860 (if (not (and (symbolp last-command-event)
18152
e184e7061c9a (describe-language-environment):
Richard M. Stallman <rms@gnu.org>
parents: 18068
diff changeset
861 (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
862 (error "Bogus calling sequence"))
18152
e184e7061c9a (describe-language-environment):
Richard M. Stallman <rms@gnu.org>
parents: 18068
diff changeset
863 (describe-language-environment language-name)))
e184e7061c9a (describe-language-environment):
Richard M. Stallman <rms@gnu.org>
parents: 18068
diff changeset
864
e184e7061c9a (describe-language-environment):
Richard M. Stallman <rms@gnu.org>
parents: 18068
diff changeset
865 (defun describe-language-environment (language-name)
e184e7061c9a (describe-language-environment):
Richard M. Stallman <rms@gnu.org>
parents: 18068
diff changeset
866 "Describe how Emacs supports language environment LANGUAGE-NAME."
19653
431753f747ea (describe-input-method): Fix previous
Kenichi Handa <handa@m17n.org>
parents: 19649
diff changeset
867 (interactive
431753f747ea (describe-input-method): Fix previous
Kenichi Handa <handa@m17n.org>
parents: 19649
diff changeset
868 (list (read-language-name
431753f747ea (describe-input-method): Fix previous
Kenichi Handa <handa@m17n.org>
parents: 19649
diff changeset
869 'documentation
20091
aac4c6a58684 (describe-language-environment): Fix prompt.
Karl Heuer <kwzh@gnu.org>
parents: 19917
diff changeset
870 "Describe language environment (default, current choice): ")))
18634
8b309d07a95e (set-language-environment): Do the real work here.
Richard M. Stallman <rms@gnu.org>
parents: 18633
diff changeset
871 (if (null language-name)
8b309d07a95e (set-language-environment): Do the real work here.
Richard M. Stallman <rms@gnu.org>
parents: 18633
diff changeset
872 (setq language-name current-language-environment))
18152
e184e7061c9a (describe-language-environment):
Richard M. Stallman <rms@gnu.org>
parents: 18068
diff changeset
873 (if (or (null language-name)
e184e7061c9a (describe-language-environment):
Richard M. Stallman <rms@gnu.org>
parents: 18068
diff changeset
874 (null (get-language-info language-name 'documentation)))
e184e7061c9a (describe-language-environment):
Richard M. Stallman <rms@gnu.org>
parents: 18068
diff changeset
875 (error "No documentation for the specified language"))
19649
b2bf3c43c86a (get-language-info): Accept a symbol
Kenichi Handa <handa@m17n.org>
parents: 19615
diff changeset
876 (if (symbolp language-name)
b2bf3c43c86a (get-language-info): Accept a symbol
Kenichi Handa <handa@m17n.org>
parents: 19615
diff changeset
877 (setq language-name (symbol-name language-name)))
18152
e184e7061c9a (describe-language-environment):
Richard M. Stallman <rms@gnu.org>
parents: 18068
diff changeset
878 (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
879 (with-output-to-temp-buffer "*Help*"
17758
8c67c2e2cc29 (build-describe-language-support-function,
Kenichi Handa <handa@m17n.org>
parents: 17526
diff changeset
880 (if (stringp doc)
18301
a4da36c7bb08 Define describe-coding-system instead of
Kenichi Handa <handa@m17n.org>
parents: 18217
diff changeset
881 (progn
a4da36c7bb08 Define describe-coding-system instead of
Kenichi Handa <handa@m17n.org>
parents: 18217
diff changeset
882 (princ-list doc)
a4da36c7bb08 Define describe-coding-system instead of
Kenichi Handa <handa@m17n.org>
parents: 18217
diff changeset
883 (terpri)))
17991
65407fdc4a33 Delete defining "i" in mule-keymap.
Kenichi Handa <handa@m17n.org>
parents: 17840
diff changeset
884 (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
885 (if (stringp str)
65407fdc4a33 Delete defining "i" in mule-keymap.
Kenichi Handa <handa@m17n.org>
parents: 17840
diff changeset
886 (progn
18152
e184e7061c9a (describe-language-environment):
Richard M. Stallman <rms@gnu.org>
parents: 18068
diff changeset
887 (princ "Sample text:\n")
18301
a4da36c7bb08 Define describe-coding-system instead of
Kenichi Handa <handa@m17n.org>
parents: 18217
diff changeset
888 (princ-list " " str)
a4da36c7bb08 Define describe-coding-system instead of
Kenichi Handa <handa@m17n.org>
parents: 18217
diff changeset
889 (terpri))))
18152
e184e7061c9a (describe-language-environment):
Richard M. Stallman <rms@gnu.org>
parents: 18068
diff changeset
890 (princ "Input methods:\n")
18301
a4da36c7bb08 Define describe-coding-system instead of
Kenichi Handa <handa@m17n.org>
parents: 18217
diff changeset
891 (let ((l input-method-alist))
17991
65407fdc4a33 Delete defining "i" in mule-keymap.
Kenichi Handa <handa@m17n.org>
parents: 17840
diff changeset
892 (while l
18301
a4da36c7bb08 Define describe-coding-system instead of
Kenichi Handa <handa@m17n.org>
parents: 18217
diff changeset
893 (if (string= language-name (nth 1 (car l)))
a4da36c7bb08 Define describe-coding-system instead of
Kenichi Handa <handa@m17n.org>
parents: 18217
diff changeset
894 (princ-list " " (car (car l))
a4da36c7bb08 Define describe-coding-system instead of
Kenichi Handa <handa@m17n.org>
parents: 18217
diff changeset
895 (format " (`%s' in mode line)" (nth 3 (car l)))))
17991
65407fdc4a33 Delete defining "i" in mule-keymap.
Kenichi Handa <handa@m17n.org>
parents: 17840
diff changeset
896 (setq l (cdr l))))
18152
e184e7061c9a (describe-language-environment):
Richard M. Stallman <rms@gnu.org>
parents: 18068
diff changeset
897 (terpri)
e184e7061c9a (describe-language-environment):
Richard M. Stallman <rms@gnu.org>
parents: 18068
diff changeset
898 (princ "Character sets:\n")
17991
65407fdc4a33 Delete defining "i" in mule-keymap.
Kenichi Handa <handa@m17n.org>
parents: 17840
diff changeset
899 (let ((l (get-language-info language-name 'charset)))
65407fdc4a33 Delete defining "i" in mule-keymap.
Kenichi Handa <handa@m17n.org>
parents: 17840
diff changeset
900 (if (null l)
65407fdc4a33 Delete defining "i" in mule-keymap.
Kenichi Handa <handa@m17n.org>
parents: 17840
diff changeset
901 (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
902 (while l
17991
65407fdc4a33 Delete defining "i" in mule-keymap.
Kenichi Handa <handa@m17n.org>
parents: 17840
diff changeset
903 (princ-list " " (car l) ": "
65407fdc4a33 Delete defining "i" in mule-keymap.
Kenichi Handa <handa@m17n.org>
parents: 17840
diff changeset
904 (charset-description (car l)))
65407fdc4a33 Delete defining "i" in mule-keymap.
Kenichi Handa <handa@m17n.org>
parents: 17840
diff changeset
905 (setq l (cdr l)))))
18152
e184e7061c9a (describe-language-environment):
Richard M. Stallman <rms@gnu.org>
parents: 18068
diff changeset
906 (terpri)
e184e7061c9a (describe-language-environment):
Richard M. Stallman <rms@gnu.org>
parents: 18068
diff changeset
907 (princ "Coding systems:\n")
17991
65407fdc4a33 Delete defining "i" in mule-keymap.
Kenichi Handa <handa@m17n.org>
parents: 17840
diff changeset
908 (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
909 (if (null l)
65407fdc4a33 Delete defining "i" in mule-keymap.
Kenichi Handa <handa@m17n.org>
parents: 17840
diff changeset
910 (princ-list " nothing specific to " language-name)
65407fdc4a33 Delete defining "i" in mule-keymap.
Kenichi Handa <handa@m17n.org>
parents: 17840
diff changeset
911 (while l
18152
e184e7061c9a (describe-language-environment):
Richard M. Stallman <rms@gnu.org>
parents: 18068
diff changeset
912 (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
913 (car l)
e184e7061c9a (describe-language-environment):
Richard M. Stallman <rms@gnu.org>
parents: 18068
diff changeset
914 (coding-system-mnemonic (car l))
18176
fc07ea29cd81 Define mouse-set-font in mule-menu-keymap.
Kenichi Handa <handa@m17n.org>
parents: 18152
diff changeset
915 (coding-system-doc-string (car l))))
20165
2d0abf12009b (set-default-coding-systems):
Kenichi Handa <handa@m17n.org>
parents: 20116
diff changeset
916 (let ((aliases (coding-system-get (car l) 'alias-coding-systems)))
2d0abf12009b (set-default-coding-systems):
Kenichi Handa <handa@m17n.org>
parents: 20116
diff changeset
917 (when aliases
2d0abf12009b (set-default-coding-systems):
Kenichi Handa <handa@m17n.org>
parents: 20116
diff changeset
918 (princ "\t")
2d0abf12009b (set-default-coding-systems):
Kenichi Handa <handa@m17n.org>
parents: 20116
diff changeset
919 (princ (cons 'alias: (cdr aliases)))
2d0abf12009b (set-default-coding-systems):
Kenichi Handa <handa@m17n.org>
parents: 20116
diff changeset
920 (terpri)))
17991
65407fdc4a33 Delete defining "i" in mule-keymap.
Kenichi Handa <handa@m17n.org>
parents: 17840
diff changeset
921 (setq l (cdr l))))))))
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
922
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
923 ;;; Charset property
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
924
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
925 (defsubst get-charset-property (charset propname)
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
926 "Return the value of CHARSET's PROPNAME property.
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
927 This is the last value stored with
19083
8fdb29b769ed Doc fixes; fix error message text.
Richard M. Stallman <rms@gnu.org>
parents: 19036
diff changeset
928 (put-charset-property CHARSET PROPNAME VALUE)."
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
929 (plist-get (charset-plist charset) propname))
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
930
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
931 (defsubst put-charset-property (charset propname value)
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
932 "Store CHARSETS's PROPNAME property with value VALUE.
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
933 It can be retrieved with `(get-charset-property CHARSET PROPNAME)'."
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
934 (set-charset-plist charset
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
935 (plist-put (charset-plist charset) propname value)))
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
936
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
937 ;;; Character code property
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
938 (put 'char-code-property-table 'char-table-extra-slots 0)
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
939
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
940 (defvar char-code-property-table
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
941 (make-char-table 'char-code-property-table)
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
942 "Char-table containing a property list of each character code.
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
943
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
944 See also the documentation of `get-char-code-property' and
19083
8fdb29b769ed Doc fixes; fix error message text.
Richard M. Stallman <rms@gnu.org>
parents: 19036
diff changeset
945 `put-char-code-property'.")
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
946
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
947 (defun get-char-code-property (char propname)
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
948 "Return the value of CHAR's PROPNAME property in `char-code-property-table'."
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
949 (let ((plist (aref char-code-property-table char)))
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
950 (if (listp plist)
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
951 (car (cdr (memq propname plist))))))
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
952
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
953 (defun put-char-code-property (char propname value)
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
954 "Store CHAR's PROPNAME property with VALUE in `char-code-property-table'.
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
955 It can be retrieved with `(get-char-code-property CHAR PROPNAME)'."
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
956 (let ((plist (aref char-code-property-table char)))
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
957 (if plist
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
958 (let ((slot (memq propname plist)))
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
959 (if slot
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
960 (setcar (cdr slot) value)
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
961 (nconc plist (list propname value))))
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
962 (aset char-code-property-table char (list propname value)))))
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
963
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
964 ;;; mule-cmds.el ends here