annotate lisp/international/mule-cmds.el @ 22899:5f874a55feb3

(set-default-coding-systems): In --unibyte mode, don't set default-file-name-coding-system.
author Richard M. Stallman <rms@gnu.org>
date Tue, 04 Aug 1998 09:18:36 +0000
parents e24b79da83d6
children 776bc4293c87
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
21579
b26c7c2891b4 (global-map [menu-bar mule]):
Richard M. Stallman <rms@gnu.org>
parents: 21471
diff changeset
53 (define-key global-map [menu-bar mule]
b26c7c2891b4 (global-map [menu-bar mule]):
Richard M. Stallman <rms@gnu.org>
parents: 21471
diff changeset
54 `(menu-item "Mule" ,mule-menu-keymap
b26c7c2891b4 (global-map [menu-bar mule]):
Richard M. Stallman <rms@gnu.org>
parents: 21471
diff changeset
55 :visible default-enable-multibyte-characters))
17991
65407fdc4a33 Delete defining "i" in mule-keymap.
Kenichi Handa <handa@m17n.org>
parents: 17840
diff changeset
56
65407fdc4a33 Delete defining "i" in mule-keymap.
Kenichi Handa <handa@m17n.org>
parents: 17840
diff changeset
57 (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
58
18152
e184e7061c9a (describe-language-environment):
Richard M. Stallman <rms@gnu.org>
parents: 18068
diff changeset
59 (defvar describe-language-environment-map nil)
e184e7061c9a (describe-language-environment):
Richard M. Stallman <rms@gnu.org>
parents: 18068
diff changeset
60 (define-prefix-command 'describe-language-environment-map)
17991
65407fdc4a33 Delete defining "i" in mule-keymap.
Kenichi Handa <handa@m17n.org>
parents: 17840
diff changeset
61
65407fdc4a33 Delete defining "i" in mule-keymap.
Kenichi Handa <handa@m17n.org>
parents: 17840
diff changeset
62 (defvar setup-language-environment-map nil)
65407fdc4a33 Delete defining "i" in mule-keymap.
Kenichi Handa <handa@m17n.org>
parents: 17840
diff changeset
63 (define-prefix-command 'setup-language-environment-map)
65407fdc4a33 Delete defining "i" in mule-keymap.
Kenichi Handa <handa@m17n.org>
parents: 17840
diff changeset
64
65407fdc4a33 Delete defining "i" in mule-keymap.
Kenichi Handa <handa@m17n.org>
parents: 17840
diff changeset
65 (defvar set-coding-system-map nil)
65407fdc4a33 Delete defining "i" in mule-keymap.
Kenichi Handa <handa@m17n.org>
parents: 17840
diff changeset
66 (define-prefix-command 'set-coding-system-map)
65407fdc4a33 Delete defining "i" in mule-keymap.
Kenichi Handa <handa@m17n.org>
parents: 17840
diff changeset
67
18152
e184e7061c9a (describe-language-environment):
Richard M. Stallman <rms@gnu.org>
parents: 18068
diff changeset
68 (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
69 '("Describe Language Environment" . describe-language-environment-map)
17991
65407fdc4a33 Delete defining "i" in mule-keymap.
Kenichi Handa <handa@m17n.org>
parents: 17840
diff changeset
70 t)
65407fdc4a33 Delete defining "i" in mule-keymap.
Kenichi Handa <handa@m17n.org>
parents: 17840
diff changeset
71 (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
72 '("Set Language Environment" . setup-language-environment-map)
17991
65407fdc4a33 Delete defining "i" in mule-keymap.
Kenichi Handa <handa@m17n.org>
parents: 17840
diff changeset
73 t)
18351
8cc30b266976 Define mouse-set-font in mule-menu-keymap agian.
Kenichi Handa <handa@m17n.org>
parents: 18301
diff changeset
74 (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
75 '("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
76 t)
17991
65407fdc4a33 Delete defining "i" in mule-keymap.
Kenichi Handa <handa@m17n.org>
parents: 17840
diff changeset
77 (define-key-after mule-menu-keymap [separator-mule]
65407fdc4a33 Delete defining "i" in mule-keymap.
Kenichi Handa <handa@m17n.org>
parents: 17840
diff changeset
78 '("--")
65407fdc4a33 Delete defining "i" in mule-keymap.
Kenichi Handa <handa@m17n.org>
parents: 17840
diff changeset
79 t)
65407fdc4a33 Delete defining "i" in mule-keymap.
Kenichi Handa <handa@m17n.org>
parents: 17840
diff changeset
80 (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
81 '("Toggle Input Method" . toggle-input-method)
17991
65407fdc4a33 Delete defining "i" in mule-keymap.
Kenichi Handa <handa@m17n.org>
parents: 17840
diff changeset
82 t)
20295
27ae44142cfd (set-input-method): Renamed from select-input-method.
Karl Heuer <kwzh@gnu.org>
parents: 20231
diff changeset
83 (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
84 '("Select Input Method" . set-input-method)
17991
65407fdc4a33 Delete defining "i" in mule-keymap.
Kenichi Handa <handa@m17n.org>
parents: 17840
diff changeset
85 t)
65407fdc4a33 Delete defining "i" in mule-keymap.
Kenichi Handa <handa@m17n.org>
parents: 17840
diff changeset
86 (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
87 '("Describe Input Method" . describe-input-method)
17991
65407fdc4a33 Delete defining "i" in mule-keymap.
Kenichi Handa <handa@m17n.org>
parents: 17840
diff changeset
88 t)
65407fdc4a33 Delete defining "i" in mule-keymap.
Kenichi Handa <handa@m17n.org>
parents: 17840
diff changeset
89 (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
90 '("--")
65407fdc4a33 Delete defining "i" in mule-keymap.
Kenichi Handa <handa@m17n.org>
parents: 17840
diff changeset
91 t)
18301
a4da36c7bb08 Define describe-coding-system instead of
Kenichi Handa <handa@m17n.org>
parents: 18217
diff changeset
92 (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
93 '("Describe Coding Systems" . describe-coding-system)
17991
65407fdc4a33 Delete defining "i" in mule-keymap.
Kenichi Handa <handa@m17n.org>
parents: 17840
diff changeset
94 t)
65407fdc4a33 Delete defining "i" in mule-keymap.
Kenichi Handa <handa@m17n.org>
parents: 17840
diff changeset
95 (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
96 '("Set Coding System" . set-coding-system-map)
17991
65407fdc4a33 Delete defining "i" in mule-keymap.
Kenichi Handa <handa@m17n.org>
parents: 17840
diff changeset
97 t)
65407fdc4a33 Delete defining "i" in mule-keymap.
Kenichi Handa <handa@m17n.org>
parents: 17840
diff changeset
98 (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
99 '("--")
65407fdc4a33 Delete defining "i" in mule-keymap.
Kenichi Handa <handa@m17n.org>
parents: 17840
diff changeset
100 t)
65407fdc4a33 Delete defining "i" in mule-keymap.
Kenichi Handa <handa@m17n.org>
parents: 17840
diff changeset
101 (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
102 '("Show All of MULE Status" . mule-diag)
17991
65407fdc4a33 Delete defining "i" in mule-keymap.
Kenichi Handa <handa@m17n.org>
parents: 17840
diff changeset
103 t)
65407fdc4a33 Delete defining "i" in mule-keymap.
Kenichi Handa <handa@m17n.org>
parents: 17840
diff changeset
104 (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
105 '("Show Script Examples" . view-hello-file)
17991
65407fdc4a33 Delete defining "i" in mule-keymap.
Kenichi Handa <handa@m17n.org>
parents: 17840
diff changeset
106 t)
65407fdc4a33 Delete defining "i" in mule-keymap.
Kenichi Handa <handa@m17n.org>
parents: 17840
diff changeset
107
65407fdc4a33 Delete defining "i" in mule-keymap.
Kenichi Handa <handa@m17n.org>
parents: 17840
diff changeset
108 (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
109 '("Buffer File" . set-buffer-file-coding-system)
17991
65407fdc4a33 Delete defining "i" in mule-keymap.
Kenichi Handa <handa@m17n.org>
parents: 17840
diff changeset
110 t)
19673
da7f50da6773 (set-coding-system-map):
Richard M. Stallman <rms@gnu.org>
parents: 19654
diff changeset
111 (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
112 '("Next Command" . universal-coding-system-argument)
da7f50da6773 (set-coding-system-map):
Richard M. Stallman <rms@gnu.org>
parents: 19654
diff changeset
113 t)
17991
65407fdc4a33 Delete defining "i" in mule-keymap.
Kenichi Handa <handa@m17n.org>
parents: 17840
diff changeset
114 (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
115 '("Terminal" . set-terminal-coding-system)
65407fdc4a33 Delete defining "i" in mule-keymap.
Kenichi Handa <handa@m17n.org>
parents: 17840
diff changeset
116 t)
65407fdc4a33 Delete defining "i" in mule-keymap.
Kenichi Handa <handa@m17n.org>
parents: 17840
diff changeset
117 (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
118 '("Keyboard" . set-keyboard-coding-system)
65407fdc4a33 Delete defining "i" in mule-keymap.
Kenichi Handa <handa@m17n.org>
parents: 17840
diff changeset
119 t)
65407fdc4a33 Delete defining "i" in mule-keymap.
Kenichi Handa <handa@m17n.org>
parents: 17840
diff changeset
120 (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
121 '("Buffer Process" . set-buffer-process-coding-system)
17991
65407fdc4a33 Delete defining "i" in mule-keymap.
Kenichi Handa <handa@m17n.org>
parents: 17840
diff changeset
122 t)
65407fdc4a33 Delete defining "i" in mule-keymap.
Kenichi Handa <handa@m17n.org>
parents: 17840
diff changeset
123
65407fdc4a33 Delete defining "i" in mule-keymap.
Kenichi Handa <handa@m17n.org>
parents: 17840
diff changeset
124 (define-key setup-language-environment-map
65407fdc4a33 Delete defining "i" in mule-keymap.
Kenichi Handa <handa@m17n.org>
parents: 17840
diff changeset
125 [Default] '("Default" . setup-specified-language-environment))
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
126
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
127 ;; These are meaningless when running under X.
17991
65407fdc4a33 Delete defining "i" in mule-keymap.
Kenichi Handa <handa@m17n.org>
parents: 17840
diff changeset
128 (put 'set-terminal-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)))
17991
65407fdc4a33 Delete defining "i" in mule-keymap.
Kenichi Handa <handa@m17n.org>
parents: 17840
diff changeset
130 (put 'set-keyboard-coding-system 'menu-enable
19614
a0db11a32775 (set-terminal-coding-system):
Richard M. Stallman <rms@gnu.org>
parents: 19555
diff changeset
131 '(not (eq window-system 'x)))
18301
a4da36c7bb08 Define describe-coding-system instead of
Kenichi Handa <handa@m17n.org>
parents: 18217
diff changeset
132 ;; 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
133 (put 'set-buffer-process-coding-system 'menu-enable
a4da36c7bb08 Define describe-coding-system instead of
Kenichi Handa <handa@m17n.org>
parents: 18217
diff changeset
134 '(get-buffer-process (current-buffer)))
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
135
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
136 ;; This should be a single character key binding because users use it
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
137 ;; very frequently while editing multilingual text. Now we can use
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
138 ;; only two such keys: "\C-\\" and "\C-^", but the latter is not
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
139 ;; convenient because it requires shifting on most keyboards. An
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
140 ;; alternative is "\C-\]" which is now bound to `abort-recursive-edit'
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
141 ;; but it won't be used that frequently.
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
142 (define-key global-map "\C-\\" 'toggle-input-method)
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
143
18807
75b2e402c45d (global-map): Turn off the S-SPC binding.
Richard M. Stallman <rms@gnu.org>
parents: 18801
diff changeset
144 ;;; 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
145 ;;; meaning to type SPC. -- rms.
75b2e402c45d (global-map): Turn off the S-SPC binding.
Richard M. Stallman <rms@gnu.org>
parents: 18801
diff changeset
146 ;;; ;; 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
147 ;;; (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
148
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
149 (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
150 "Change whether this buffer uses multibyte characters.
141c2d41d39c (toggle-enable-multibyte-characters): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents: 20467
diff changeset
151 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
152
141c2d41d39c (toggle-enable-multibyte-characters): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents: 20467
diff changeset
153 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
154 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
155 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
156 characters that the current buffer contains.
141c2d41d39c (toggle-enable-multibyte-characters): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents: 20467
diff changeset
157
141c2d41d39c (toggle-enable-multibyte-characters): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents: 20467
diff changeset
158 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
159 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
160 wrong, use this command again to toggle back to the right mode."
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
161 (interactive "P")
20830
237a0f70c61d (toggle-enable-multibyte-characters): Use set-buffer-multibyte.
Richard M. Stallman <rms@gnu.org>
parents: 20733
diff changeset
162 (let ((new-flag
237a0f70c61d (toggle-enable-multibyte-characters): Use set-buffer-multibyte.
Richard M. Stallman <rms@gnu.org>
parents: 20733
diff changeset
163 (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
164 (> (prefix-numeric-value arg) 0))))
237a0f70c61d (toggle-enable-multibyte-characters): Use set-buffer-multibyte.
Richard M. Stallman <rms@gnu.org>
parents: 20733
diff changeset
165 (set-buffer-multibyte new-flag))
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
166 (force-mode-line-update))
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
167
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
168 (defun view-hello-file ()
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
169 "Display the HELLO file which list up many languages and characters."
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
170 (interactive)
17294
d7ae63db9e6e Prefix for Mule related commands is changed.
Kenichi Handa <handa@m17n.org>
parents: 17090
diff changeset
171 ;; 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
172 (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
173 (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
174 (find-file-read-only (expand-file-name "HELLO" data-directory))))
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
175
17991
65407fdc4a33 Delete defining "i" in mule-keymap.
Kenichi Handa <handa@m17n.org>
parents: 17840
diff changeset
176 (defun universal-coding-system-argument ()
65407fdc4a33 Delete defining "i" in mule-keymap.
Kenichi Handa <handa@m17n.org>
parents: 17840
diff changeset
177 "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
178 (interactive)
21882
4fb3860a1f26 (find-coding-systems-for-charsets):
Kenichi Handa <handa@m17n.org>
parents: 21856
diff changeset
179 (let* ((default (and buffer-file-coding-system
4fb3860a1f26 (find-coding-systems-for-charsets):
Kenichi Handa <handa@m17n.org>
parents: 21856
diff changeset
180 (not (eq (coding-system-type buffer-file-coding-system)
4fb3860a1f26 (find-coding-systems-for-charsets):
Kenichi Handa <handa@m17n.org>
parents: 21856
diff changeset
181 t))
4fb3860a1f26 (find-coding-systems-for-charsets):
Kenichi Handa <handa@m17n.org>
parents: 21856
diff changeset
182 buffer-file-coding-system))
4fb3860a1f26 (find-coding-systems-for-charsets):
Kenichi Handa <handa@m17n.org>
parents: 21856
diff changeset
183 (coding-system (read-coding-system
4fb3860a1f26 (find-coding-systems-for-charsets):
Kenichi Handa <handa@m17n.org>
parents: 21856
diff changeset
184 (if default
4fb3860a1f26 (find-coding-systems-for-charsets):
Kenichi Handa <handa@m17n.org>
parents: 21856
diff changeset
185 (format "Coding system for following command (default, %s): " default)
4fb3860a1f26 (find-coding-systems-for-charsets):
Kenichi Handa <handa@m17n.org>
parents: 21856
diff changeset
186 "Coding system for following command: ")
4fb3860a1f26 (find-coding-systems-for-charsets):
Kenichi Handa <handa@m17n.org>
parents: 21856
diff changeset
187 default))
17991
65407fdc4a33 Delete defining "i" in mule-keymap.
Kenichi Handa <handa@m17n.org>
parents: 17840
diff changeset
188 (keyseq (read-key-sequence
19798
054497f70932 (universal-coding-system-argument): Improve prompt strings.
Richard M. Stallman <rms@gnu.org>
parents: 19784
diff changeset
189 (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
190 (cmd (key-binding keyseq)))
65407fdc4a33 Delete defining "i" in mule-keymap.
Kenichi Handa <handa@m17n.org>
parents: 17840
diff changeset
191 (let ((coding-system-for-read coding-system)
65407fdc4a33 Delete defining "i" in mule-keymap.
Kenichi Handa <handa@m17n.org>
parents: 17840
diff changeset
192 (coding-system-for-write coding-system))
65407fdc4a33 Delete defining "i" in mule-keymap.
Kenichi Handa <handa@m17n.org>
parents: 17840
diff changeset
193 (message "")
65407fdc4a33 Delete defining "i" in mule-keymap.
Kenichi Handa <handa@m17n.org>
parents: 17840
diff changeset
194 (call-interactively cmd))))
65407fdc4a33 Delete defining "i" in mule-keymap.
Kenichi Handa <handa@m17n.org>
parents: 17840
diff changeset
195
19141
9e0468e59b5f (set-default-coding-systems): New function.
Kenichi Handa <handa@m17n.org>
parents: 19083
diff changeset
196 (defun set-default-coding-systems (coding-system)
19267
6e152439176f (set-default-coding-systems):
Kenichi Handa <handa@m17n.org>
parents: 19141
diff changeset
197 "Set default value of various coding systems to CODING-SYSTEM.
21042
b6530c2add6a (set-default-coding-systems): Set
Kenichi Handa <handa@m17n.org>
parents: 20941
diff changeset
198 This sets the following coding systems:
19267
6e152439176f (set-default-coding-systems):
Kenichi Handa <handa@m17n.org>
parents: 19141
diff changeset
199 o coding system of a newly created buffer
20165
2d0abf12009b (set-default-coding-systems):
Kenichi Handa <handa@m17n.org>
parents: 20116
diff changeset
200 o default coding system for subprocess I/O
2d0abf12009b (set-default-coding-systems):
Kenichi Handa <handa@m17n.org>
parents: 20116
diff changeset
201 This also sets the following values:
21042
b6530c2add6a (set-default-coding-systems): Set
Kenichi Handa <handa@m17n.org>
parents: 20941
diff changeset
202 o default value used as file-name-coding-system for converting file names.
20165
2d0abf12009b (set-default-coding-systems):
Kenichi Handa <handa@m17n.org>
parents: 20116
diff changeset
203 o default value for the command `set-terminal-coding-system'
2d0abf12009b (set-default-coding-systems):
Kenichi Handa <handa@m17n.org>
parents: 20116
diff changeset
204 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
205 (check-coding-system coding-system)
9e0468e59b5f (set-default-coding-systems): New function.
Kenichi Handa <handa@m17n.org>
parents: 19083
diff changeset
206 (setq-default buffer-file-coding-system coding-system)
22899
5f874a55feb3 (set-default-coding-systems):
Richard M. Stallman <rms@gnu.org>
parents: 22887
diff changeset
207 (if default-enable-multibyte-characters
5f874a55feb3 (set-default-coding-systems):
Richard M. Stallman <rms@gnu.org>
parents: 22887
diff changeset
208 (setq default-file-name-coding-system coding-system))
19141
9e0468e59b5f (set-default-coding-systems): New function.
Kenichi Handa <handa@m17n.org>
parents: 19083
diff changeset
209 (setq default-terminal-coding-system coding-system)
9e0468e59b5f (set-default-coding-systems): New function.
Kenichi Handa <handa@m17n.org>
parents: 19083
diff changeset
210 (setq default-keyboard-coding-system coding-system)
9e0468e59b5f (set-default-coding-systems): New function.
Kenichi Handa <handa@m17n.org>
parents: 19083
diff changeset
211 (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
212
22887
e24b79da83d6 (language-info-alist): Doc-string
Kenichi Handa <handa@m17n.org>
parents: 22854
diff changeset
213 (defalias 'update-iso-coding-systems 'update-coding-systems-internal)
e24b79da83d6 (language-info-alist): Doc-string
Kenichi Handa <handa@m17n.org>
parents: 22854
diff changeset
214 (make-obsolete 'update-iso-coding-systems 'update-coding-systems-internal)
e24b79da83d6 (language-info-alist): Doc-string
Kenichi Handa <handa@m17n.org>
parents: 22854
diff changeset
215
19267
6e152439176f (set-default-coding-systems):
Kenichi Handa <handa@m17n.org>
parents: 19141
diff changeset
216 (defun prefer-coding-system (coding-system)
6e152439176f (set-default-coding-systems):
Kenichi Handa <handa@m17n.org>
parents: 19141
diff changeset
217 "Add CODING-SYSTEM at the front of the priority list for automatic detection.
21042
b6530c2add6a (set-default-coding-systems): Set
Kenichi Handa <handa@m17n.org>
parents: 20941
diff changeset
218 This also sets the following coding systems:
19267
6e152439176f (set-default-coding-systems):
Kenichi Handa <handa@m17n.org>
parents: 19141
diff changeset
219 o coding system of a newly created buffer
20165
2d0abf12009b (set-default-coding-systems):
Kenichi Handa <handa@m17n.org>
parents: 20116
diff changeset
220 o default coding system for subprocess I/O
2d0abf12009b (set-default-coding-systems):
Kenichi Handa <handa@m17n.org>
parents: 20116
diff changeset
221 This also sets the following values:
21042
b6530c2add6a (set-default-coding-systems): Set
Kenichi Handa <handa@m17n.org>
parents: 20941
diff changeset
222 o default value used as file-name-coding-system for converting file names.
20165
2d0abf12009b (set-default-coding-systems):
Kenichi Handa <handa@m17n.org>
parents: 20116
diff changeset
223 o default value for the command `set-terminal-coding-system'
2d0abf12009b (set-default-coding-systems):
Kenichi Handa <handa@m17n.org>
parents: 20116
diff changeset
224 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
225 (interactive "zPrefer coding system: ")
6e152439176f (set-default-coding-systems):
Kenichi Handa <handa@m17n.org>
parents: 19141
diff changeset
226 (if (not (and coding-system (coding-system-p coding-system)))
6e152439176f (set-default-coding-systems):
Kenichi Handa <handa@m17n.org>
parents: 19141
diff changeset
227 (error "Invalid coding system `%s'" coding-system))
6e152439176f (set-default-coding-systems):
Kenichi Handa <handa@m17n.org>
parents: 19141
diff changeset
228 (let ((coding-category (coding-system-category coding-system))
20165
2d0abf12009b (set-default-coding-systems):
Kenichi Handa <handa@m17n.org>
parents: 20116
diff changeset
229 (base (coding-system-base coding-system)))
19267
6e152439176f (set-default-coding-systems):
Kenichi Handa <handa@m17n.org>
parents: 19141
diff changeset
230 (if (not coding-category)
6e152439176f (set-default-coding-systems):
Kenichi Handa <handa@m17n.org>
parents: 19141
diff changeset
231 ;; CODING-SYSTEM is no-conversion or undecided.
6e152439176f (set-default-coding-systems):
Kenichi Handa <handa@m17n.org>
parents: 19141
diff changeset
232 (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
233 (set coding-category (or base coding-system))
22887
e24b79da83d6 (language-info-alist): Doc-string
Kenichi Handa <handa@m17n.org>
parents: 22854
diff changeset
234 (update-coding-systems-internal)
19267
6e152439176f (set-default-coding-systems):
Kenichi Handa <handa@m17n.org>
parents: 19141
diff changeset
235 (if (not (eq coding-category (car coding-category-list)))
6e152439176f (set-default-coding-systems):
Kenichi Handa <handa@m17n.org>
parents: 19141
diff changeset
236 ;; We must change the order.
6e152439176f (set-default-coding-systems):
Kenichi Handa <handa@m17n.org>
parents: 19141
diff changeset
237 (setq coding-category-list
6e152439176f (set-default-coding-systems):
Kenichi Handa <handa@m17n.org>
parents: 19141
diff changeset
238 (cons coding-category
6e152439176f (set-default-coding-systems):
Kenichi Handa <handa@m17n.org>
parents: 19141
diff changeset
239 (delq coding-category coding-category-list))))
20165
2d0abf12009b (set-default-coding-systems):
Kenichi Handa <handa@m17n.org>
parents: 20116
diff changeset
240 (if (and base (interactive-p))
2d0abf12009b (set-default-coding-systems):
Kenichi Handa <handa@m17n.org>
parents: 20116
diff changeset
241 (message "Highest priority is set to %s (base of %s)"
2d0abf12009b (set-default-coding-systems):
Kenichi Handa <handa@m17n.org>
parents: 20116
diff changeset
242 base coding-system))
2d0abf12009b (set-default-coding-systems):
Kenichi Handa <handa@m17n.org>
parents: 20116
diff changeset
243 (set-default-coding-systems (or base coding-system))))
19267
6e152439176f (set-default-coding-systems):
Kenichi Handa <handa@m17n.org>
parents: 19141
diff changeset
244
22153
a63d4ba6813a Several doc fixes.
Richard M. Stallman <rms@gnu.org>
parents: 22025
diff changeset
245 (defun find-coding-systems-region-subset-p (list1 list2)
20733
079907c59fb2 (set-language-info): Doc-string
Kenichi Handa <handa@m17n.org>
parents: 20485
diff changeset
246 "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
247 Comparison done with EQ."
079907c59fb2 (set-language-info): Doc-string
Kenichi Handa <handa@m17n.org>
parents: 20485
diff changeset
248 (catch 'tag
079907c59fb2 (set-language-info): Doc-string
Kenichi Handa <handa@m17n.org>
parents: 20485
diff changeset
249 (while list1
079907c59fb2 (set-language-info): Doc-string
Kenichi Handa <handa@m17n.org>
parents: 20485
diff changeset
250 (or (memq (car list1) list2)
079907c59fb2 (set-language-info): Doc-string
Kenichi Handa <handa@m17n.org>
parents: 20485
diff changeset
251 (throw 'tag nil))
079907c59fb2 (set-language-info): Doc-string
Kenichi Handa <handa@m17n.org>
parents: 20485
diff changeset
252 (setq list1 (cdr list1)))
079907c59fb2 (set-language-info): Doc-string
Kenichi Handa <handa@m17n.org>
parents: 20485
diff changeset
253 t))
079907c59fb2 (set-language-info): Doc-string
Kenichi Handa <handa@m17n.org>
parents: 20485
diff changeset
254
21377
bc409dfad8e7 (subset-p): Renamed from
Kenichi Handa <handa@m17n.org>
parents: 21229
diff changeset
255 (defun find-coding-systems-region (from to)
20733
079907c59fb2 (set-language-info): Doc-string
Kenichi Handa <handa@m17n.org>
parents: 20485
diff changeset
256 "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
257 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
258 in the text.
079907c59fb2 (set-language-info): Doc-string
Kenichi Handa <handa@m17n.org>
parents: 20485
diff changeset
259
079907c59fb2 (set-language-info): Doc-string
Kenichi Handa <handa@m17n.org>
parents: 20485
diff changeset
260 If the text contains no multibyte charcters, return a list of a single
21377
bc409dfad8e7 (subset-p): Renamed from
Kenichi Handa <handa@m17n.org>
parents: 21229
diff changeset
261 element `undecided'."
bc409dfad8e7 (subset-p): Renamed from
Kenichi Handa <handa@m17n.org>
parents: 21229
diff changeset
262 (find-coding-systems-for-charsets (find-charset-region from to)))
bc409dfad8e7 (subset-p): Renamed from
Kenichi Handa <handa@m17n.org>
parents: 21229
diff changeset
263
bc409dfad8e7 (subset-p): Renamed from
Kenichi Handa <handa@m17n.org>
parents: 21229
diff changeset
264 (defun find-coding-systems-string (string)
bc409dfad8e7 (subset-p): Renamed from
Kenichi Handa <handa@m17n.org>
parents: 21229
diff changeset
265 "Return a list of proper coding systems to encode STRING.
bc409dfad8e7 (subset-p): Renamed from
Kenichi Handa <handa@m17n.org>
parents: 21229
diff changeset
266 All coding systems in the list can safely encode any multibyte characters
bc409dfad8e7 (subset-p): Renamed from
Kenichi Handa <handa@m17n.org>
parents: 21229
diff changeset
267 in STRING.
bc409dfad8e7 (subset-p): Renamed from
Kenichi Handa <handa@m17n.org>
parents: 21229
diff changeset
268
bc409dfad8e7 (subset-p): Renamed from
Kenichi Handa <handa@m17n.org>
parents: 21229
diff changeset
269 If STRING contains no multibyte charcters, return a list of a single
bc409dfad8e7 (subset-p): Renamed from
Kenichi Handa <handa@m17n.org>
parents: 21229
diff changeset
270 element `undecided'."
bc409dfad8e7 (subset-p): Renamed from
Kenichi Handa <handa@m17n.org>
parents: 21229
diff changeset
271 (find-coding-systems-for-charsets (find-charset-string string)))
20733
079907c59fb2 (set-language-info): Doc-string
Kenichi Handa <handa@m17n.org>
parents: 20485
diff changeset
272
21377
bc409dfad8e7 (subset-p): Renamed from
Kenichi Handa <handa@m17n.org>
parents: 21229
diff changeset
273 (defun find-coding-systems-for-charsets (charsets)
bc409dfad8e7 (subset-p): Renamed from
Kenichi Handa <handa@m17n.org>
parents: 21229
diff changeset
274 "Return a list of proper coding systems to encode characters of CHARSETS.
bc409dfad8e7 (subset-p): Renamed from
Kenichi Handa <handa@m17n.org>
parents: 21229
diff changeset
275 CHARSETS is a list of character sets."
bc409dfad8e7 (subset-p): Renamed from
Kenichi Handa <handa@m17n.org>
parents: 21229
diff changeset
276 (if (or (null charsets)
bc409dfad8e7 (subset-p): Renamed from
Kenichi Handa <handa@m17n.org>
parents: 21229
diff changeset
277 (and (= (length charsets) 1)
bc409dfad8e7 (subset-p): Renamed from
Kenichi Handa <handa@m17n.org>
parents: 21229
diff changeset
278 (eq 'ascii (car charsets))))
bc409dfad8e7 (subset-p): Renamed from
Kenichi Handa <handa@m17n.org>
parents: 21229
diff changeset
279 '(undecided)
bc409dfad8e7 (subset-p): Renamed from
Kenichi Handa <handa@m17n.org>
parents: 21229
diff changeset
280 (let ((l coding-system-list)
21882
4fb3860a1f26 (find-coding-systems-for-charsets):
Kenichi Handa <handa@m17n.org>
parents: 21856
diff changeset
281 (charset-prefered-codings
21377
bc409dfad8e7 (subset-p): Renamed from
Kenichi Handa <handa@m17n.org>
parents: 21229
diff changeset
282 (mapcar (function
bc409dfad8e7 (subset-p): Renamed from
Kenichi Handa <handa@m17n.org>
parents: 21229
diff changeset
283 (lambda (x)
bc409dfad8e7 (subset-p): Renamed from
Kenichi Handa <handa@m17n.org>
parents: 21229
diff changeset
284 (get-charset-property x 'prefered-coding-system)))
bc409dfad8e7 (subset-p): Renamed from
Kenichi Handa <handa@m17n.org>
parents: 21229
diff changeset
285 charsets))
21882
4fb3860a1f26 (find-coding-systems-for-charsets):
Kenichi Handa <handa@m17n.org>
parents: 21856
diff changeset
286 (priorities (mapcar (function (lambda (x) (symbol-value x)))
4fb3860a1f26 (find-coding-systems-for-charsets):
Kenichi Handa <handa@m17n.org>
parents: 21856
diff changeset
287 coding-category-list))
21377
bc409dfad8e7 (subset-p): Renamed from
Kenichi Handa <handa@m17n.org>
parents: 21229
diff changeset
288 codings coding safe)
bc409dfad8e7 (subset-p): Renamed from
Kenichi Handa <handa@m17n.org>
parents: 21229
diff changeset
289 (while l
bc409dfad8e7 (subset-p): Renamed from
Kenichi Handa <handa@m17n.org>
parents: 21229
diff changeset
290 (setq coding (car l) l (cdr l))
bc409dfad8e7 (subset-p): Renamed from
Kenichi Handa <handa@m17n.org>
parents: 21229
diff changeset
291 (if (and (eq coding (coding-system-base coding))
bc409dfad8e7 (subset-p): Renamed from
Kenichi Handa <handa@m17n.org>
parents: 21229
diff changeset
292 (setq safe (coding-system-get coding 'safe-charsets))
bc409dfad8e7 (subset-p): Renamed from
Kenichi Handa <handa@m17n.org>
parents: 21229
diff changeset
293 (or (eq safe t)
22153
a63d4ba6813a Several doc fixes.
Richard M. Stallman <rms@gnu.org>
parents: 22025
diff changeset
294 (find-coding-systems-region-subset-p charsets safe)))
21377
bc409dfad8e7 (subset-p): Renamed from
Kenichi Handa <handa@m17n.org>
parents: 21229
diff changeset
295 ;; We put the higher priority to coding systems included
21882
4fb3860a1f26 (find-coding-systems-for-charsets):
Kenichi Handa <handa@m17n.org>
parents: 21856
diff changeset
296 ;; in CHARSET-PREFERED-CODINGS, and within them, put the
4fb3860a1f26 (find-coding-systems-for-charsets):
Kenichi Handa <handa@m17n.org>
parents: 21856
diff changeset
297 ;; higher priority to coding systems which support smaller
21377
bc409dfad8e7 (subset-p): Renamed from
Kenichi Handa <handa@m17n.org>
parents: 21229
diff changeset
298 ;; number of charsets.
bc409dfad8e7 (subset-p): Renamed from
Kenichi Handa <handa@m17n.org>
parents: 21229
diff changeset
299 (let ((priority
21882
4fb3860a1f26 (find-coding-systems-for-charsets):
Kenichi Handa <handa@m17n.org>
parents: 21856
diff changeset
300 (+ (if (coding-system-get coding 'mime-charset) 4096 0)
4fb3860a1f26 (find-coding-systems-for-charsets):
Kenichi Handa <handa@m17n.org>
parents: 21856
diff changeset
301 (lsh (length (memq coding priorities)) 7)
4fb3860a1f26 (find-coding-systems-for-charsets):
Kenichi Handa <handa@m17n.org>
parents: 21856
diff changeset
302 (if (memq coding charset-prefered-codings) 64 0)
4fb3860a1f26 (find-coding-systems-for-charsets):
Kenichi Handa <handa@m17n.org>
parents: 21856
diff changeset
303 (if (> (coding-system-type coding) 0) 32 0)
4fb3860a1f26 (find-coding-systems-for-charsets):
Kenichi Handa <handa@m17n.org>
parents: 21856
diff changeset
304 (if (consp safe) (- 32 (length safe)) 0))))
21377
bc409dfad8e7 (subset-p): Renamed from
Kenichi Handa <handa@m17n.org>
parents: 21229
diff changeset
305 (setq codings (cons (cons priority coding) codings)))))
bc409dfad8e7 (subset-p): Renamed from
Kenichi Handa <handa@m17n.org>
parents: 21229
diff changeset
306 (mapcar 'cdr
bc409dfad8e7 (subset-p): Renamed from
Kenichi Handa <handa@m17n.org>
parents: 21229
diff changeset
307 (sort codings (function (lambda (x y) (> (car x) (car y))))))
bc409dfad8e7 (subset-p): Renamed from
Kenichi Handa <handa@m17n.org>
parents: 21229
diff changeset
308 )))
20733
079907c59fb2 (set-language-info): Doc-string
Kenichi Handa <handa@m17n.org>
parents: 20485
diff changeset
309
22815
6af93eeeca10 (find-multibyte-characters): New
Kenichi Handa <handa@m17n.org>
parents: 22778
diff changeset
310 (defun find-multibyte-characters (from to &optional maxcount excludes)
6af93eeeca10 (find-multibyte-characters): New
Kenichi Handa <handa@m17n.org>
parents: 22778
diff changeset
311 "Find multibyte characters in the region specified by FROM and TO.
6af93eeeca10 (find-multibyte-characters): New
Kenichi Handa <handa@m17n.org>
parents: 22778
diff changeset
312 If FROM is a string, find multibyte characters in the string.
6af93eeeca10 (find-multibyte-characters): New
Kenichi Handa <handa@m17n.org>
parents: 22778
diff changeset
313 The return value is an alist of the following format:
6af93eeeca10 (find-multibyte-characters): New
Kenichi Handa <handa@m17n.org>
parents: 22778
diff changeset
314 ((CHARSET COUNT CHAR ...) ...)
6af93eeeca10 (find-multibyte-characters): New
Kenichi Handa <handa@m17n.org>
parents: 22778
diff changeset
315 where
6af93eeeca10 (find-multibyte-characters): New
Kenichi Handa <handa@m17n.org>
parents: 22778
diff changeset
316 CHARSET is a character set,
6af93eeeca10 (find-multibyte-characters): New
Kenichi Handa <handa@m17n.org>
parents: 22778
diff changeset
317 COUNT is a number of characters,
6af93eeeca10 (find-multibyte-characters): New
Kenichi Handa <handa@m17n.org>
parents: 22778
diff changeset
318 CHARs are found characters of the character set.
6af93eeeca10 (find-multibyte-characters): New
Kenichi Handa <handa@m17n.org>
parents: 22778
diff changeset
319 Optional 3rd arg MAXCOUNT limits how many CHARs are put in the above list.
6af93eeeca10 (find-multibyte-characters): New
Kenichi Handa <handa@m17n.org>
parents: 22778
diff changeset
320 Optioanl 4th arg EXCLUDE is a list of character sets to be ignored."
6af93eeeca10 (find-multibyte-characters): New
Kenichi Handa <handa@m17n.org>
parents: 22778
diff changeset
321 (let ((chars nil)
6af93eeeca10 (find-multibyte-characters): New
Kenichi Handa <handa@m17n.org>
parents: 22778
diff changeset
322 charset char)
6af93eeeca10 (find-multibyte-characters): New
Kenichi Handa <handa@m17n.org>
parents: 22778
diff changeset
323 (if (stringp from)
6af93eeeca10 (find-multibyte-characters): New
Kenichi Handa <handa@m17n.org>
parents: 22778
diff changeset
324 (let ((idx 0))
6af93eeeca10 (find-multibyte-characters): New
Kenichi Handa <handa@m17n.org>
parents: 22778
diff changeset
325 (while (setq idx (string-match "[^\000-\177]" from idx))
6af93eeeca10 (find-multibyte-characters): New
Kenichi Handa <handa@m17n.org>
parents: 22778
diff changeset
326 (setq char (aref from idx)
6af93eeeca10 (find-multibyte-characters): New
Kenichi Handa <handa@m17n.org>
parents: 22778
diff changeset
327 charset (char-charset char))
6af93eeeca10 (find-multibyte-characters): New
Kenichi Handa <handa@m17n.org>
parents: 22778
diff changeset
328 (if (not (memq charset excludes))
6af93eeeca10 (find-multibyte-characters): New
Kenichi Handa <handa@m17n.org>
parents: 22778
diff changeset
329 (let ((slot (assq charset chars)))
6af93eeeca10 (find-multibyte-characters): New
Kenichi Handa <handa@m17n.org>
parents: 22778
diff changeset
330 (if slot
6af93eeeca10 (find-multibyte-characters): New
Kenichi Handa <handa@m17n.org>
parents: 22778
diff changeset
331 (if (not (memq char (nthcdr 2 slot)))
6af93eeeca10 (find-multibyte-characters): New
Kenichi Handa <handa@m17n.org>
parents: 22778
diff changeset
332 (let ((count (nth 1 slot)))
6af93eeeca10 (find-multibyte-characters): New
Kenichi Handa <handa@m17n.org>
parents: 22778
diff changeset
333 (setcar (cdr slot) (1+ count))
6af93eeeca10 (find-multibyte-characters): New
Kenichi Handa <handa@m17n.org>
parents: 22778
diff changeset
334 (if (or (not maxcount) (< count maxcount))
6af93eeeca10 (find-multibyte-characters): New
Kenichi Handa <handa@m17n.org>
parents: 22778
diff changeset
335 (nconc slot (list char)))))
6af93eeeca10 (find-multibyte-characters): New
Kenichi Handa <handa@m17n.org>
parents: 22778
diff changeset
336 (setq chars (cons (list charset 1 char) chars)))))
6af93eeeca10 (find-multibyte-characters): New
Kenichi Handa <handa@m17n.org>
parents: 22778
diff changeset
337 (setq idx (1+ idx))))
6af93eeeca10 (find-multibyte-characters): New
Kenichi Handa <handa@m17n.org>
parents: 22778
diff changeset
338 (save-excursion
6af93eeeca10 (find-multibyte-characters): New
Kenichi Handa <handa@m17n.org>
parents: 22778
diff changeset
339 (goto-char from)
6af93eeeca10 (find-multibyte-characters): New
Kenichi Handa <handa@m17n.org>
parents: 22778
diff changeset
340 (while (re-search-forward "[^\000-\177]" to t)
6af93eeeca10 (find-multibyte-characters): New
Kenichi Handa <handa@m17n.org>
parents: 22778
diff changeset
341 (setq char (preceding-char)
6af93eeeca10 (find-multibyte-characters): New
Kenichi Handa <handa@m17n.org>
parents: 22778
diff changeset
342 charset (char-charset char))
6af93eeeca10 (find-multibyte-characters): New
Kenichi Handa <handa@m17n.org>
parents: 22778
diff changeset
343 (if (not (memq charset excludes))
6af93eeeca10 (find-multibyte-characters): New
Kenichi Handa <handa@m17n.org>
parents: 22778
diff changeset
344 (let ((slot (assq charset chars)))
6af93eeeca10 (find-multibyte-characters): New
Kenichi Handa <handa@m17n.org>
parents: 22778
diff changeset
345 (if slot
6af93eeeca10 (find-multibyte-characters): New
Kenichi Handa <handa@m17n.org>
parents: 22778
diff changeset
346 (if (not (memq char (nthcdr 2 slot)))
6af93eeeca10 (find-multibyte-characters): New
Kenichi Handa <handa@m17n.org>
parents: 22778
diff changeset
347 (let ((count (nth 1 slot)))
6af93eeeca10 (find-multibyte-characters): New
Kenichi Handa <handa@m17n.org>
parents: 22778
diff changeset
348 (setcar (cdr slot) (1+ count))
6af93eeeca10 (find-multibyte-characters): New
Kenichi Handa <handa@m17n.org>
parents: 22778
diff changeset
349 (if (or (not maxcount) (< count maxcount))
6af93eeeca10 (find-multibyte-characters): New
Kenichi Handa <handa@m17n.org>
parents: 22778
diff changeset
350 (nconc slot (list char)))))
6af93eeeca10 (find-multibyte-characters): New
Kenichi Handa <handa@m17n.org>
parents: 22778
diff changeset
351 (setq chars (cons (list charset 1 char) chars))))))))
6af93eeeca10 (find-multibyte-characters): New
Kenichi Handa <handa@m17n.org>
parents: 22778
diff changeset
352 (nreverse chars)))
6af93eeeca10 (find-multibyte-characters): New
Kenichi Handa <handa@m17n.org>
parents: 22778
diff changeset
353
22025
369ac7fae774 (last-coding-system-specified): New var.
Richard M. Stallman <rms@gnu.org>
parents: 21983
diff changeset
354 (defvar last-coding-system-specified nil
369ac7fae774 (last-coding-system-specified): New var.
Richard M. Stallman <rms@gnu.org>
parents: 21983
diff changeset
355 "Most recent coding system explicitly specified by the user when asked.
369ac7fae774 (last-coding-system-specified): New var.
Richard M. Stallman <rms@gnu.org>
parents: 21983
diff changeset
356 This variable is set whenever Emacs asks the user which coding system
369ac7fae774 (last-coding-system-specified): New var.
Richard M. Stallman <rms@gnu.org>
parents: 21983
diff changeset
357 to use in order to write a file. If you set it to nil explicitly,
369ac7fae774 (last-coding-system-specified): New var.
Richard M. Stallman <rms@gnu.org>
parents: 21983
diff changeset
358 then call `write-region', then afterward this variable will be non-nil
369ac7fae774 (last-coding-system-specified): New var.
Richard M. Stallman <rms@gnu.org>
parents: 21983
diff changeset
359 only if the user was explicitly asked and specified a coding system.")
369ac7fae774 (last-coding-system-specified): New var.
Richard M. Stallman <rms@gnu.org>
parents: 21983
diff changeset
360
20733
079907c59fb2 (set-language-info): Doc-string
Kenichi Handa <handa@m17n.org>
parents: 20485
diff changeset
361 (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
362 "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
363 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
364 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
365
079907c59fb2 (set-language-info): Doc-string
Kenichi Handa <handa@m17n.org>
parents: 20485
diff changeset
366 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
367 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
368 current buffer is used.
079907c59fb2 (set-language-info): Doc-string
Kenichi Handa <handa@m17n.org>
parents: 20485
diff changeset
369
20842
428831a6f4d1 (find-safe-coding-system): Return
Kenichi Handa <handa@m17n.org>
parents: 20830
diff changeset
370 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
371 returned without any user interaction.
20733
079907c59fb2 (set-language-info): Doc-string
Kenichi Handa <handa@m17n.org>
parents: 20485
diff changeset
372
079907c59fb2 (set-language-info): Doc-string
Kenichi Handa <handa@m17n.org>
parents: 20485
diff changeset
373 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
374 and TO is ignored."
079907c59fb2 (set-language-info): Doc-string
Kenichi Handa <handa@m17n.org>
parents: 20485
diff changeset
375 (or default-coding-system
079907c59fb2 (set-language-info): Doc-string
Kenichi Handa <handa@m17n.org>
parents: 20485
diff changeset
376 (setq default-coding-system buffer-file-coding-system))
22815
6af93eeeca10 (find-multibyte-characters): New
Kenichi Handa <handa@m17n.org>
parents: 22778
diff changeset
377 (let* ((charsets (if (stringp from) (find-charset-string from)
6af93eeeca10 (find-multibyte-characters): New
Kenichi Handa <handa@m17n.org>
parents: 22778
diff changeset
378 (find-charset-region from to)))
6af93eeeca10 (find-multibyte-characters): New
Kenichi Handa <handa@m17n.org>
parents: 22778
diff changeset
379 (safe-coding-systems (find-coding-systems-for-charsets charsets)))
20733
079907c59fb2 (set-language-info): Doc-string
Kenichi Handa <handa@m17n.org>
parents: 20485
diff changeset
380 (if (or (eq (car safe-coding-systems) 'undecided)
079907c59fb2 (set-language-info): Doc-string
Kenichi Handa <handa@m17n.org>
parents: 20485
diff changeset
381 (and default-coding-system
079907c59fb2 (set-language-info): Doc-string
Kenichi Handa <handa@m17n.org>
parents: 20485
diff changeset
382 (memq (coding-system-base default-coding-system)
079907c59fb2 (set-language-info): Doc-string
Kenichi Handa <handa@m17n.org>
parents: 20485
diff changeset
383 safe-coding-systems)))
079907c59fb2 (set-language-info): Doc-string
Kenichi Handa <handa@m17n.org>
parents: 20485
diff changeset
384 default-coding-system
079907c59fb2 (set-language-info): Doc-string
Kenichi Handa <handa@m17n.org>
parents: 20485
diff changeset
385
21882
4fb3860a1f26 (find-coding-systems-for-charsets):
Kenichi Handa <handa@m17n.org>
parents: 21856
diff changeset
386 ;; At first, change each coding system to the corresponding
4fb3860a1f26 (find-coding-systems-for-charsets):
Kenichi Handa <handa@m17n.org>
parents: 21856
diff changeset
387 ;; mime-charset name if it is also a coding system.
4fb3860a1f26 (find-coding-systems-for-charsets):
Kenichi Handa <handa@m17n.org>
parents: 21856
diff changeset
388 (let ((l safe-coding-systems)
4fb3860a1f26 (find-coding-systems-for-charsets):
Kenichi Handa <handa@m17n.org>
parents: 21856
diff changeset
389 mime-charset)
4fb3860a1f26 (find-coding-systems-for-charsets):
Kenichi Handa <handa@m17n.org>
parents: 21856
diff changeset
390 (while l
4fb3860a1f26 (find-coding-systems-for-charsets):
Kenichi Handa <handa@m17n.org>
parents: 21856
diff changeset
391 (setq mime-charset (coding-system-get (car l) 'mime-charset))
4fb3860a1f26 (find-coding-systems-for-charsets):
Kenichi Handa <handa@m17n.org>
parents: 21856
diff changeset
392 (if (and mime-charset (coding-system-p mime-charset))
4fb3860a1f26 (find-coding-systems-for-charsets):
Kenichi Handa <handa@m17n.org>
parents: 21856
diff changeset
393 (setcar l mime-charset))
4fb3860a1f26 (find-coding-systems-for-charsets):
Kenichi Handa <handa@m17n.org>
parents: 21856
diff changeset
394 (setq l (cdr l))))
4fb3860a1f26 (find-coding-systems-for-charsets):
Kenichi Handa <handa@m17n.org>
parents: 21856
diff changeset
395
22815
6af93eeeca10 (find-multibyte-characters): New
Kenichi Handa <handa@m17n.org>
parents: 22778
diff changeset
396 (let ((non-safe-chars (find-multibyte-characters
6af93eeeca10 (find-multibyte-characters): New
Kenichi Handa <handa@m17n.org>
parents: 22778
diff changeset
397 from to 3
6af93eeeca10 (find-multibyte-characters): New
Kenichi Handa <handa@m17n.org>
parents: 22778
diff changeset
398 (and default-coding-system
6af93eeeca10 (find-multibyte-characters): New
Kenichi Handa <handa@m17n.org>
parents: 22778
diff changeset
399 (coding-system-get default-coding-system
6af93eeeca10 (find-multibyte-characters): New
Kenichi Handa <handa@m17n.org>
parents: 22778
diff changeset
400 'safe-charsets))))
6af93eeeca10 (find-multibyte-characters): New
Kenichi Handa <handa@m17n.org>
parents: 22778
diff changeset
401 overlays)
6af93eeeca10 (find-multibyte-characters): New
Kenichi Handa <handa@m17n.org>
parents: 22778
diff changeset
402 (save-excursion
6af93eeeca10 (find-multibyte-characters): New
Kenichi Handa <handa@m17n.org>
parents: 22778
diff changeset
403 ;; Highlight characters that default-coding-system can't encode.
6af93eeeca10 (find-multibyte-characters): New
Kenichi Handa <handa@m17n.org>
parents: 22778
diff changeset
404 (when (integerp from)
6af93eeeca10 (find-multibyte-characters): New
Kenichi Handa <handa@m17n.org>
parents: 22778
diff changeset
405 (goto-char from)
6af93eeeca10 (find-multibyte-characters): New
Kenichi Handa <handa@m17n.org>
parents: 22778
diff changeset
406 (let ((found nil))
6af93eeeca10 (find-multibyte-characters): New
Kenichi Handa <handa@m17n.org>
parents: 22778
diff changeset
407 (while (and (not found)
6af93eeeca10 (find-multibyte-characters): New
Kenichi Handa <handa@m17n.org>
parents: 22778
diff changeset
408 (re-search-forward "[^\000-\177]" to t))
6af93eeeca10 (find-multibyte-characters): New
Kenichi Handa <handa@m17n.org>
parents: 22778
diff changeset
409 (setq found (assq (char-charset (preceding-char))
6af93eeeca10 (find-multibyte-characters): New
Kenichi Handa <handa@m17n.org>
parents: 22778
diff changeset
410 non-safe-chars))))
6af93eeeca10 (find-multibyte-characters): New
Kenichi Handa <handa@m17n.org>
parents: 22778
diff changeset
411 (beginning-of-line)
6af93eeeca10 (find-multibyte-characters): New
Kenichi Handa <handa@m17n.org>
parents: 22778
diff changeset
412 (set-window-start (selected-window) (point))
6af93eeeca10 (find-multibyte-characters): New
Kenichi Handa <handa@m17n.org>
parents: 22778
diff changeset
413 (save-excursion
6af93eeeca10 (find-multibyte-characters): New
Kenichi Handa <handa@m17n.org>
parents: 22778
diff changeset
414 (while (re-search-forward "[^\000-\177]" to t)
6af93eeeca10 (find-multibyte-characters): New
Kenichi Handa <handa@m17n.org>
parents: 22778
diff changeset
415 (let* ((char (preceding-char))
6af93eeeca10 (find-multibyte-characters): New
Kenichi Handa <handa@m17n.org>
parents: 22778
diff changeset
416 (charset (char-charset char)))
6af93eeeca10 (find-multibyte-characters): New
Kenichi Handa <handa@m17n.org>
parents: 22778
diff changeset
417 (when (assq charset non-safe-chars)
6af93eeeca10 (find-multibyte-characters): New
Kenichi Handa <handa@m17n.org>
parents: 22778
diff changeset
418 (setq overlays (cons (make-overlay (1- (point)) (point))
6af93eeeca10 (find-multibyte-characters): New
Kenichi Handa <handa@m17n.org>
parents: 22778
diff changeset
419 overlays))
6af93eeeca10 (find-multibyte-characters): New
Kenichi Handa <handa@m17n.org>
parents: 22778
diff changeset
420 (overlay-put (car overlays) 'face 'highlight))))))
6af93eeeca10 (find-multibyte-characters): New
Kenichi Handa <handa@m17n.org>
parents: 22778
diff changeset
421
6af93eeeca10 (find-multibyte-characters): New
Kenichi Handa <handa@m17n.org>
parents: 22778
diff changeset
422 ;; At last, ask a user to select a proper coding system.
6af93eeeca10 (find-multibyte-characters): New
Kenichi Handa <handa@m17n.org>
parents: 22778
diff changeset
423 (unwind-protect
6af93eeeca10 (find-multibyte-characters): New
Kenichi Handa <handa@m17n.org>
parents: 22778
diff changeset
424 (save-window-excursion
6af93eeeca10 (find-multibyte-characters): New
Kenichi Handa <handa@m17n.org>
parents: 22778
diff changeset
425 ;; At first, show a helpful message.
6af93eeeca10 (find-multibyte-characters): New
Kenichi Handa <handa@m17n.org>
parents: 22778
diff changeset
426 (with-output-to-temp-buffer "*Warning*"
6af93eeeca10 (find-multibyte-characters): New
Kenichi Handa <handa@m17n.org>
parents: 22778
diff changeset
427 (save-excursion
6af93eeeca10 (find-multibyte-characters): New
Kenichi Handa <handa@m17n.org>
parents: 22778
diff changeset
428 (set-buffer standard-output)
6af93eeeca10 (find-multibyte-characters): New
Kenichi Handa <handa@m17n.org>
parents: 22778
diff changeset
429 (insert "The target text contains the following non ASCII character(s):\n")
6af93eeeca10 (find-multibyte-characters): New
Kenichi Handa <handa@m17n.org>
parents: 22778
diff changeset
430 (let ((len (length non-safe-chars))
6af93eeeca10 (find-multibyte-characters): New
Kenichi Handa <handa@m17n.org>
parents: 22778
diff changeset
431 (shown 0))
6af93eeeca10 (find-multibyte-characters): New
Kenichi Handa <handa@m17n.org>
parents: 22778
diff changeset
432 (while (and non-safe-chars (< shown 3))
6af93eeeca10 (find-multibyte-characters): New
Kenichi Handa <handa@m17n.org>
parents: 22778
diff changeset
433 (when (> (length (car non-safe-chars)) 2)
6af93eeeca10 (find-multibyte-characters): New
Kenichi Handa <handa@m17n.org>
parents: 22778
diff changeset
434 (setq shown (1+ shown))
6af93eeeca10 (find-multibyte-characters): New
Kenichi Handa <handa@m17n.org>
parents: 22778
diff changeset
435 (insert (format "%25s: " (car (car non-safe-chars))))
6af93eeeca10 (find-multibyte-characters): New
Kenichi Handa <handa@m17n.org>
parents: 22778
diff changeset
436 (let ((l (nthcdr 2 (car non-safe-chars))))
6af93eeeca10 (find-multibyte-characters): New
Kenichi Handa <handa@m17n.org>
parents: 22778
diff changeset
437 (while l
6af93eeeca10 (find-multibyte-characters): New
Kenichi Handa <handa@m17n.org>
parents: 22778
diff changeset
438 (insert (car l))
6af93eeeca10 (find-multibyte-characters): New
Kenichi Handa <handa@m17n.org>
parents: 22778
diff changeset
439 (setq l (cdr l))))
6af93eeeca10 (find-multibyte-characters): New
Kenichi Handa <handa@m17n.org>
parents: 22778
diff changeset
440 (if (> (nth 1 (car non-safe-chars)) 3)
6af93eeeca10 (find-multibyte-characters): New
Kenichi Handa <handa@m17n.org>
parents: 22778
diff changeset
441 (insert "..."))
6af93eeeca10 (find-multibyte-characters): New
Kenichi Handa <handa@m17n.org>
parents: 22778
diff changeset
442 (insert "\n"))
6af93eeeca10 (find-multibyte-characters): New
Kenichi Handa <handa@m17n.org>
parents: 22778
diff changeset
443 (setq non-safe-chars (cdr non-safe-chars)))
6af93eeeca10 (find-multibyte-characters): New
Kenichi Handa <handa@m17n.org>
parents: 22778
diff changeset
444 (if (< shown len)
6af93eeeca10 (find-multibyte-characters): New
Kenichi Handa <handa@m17n.org>
parents: 22778
diff changeset
445 (insert (format "%27s\n" "..."))))
6af93eeeca10 (find-multibyte-characters): New
Kenichi Handa <handa@m17n.org>
parents: 22778
diff changeset
446 (insert (format "\
6af93eeeca10 (find-multibyte-characters): New
Kenichi Handa <handa@m17n.org>
parents: 22778
diff changeset
447 These can't be encoded safely by the coding system %s.
20733
079907c59fb2 (set-language-info): Doc-string
Kenichi Handa <handa@m17n.org>
parents: 20485
diff changeset
448
079907c59fb2 (set-language-info): Doc-string
Kenichi Handa <handa@m17n.org>
parents: 20485
diff changeset
449 Please select one from the following safe coding systems:\n"
22815
6af93eeeca10 (find-multibyte-characters): New
Kenichi Handa <handa@m17n.org>
parents: 22778
diff changeset
450 default-coding-system))
6af93eeeca10 (find-multibyte-characters): New
Kenichi Handa <handa@m17n.org>
parents: 22778
diff changeset
451 (let ((pos (point))
6af93eeeca10 (find-multibyte-characters): New
Kenichi Handa <handa@m17n.org>
parents: 22778
diff changeset
452 (fill-prefix " "))
6af93eeeca10 (find-multibyte-characters): New
Kenichi Handa <handa@m17n.org>
parents: 22778
diff changeset
453 (mapcar (function (lambda (x) (princ " ") (princ x)))
6af93eeeca10 (find-multibyte-characters): New
Kenichi Handa <handa@m17n.org>
parents: 22778
diff changeset
454 safe-coding-systems)
6af93eeeca10 (find-multibyte-characters): New
Kenichi Handa <handa@m17n.org>
parents: 22778
diff changeset
455 (fill-region-as-paragraph pos (point)))))
20733
079907c59fb2 (set-language-info): Doc-string
Kenichi Handa <handa@m17n.org>
parents: 20485
diff changeset
456
22815
6af93eeeca10 (find-multibyte-characters): New
Kenichi Handa <handa@m17n.org>
parents: 22778
diff changeset
457 ;; Read a coding system.
6af93eeeca10 (find-multibyte-characters): New
Kenichi Handa <handa@m17n.org>
parents: 22778
diff changeset
458 (let* ((safe-names (mapcar (lambda (x) (list (symbol-name x)))
6af93eeeca10 (find-multibyte-characters): New
Kenichi Handa <handa@m17n.org>
parents: 22778
diff changeset
459 safe-coding-systems))
6af93eeeca10 (find-multibyte-characters): New
Kenichi Handa <handa@m17n.org>
parents: 22778
diff changeset
460 (name (completing-read
6af93eeeca10 (find-multibyte-characters): New
Kenichi Handa <handa@m17n.org>
parents: 22778
diff changeset
461 (format "Select coding system (default %s): "
6af93eeeca10 (find-multibyte-characters): New
Kenichi Handa <handa@m17n.org>
parents: 22778
diff changeset
462 (car safe-coding-systems))
6af93eeeca10 (find-multibyte-characters): New
Kenichi Handa <handa@m17n.org>
parents: 22778
diff changeset
463 safe-names nil t nil nil
6af93eeeca10 (find-multibyte-characters): New
Kenichi Handa <handa@m17n.org>
parents: 22778
diff changeset
464 (car (car safe-names)))))
6af93eeeca10 (find-multibyte-characters): New
Kenichi Handa <handa@m17n.org>
parents: 22778
diff changeset
465 (setq last-coding-system-specified (intern name))
6af93eeeca10 (find-multibyte-characters): New
Kenichi Handa <handa@m17n.org>
parents: 22778
diff changeset
466 (if (integerp (coding-system-eol-type default-coding-system))
6af93eeeca10 (find-multibyte-characters): New
Kenichi Handa <handa@m17n.org>
parents: 22778
diff changeset
467 (setq last-coding-system-specified
6af93eeeca10 (find-multibyte-characters): New
Kenichi Handa <handa@m17n.org>
parents: 22778
diff changeset
468 (coding-system-change-eol-conversion
6af93eeeca10 (find-multibyte-characters): New
Kenichi Handa <handa@m17n.org>
parents: 22778
diff changeset
469 last-coding-system-specified
6af93eeeca10 (find-multibyte-characters): New
Kenichi Handa <handa@m17n.org>
parents: 22778
diff changeset
470 (coding-system-eol-type default-coding-system))))
6af93eeeca10 (find-multibyte-characters): New
Kenichi Handa <handa@m17n.org>
parents: 22778
diff changeset
471 last-coding-system-specified))
6af93eeeca10 (find-multibyte-characters): New
Kenichi Handa <handa@m17n.org>
parents: 22778
diff changeset
472 (kill-buffer "*Warning*")
6af93eeeca10 (find-multibyte-characters): New
Kenichi Handa <handa@m17n.org>
parents: 22778
diff changeset
473 (while overlays
6af93eeeca10 (find-multibyte-characters): New
Kenichi Handa <handa@m17n.org>
parents: 22778
diff changeset
474 (delete-overlay (car overlays))
6af93eeeca10 (find-multibyte-characters): New
Kenichi Handa <handa@m17n.org>
parents: 22778
diff changeset
475 (setq overlays (cdr overlays)))))))))
20733
079907c59fb2 (set-language-info): Doc-string
Kenichi Handa <handa@m17n.org>
parents: 20485
diff changeset
476
079907c59fb2 (set-language-info): Doc-string
Kenichi Handa <handa@m17n.org>
parents: 20485
diff changeset
477 (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
478
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
479
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
480 ;;; Language support staffs.
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
481
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
482 (defvar language-info-alist nil
22153
a63d4ba6813a Several doc fixes.
Richard M. Stallman <rms@gnu.org>
parents: 22025
diff changeset
483 "Alist of language environment definitions.
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
484 Each element looks like:
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
485 (LANGUAGE-NAME . ((KEY . INFO) ...))
22153
a63d4ba6813a Several doc fixes.
Richard M. Stallman <rms@gnu.org>
parents: 22025
diff changeset
486 where LANGUAGE-NAME is a string, the name of the language environment,
a63d4ba6813a Several doc fixes.
Richard M. Stallman <rms@gnu.org>
parents: 22025
diff changeset
487 KEY is a symbol denoting the kind of information, and
a63d4ba6813a Several doc fixes.
Richard M. Stallman <rms@gnu.org>
parents: 22025
diff changeset
488 INFO is the data associated with KEY.
a63d4ba6813a Several doc fixes.
Richard M. Stallman <rms@gnu.org>
parents: 22025
diff changeset
489 Meaningful values for KEY include
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
490
22153
a63d4ba6813a Several doc fixes.
Richard M. Stallman <rms@gnu.org>
parents: 22025
diff changeset
491 documentation value is documentation of what this language environment
a63d4ba6813a Several doc fixes.
Richard M. Stallman <rms@gnu.org>
parents: 22025
diff changeset
492 is meant for, and how to use it.
a63d4ba6813a Several doc fixes.
Richard M. Stallman <rms@gnu.org>
parents: 22025
diff changeset
493 charset value is a list of the character sets used by this
a63d4ba6813a Several doc fixes.
Richard M. Stallman <rms@gnu.org>
parents: 22025
diff changeset
494 language environment.
a63d4ba6813a Several doc fixes.
Richard M. Stallman <rms@gnu.org>
parents: 22025
diff changeset
495 sample-text value is one line of text,
a63d4ba6813a Several doc fixes.
Richard M. Stallman <rms@gnu.org>
parents: 22025
diff changeset
496 written using those character sets,
a63d4ba6813a Several doc fixes.
Richard M. Stallman <rms@gnu.org>
parents: 22025
diff changeset
497 appropriate for this language environment.
a63d4ba6813a Several doc fixes.
Richard M. Stallman <rms@gnu.org>
parents: 22025
diff changeset
498 setup-function value is a function to call to switch to this
a63d4ba6813a Several doc fixes.
Richard M. Stallman <rms@gnu.org>
parents: 22025
diff changeset
499 language environment.
a63d4ba6813a Several doc fixes.
Richard M. Stallman <rms@gnu.org>
parents: 22025
diff changeset
500 exit-function value is a function to call to leave this
a63d4ba6813a Several doc fixes.
Richard M. Stallman <rms@gnu.org>
parents: 22025
diff changeset
501 language environment.
a63d4ba6813a Several doc fixes.
Richard M. Stallman <rms@gnu.org>
parents: 22025
diff changeset
502 coding-system value is a list of coding systems that are good
a63d4ba6813a Several doc fixes.
Richard M. Stallman <rms@gnu.org>
parents: 22025
diff changeset
503 for saving text written in this language environment.
a63d4ba6813a Several doc fixes.
Richard M. Stallman <rms@gnu.org>
parents: 22025
diff changeset
504 This list serves as suggestions to the user;
a63d4ba6813a Several doc fixes.
Richard M. Stallman <rms@gnu.org>
parents: 22025
diff changeset
505 in effect, as a kind of documentation.
a63d4ba6813a Several doc fixes.
Richard M. Stallman <rms@gnu.org>
parents: 22025
diff changeset
506 coding-priority value is a list of coding systems for this language
a63d4ba6813a Several doc fixes.
Richard M. Stallman <rms@gnu.org>
parents: 22025
diff changeset
507 environment, in order of decreasing priority.
a63d4ba6813a Several doc fixes.
Richard M. Stallman <rms@gnu.org>
parents: 22025
diff changeset
508 This is used to set up the coding system priority
22887
e24b79da83d6 (language-info-alist): Doc-string
Kenichi Handa <handa@m17n.org>
parents: 22854
diff changeset
509 list when you switch to this language environment.
e24b79da83d6 (language-info-alist): Doc-string
Kenichi Handa <handa@m17n.org>
parents: 22854
diff changeset
510
e24b79da83d6 (language-info-alist): Doc-string
Kenichi Handa <handa@m17n.org>
parents: 22854
diff changeset
511 nonascii-translation-table
e24b79da83d6 (language-info-alist): Doc-string
Kenichi Handa <handa@m17n.org>
parents: 22854
diff changeset
512 value is a translation table to be set to the
e24b79da83d6 (language-info-alist): Doc-string
Kenichi Handa <handa@m17n.org>
parents: 22854
diff changeset
513 variable `nonascii-translation-table' in this
e24b79da83d6 (language-info-alist): Doc-string
Kenichi Handa <handa@m17n.org>
parents: 22854
diff changeset
514 language environment.
e24b79da83d6 (language-info-alist): Doc-string
Kenichi Handa <handa@m17n.org>
parents: 22854
diff changeset
515
e24b79da83d6 (language-info-alist): Doc-string
Kenichi Handa <handa@m17n.org>
parents: 22854
diff changeset
516 charset-origin-alist
e24b79da83d6 (language-info-alist): Doc-string
Kenichi Handa <handa@m17n.org>
parents: 22854
diff changeset
517 value is an alist to be set to the variable
e24b79da83d6 (language-info-alist): Doc-string
Kenichi Handa <handa@m17n.org>
parents: 22854
diff changeset
518 `charset-origin-alist' in this language environment.")
22153
a63d4ba6813a Several doc fixes.
Richard M. Stallman <rms@gnu.org>
parents: 22025
diff changeset
519
a63d4ba6813a Several doc fixes.
Richard M. Stallman <rms@gnu.org>
parents: 22025
diff changeset
520 (defun get-language-info (lang-env key)
a63d4ba6813a Several doc fixes.
Richard M. Stallman <rms@gnu.org>
parents: 22025
diff changeset
521 "Return information listed under KEY for language environment LANG-ENV.
a63d4ba6813a Several doc fixes.
Richard M. Stallman <rms@gnu.org>
parents: 22025
diff changeset
522 KEY is a symbol denoting the kind of information.
a63d4ba6813a Several doc fixes.
Richard M. Stallman <rms@gnu.org>
parents: 22025
diff changeset
523 For a list of useful values for KEY and their meanings,
a63d4ba6813a Several doc fixes.
Richard M. Stallman <rms@gnu.org>
parents: 22025
diff changeset
524 see `language-info-alist'."
a63d4ba6813a Several doc fixes.
Richard M. Stallman <rms@gnu.org>
parents: 22025
diff changeset
525 (if (symbolp lang-env)
a63d4ba6813a Several doc fixes.
Richard M. Stallman <rms@gnu.org>
parents: 22025
diff changeset
526 (setq lang-env (symbol-name lang-env)))
a63d4ba6813a Several doc fixes.
Richard M. Stallman <rms@gnu.org>
parents: 22025
diff changeset
527 (let ((lang-slot (assoc-ignore-case lang-env language-info-alist)))
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
528 (if lang-slot
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
529 (cdr (assq key (cdr lang-slot))))))
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
530
22200
a0d60a6c87da (register-input-method): Rename arg ENV to LANG-ENV. Fix previous change.
Richard M. Stallman <rms@gnu.org>
parents: 22153
diff changeset
531 (defun set-language-info (lang-env key info)
22153
a63d4ba6813a Several doc fixes.
Richard M. Stallman <rms@gnu.org>
parents: 22025
diff changeset
532 "Modify part of the definition of language environment LANG-ENV.
a63d4ba6813a Several doc fixes.
Richard M. Stallman <rms@gnu.org>
parents: 22025
diff changeset
533 Specifically, this stores the information INFO under KEY
a63d4ba6813a Several doc fixes.
Richard M. Stallman <rms@gnu.org>
parents: 22025
diff changeset
534 in the definition of this language environment.
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
535 KEY is a symbol denoting the kind of information.
22153
a63d4ba6813a Several doc fixes.
Richard M. Stallman <rms@gnu.org>
parents: 22025
diff changeset
536 INFO is the value for that information.
20733
079907c59fb2 (set-language-info): Doc-string
Kenichi Handa <handa@m17n.org>
parents: 20485
diff changeset
537
22153
a63d4ba6813a Several doc fixes.
Richard M. Stallman <rms@gnu.org>
parents: 22025
diff changeset
538 For a list of useful values for KEY and their meanings,
22200
a0d60a6c87da (register-input-method): Rename arg ENV to LANG-ENV. Fix previous change.
Richard M. Stallman <rms@gnu.org>
parents: 22153
diff changeset
539 see `language-info-alist'."
22153
a63d4ba6813a Several doc fixes.
Richard M. Stallman <rms@gnu.org>
parents: 22025
diff changeset
540 (if (symbolp lang-env)
a63d4ba6813a Several doc fixes.
Richard M. Stallman <rms@gnu.org>
parents: 22025
diff changeset
541 (setq lang-env (symbol-name lang-env)))
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
542 (let (lang-slot key-slot)
22153
a63d4ba6813a Several doc fixes.
Richard M. Stallman <rms@gnu.org>
parents: 22025
diff changeset
543 (setq lang-slot (assoc lang-env language-info-alist))
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
544 (if (null lang-slot) ; If no slot for the language, add it.
22153
a63d4ba6813a Several doc fixes.
Richard M. Stallman <rms@gnu.org>
parents: 22025
diff changeset
545 (setq lang-slot (list lang-env)
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
546 language-info-alist (cons lang-slot language-info-alist)))
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
547 (setq key-slot (assq key lang-slot))
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
548 (if (null key-slot) ; If no slot for the key, add it.
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
549 (progn
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
550 (setq key-slot (list key))
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
551 (setcdr lang-slot (cons key-slot (cdr lang-slot)))))
22200
a0d60a6c87da (register-input-method): Rename arg ENV to LANG-ENV. Fix previous change.
Richard M. Stallman <rms@gnu.org>
parents: 22153
diff changeset
552 (setcdr key-slot info)))
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
553
22153
a63d4ba6813a Several doc fixes.
Richard M. Stallman <rms@gnu.org>
parents: 22025
diff changeset
554 (defun set-language-info-alist (lang-env alist &optional parents)
a63d4ba6813a Several doc fixes.
Richard M. Stallman <rms@gnu.org>
parents: 22025
diff changeset
555 "Store ALIST as the definition of language environment LANG-ENV.
a63d4ba6813a Several doc fixes.
Richard M. Stallman <rms@gnu.org>
parents: 22025
diff changeset
556 ALIST is an alist of KEY and INFO values. See the documentation of
20733
079907c59fb2 (set-language-info): Doc-string
Kenichi Handa <handa@m17n.org>
parents: 20485
diff changeset
557 `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
558
22153
a63d4ba6813a Several doc fixes.
Richard M. Stallman <rms@gnu.org>
parents: 22025
diff changeset
559 Optional arg PARENTS is a list of parent menu names; it specifies
a63d4ba6813a Several doc fixes.
Richard M. Stallman <rms@gnu.org>
parents: 22025
diff changeset
560 where to put this language environment in the
a63d4ba6813a Several doc fixes.
Richard M. Stallman <rms@gnu.org>
parents: 22025
diff changeset
561 Describe Language Environment and Set Language Environment menus.
a63d4ba6813a Several doc fixes.
Richard M. Stallman <rms@gnu.org>
parents: 22025
diff changeset
562 For example, (\"European\") means to put this language environment
a63d4ba6813a Several doc fixes.
Richard M. Stallman <rms@gnu.org>
parents: 22025
diff changeset
563 in the European submenu in each of those two menus."
a63d4ba6813a Several doc fixes.
Richard M. Stallman <rms@gnu.org>
parents: 22025
diff changeset
564 (if (symbolp lang-env)
a63d4ba6813a Several doc fixes.
Richard M. Stallman <rms@gnu.org>
parents: 22025
diff changeset
565 (setq lang-env (symbol-name lang-env)))
20733
079907c59fb2 (set-language-info): Doc-string
Kenichi Handa <handa@m17n.org>
parents: 20485
diff changeset
566 (let ((describe-map describe-language-environment-map)
079907c59fb2 (set-language-info): Doc-string
Kenichi Handa <handa@m17n.org>
parents: 20485
diff changeset
567 (setup-map setup-language-environment-map))
079907c59fb2 (set-language-info): Doc-string
Kenichi Handa <handa@m17n.org>
parents: 20485
diff changeset
568 (if parents
079907c59fb2 (set-language-info): Doc-string
Kenichi Handa <handa@m17n.org>
parents: 20485
diff changeset
569 (let ((l parents)
079907c59fb2 (set-language-info): Doc-string
Kenichi Handa <handa@m17n.org>
parents: 20485
diff changeset
570 map parent-symbol parent)
079907c59fb2 (set-language-info): Doc-string
Kenichi Handa <handa@m17n.org>
parents: 20485
diff changeset
571 (while l
079907c59fb2 (set-language-info): Doc-string
Kenichi Handa <handa@m17n.org>
parents: 20485
diff changeset
572 (if (symbolp (setq parent-symbol (car l)))
079907c59fb2 (set-language-info): Doc-string
Kenichi Handa <handa@m17n.org>
parents: 20485
diff changeset
573 (setq parent (symbol-name parent))
079907c59fb2 (set-language-info): Doc-string
Kenichi Handa <handa@m17n.org>
parents: 20485
diff changeset
574 (setq parent parent-symbol parent-symbol (intern parent)))
079907c59fb2 (set-language-info): Doc-string
Kenichi Handa <handa@m17n.org>
parents: 20485
diff changeset
575 (setq map (lookup-key describe-map (vector parent-symbol)))
079907c59fb2 (set-language-info): Doc-string
Kenichi Handa <handa@m17n.org>
parents: 20485
diff changeset
576 (if (not map)
079907c59fb2 (set-language-info): Doc-string
Kenichi Handa <handa@m17n.org>
parents: 20485
diff changeset
577 (progn
079907c59fb2 (set-language-info): Doc-string
Kenichi Handa <handa@m17n.org>
parents: 20485
diff changeset
578 (setq map (intern (format "describe-%s-environment-map"
079907c59fb2 (set-language-info): Doc-string
Kenichi Handa <handa@m17n.org>
parents: 20485
diff changeset
579 (downcase parent))))
079907c59fb2 (set-language-info): Doc-string
Kenichi Handa <handa@m17n.org>
parents: 20485
diff changeset
580 (define-prefix-command map)
079907c59fb2 (set-language-info): Doc-string
Kenichi Handa <handa@m17n.org>
parents: 20485
diff changeset
581 (define-key-after describe-map (vector parent-symbol)
079907c59fb2 (set-language-info): Doc-string
Kenichi Handa <handa@m17n.org>
parents: 20485
diff changeset
582 (cons parent map) t)))
079907c59fb2 (set-language-info): Doc-string
Kenichi Handa <handa@m17n.org>
parents: 20485
diff changeset
583 (setq describe-map (symbol-value map))
079907c59fb2 (set-language-info): Doc-string
Kenichi Handa <handa@m17n.org>
parents: 20485
diff changeset
584 (setq map (lookup-key setup-map (vector parent-symbol)))
079907c59fb2 (set-language-info): Doc-string
Kenichi Handa <handa@m17n.org>
parents: 20485
diff changeset
585 (if (not map)
079907c59fb2 (set-language-info): Doc-string
Kenichi Handa <handa@m17n.org>
parents: 20485
diff changeset
586 (progn
079907c59fb2 (set-language-info): Doc-string
Kenichi Handa <handa@m17n.org>
parents: 20485
diff changeset
587 (setq map (intern (format "setup-%s-environment-map"
079907c59fb2 (set-language-info): Doc-string
Kenichi Handa <handa@m17n.org>
parents: 20485
diff changeset
588 (downcase parent))))
079907c59fb2 (set-language-info): Doc-string
Kenichi Handa <handa@m17n.org>
parents: 20485
diff changeset
589 (define-prefix-command map)
079907c59fb2 (set-language-info): Doc-string
Kenichi Handa <handa@m17n.org>
parents: 20485
diff changeset
590 (define-key-after setup-map (vector parent-symbol)
079907c59fb2 (set-language-info): Doc-string
Kenichi Handa <handa@m17n.org>
parents: 20485
diff changeset
591 (cons parent map) t)))
079907c59fb2 (set-language-info): Doc-string
Kenichi Handa <handa@m17n.org>
parents: 20485
diff changeset
592 (setq setup-map (symbol-value map))
079907c59fb2 (set-language-info): Doc-string
Kenichi Handa <handa@m17n.org>
parents: 20485
diff changeset
593 (setq l (cdr l)))))
22200
a0d60a6c87da (register-input-method): Rename arg ENV to LANG-ENV. Fix previous change.
Richard M. Stallman <rms@gnu.org>
parents: 22153
diff changeset
594
a0d60a6c87da (register-input-method): Rename arg ENV to LANG-ENV. Fix previous change.
Richard M. Stallman <rms@gnu.org>
parents: 22153
diff changeset
595 ;; Set up menu items for this language env.
a0d60a6c87da (register-input-method): Rename arg ENV to LANG-ENV. Fix previous change.
Richard M. Stallman <rms@gnu.org>
parents: 22153
diff changeset
596 (let ((doc (assq 'documentation alist))
a0d60a6c87da (register-input-method): Rename arg ENV to LANG-ENV. Fix previous change.
Richard M. Stallman <rms@gnu.org>
parents: 22153
diff changeset
597 (setup-function (assq 'setup-function alist)))
a0d60a6c87da (register-input-method): Rename arg ENV to LANG-ENV. Fix previous change.
Richard M. Stallman <rms@gnu.org>
parents: 22153
diff changeset
598 (when doc
a0d60a6c87da (register-input-method): Rename arg ENV to LANG-ENV. Fix previous change.
Richard M. Stallman <rms@gnu.org>
parents: 22153
diff changeset
599 (define-key-after describe-map (vector (intern lang-env))
a0d60a6c87da (register-input-method): Rename arg ENV to LANG-ENV. Fix previous change.
Richard M. Stallman <rms@gnu.org>
parents: 22153
diff changeset
600 (cons lang-env 'describe-specified-language-support) t))
a0d60a6c87da (register-input-method): Rename arg ENV to LANG-ENV. Fix previous change.
Richard M. Stallman <rms@gnu.org>
parents: 22153
diff changeset
601 (when setup-function
a0d60a6c87da (register-input-method): Rename arg ENV to LANG-ENV. Fix previous change.
Richard M. Stallman <rms@gnu.org>
parents: 22153
diff changeset
602 (define-key-after setup-map (vector (intern lang-env))
a0d60a6c87da (register-input-method): Rename arg ENV to LANG-ENV. Fix previous change.
Richard M. Stallman <rms@gnu.org>
parents: 22153
diff changeset
603 (cons lang-env 'setup-specified-language-environment) t)))
a0d60a6c87da (register-input-method): Rename arg ENV to LANG-ENV. Fix previous change.
Richard M. Stallman <rms@gnu.org>
parents: 22153
diff changeset
604
20733
079907c59fb2 (set-language-info): Doc-string
Kenichi Handa <handa@m17n.org>
parents: 20485
diff changeset
605 (while alist
22200
a0d60a6c87da (register-input-method): Rename arg ENV to LANG-ENV. Fix previous change.
Richard M. Stallman <rms@gnu.org>
parents: 22153
diff changeset
606 (set-language-info lang-env (car (car alist)) (cdr (car alist)))
20733
079907c59fb2 (set-language-info): Doc-string
Kenichi Handa <handa@m17n.org>
parents: 20485
diff changeset
607 (setq alist (cdr alist)))))
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
608
19734
c4894d8a3310 (read-language-name): Use a default, not an initial input.
Richard M. Stallman <rms@gnu.org>
parents: 19725
diff changeset
609 (defun read-language-name (key prompt &optional default)
22153
a63d4ba6813a Several doc fixes.
Richard M. Stallman <rms@gnu.org>
parents: 22025
diff changeset
610 "Read a language environment name which has information for KEY.
a63d4ba6813a Several doc fixes.
Richard M. Stallman <rms@gnu.org>
parents: 22025
diff changeset
611 Prompt with PROMPT. DEFAULT is the default choice of language environment.
a63d4ba6813a Several doc fixes.
Richard M. Stallman <rms@gnu.org>
parents: 22025
diff changeset
612 This returns a language environment name as a string."
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
613 (let* ((completion-ignore-case t)
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
614 (name (completing-read prompt
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
615 language-info-alist
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
616 (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
617 t nil nil default)))
17758
8c67c2e2cc29 (build-describe-language-support-function,
Kenichi Handa <handa@m17n.org>
parents: 17526
diff changeset
618 (if (and (> (length name) 0)
8c67c2e2cc29 (build-describe-language-support-function,
Kenichi Handa <handa@m17n.org>
parents: 17526
diff changeset
619 (get-language-info name key))
8c67c2e2cc29 (build-describe-language-support-function,
Kenichi Handa <handa@m17n.org>
parents: 17526
diff changeset
620 name)))
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
621
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
622 ;;; Multilingual input methods.
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
623
18301
a4da36c7bb08 Define describe-coding-system instead of
Kenichi Handa <handa@m17n.org>
parents: 18217
diff changeset
624 (defconst leim-list-file-name "leim-list.el"
a4da36c7bb08 Define describe-coding-system instead of
Kenichi Handa <handa@m17n.org>
parents: 18217
diff changeset
625 "Name of LEIM list file.
a4da36c7bb08 Define describe-coding-system instead of
Kenichi Handa <handa@m17n.org>
parents: 18217
diff changeset
626 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
627 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
628 Emacs loads this file at startup time.")
a4da36c7bb08 Define describe-coding-system instead of
Kenichi Handa <handa@m17n.org>
parents: 18217
diff changeset
629
a4da36c7bb08 Define describe-coding-system instead of
Kenichi Handa <handa@m17n.org>
parents: 18217
diff changeset
630 (defvar leim-list-header (format "\
a4da36c7bb08 Define describe-coding-system instead of
Kenichi Handa <handa@m17n.org>
parents: 18217
diff changeset
631 ;;; %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
632 ;;
a4da36c7bb08 Define describe-coding-system instead of
Kenichi Handa <handa@m17n.org>
parents: 18217
diff changeset
633 ;; 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
634 ;; 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
635 ;; the whole input methods in Emacs.
a4da36c7bb08 Define describe-coding-system instead of
Kenichi Handa <handa@m17n.org>
parents: 18217
diff changeset
636 ;;
18969
c33e6f7947ed Typo in comment fixed.
Kenichi Handa <handa@m17n.org>
parents: 18933
diff changeset
637 ;; Each entry has the form:
18301
a4da36c7bb08 Define describe-coding-system instead of
Kenichi Handa <handa@m17n.org>
parents: 18217
diff changeset
638 ;; (register-input-method
a4da36c7bb08 Define describe-coding-system instead of
Kenichi Handa <handa@m17n.org>
parents: 18217
diff changeset
639 ;; INPUT-METHOD LANGUAGE-NAME ACTIVATE-FUNC
a4da36c7bb08 Define describe-coding-system instead of
Kenichi Handa <handa@m17n.org>
parents: 18217
diff changeset
640 ;; TITLE DESCRIPTION
a4da36c7bb08 Define describe-coding-system instead of
Kenichi Handa <handa@m17n.org>
parents: 18217
diff changeset
641 ;; ARG ...)
a4da36c7bb08 Define describe-coding-system instead of
Kenichi Handa <handa@m17n.org>
parents: 18217
diff changeset
642 ;; 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
643 ;;
a4da36c7bb08 Define describe-coding-system instead of
Kenichi Handa <handa@m17n.org>
parents: 18217
diff changeset
644 ;; 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
645 ;; loads this file at startup time.
a4da36c7bb08 Define describe-coding-system instead of
Kenichi Handa <handa@m17n.org>
parents: 18217
diff changeset
646
a4da36c7bb08 Define describe-coding-system instead of
Kenichi Handa <handa@m17n.org>
parents: 18217
diff changeset
647 "
a4da36c7bb08 Define describe-coding-system instead of
Kenichi Handa <handa@m17n.org>
parents: 18217
diff changeset
648 leim-list-file-name)
a4da36c7bb08 Define describe-coding-system instead of
Kenichi Handa <handa@m17n.org>
parents: 18217
diff changeset
649 "Header to be inserted in LEIM list file.")
a4da36c7bb08 Define describe-coding-system instead of
Kenichi Handa <handa@m17n.org>
parents: 18217
diff changeset
650
18982
2297a2cb909d (leim-list-entry-regexp): Make this match only at beginning of line.
Kenichi Handa <handa@m17n.org>
parents: 18978
diff changeset
651 (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
652 "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
653 See also the variable `leim-list-header'")
a4da36c7bb08 Define describe-coding-system instead of
Kenichi Handa <handa@m17n.org>
parents: 18217
diff changeset
654
a4da36c7bb08 Define describe-coding-system instead of
Kenichi Handa <handa@m17n.org>
parents: 18217
diff changeset
655 (defvar update-leim-list-functions
a4da36c7bb08 Define describe-coding-system instead of
Kenichi Handa <handa@m17n.org>
parents: 18217
diff changeset
656 '(quail-update-leim-list-file)
a4da36c7bb08 Define describe-coding-system instead of
Kenichi Handa <handa@m17n.org>
parents: 18217
diff changeset
657 "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
658 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
659
19615
4cdef838afb0 (update-leim-list-file): Make it handle multiple directories.
Richard M. Stallman <rms@gnu.org>
parents: 19614
diff changeset
660 (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
661 "Update LEIM list file in directories DIRS."
18301
a4da36c7bb08 Define describe-coding-system instead of
Kenichi Handa <handa@m17n.org>
parents: 18217
diff changeset
662 (let ((functions update-leim-list-functions))
a4da36c7bb08 Define describe-coding-system instead of
Kenichi Handa <handa@m17n.org>
parents: 18217
diff changeset
663 (while functions
19615
4cdef838afb0 (update-leim-list-file): Make it handle multiple directories.
Richard M. Stallman <rms@gnu.org>
parents: 19614
diff changeset
664 (apply (car functions) dirs)
18301
a4da36c7bb08 Define describe-coding-system instead of
Kenichi Handa <handa@m17n.org>
parents: 18217
diff changeset
665 (setq functions (cdr functions)))))
a4da36c7bb08 Define describe-coding-system instead of
Kenichi Handa <handa@m17n.org>
parents: 18217
diff changeset
666
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
667 (defvar current-input-method nil
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
668 "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
669 If nil, that means no input method is activated now.")
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
670 (make-variable-buffer-local 'current-input-method)
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
671 (put 'current-input-method 'permanent-local t)
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
672
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
673 (defvar current-input-method-title nil
18301
a4da36c7bb08 Define describe-coding-system instead of
Kenichi Handa <handa@m17n.org>
parents: 18217
diff changeset
674 "Title string of the current input method shown in mode line.")
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
675 (make-variable-buffer-local 'current-input-method-title)
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
676 (put 'current-input-method-title 'permanent-local t)
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
677
18801
f60dbf4f7d7c (mule-keymap): Bind l to set-language-environment.
Kenichi Handa <handa@m17n.org>
parents: 18712
diff changeset
678 (defcustom default-input-method nil
21229
38b621cd9169 (set-language-environment): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents: 21042
diff changeset
679 "*Default input method for multilingual text (a string).
18801
f60dbf4f7d7c (mule-keymap): Bind l to set-language-environment.
Kenichi Handa <handa@m17n.org>
parents: 18712
diff changeset
680 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
681 `toggle-input-method' (\\[toggle-input-method])."
21229
38b621cd9169 (set-language-environment): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents: 21042
diff changeset
682 :group 'mule
38b621cd9169 (set-language-environment): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents: 21042
diff changeset
683 :type 'string)
18801
f60dbf4f7d7c (mule-keymap): Bind l to set-language-environment.
Kenichi Handa <handa@m17n.org>
parents: 18712
diff changeset
684
19405
7ef4af7505f2 (previous-input-method): This
Kenichi Handa <handa@m17n.org>
parents: 19402
diff changeset
685 (defvar input-method-history nil
7ef4af7505f2 (previous-input-method): This
Kenichi Handa <handa@m17n.org>
parents: 19402
diff changeset
686 "History list for some commands that read input methods.")
7ef4af7505f2 (previous-input-method): This
Kenichi Handa <handa@m17n.org>
parents: 19402
diff changeset
687 (make-variable-buffer-local 'input-method-history)
7ef4af7505f2 (previous-input-method): This
Kenichi Handa <handa@m17n.org>
parents: 19402
diff changeset
688 (put 'input-method-history 'permanent-local t)
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
689
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
690 (defvar inactivate-current-input-method-function nil
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
691 "Function to call for inactivating the current input method.
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
692 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
693 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
694
df2996f7fdc3 (inactivate-current-input-method-function): Doc-string modified.
Kenichi Handa <handa@m17n.org>
parents: 19424
diff changeset
695 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
696 It is set to nil by the function `inactivate-input-method'.")
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
697 (make-variable-buffer-local 'inactivate-current-input-method-function)
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
698 (put 'inactivate-current-input-method-function 'permanent-local t)
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
699
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
700 (defvar describe-current-input-method-function nil
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
701 "Function to call for describing the current input method.
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
702 This function is called with no argument.")
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
703 (make-variable-buffer-local 'describe-current-input-method-function)
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
704 (put 'describe-current-input-method-function 'permanent-local t)
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
705
18301
a4da36c7bb08 Define describe-coding-system instead of
Kenichi Handa <handa@m17n.org>
parents: 18217
diff changeset
706 (defvar input-method-alist nil
22153
a63d4ba6813a Several doc fixes.
Richard M. Stallman <rms@gnu.org>
parents: 22025
diff changeset
707 "Alist of input method names vs how to use them.
18301
a4da36c7bb08 Define describe-coding-system instead of
Kenichi Handa <handa@m17n.org>
parents: 18217
diff changeset
708 Each element has the form:
22153
a63d4ba6813a Several doc fixes.
Richard M. Stallman <rms@gnu.org>
parents: 22025
diff changeset
709 (INPUT-METHOD LANGUAGE-ENV ACTIVATE-FUNC TITLE DESCRIPTION ARGS...)
a63d4ba6813a Several doc fixes.
Richard M. Stallman <rms@gnu.org>
parents: 22025
diff changeset
710 See the function `register-input-method' for the meanings of the elements.")
18301
a4da36c7bb08 Define describe-coding-system instead of
Kenichi Handa <handa@m17n.org>
parents: 18217
diff changeset
711
22200
a0d60a6c87da (register-input-method): Rename arg ENV to LANG-ENV. Fix previous change.
Richard M. Stallman <rms@gnu.org>
parents: 22153
diff changeset
712 (defun register-input-method (input-method lang-env &rest args)
22153
a63d4ba6813a Several doc fixes.
Richard M. Stallman <rms@gnu.org>
parents: 22025
diff changeset
713 "Register INPUT-METHOD as an input method for language environment ENV.
22200
a0d60a6c87da (register-input-method): Rename arg ENV to LANG-ENV. Fix previous change.
Richard M. Stallman <rms@gnu.org>
parents: 22153
diff changeset
714 INPUT-METHOD and LANG-ENV are symbols or strings.
22153
a63d4ba6813a Several doc fixes.
Richard M. Stallman <rms@gnu.org>
parents: 22025
diff changeset
715
18301
a4da36c7bb08 Define describe-coding-system instead of
Kenichi Handa <handa@m17n.org>
parents: 18217
diff changeset
716 The remaining arguments are:
22153
a63d4ba6813a Several doc fixes.
Richard M. Stallman <rms@gnu.org>
parents: 22025
diff changeset
717 ACTIVATE-FUNC, TITLE, DESCRIPTION, and ARGS...
a63d4ba6813a Several doc fixes.
Richard M. Stallman <rms@gnu.org>
parents: 22025
diff changeset
718 ACTIVATE-FUNC is a function to call to activate this method.
a63d4ba6813a Several doc fixes.
Richard M. Stallman <rms@gnu.org>
parents: 22025
diff changeset
719 TITLE is a string to show in the mode line when this method is active.
a63d4ba6813a Several doc fixes.
Richard M. Stallman <rms@gnu.org>
parents: 22025
diff changeset
720 DESCRIPTION is a string describing this method and what it is good for.
a63d4ba6813a Several doc fixes.
Richard M. Stallman <rms@gnu.org>
parents: 22025
diff changeset
721 The ARGS, if any, are passed as arguments to ACTIVATE-FUNC.
a63d4ba6813a Several doc fixes.
Richard M. Stallman <rms@gnu.org>
parents: 22025
diff changeset
722 All told, the arguments to ACTIVATE-FUNC are INPUT-METHOD and the ARGS."
22200
a0d60a6c87da (register-input-method): Rename arg ENV to LANG-ENV. Fix previous change.
Richard M. Stallman <rms@gnu.org>
parents: 22153
diff changeset
723 (if (symbolp lang-env)
a0d60a6c87da (register-input-method): Rename arg ENV to LANG-ENV. Fix previous change.
Richard M. Stallman <rms@gnu.org>
parents: 22153
diff changeset
724 (setq lang-env (symbol-name lang-env)))
19649
b2bf3c43c86a (get-language-info): Accept a symbol
Kenichi Handa <handa@m17n.org>
parents: 19615
diff changeset
725 (if (symbolp input-method)
b2bf3c43c86a (get-language-info): Accept a symbol
Kenichi Handa <handa@m17n.org>
parents: 19615
diff changeset
726 (setq input-method (symbol-name input-method)))
22200
a0d60a6c87da (register-input-method): Rename arg ENV to LANG-ENV. Fix previous change.
Richard M. Stallman <rms@gnu.org>
parents: 22153
diff changeset
727 (let ((info (cons lang-env args))
18301
a4da36c7bb08 Define describe-coding-system instead of
Kenichi Handa <handa@m17n.org>
parents: 18217
diff changeset
728 (slot (assoc input-method input-method-alist)))
a4da36c7bb08 Define describe-coding-system instead of
Kenichi Handa <handa@m17n.org>
parents: 18217
diff changeset
729 (if slot
a4da36c7bb08 Define describe-coding-system instead of
Kenichi Handa <handa@m17n.org>
parents: 18217
diff changeset
730 (setcdr slot info)
a4da36c7bb08 Define describe-coding-system instead of
Kenichi Handa <handa@m17n.org>
parents: 18217
diff changeset
731 (setq slot (cons input-method info))
a4da36c7bb08 Define describe-coding-system instead of
Kenichi Handa <handa@m17n.org>
parents: 18217
diff changeset
732 (setq input-method-alist (cons slot input-method-alist)))))
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
733
19328
a616b45ffa31 (read-input-method-name): Replace INITIAL-INPUT arg with DEFAULT arg.
Richard M. Stallman <rms@gnu.org>
parents: 19267
diff changeset
734 (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
735 "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
736 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
737 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
738 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
739
b2bf3c43c86a (get-language-info): Accept a symbol
Kenichi Handa <handa@m17n.org>
parents: 19615
diff changeset
740 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
741 (if default
a616b45ffa31 (read-input-method-name): Replace INITIAL-INPUT arg with DEFAULT arg.
Richard M. Stallman <rms@gnu.org>
parents: 19267
diff changeset
742 (setq prompt (format prompt default)))
18301
a4da36c7bb08 Define describe-coding-system instead of
Kenichi Handa <handa@m17n.org>
parents: 18217
diff changeset
743 (let* ((completion-ignore-case t)
19405
7ef4af7505f2 (previous-input-method): This
Kenichi Handa <handa@m17n.org>
parents: 19402
diff changeset
744 ;; This binding is necessary because input-method-history is
7ef4af7505f2 (previous-input-method): This
Kenichi Handa <handa@m17n.org>
parents: 19402
diff changeset
745 ;; buffer local.
18301
a4da36c7bb08 Define describe-coding-system instead of
Kenichi Handa <handa@m17n.org>
parents: 18217
diff changeset
746 (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
747 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
748 default)))
18301
a4da36c7bb08 Define describe-coding-system instead of
Kenichi Handa <handa@m17n.org>
parents: 18217
diff changeset
749 (if (> (length input-method) 0)
a4da36c7bb08 Define describe-coding-system instead of
Kenichi Handa <handa@m17n.org>
parents: 18217
diff changeset
750 input-method
a4da36c7bb08 Define describe-coding-system instead of
Kenichi Handa <handa@m17n.org>
parents: 18217
diff changeset
751 (if inhibit-null
18978
0f01c27a9756 (read-input-method-name): Show more appropriate error message.
Kenichi Handa <handa@m17n.org>
parents: 18969
diff changeset
752 (error "No valid input method is specified")))))
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
753
18301
a4da36c7bb08 Define describe-coding-system instead of
Kenichi Handa <handa@m17n.org>
parents: 18217
diff changeset
754 (defun activate-input-method (input-method)
22153
a63d4ba6813a Several doc fixes.
Richard M. Stallman <rms@gnu.org>
parents: 22025
diff changeset
755 "Switch to input method INPUT-METHOD for the current buffer.
a63d4ba6813a Several doc fixes.
Richard M. Stallman <rms@gnu.org>
parents: 22025
diff changeset
756 If some other input method is already active, turn it off first.
a63d4ba6813a Several doc fixes.
Richard M. Stallman <rms@gnu.org>
parents: 22025
diff changeset
757 If INPUT-METHOD is nil, deactivate any current input method."
19649
b2bf3c43c86a (get-language-info): Accept a symbol
Kenichi Handa <handa@m17n.org>
parents: 19615
diff changeset
758 (if (symbolp input-method)
b2bf3c43c86a (get-language-info): Accept a symbol
Kenichi Handa <handa@m17n.org>
parents: 19615
diff changeset
759 (setq input-method (symbol-name input-method)))
19405
7ef4af7505f2 (previous-input-method): This
Kenichi Handa <handa@m17n.org>
parents: 19402
diff changeset
760 (if (and current-input-method
7ef4af7505f2 (previous-input-method): This
Kenichi Handa <handa@m17n.org>
parents: 19402
diff changeset
761 (not (string= current-input-method input-method)))
19402
b904f6547598 (toggle-input-method)
Richard M. Stallman <rms@gnu.org>
parents: 19329
diff changeset
762 (inactivate-input-method))
22153
a63d4ba6813a Several doc fixes.
Richard M. Stallman <rms@gnu.org>
parents: 22025
diff changeset
763 (unless (or current-input-method (null input-method))
18301
a4da36c7bb08 Define describe-coding-system instead of
Kenichi Handa <handa@m17n.org>
parents: 18217
diff changeset
764 (let ((slot (assoc input-method input-method-alist)))
a4da36c7bb08 Define describe-coding-system instead of
Kenichi Handa <handa@m17n.org>
parents: 18217
diff changeset
765 (if (null slot)
19405
7ef4af7505f2 (previous-input-method): This
Kenichi Handa <handa@m17n.org>
parents: 19402
diff changeset
766 (error "Can't activate input method `%s'" input-method))
20165
2d0abf12009b (set-default-coding-systems):
Kenichi Handa <handa@m17n.org>
parents: 20116
diff changeset
767 (let ((func (nth 2 slot)))
2d0abf12009b (set-default-coding-systems):
Kenichi Handa <handa@m17n.org>
parents: 20116
diff changeset
768 (if (functionp func)
2d0abf12009b (set-default-coding-systems):
Kenichi Handa <handa@m17n.org>
parents: 20116
diff changeset
769 (apply (nth 2 slot) input-method (nthcdr 5 slot))
2d0abf12009b (set-default-coding-systems):
Kenichi Handa <handa@m17n.org>
parents: 20116
diff changeset
770 (if (and (consp func) (symbolp (car func)) (symbolp (cdr func)))
2d0abf12009b (set-default-coding-systems):
Kenichi Handa <handa@m17n.org>
parents: 20116
diff changeset
771 (progn
2d0abf12009b (set-default-coding-systems):
Kenichi Handa <handa@m17n.org>
parents: 20116
diff changeset
772 (require (cdr func))
2d0abf12009b (set-default-coding-systems):
Kenichi Handa <handa@m17n.org>
parents: 20116
diff changeset
773 (apply (car func) input-method (nthcdr 5 slot)))
2d0abf12009b (set-default-coding-systems):
Kenichi Handa <handa@m17n.org>
parents: 20116
diff changeset
774 (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
775 (setq current-input-method input-method)
19405
7ef4af7505f2 (previous-input-method): This
Kenichi Handa <handa@m17n.org>
parents: 19402
diff changeset
776 (setq current-input-method-title (nth 3 slot))
22854
dd7dcda2d47b (activate-input-method): Update mode line.
Kenichi Handa <handa@m17n.org>
parents: 22815
diff changeset
777 (unwind-protect
dd7dcda2d47b (activate-input-method): Update mode line.
Kenichi Handa <handa@m17n.org>
parents: 22815
diff changeset
778 (run-hooks 'input-method-activate-hook)
dd7dcda2d47b (activate-input-method): Update mode line.
Kenichi Handa <handa@m17n.org>
parents: 22815
diff changeset
779 (force-mode-line-update)))))
17991
65407fdc4a33 Delete defining "i" in mule-keymap.
Kenichi Handa <handa@m17n.org>
parents: 17840
diff changeset
780
65407fdc4a33 Delete defining "i" in mule-keymap.
Kenichi Handa <handa@m17n.org>
parents: 17840
diff changeset
781 (defun inactivate-input-method ()
19555
df2996f7fdc3 (inactivate-current-input-method-function): Doc-string modified.
Kenichi Handa <handa@m17n.org>
parents: 19424
diff changeset
782 "Turn off the current input method."
19405
7ef4af7505f2 (previous-input-method): This
Kenichi Handa <handa@m17n.org>
parents: 19402
diff changeset
783 (when current-input-method
7ef4af7505f2 (previous-input-method): This
Kenichi Handa <handa@m17n.org>
parents: 19402
diff changeset
784 (if input-method-history
7ef4af7505f2 (previous-input-method): This
Kenichi Handa <handa@m17n.org>
parents: 19402
diff changeset
785 (unless (string= current-input-method (car input-method-history))
7ef4af7505f2 (previous-input-method): This
Kenichi Handa <handa@m17n.org>
parents: 19402
diff changeset
786 (setq input-method-history
7ef4af7505f2 (previous-input-method): This
Kenichi Handa <handa@m17n.org>
parents: 19402
diff changeset
787 (cons current-input-method
7ef4af7505f2 (previous-input-method): This
Kenichi Handa <handa@m17n.org>
parents: 19402
diff changeset
788 (delete current-input-method input-method-history))))
7ef4af7505f2 (previous-input-method): This
Kenichi Handa <handa@m17n.org>
parents: 19402
diff changeset
789 (setq input-method-history (list current-input-method)))
7ef4af7505f2 (previous-input-method): This
Kenichi Handa <handa@m17n.org>
parents: 19402
diff changeset
790 (unwind-protect
7ef4af7505f2 (previous-input-method): This
Kenichi Handa <handa@m17n.org>
parents: 19402
diff changeset
791 (funcall inactivate-current-input-method-function)
17991
65407fdc4a33 Delete defining "i" in mule-keymap.
Kenichi Handa <handa@m17n.org>
parents: 17840
diff changeset
792 (unwind-protect
19405
7ef4af7505f2 (previous-input-method): This
Kenichi Handa <handa@m17n.org>
parents: 19402
diff changeset
793 (run-hooks 'input-method-inactivate-hook)
7ef4af7505f2 (previous-input-method): This
Kenichi Handa <handa@m17n.org>
parents: 19402
diff changeset
794 (setq current-input-method nil
22854
dd7dcda2d47b (activate-input-method): Update mode line.
Kenichi Handa <handa@m17n.org>
parents: 22815
diff changeset
795 current-input-method-title nil)
dd7dcda2d47b (activate-input-method): Update mode line.
Kenichi Handa <handa@m17n.org>
parents: 22815
diff changeset
796 (force-mode-line-update)))))
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
797
20295
27ae44142cfd (set-input-method): Renamed from select-input-method.
Karl Heuer <kwzh@gnu.org>
parents: 20231
diff changeset
798 (defun set-input-method (input-method)
22153
a63d4ba6813a Several doc fixes.
Richard M. Stallman <rms@gnu.org>
parents: 22025
diff changeset
799 "Select and activate input method INPUT-METHOD for the current buffer.
a63d4ba6813a Several doc fixes.
Richard M. Stallman <rms@gnu.org>
parents: 22025
diff changeset
800 This also sets the default input method to the one you specify."
18301
a4da36c7bb08 Define describe-coding-system instead of
Kenichi Handa <handa@m17n.org>
parents: 18217
diff changeset
801 (interactive
19405
7ef4af7505f2 (previous-input-method): This
Kenichi Handa <handa@m17n.org>
parents: 19402
diff changeset
802 (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
803 (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
804 (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
805 default t))))
18301
a4da36c7bb08 Define describe-coding-system instead of
Kenichi Handa <handa@m17n.org>
parents: 18217
diff changeset
806 (activate-input-method input-method)
19402
b904f6547598 (toggle-input-method)
Richard M. Stallman <rms@gnu.org>
parents: 19329
diff changeset
807 (setq default-input-method input-method))
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
808
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
809 (defun toggle-input-method (&optional arg)
17991
65407fdc4a33 Delete defining "i" in mule-keymap.
Kenichi Handa <handa@m17n.org>
parents: 17840
diff changeset
810 "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
811
21983
487cd71c058d (toggle-input-method): Use a more
Richard M. Stallman <rms@gnu.org>
parents: 21882
diff changeset
812 With no prefix argument, if some input method is currently activated,
487cd71c058d (toggle-input-method): Use a more
Richard M. Stallman <rms@gnu.org>
parents: 21882
diff changeset
813 turn it off. Otherwise, activate an input method--the one most recently used,
487cd71c058d (toggle-input-method): Use a more
Richard M. Stallman <rms@gnu.org>
parents: 21882
diff changeset
814 or the one specified in `default-input-method', or one read from the
487cd71c058d (toggle-input-method): Use a more
Richard M. Stallman <rms@gnu.org>
parents: 21882
diff changeset
815 minibuffer.
19405
7ef4af7505f2 (previous-input-method): This
Kenichi Handa <handa@m17n.org>
parents: 19402
diff changeset
816
21983
487cd71c058d (toggle-input-method): Use a more
Richard M. Stallman <rms@gnu.org>
parents: 21882
diff changeset
817 With a prefix arg, read an input method from minibuffer and turn it on.
487cd71c058d (toggle-input-method): Use a more
Richard M. Stallman <rms@gnu.org>
parents: 21882
diff changeset
818 The default is the most recent input method specified
487cd71c058d (toggle-input-method): Use a more
Richard M. Stallman <rms@gnu.org>
parents: 21882
diff changeset
819 \(not including the currently active input method, if any).
19405
7ef4af7505f2 (previous-input-method): This
Kenichi Handa <handa@m17n.org>
parents: 19402
diff changeset
820
7ef4af7505f2 (previous-input-method): This
Kenichi Handa <handa@m17n.org>
parents: 19402
diff changeset
821 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
822 (interactive "P")
21983
487cd71c058d (toggle-input-method): Use a more
Richard M. Stallman <rms@gnu.org>
parents: 21882
diff changeset
823 (if (and current-input-method (not arg))
487cd71c058d (toggle-input-method): Use a more
Richard M. Stallman <rms@gnu.org>
parents: 21882
diff changeset
824 (inactivate-input-method)
487cd71c058d (toggle-input-method): Use a more
Richard M. Stallman <rms@gnu.org>
parents: 21882
diff changeset
825 (let ((default (or (car input-method-history) default-input-method)))
487cd71c058d (toggle-input-method): Use a more
Richard M. Stallman <rms@gnu.org>
parents: 21882
diff changeset
826 (if (and arg default (equal current-input-method default)
487cd71c058d (toggle-input-method): Use a more
Richard M. Stallman <rms@gnu.org>
parents: 21882
diff changeset
827 (> (length input-method-history) 1))
487cd71c058d (toggle-input-method): Use a more
Richard M. Stallman <rms@gnu.org>
parents: 21882
diff changeset
828 (setq default (nth 1 input-method-history)))
19405
7ef4af7505f2 (previous-input-method): This
Kenichi Handa <handa@m17n.org>
parents: 19402
diff changeset
829 (activate-input-method
7ef4af7505f2 (previous-input-method): This
Kenichi Handa <handa@m17n.org>
parents: 19402
diff changeset
830 (if (or arg (not default))
21983
487cd71c058d (toggle-input-method): Use a more
Richard M. Stallman <rms@gnu.org>
parents: 21882
diff changeset
831 (progn
487cd71c058d (toggle-input-method): Use a more
Richard M. Stallman <rms@gnu.org>
parents: 21882
diff changeset
832 (read-input-method-name
487cd71c058d (toggle-input-method): Use a more
Richard M. Stallman <rms@gnu.org>
parents: 21882
diff changeset
833 (if default "Input method (default %s): " "Input method: " )
487cd71c058d (toggle-input-method): Use a more
Richard M. Stallman <rms@gnu.org>
parents: 21882
diff changeset
834 default t))
19405
7ef4af7505f2 (previous-input-method): This
Kenichi Handa <handa@m17n.org>
parents: 19402
diff changeset
835 default))
7ef4af7505f2 (previous-input-method): This
Kenichi Handa <handa@m17n.org>
parents: 19402
diff changeset
836 (or default-input-method
7ef4af7505f2 (previous-input-method): This
Kenichi Handa <handa@m17n.org>
parents: 19402
diff changeset
837 (setq default-input-method current-input-method)))))
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
838
18301
a4da36c7bb08 Define describe-coding-system instead of
Kenichi Handa <handa@m17n.org>
parents: 18217
diff changeset
839 (defun describe-input-method (input-method)
22153
a63d4ba6813a Several doc fixes.
Richard M. Stallman <rms@gnu.org>
parents: 22025
diff changeset
840 "Describe input method INPUT-METHOD."
18301
a4da36c7bb08 Define describe-coding-system instead of
Kenichi Handa <handa@m17n.org>
parents: 18217
diff changeset
841 (interactive
a4da36c7bb08 Define describe-coding-system instead of
Kenichi Handa <handa@m17n.org>
parents: 18217
diff changeset
842 (list (read-input-method-name
a4da36c7bb08 Define describe-coding-system instead of
Kenichi Handa <handa@m17n.org>
parents: 18217
diff changeset
843 "Describe input method (default, current choice): ")))
19653
431753f747ea (describe-input-method): Fix previous
Kenichi Handa <handa@m17n.org>
parents: 19649
diff changeset
844 (if (and input-method (symbolp input-method))
19649
b2bf3c43c86a (get-language-info): Accept a symbol
Kenichi Handa <handa@m17n.org>
parents: 19615
diff changeset
845 (setq input-method (symbol-name input-method)))
18301
a4da36c7bb08 Define describe-coding-system instead of
Kenichi Handa <handa@m17n.org>
parents: 18217
diff changeset
846 (if (null input-method)
a4da36c7bb08 Define describe-coding-system instead of
Kenichi Handa <handa@m17n.org>
parents: 18217
diff changeset
847 (describe-current-input-method)
a4da36c7bb08 Define describe-coding-system instead of
Kenichi Handa <handa@m17n.org>
parents: 18217
diff changeset
848 (with-output-to-temp-buffer "*Help*"
a4da36c7bb08 Define describe-coding-system instead of
Kenichi Handa <handa@m17n.org>
parents: 18217
diff changeset
849 (let ((elt (assoc input-method input-method-alist)))
a4da36c7bb08 Define describe-coding-system instead of
Kenichi Handa <handa@m17n.org>
parents: 18217
diff changeset
850 (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
851 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
852
a4da36c7bb08 Define describe-coding-system instead of
Kenichi Handa <handa@m17n.org>
parents: 18217
diff changeset
853 (defun describe-current-input-method ()
19083
8fdb29b769ed Doc fixes; fix error message text.
Richard M. Stallman <rms@gnu.org>
parents: 19036
diff changeset
854 "Describe the input method currently in use."
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
855 (if current-input-method
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
856 (if (and (symbolp describe-current-input-method-function)
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
857 (fboundp describe-current-input-method-function))
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
858 (funcall describe-current-input-method-function)
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
859 (message "No way to describe the current input method `%s'"
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
860 (cdr current-input-method))
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
861 (ding))
18301
a4da36c7bb08 Define describe-coding-system instead of
Kenichi Handa <handa@m17n.org>
parents: 18217
diff changeset
862 (error "No input method is activated now")))
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
863
20116
8c1995cc7702 (read-multilingual-string): Use
Kenichi Handa <handa@m17n.org>
parents: 20091
diff changeset
864 (defun read-multilingual-string (prompt &optional initial-input input-method)
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
865 "Read a multilingual string from minibuffer, prompting with string PROMPT.
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
866 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
867 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
868 initially.
a4da36c7bb08 Define describe-coding-system instead of
Kenichi Handa <handa@m17n.org>
parents: 18217
diff changeset
869 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
870 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
871 or a string."
18712
7366898bee9e (read-multilingual-string): Adjusted
Kenichi Handa <handa@m17n.org>
parents: 18634
diff changeset
872 (setq input-method
7366898bee9e (read-multilingual-string): Adjusted
Kenichi Handa <handa@m17n.org>
parents: 18634
diff changeset
873 (or input-method
20116
8c1995cc7702 (read-multilingual-string): Use
Kenichi Handa <handa@m17n.org>
parents: 20091
diff changeset
874 current-input-method
18712
7366898bee9e (read-multilingual-string): Adjusted
Kenichi Handa <handa@m17n.org>
parents: 18634
diff changeset
875 default-input-method
7366898bee9e (read-multilingual-string): Adjusted
Kenichi Handa <handa@m17n.org>
parents: 18634
diff changeset
876 (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
877 (if (and input-method (symbolp input-method))
19649
b2bf3c43c86a (get-language-info): Accept a symbol
Kenichi Handa <handa@m17n.org>
parents: 19615
diff changeset
878 (setq input-method (symbol-name input-method)))
22778
42258900078d (read-multilingual-string): Don't
Kenichi Handa <handa@m17n.org>
parents: 22727
diff changeset
879 (let ((current-input-method input-method))
42258900078d (read-multilingual-string): Don't
Kenichi Handa <handa@m17n.org>
parents: 22727
diff changeset
880 (read-string prompt initial-input nil nil t)))
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
881
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
882 ;; Variables to control behavior of input methods. All input methods
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
883 ;; should react to these variables.
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
884
20165
2d0abf12009b (set-default-coding-systems):
Kenichi Handa <handa@m17n.org>
parents: 20116
diff changeset
885 (defcustom input-method-verbose-flag 'default
2d0abf12009b (set-default-coding-systems):
Kenichi Handa <handa@m17n.org>
parents: 20116
diff changeset
886 "*A flag to control extra guidance given by input methods.
2d0abf12009b (set-default-coding-systems):
Kenichi Handa <handa@m17n.org>
parents: 20116
diff changeset
887 The value should be nil, t, `complex-only', or `default'.
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
888
19917
834c629f9220 (select-input-method): No error if enable-multibyte-characters is nil.
Richard M. Stallman <rms@gnu.org>
parents: 19848
diff changeset
889 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
890 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
891 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
892
2d0abf12009b (set-default-coding-systems):
Kenichi Handa <handa@m17n.org>
parents: 20116
diff changeset
893 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
894 nil, extra guidance is always suppressed.
19848
68c5c0b3ed0d (input-method-verbose-flag):
Kenichi Handa <handa@m17n.org>
parents: 19798
diff changeset
895
20165
2d0abf12009b (set-default-coding-systems):
Kenichi Handa <handa@m17n.org>
parents: 20116
diff changeset
896 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
897 `chinese-py' and `japanese' give extra guidance.
2d0abf12009b (set-default-coding-systems):
Kenichi Handa <handa@m17n.org>
parents: 20116
diff changeset
898
2d0abf12009b (set-default-coding-systems):
Kenichi Handa <handa@m17n.org>
parents: 20116
diff changeset
899 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
900 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
901 the minibuffer.
2d0abf12009b (set-default-coding-systems):
Kenichi Handa <handa@m17n.org>
parents: 20116
diff changeset
902
2d0abf12009b (set-default-coding-systems):
Kenichi Handa <handa@m17n.org>
parents: 20116
diff changeset
903 See also the variable `input-method-highlight-flag'."
2d0abf12009b (set-default-coding-systems):
Kenichi Handa <handa@m17n.org>
parents: 20116
diff changeset
904 :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
905 :group 'mule)
b904f6547598 (toggle-input-method)
Richard M. Stallman <rms@gnu.org>
parents: 19329
diff changeset
906
b904f6547598 (toggle-input-method)
Richard M. Stallman <rms@gnu.org>
parents: 19329
diff changeset
907 (defcustom input-method-highlight-flag t
b904f6547598 (toggle-input-method)
Richard M. Stallman <rms@gnu.org>
parents: 19329
diff changeset
908 "*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
909 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
910 the text inserted so far is temporarily underlined.
20165
2d0abf12009b (set-default-coding-systems):
Kenichi Handa <handa@m17n.org>
parents: 20116
diff changeset
911 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
912 See also the variable `input-method-verbose-flag'."
19402
b904f6547598 (toggle-input-method)
Richard M. Stallman <rms@gnu.org>
parents: 19329
diff changeset
913 :type 'boolean
b904f6547598 (toggle-input-method)
Richard M. Stallman <rms@gnu.org>
parents: 19329
diff changeset
914 :group 'mule)
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
915
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
916 (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
917 "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
918
df2996f7fdc3 (inactivate-current-input-method-function): Doc-string modified.
Kenichi Handa <handa@m17n.org>
parents: 19424
diff changeset
919 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
920 just activated.")
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
921
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
922 (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
923 "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
924
df2996f7fdc3 (inactivate-current-input-method-function): Doc-string modified.
Kenichi Handa <handa@m17n.org>
parents: 19424
diff changeset
925 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
926 just inactivated.")
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
927
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
928 (defvar input-method-after-insert-chunk-hook nil
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
929 "Normal hook run just after an input method insert some chunk of text.")
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
930
19405
7ef4af7505f2 (previous-input-method): This
Kenichi Handa <handa@m17n.org>
parents: 19402
diff changeset
931 (defvar input-method-exit-on-invalid-key nil
7ef4af7505f2 (previous-input-method): This
Kenichi Handa <handa@m17n.org>
parents: 19402
diff changeset
932 "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
933 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
934 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
935 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
936 back on.
7ef4af7505f2 (previous-input-method): This
Kenichi Handa <handa@m17n.org>
parents: 19402
diff changeset
937 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
938
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
939
20165
2d0abf12009b (set-default-coding-systems):
Kenichi Handa <handa@m17n.org>
parents: 20116
diff changeset
940 (defvar set-language-environment-hook nil
2d0abf12009b (set-default-coding-systems):
Kenichi Handa <handa@m17n.org>
parents: 20116
diff changeset
941 "Normal hook run after some language environment is set.
2d0abf12009b (set-default-coding-systems):
Kenichi Handa <handa@m17n.org>
parents: 20116
diff changeset
942
2d0abf12009b (set-default-coding-systems):
Kenichi Handa <handa@m17n.org>
parents: 20116
diff changeset
943 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
944 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
945 another function in `exit-language-environment-hook' (which see) to
2d0abf12009b (set-default-coding-systems):
Kenichi Handa <handa@m17n.org>
parents: 20116
diff changeset
946 cancel the effect.")
2d0abf12009b (set-default-coding-systems):
Kenichi Handa <handa@m17n.org>
parents: 20116
diff changeset
947
2d0abf12009b (set-default-coding-systems):
Kenichi Handa <handa@m17n.org>
parents: 20116
diff changeset
948 (defvar exit-language-environment-hook nil
2d0abf12009b (set-default-coding-systems):
Kenichi Handa <handa@m17n.org>
parents: 20116
diff changeset
949 "Normal hook run after exiting from some language environment.
2d0abf12009b (set-default-coding-systems):
Kenichi Handa <handa@m17n.org>
parents: 20116
diff changeset
950 When this hook is run, the variable `current-language-environment'
2d0abf12009b (set-default-coding-systems):
Kenichi Handa <handa@m17n.org>
parents: 20116
diff changeset
951 is still bound to the language environment being exited.
2d0abf12009b (set-default-coding-systems):
Kenichi Handa <handa@m17n.org>
parents: 20116
diff changeset
952
2d0abf12009b (set-default-coding-systems):
Kenichi Handa <handa@m17n.org>
parents: 20116
diff changeset
953 This hook is mainly used for cancelling the effect of
2d0abf12009b (set-default-coding-systems):
Kenichi Handa <handa@m17n.org>
parents: 20116
diff changeset
954 `set-language-environment-hook' (which-see).")
2d0abf12009b (set-default-coding-systems):
Kenichi Handa <handa@m17n.org>
parents: 20116
diff changeset
955
17991
65407fdc4a33 Delete defining "i" in mule-keymap.
Kenichi Handa <handa@m17n.org>
parents: 17840
diff changeset
956 (defun setup-specified-language-environment ()
22200
a0d60a6c87da (register-input-method): Rename arg ENV to LANG-ENV. Fix previous change.
Richard M. Stallman <rms@gnu.org>
parents: 22153
diff changeset
957 "Switch to a specified language environment."
17991
65407fdc4a33 Delete defining "i" in mule-keymap.
Kenichi Handa <handa@m17n.org>
parents: 17840
diff changeset
958 (interactive)
18634
8b309d07a95e (set-language-environment): Do the real work here.
Richard M. Stallman <rms@gnu.org>
parents: 18633
diff changeset
959 (let (language-name)
17991
65407fdc4a33 Delete defining "i" in mule-keymap.
Kenichi Handa <handa@m17n.org>
parents: 17840
diff changeset
960 (if (and (symbolp last-command-event)
65407fdc4a33 Delete defining "i" in mule-keymap.
Kenichi Handa <handa@m17n.org>
parents: 17840
diff changeset
961 (or (not (eq last-command-event 'Default))
65407fdc4a33 Delete defining "i" in mule-keymap.
Kenichi Handa <handa@m17n.org>
parents: 17840
diff changeset
962 (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
963 (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
964 (set-language-environment language-name)
17991
65407fdc4a33 Delete defining "i" in mule-keymap.
Kenichi Handa <handa@m17n.org>
parents: 17840
diff changeset
965 (error "Bogus calling sequence"))))
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
966
21229
38b621cd9169 (set-language-environment): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents: 21042
diff changeset
967 (defcustom current-language-environment "English"
38b621cd9169 (set-language-environment): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents: 21042
diff changeset
968 "The last language environment specified with `set-language-environment'."
38b621cd9169 (set-language-environment): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents: 21042
diff changeset
969 :set 'set-language-environment
38b621cd9169 (set-language-environment): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents: 21042
diff changeset
970 :initialize 'custom-initialize-default
38b621cd9169 (set-language-environment): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents: 21042
diff changeset
971 :group 'mule
38b621cd9169 (set-language-environment): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents: 21042
diff changeset
972 :type 'string)
18634
8b309d07a95e (set-language-environment): Do the real work here.
Richard M. Stallman <rms@gnu.org>
parents: 18633
diff changeset
973
18066
eecd891e2b63 (set-language-environment): Add autoload cookie.
Richard M. Stallman <rms@gnu.org>
parents: 17991
diff changeset
974 (defun set-language-environment (language-name)
18068
317f57f07b14 Doc fix for previous change.
Richard M. Stallman <rms@gnu.org>
parents: 18066
diff changeset
975 "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
976 This sets the coding system priority and the default input method
21229
38b621cd9169 (set-language-environment): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents: 21042
diff changeset
977 and sometimes other things. LANGUAGE-NAME should be a string
38b621cd9169 (set-language-environment): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents: 21042
diff changeset
978 which is the name of a language environment. For example, \"Latin-1\"
38b621cd9169 (set-language-environment): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents: 21042
diff changeset
979 specifies the character set for the major languages of Western Europe."
20165
2d0abf12009b (set-default-coding-systems):
Kenichi Handa <handa@m17n.org>
parents: 20116
diff changeset
980 (interactive (list (read-language-name
2d0abf12009b (set-default-coding-systems):
Kenichi Handa <handa@m17n.org>
parents: 20116
diff changeset
981 'setup-function
2d0abf12009b (set-default-coding-systems):
Kenichi Handa <handa@m17n.org>
parents: 20116
diff changeset
982 "Set language environment (default, English): ")))
19649
b2bf3c43c86a (get-language-info): Accept a symbol
Kenichi Handa <handa@m17n.org>
parents: 19615
diff changeset
983 (if language-name
b2bf3c43c86a (get-language-info): Accept a symbol
Kenichi Handa <handa@m17n.org>
parents: 19615
diff changeset
984 (if (symbolp language-name)
b2bf3c43c86a (get-language-info): Accept a symbol
Kenichi Handa <handa@m17n.org>
parents: 19615
diff changeset
985 (setq language-name (symbol-name language-name)))
b2bf3c43c86a (get-language-info): Accept a symbol
Kenichi Handa <handa@m17n.org>
parents: 19615
diff changeset
986 (setq language-name "English"))
18801
f60dbf4f7d7c (mule-keymap): Bind l to set-language-environment.
Kenichi Handa <handa@m17n.org>
parents: 18712
diff changeset
987 (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
988 (error "Language environment not defined: %S" language-name))
20165
2d0abf12009b (set-default-coding-systems):
Kenichi Handa <handa@m17n.org>
parents: 20116
diff changeset
989 (if current-language-environment
2d0abf12009b (set-default-coding-systems):
Kenichi Handa <handa@m17n.org>
parents: 20116
diff changeset
990 (let ((func (get-language-info current-language-environment
2d0abf12009b (set-default-coding-systems):
Kenichi Handa <handa@m17n.org>
parents: 20116
diff changeset
991 'exit-function)))
20231
7f0ea4977b32 (set-language-environment): Run
Kenichi Handa <handa@m17n.org>
parents: 20165
diff changeset
992 (run-hooks 'exit-language-environment-hook)
7f0ea4977b32 (set-language-environment): Run
Kenichi Handa <handa@m17n.org>
parents: 20165
diff changeset
993 (if (fboundp func) (funcall func))))
22565
3d2804459d84 (set-language-environment): Allow all language environments, even in
Richard M. Stallman <rms@gnu.org>
parents: 22200
diff changeset
994 (when (and (not default-enable-multibyte-characters)
22727
eb18b97af384 (set-language-environment): Test unibyte-syntax instead of using a
Richard M. Stallman <rms@gnu.org>
parents: 22565
diff changeset
995 (get-language-info language-name 'unibyte-syntax))
22565
3d2804459d84 (set-language-environment): Allow all language environments, even in
Richard M. Stallman <rms@gnu.org>
parents: 22200
diff changeset
996 (set-terminal-coding-system (intern (downcase language-name)))
3d2804459d84 (set-language-environment): Allow all language environments, even in
Richard M. Stallman <rms@gnu.org>
parents: 22200
diff changeset
997 (standard-display-european-internal))
20165
2d0abf12009b (set-default-coding-systems):
Kenichi Handa <handa@m17n.org>
parents: 20116
diff changeset
998 (setq current-language-environment language-name)
22887
e24b79da83d6 (language-info-alist): Doc-string
Kenichi Handa <handa@m17n.org>
parents: 22854
diff changeset
999 (setq nonascii-translation-table
e24b79da83d6 (language-info-alist): Doc-string
Kenichi Handa <handa@m17n.org>
parents: 22854
diff changeset
1000 (get-language-info language-name 'nonascii-translation-table))
e24b79da83d6 (language-info-alist): Doc-string
Kenichi Handa <handa@m17n.org>
parents: 22854
diff changeset
1001 (setq charset-origin-alist
e24b79da83d6 (language-info-alist): Doc-string
Kenichi Handa <handa@m17n.org>
parents: 22854
diff changeset
1002 (get-language-info language-name 'charset-origin-alist))
18634
8b309d07a95e (set-language-environment): Do the real work here.
Richard M. Stallman <rms@gnu.org>
parents: 18633
diff changeset
1003 (funcall (get-language-info language-name 'setup-function))
20165
2d0abf12009b (set-default-coding-systems):
Kenichi Handa <handa@m17n.org>
parents: 20116
diff changeset
1004 (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
1005 (force-mode-line-update t))
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1006
21856
68e39b75b862 (set-language-environment): Fix previous change.
Richard M. Stallman <rms@gnu.org>
parents: 21770
diff changeset
1007 (defun standard-display-european-internal ()
68e39b75b862 (set-language-environment): Fix previous change.
Richard M. Stallman <rms@gnu.org>
parents: 21770
diff changeset
1008 ;; Actually set up direct output of non-ASCII characters.
68e39b75b862 (set-language-environment): Fix previous change.
Richard M. Stallman <rms@gnu.org>
parents: 21770
diff changeset
1009 (standard-display-8bit 160 255)
68e39b75b862 (set-language-environment): Fix previous change.
Richard M. Stallman <rms@gnu.org>
parents: 21770
diff changeset
1010 ;; Make non-line-break space display as a plain space.
68e39b75b862 (set-language-environment): Fix previous change.
Richard M. Stallman <rms@gnu.org>
parents: 21770
diff changeset
1011 ;; Most X fonts do the wrong thing for code 160.
68e39b75b862 (set-language-environment): Fix previous change.
Richard M. Stallman <rms@gnu.org>
parents: 21770
diff changeset
1012 (aset standard-display-table 160 [32])
68e39b75b862 (set-language-environment): Fix previous change.
Richard M. Stallman <rms@gnu.org>
parents: 21770
diff changeset
1013 ;; Most Windows programs send out apostrophe's as \222. Most X fonts
68e39b75b862 (set-language-environment): Fix previous change.
Richard M. Stallman <rms@gnu.org>
parents: 21770
diff changeset
1014 ;; don't contain a character at that position. Map it to the ASCII
68e39b75b862 (set-language-environment): Fix previous change.
Richard M. Stallman <rms@gnu.org>
parents: 21770
diff changeset
1015 ;; apostrophe.
68e39b75b862 (set-language-environment): Fix previous change.
Richard M. Stallman <rms@gnu.org>
parents: 21770
diff changeset
1016 (aset standard-display-table 146 [39]))
68e39b75b862 (set-language-environment): Fix previous change.
Richard M. Stallman <rms@gnu.org>
parents: 21770
diff changeset
1017
20733
079907c59fb2 (set-language-info): Doc-string
Kenichi Handa <handa@m17n.org>
parents: 20485
diff changeset
1018 (defun set-language-environment-coding-systems (language-name)
079907c59fb2 (set-language-info): Doc-string
Kenichi Handa <handa@m17n.org>
parents: 20485
diff changeset
1019 "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
1020 (let* ((priority (get-language-info language-name 'coding-priority))
079907c59fb2 (set-language-info): Doc-string
Kenichi Handa <handa@m17n.org>
parents: 20485
diff changeset
1021 (default-coding (car priority)))
079907c59fb2 (set-language-info): Doc-string
Kenichi Handa <handa@m17n.org>
parents: 20485
diff changeset
1022 (if priority
079907c59fb2 (set-language-info): Doc-string
Kenichi Handa <handa@m17n.org>
parents: 20485
diff changeset
1023 (let ((categories (mapcar 'coding-system-category priority)))
079907c59fb2 (set-language-info): Doc-string
Kenichi Handa <handa@m17n.org>
parents: 20485
diff changeset
1024 (set-default-coding-systems default-coding)
079907c59fb2 (set-language-info): Doc-string
Kenichi Handa <handa@m17n.org>
parents: 20485
diff changeset
1025 (set-coding-priority categories)
079907c59fb2 (set-language-info): Doc-string
Kenichi Handa <handa@m17n.org>
parents: 20485
diff changeset
1026 (while priority
079907c59fb2 (set-language-info): Doc-string
Kenichi Handa <handa@m17n.org>
parents: 20485
diff changeset
1027 (set (car categories) (car priority))
079907c59fb2 (set-language-info): Doc-string
Kenichi Handa <handa@m17n.org>
parents: 20485
diff changeset
1028 (setq priority (cdr priority) categories (cdr categories)))
22887
e24b79da83d6 (language-info-alist): Doc-string
Kenichi Handa <handa@m17n.org>
parents: 22854
diff changeset
1029 (update-coding-systems-internal)))))
20733
079907c59fb2 (set-language-info): Doc-string
Kenichi Handa <handa@m17n.org>
parents: 20485
diff changeset
1030
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1031 ;; Print all arguments with `princ', then print "\n".
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1032 (defsubst princ-list (&rest args)
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1033 (while args (princ (car args)) (setq args (cdr args)))
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1034 (princ "\n"))
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1035
17840
2517414676ed (set-language-info): Change the special treatment
Kenichi Handa <handa@m17n.org>
parents: 17758
diff changeset
1036 ;; 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
1037 ;; 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
1038 ;; called from the menu:
18152
e184e7061c9a (describe-language-environment):
Richard M. Stallman <rms@gnu.org>
parents: 18068
diff changeset
1039 ;; [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
1040 ;; 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
1041 (defun describe-specified-language-support ()
19083
8fdb29b769ed Doc fixes; fix error message text.
Richard M. Stallman <rms@gnu.org>
parents: 19036
diff changeset
1042 "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
1043 (interactive)
18152
e184e7061c9a (describe-language-environment):
Richard M. Stallman <rms@gnu.org>
parents: 18068
diff changeset
1044 (let (language-name)
17840
2517414676ed (set-language-info): Change the special treatment
Kenichi Handa <handa@m17n.org>
parents: 17758
diff changeset
1045 (if (not (and (symbolp last-command-event)
18152
e184e7061c9a (describe-language-environment):
Richard M. Stallman <rms@gnu.org>
parents: 18068
diff changeset
1046 (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
1047 (error "Bogus calling sequence"))
18152
e184e7061c9a (describe-language-environment):
Richard M. Stallman <rms@gnu.org>
parents: 18068
diff changeset
1048 (describe-language-environment language-name)))
e184e7061c9a (describe-language-environment):
Richard M. Stallman <rms@gnu.org>
parents: 18068
diff changeset
1049
e184e7061c9a (describe-language-environment):
Richard M. Stallman <rms@gnu.org>
parents: 18068
diff changeset
1050 (defun describe-language-environment (language-name)
e184e7061c9a (describe-language-environment):
Richard M. Stallman <rms@gnu.org>
parents: 18068
diff changeset
1051 "Describe how Emacs supports language environment LANGUAGE-NAME."
19653
431753f747ea (describe-input-method): Fix previous
Kenichi Handa <handa@m17n.org>
parents: 19649
diff changeset
1052 (interactive
431753f747ea (describe-input-method): Fix previous
Kenichi Handa <handa@m17n.org>
parents: 19649
diff changeset
1053 (list (read-language-name
431753f747ea (describe-input-method): Fix previous
Kenichi Handa <handa@m17n.org>
parents: 19649
diff changeset
1054 'documentation
20091
aac4c6a58684 (describe-language-environment): Fix prompt.
Karl Heuer <kwzh@gnu.org>
parents: 19917
diff changeset
1055 "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
1056 (if (null language-name)
8b309d07a95e (set-language-environment): Do the real work here.
Richard M. Stallman <rms@gnu.org>
parents: 18633
diff changeset
1057 (setq language-name current-language-environment))
18152
e184e7061c9a (describe-language-environment):
Richard M. Stallman <rms@gnu.org>
parents: 18068
diff changeset
1058 (if (or (null language-name)
e184e7061c9a (describe-language-environment):
Richard M. Stallman <rms@gnu.org>
parents: 18068
diff changeset
1059 (null (get-language-info language-name 'documentation)))
e184e7061c9a (describe-language-environment):
Richard M. Stallman <rms@gnu.org>
parents: 18068
diff changeset
1060 (error "No documentation for the specified language"))
19649
b2bf3c43c86a (get-language-info): Accept a symbol
Kenichi Handa <handa@m17n.org>
parents: 19615
diff changeset
1061 (if (symbolp language-name)
b2bf3c43c86a (get-language-info): Accept a symbol
Kenichi Handa <handa@m17n.org>
parents: 19615
diff changeset
1062 (setq language-name (symbol-name language-name)))
18152
e184e7061c9a (describe-language-environment):
Richard M. Stallman <rms@gnu.org>
parents: 18068
diff changeset
1063 (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
1064 (with-output-to-temp-buffer "*Help*"
21471
ae34e7d5c51f (describe-language-environment):
Kenichi Handa <handa@m17n.org>
parents: 21377
diff changeset
1065 (princ-list language-name " language environment" "\n")
17758
8c67c2e2cc29 (build-describe-language-support-function,
Kenichi Handa <handa@m17n.org>
parents: 17526
diff changeset
1066 (if (stringp doc)
18301
a4da36c7bb08 Define describe-coding-system instead of
Kenichi Handa <handa@m17n.org>
parents: 18217
diff changeset
1067 (progn
a4da36c7bb08 Define describe-coding-system instead of
Kenichi Handa <handa@m17n.org>
parents: 18217
diff changeset
1068 (princ-list doc)
a4da36c7bb08 Define describe-coding-system instead of
Kenichi Handa <handa@m17n.org>
parents: 18217
diff changeset
1069 (terpri)))
17991
65407fdc4a33 Delete defining "i" in mule-keymap.
Kenichi Handa <handa@m17n.org>
parents: 17840
diff changeset
1070 (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
1071 (if (stringp str)
65407fdc4a33 Delete defining "i" in mule-keymap.
Kenichi Handa <handa@m17n.org>
parents: 17840
diff changeset
1072 (progn
18152
e184e7061c9a (describe-language-environment):
Richard M. Stallman <rms@gnu.org>
parents: 18068
diff changeset
1073 (princ "Sample text:\n")
18301
a4da36c7bb08 Define describe-coding-system instead of
Kenichi Handa <handa@m17n.org>
parents: 18217
diff changeset
1074 (princ-list " " str)
a4da36c7bb08 Define describe-coding-system instead of
Kenichi Handa <handa@m17n.org>
parents: 18217
diff changeset
1075 (terpri))))
18152
e184e7061c9a (describe-language-environment):
Richard M. Stallman <rms@gnu.org>
parents: 18068
diff changeset
1076 (princ "Input methods:\n")
18301
a4da36c7bb08 Define describe-coding-system instead of
Kenichi Handa <handa@m17n.org>
parents: 18217
diff changeset
1077 (let ((l input-method-alist))
17991
65407fdc4a33 Delete defining "i" in mule-keymap.
Kenichi Handa <handa@m17n.org>
parents: 17840
diff changeset
1078 (while l
18301
a4da36c7bb08 Define describe-coding-system instead of
Kenichi Handa <handa@m17n.org>
parents: 18217
diff changeset
1079 (if (string= language-name (nth 1 (car l)))
a4da36c7bb08 Define describe-coding-system instead of
Kenichi Handa <handa@m17n.org>
parents: 18217
diff changeset
1080 (princ-list " " (car (car l))
a4da36c7bb08 Define describe-coding-system instead of
Kenichi Handa <handa@m17n.org>
parents: 18217
diff changeset
1081 (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
1082 (setq l (cdr l))))
18152
e184e7061c9a (describe-language-environment):
Richard M. Stallman <rms@gnu.org>
parents: 18068
diff changeset
1083 (terpri)
e184e7061c9a (describe-language-environment):
Richard M. Stallman <rms@gnu.org>
parents: 18068
diff changeset
1084 (princ "Character sets:\n")
17991
65407fdc4a33 Delete defining "i" in mule-keymap.
Kenichi Handa <handa@m17n.org>
parents: 17840
diff changeset
1085 (let ((l (get-language-info language-name 'charset)))
65407fdc4a33 Delete defining "i" in mule-keymap.
Kenichi Handa <handa@m17n.org>
parents: 17840
diff changeset
1086 (if (null l)
65407fdc4a33 Delete defining "i" in mule-keymap.
Kenichi Handa <handa@m17n.org>
parents: 17840
diff changeset
1087 (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
1088 (while l
17991
65407fdc4a33 Delete defining "i" in mule-keymap.
Kenichi Handa <handa@m17n.org>
parents: 17840
diff changeset
1089 (princ-list " " (car l) ": "
65407fdc4a33 Delete defining "i" in mule-keymap.
Kenichi Handa <handa@m17n.org>
parents: 17840
diff changeset
1090 (charset-description (car l)))
65407fdc4a33 Delete defining "i" in mule-keymap.
Kenichi Handa <handa@m17n.org>
parents: 17840
diff changeset
1091 (setq l (cdr l)))))
18152
e184e7061c9a (describe-language-environment):
Richard M. Stallman <rms@gnu.org>
parents: 18068
diff changeset
1092 (terpri)
e184e7061c9a (describe-language-environment):
Richard M. Stallman <rms@gnu.org>
parents: 18068
diff changeset
1093 (princ "Coding systems:\n")
17991
65407fdc4a33 Delete defining "i" in mule-keymap.
Kenichi Handa <handa@m17n.org>
parents: 17840
diff changeset
1094 (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
1095 (if (null l)
65407fdc4a33 Delete defining "i" in mule-keymap.
Kenichi Handa <handa@m17n.org>
parents: 17840
diff changeset
1096 (princ-list " nothing specific to " language-name)
65407fdc4a33 Delete defining "i" in mule-keymap.
Kenichi Handa <handa@m17n.org>
parents: 17840
diff changeset
1097 (while l
18152
e184e7061c9a (describe-language-environment):
Richard M. Stallman <rms@gnu.org>
parents: 18068
diff changeset
1098 (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
1099 (car l)
e184e7061c9a (describe-language-environment):
Richard M. Stallman <rms@gnu.org>
parents: 18068
diff changeset
1100 (coding-system-mnemonic (car l))
18176
fc07ea29cd81 Define mouse-set-font in mule-menu-keymap.
Kenichi Handa <handa@m17n.org>
parents: 18152
diff changeset
1101 (coding-system-doc-string (car l))))
20165
2d0abf12009b (set-default-coding-systems):
Kenichi Handa <handa@m17n.org>
parents: 20116
diff changeset
1102 (let ((aliases (coding-system-get (car l) 'alias-coding-systems)))
2d0abf12009b (set-default-coding-systems):
Kenichi Handa <handa@m17n.org>
parents: 20116
diff changeset
1103 (when aliases
2d0abf12009b (set-default-coding-systems):
Kenichi Handa <handa@m17n.org>
parents: 20116
diff changeset
1104 (princ "\t")
2d0abf12009b (set-default-coding-systems):
Kenichi Handa <handa@m17n.org>
parents: 20116
diff changeset
1105 (princ (cons 'alias: (cdr aliases)))
2d0abf12009b (set-default-coding-systems):
Kenichi Handa <handa@m17n.org>
parents: 20116
diff changeset
1106 (terpri)))
17991
65407fdc4a33 Delete defining "i" in mule-keymap.
Kenichi Handa <handa@m17n.org>
parents: 17840
diff changeset
1107 (setq l (cdr l))))))))
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1108
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1109 ;;; Charset property
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1110
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1111 (defsubst get-charset-property (charset propname)
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1112 "Return the value of CHARSET's PROPNAME property.
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1113 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
1114 (put-charset-property CHARSET PROPNAME VALUE)."
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1115 (plist-get (charset-plist charset) propname))
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1116
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1117 (defsubst put-charset-property (charset propname value)
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1118 "Store CHARSETS's PROPNAME property with value VALUE.
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1119 It can be retrieved with `(get-charset-property CHARSET PROPNAME)'."
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1120 (set-charset-plist charset
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1121 (plist-put (charset-plist charset) propname value)))
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1122
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1123 ;;; Character code property
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1124 (put 'char-code-property-table 'char-table-extra-slots 0)
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1125
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1126 (defvar char-code-property-table
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1127 (make-char-table 'char-code-property-table)
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1128 "Char-table containing a property list of each character code.
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1129
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1130 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
1131 `put-char-code-property'.")
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1132
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1133 (defun get-char-code-property (char propname)
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1134 "Return the value of CHAR's PROPNAME property in `char-code-property-table'."
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1135 (let ((plist (aref char-code-property-table char)))
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1136 (if (listp plist)
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1137 (car (cdr (memq propname plist))))))
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1138
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1139 (defun put-char-code-property (char propname value)
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1140 "Store CHAR's PROPNAME property with VALUE in `char-code-property-table'.
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1141 It can be retrieved with `(get-char-code-property CHAR PROPNAME)'."
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1142 (let ((plist (aref char-code-property-table char)))
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1143 (if plist
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1144 (let ((slot (memq propname plist)))
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1145 (if slot
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1146 (setcar (cdr slot) value)
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1147 (nconc plist (list propname value))))
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1148 (aset char-code-property-table char (list propname value)))))
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1149
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1150 ;;; mule-cmds.el ends here