annotate lisp/mule/mule-cmds.el @ 207:e45d5e7c476e r20-4b2

Import from CVS: tag r20-4b2
author cvs
date Mon, 13 Aug 2007 10:03:52 +0200
parents 850242ba4a81
children 41ff10fd062f
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
187
b405438285a2 Import from CVS: tag r20-3b20
cvs
parents: 165
diff changeset
1 ;;; mule-cmds.el --- Commands for multilingual environment
155
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
2
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
3 ;; Copyright (C) 1995 Electrotechnical Laboratory, JAPAN.
197
acd284d43ca1 Import from CVS: tag r20-3b25
cvs
parents: 187
diff changeset
4 ;; Licensed to the Free Software Foundation.
155
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
5 ;; Copyright (C) 1997 MORIOKA Tomohiko
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
6
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
7 ;; Keywords: mule, multilingual
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
8
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
9 ;; This file is part of XEmacs.
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
10
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
11 ;; XEmacs is free software; you can redistribute it and/or modify it
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
12 ;; under the terms of the GNU General Public License as published by
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
13 ;; the Free Software Foundation; either version 2, or (at your option)
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
14 ;; any later version.
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
15
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
16 ;; XEmacs is distributed in the hope that it will be useful, but
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
17 ;; WITHOUT ANY WARRANTY; without even the implied warranty of
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
18 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
19 ;; General Public License for more details.
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
20
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
21 ;; You should have received a copy of the GNU General Public License
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
22 ;; along with XEmacs; see the file COPYING. If not, write to the Free
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
23 ;; Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
24 ;; 02111-1307, USA.
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
25
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
26 ;;; Code:
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
27
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
28 ;;; MULE related key bindings and menus.
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
29
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
30 (defvar mule-keymap (make-sparse-keymap "MULE")
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
31 "Keymap for MULE (Multilingual environment) specific commands.")
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
32
165
5a88923fcbfe Import from CVS: tag r20-3b9
cvs
parents: 155
diff changeset
33 ;; Keep "C-x C-m ..." for mule specific commands.
207
e45d5e7c476e Import from CVS: tag r20-4b2
cvs
parents: 203
diff changeset
34 (define-key ctl-x-map "\C-m" mule-keymap)
155
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
35
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
36 (define-key mule-keymap "f" 'set-buffer-file-coding-system)
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
37 (define-key mule-keymap "F" 'set-default-buffer-file-coding-system) ; XEmacs
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
38 (define-key mule-keymap "t" 'set-terminal-coding-system)
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
39 (define-key mule-keymap "k" 'set-keyboard-coding-system)
207
e45d5e7c476e Import from CVS: tag r20-4b2
cvs
parents: 203
diff changeset
40 (define-key mule-keymap "p" 'set-buffer-process-coding-system)
197
acd284d43ca1 Import from CVS: tag r20-3b25
cvs
parents: 187
diff changeset
41 (define-key mule-keymap "\C-\\" 'select-input-method)
207
e45d5e7c476e Import from CVS: tag r20-4b2
cvs
parents: 203
diff changeset
42 (define-key mule-keymap "c" 'universal-coding-system-argument)
e45d5e7c476e Import from CVS: tag r20-4b2
cvs
parents: 203
diff changeset
43 ;;(define-key mule-keymap "c" 'list-coding-system-briefly) ; XEmacs
155
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
44 (define-key mule-keymap "C" 'list-coding-system) ; XEmacs
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
45 (define-key mule-keymap "r" 'toggle-display-direction) ; XEmacs
197
acd284d43ca1 Import from CVS: tag r20-3b25
cvs
parents: 187
diff changeset
46 (define-key mule-keymap "l" 'set-language-environment)
155
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
47
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
48 (define-key help-map "\C-L" 'describe-language-support)
197
acd284d43ca1 Import from CVS: tag r20-3b25
cvs
parents: 187
diff changeset
49 (define-key help-map "L" 'describe-language-environment)
155
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
50 (define-key help-map "\C-\\" 'describe-input-method)
197
acd284d43ca1 Import from CVS: tag r20-3b25
cvs
parents: 187
diff changeset
51 (define-key help-map "I" 'describe-input-method)
207
e45d5e7c476e Import from CVS: tag r20-4b2
cvs
parents: 203
diff changeset
52 (define-key help-map "C" 'describe-coding-system)
155
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
53 (define-key help-map "h" 'view-hello-file)
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
54
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
55 ;; Menu for XEmacs were moved to x11/x-menubar.el.
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
56
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
57
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
58 ;; This should be a single character key binding because users use it
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
59 ;; very frequently while editing multilingual text. Now we can use
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
60 ;; only two such keys: "\C-\\" and "\C-^", but the latter is not
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
61 ;; convenient because it requires shifting on most keyboards. An
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
62 ;; alternative is "\C-\]" which is now bound to `abort-recursive-edit'
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
63 ;; but it won't be used that frequently.
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
64 (define-key global-map "\C-\\" 'toggle-input-method)
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
65
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
66 (defun view-hello-file ()
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
67 "Display the HELLO file which list up many languages and characters."
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
68 (interactive)
165
5a88923fcbfe Import from CVS: tag r20-3b9
cvs
parents: 155
diff changeset
69 ;; We have to decode the file in any environment.
5a88923fcbfe Import from CVS: tag r20-3b9
cvs
parents: 155
diff changeset
70 (let ((coding-system-for-read 'iso-2022-7))
5a88923fcbfe Import from CVS: tag r20-3b9
cvs
parents: 155
diff changeset
71 (find-file-read-only (expand-file-name "HELLO" data-directory))))
155
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
72
207
e45d5e7c476e Import from CVS: tag r20-4b2
cvs
parents: 203
diff changeset
73 (defun universal-coding-system-argument ()
e45d5e7c476e Import from CVS: tag r20-4b2
cvs
parents: 203
diff changeset
74 "Execute an I/O command using the specified coding system."
e45d5e7c476e Import from CVS: tag r20-4b2
cvs
parents: 203
diff changeset
75 (interactive)
e45d5e7c476e Import from CVS: tag r20-4b2
cvs
parents: 203
diff changeset
76 (let* ((coding-system
e45d5e7c476e Import from CVS: tag r20-4b2
cvs
parents: 203
diff changeset
77 (read-coding-system "Coding system for following command: "))
e45d5e7c476e Import from CVS: tag r20-4b2
cvs
parents: 203
diff changeset
78 (keyseq (read-key-sequence
e45d5e7c476e Import from CVS: tag r20-4b2
cvs
parents: 203
diff changeset
79 (format "Command to execute with %s:" coding-system)))
e45d5e7c476e Import from CVS: tag r20-4b2
cvs
parents: 203
diff changeset
80 (cmd (key-binding keyseq)))
e45d5e7c476e Import from CVS: tag r20-4b2
cvs
parents: 203
diff changeset
81 (let ((coding-system-for-read coding-system)
e45d5e7c476e Import from CVS: tag r20-4b2
cvs
parents: 203
diff changeset
82 (coding-system-for-write coding-system))
e45d5e7c476e Import from CVS: tag r20-4b2
cvs
parents: 203
diff changeset
83 (message "")
e45d5e7c476e Import from CVS: tag r20-4b2
cvs
parents: 203
diff changeset
84 (call-interactively cmd))))
e45d5e7c476e Import from CVS: tag r20-4b2
cvs
parents: 203
diff changeset
85
e45d5e7c476e Import from CVS: tag r20-4b2
cvs
parents: 203
diff changeset
86 (defun set-default-coding-systems (coding-system)
e45d5e7c476e Import from CVS: tag r20-4b2
cvs
parents: 203
diff changeset
87 "Set default value of various coding systems to CODING-SYSTEM.
e45d5e7c476e Import from CVS: tag r20-4b2
cvs
parents: 203
diff changeset
88 The follwing coding systems are set:
e45d5e7c476e Import from CVS: tag r20-4b2
cvs
parents: 203
diff changeset
89 o coding system of a newly created buffer
e45d5e7c476e Import from CVS: tag r20-4b2
cvs
parents: 203
diff changeset
90 o default coding system for terminal output
e45d5e7c476e Import from CVS: tag r20-4b2
cvs
parents: 203
diff changeset
91 o default coding system for keyboard input
e45d5e7c476e Import from CVS: tag r20-4b2
cvs
parents: 203
diff changeset
92 o default coding system for subprocess I/O"
e45d5e7c476e Import from CVS: tag r20-4b2
cvs
parents: 203
diff changeset
93 (check-coding-system coding-system)
e45d5e7c476e Import from CVS: tag r20-4b2
cvs
parents: 203
diff changeset
94 ;;(setq-default buffer-file-coding-system coding-system)
e45d5e7c476e Import from CVS: tag r20-4b2
cvs
parents: 203
diff changeset
95 (set-default-buffer-file-coding-system coding-system)
e45d5e7c476e Import from CVS: tag r20-4b2
cvs
parents: 203
diff changeset
96 ;;(setq default-terminal-coding-system coding-system)
e45d5e7c476e Import from CVS: tag r20-4b2
cvs
parents: 203
diff changeset
97 (setq terminal-coding-system coding-system)
e45d5e7c476e Import from CVS: tag r20-4b2
cvs
parents: 203
diff changeset
98 ;;(setq default-keyboard-coding-system coding-system)
e45d5e7c476e Import from CVS: tag r20-4b2
cvs
parents: 203
diff changeset
99 (setq keyboard-coding-system coding-system)
e45d5e7c476e Import from CVS: tag r20-4b2
cvs
parents: 203
diff changeset
100 ;;(setq default-process-coding-system (cons coding-system coding-system))
e45d5e7c476e Import from CVS: tag r20-4b2
cvs
parents: 203
diff changeset
101 (add-hook 'comint-exec-hook
e45d5e7c476e Import from CVS: tag r20-4b2
cvs
parents: 203
diff changeset
102 (lambda ()
e45d5e7c476e Import from CVS: tag r20-4b2
cvs
parents: 203
diff changeset
103 (let ((proc (get-buffer-process (current-buffer))))
e45d5e7c476e Import from CVS: tag r20-4b2
cvs
parents: 203
diff changeset
104 (set-process-input-coding-system proc coding-system)
e45d5e7c476e Import from CVS: tag r20-4b2
cvs
parents: 203
diff changeset
105 (set-process-output-coding-system proc coding-system)
e45d5e7c476e Import from CVS: tag r20-4b2
cvs
parents: 203
diff changeset
106 )))
e45d5e7c476e Import from CVS: tag r20-4b2
cvs
parents: 203
diff changeset
107 (setq file-name-coding-system coding-system)
e45d5e7c476e Import from CVS: tag r20-4b2
cvs
parents: 203
diff changeset
108 )
e45d5e7c476e Import from CVS: tag r20-4b2
cvs
parents: 203
diff changeset
109
e45d5e7c476e Import from CVS: tag r20-4b2
cvs
parents: 203
diff changeset
110 (defun prefer-coding-system (coding-system)
e45d5e7c476e Import from CVS: tag r20-4b2
cvs
parents: 203
diff changeset
111 "Add CODING-SYSTEM at the front of the priority list for automatic detection.
e45d5e7c476e Import from CVS: tag r20-4b2
cvs
parents: 203
diff changeset
112 This also sets the following coding systems to CODING-SYSTEM:
e45d5e7c476e Import from CVS: tag r20-4b2
cvs
parents: 203
diff changeset
113 o coding system of a newly created buffer
e45d5e7c476e Import from CVS: tag r20-4b2
cvs
parents: 203
diff changeset
114 o default coding system for terminal output
e45d5e7c476e Import from CVS: tag r20-4b2
cvs
parents: 203
diff changeset
115 o default coding system for keyboard input
e45d5e7c476e Import from CVS: tag r20-4b2
cvs
parents: 203
diff changeset
116 o default coding system for subprocess I/O"
e45d5e7c476e Import from CVS: tag r20-4b2
cvs
parents: 203
diff changeset
117 (interactive "zPrefer coding system: ")
e45d5e7c476e Import from CVS: tag r20-4b2
cvs
parents: 203
diff changeset
118 (if (not (and coding-system (coding-system-p coding-system)))
e45d5e7c476e Import from CVS: tag r20-4b2
cvs
parents: 203
diff changeset
119 (error "Invalid coding system `%s'" coding-system))
e45d5e7c476e Import from CVS: tag r20-4b2
cvs
parents: 203
diff changeset
120 (let ((coding-category (coding-system-category coding-system))
e45d5e7c476e Import from CVS: tag r20-4b2
cvs
parents: 203
diff changeset
121 (parent (coding-system-parent coding-system)))
e45d5e7c476e Import from CVS: tag r20-4b2
cvs
parents: 203
diff changeset
122 (if (not coding-category)
e45d5e7c476e Import from CVS: tag r20-4b2
cvs
parents: 203
diff changeset
123 ;; CODING-SYSTEM is no-conversion or undecided.
e45d5e7c476e Import from CVS: tag r20-4b2
cvs
parents: 203
diff changeset
124 (error "Can't prefer the coding system `%s'" coding-system))
e45d5e7c476e Import from CVS: tag r20-4b2
cvs
parents: 203
diff changeset
125 (set coding-category (or parent coding-system))
e45d5e7c476e Import from CVS: tag r20-4b2
cvs
parents: 203
diff changeset
126 (if (not (eq coding-category (car coding-category-list)))
e45d5e7c476e Import from CVS: tag r20-4b2
cvs
parents: 203
diff changeset
127 ;; We must change the order.
e45d5e7c476e Import from CVS: tag r20-4b2
cvs
parents: 203
diff changeset
128 (setq coding-category-list
e45d5e7c476e Import from CVS: tag r20-4b2
cvs
parents: 203
diff changeset
129 (cons coding-category
e45d5e7c476e Import from CVS: tag r20-4b2
cvs
parents: 203
diff changeset
130 (delq coding-category coding-category-list))))
e45d5e7c476e Import from CVS: tag r20-4b2
cvs
parents: 203
diff changeset
131 (if (and parent (interactive-p))
e45d5e7c476e Import from CVS: tag r20-4b2
cvs
parents: 203
diff changeset
132 (message "Highest priority is set to %s (parent of %s)"
e45d5e7c476e Import from CVS: tag r20-4b2
cvs
parents: 203
diff changeset
133 parent coding-system))
e45d5e7c476e Import from CVS: tag r20-4b2
cvs
parents: 203
diff changeset
134 (set-default-coding-systems (or parent coding-system))))
e45d5e7c476e Import from CVS: tag r20-4b2
cvs
parents: 203
diff changeset
135
155
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
136
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
137 ;;; Language support staffs.
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
138
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
139 (defvar language-info-alist nil
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
140 "Alist of language names vs the corresponding information of various kind.
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
141 Each element looks like:
165
5a88923fcbfe Import from CVS: tag r20-3b9
cvs
parents: 155
diff changeset
142 (LANGUAGE-NAME . ((KEY . INFO) ...))
155
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
143 where LANGUAGE-NAME is a string,
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
144 KEY is a symbol denoting the kind of information,
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
145 INFO is any Lisp object which contains the actual information related
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
146 to KEY.")
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
147
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
148 (defun get-language-info (language-name key)
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
149 "Return the information for LANGUAGE-NAME of the kind KEY.
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
150 KEY is a symbol denoting the kind of required information."
197
acd284d43ca1 Import from CVS: tag r20-3b25
cvs
parents: 187
diff changeset
151 (if (symbolp language-name)
acd284d43ca1 Import from CVS: tag r20-3b25
cvs
parents: 187
diff changeset
152 (setq language-name (symbol-name language-name)))
acd284d43ca1 Import from CVS: tag r20-3b25
cvs
parents: 187
diff changeset
153 (let ((lang-slot (assoc-ignore-case language-name language-info-alist)))
155
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
154 (if lang-slot
165
5a88923fcbfe Import from CVS: tag r20-3b9
cvs
parents: 155
diff changeset
155 (cdr (assq key (cdr lang-slot))))))
155
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
156
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
157 (defun set-language-info (language-name key info)
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
158 "Set for LANGUAGE-NAME the information INFO under KEY.
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
159 KEY is a symbol denoting the kind of information.
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
160 INFO is any Lisp object which contains the actual information.
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
161
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
162 Currently, the following KEYs are used by Emacs:
197
acd284d43ca1 Import from CVS: tag r20-3b25
cvs
parents: 187
diff changeset
163
155
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
164 charset: list of symbols whose values are charsets specific to the language.
197
acd284d43ca1 Import from CVS: tag r20-3b25
cvs
parents: 187
diff changeset
165
155
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
166 coding-system: list of coding systems specific to the langauge.
197
acd284d43ca1 Import from CVS: tag r20-3b25
cvs
parents: 187
diff changeset
167
155
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
168 tutorial: a tutorial file name written in the language.
197
acd284d43ca1 Import from CVS: tag r20-3b25
cvs
parents: 187
diff changeset
169
155
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
170 sample-text: one line short text containing characters of the language.
197
acd284d43ca1 Import from CVS: tag r20-3b25
cvs
parents: 187
diff changeset
171
acd284d43ca1 Import from CVS: tag r20-3b25
cvs
parents: 187
diff changeset
172 documentation: t or a string describing how Emacs supports the language.
acd284d43ca1 Import from CVS: tag r20-3b25
cvs
parents: 187
diff changeset
173 If a string is specified, it is shown before any other information
acd284d43ca1 Import from CVS: tag r20-3b25
cvs
parents: 187
diff changeset
174 of the language by the command `describe-language-environment'.
acd284d43ca1 Import from CVS: tag r20-3b25
cvs
parents: 187
diff changeset
175
165
5a88923fcbfe Import from CVS: tag r20-3b9
cvs
parents: 155
diff changeset
176 setup-function: a function to call for setting up environment
197
acd284d43ca1 Import from CVS: tag r20-3b25
cvs
parents: 187
diff changeset
177 convenient for a user of the language.
155
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
178
197
acd284d43ca1 Import from CVS: tag r20-3b25
cvs
parents: 187
diff changeset
179 If KEY is documentation or setup-function, you can also specify
acd284d43ca1 Import from CVS: tag r20-3b25
cvs
parents: 187
diff changeset
180 a cons cell as INFO, in which case, the car part should be
acd284d43ca1 Import from CVS: tag r20-3b25
cvs
parents: 187
diff changeset
181 a normal value as INFO for KEY (as described above),
acd284d43ca1 Import from CVS: tag r20-3b25
cvs
parents: 187
diff changeset
182 and the cdr part should be a symbol whose value is a menu keymap
acd284d43ca1 Import from CVS: tag r20-3b25
cvs
parents: 187
diff changeset
183 in which an entry for the language is defined. But, only the car part
acd284d43ca1 Import from CVS: tag r20-3b25
cvs
parents: 187
diff changeset
184 is actually set as the information.
acd284d43ca1 Import from CVS: tag r20-3b25
cvs
parents: 187
diff changeset
185
acd284d43ca1 Import from CVS: tag r20-3b25
cvs
parents: 187
diff changeset
186 We will define more KEYs in the future. To avoid conflict,
acd284d43ca1 Import from CVS: tag r20-3b25
cvs
parents: 187
diff changeset
187 if you want to use your own KEY values, make them start with `user-'."
acd284d43ca1 Import from CVS: tag r20-3b25
cvs
parents: 187
diff changeset
188 (if (symbolp language-name)
acd284d43ca1 Import from CVS: tag r20-3b25
cvs
parents: 187
diff changeset
189 (setq language-name (symbol-name language-name)))
155
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
190 (let (lang-slot key-slot)
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
191 (setq lang-slot (assoc language-name language-info-alist))
165
5a88923fcbfe Import from CVS: tag r20-3b9
cvs
parents: 155
diff changeset
192 (if (null lang-slot) ; If no slot for the language, add it.
5a88923fcbfe Import from CVS: tag r20-3b9
cvs
parents: 155
diff changeset
193 (setq lang-slot (list language-name)
5a88923fcbfe Import from CVS: tag r20-3b9
cvs
parents: 155
diff changeset
194 language-info-alist (cons lang-slot language-info-alist)))
155
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
195 (setq key-slot (assq key lang-slot))
165
5a88923fcbfe Import from CVS: tag r20-3b9
cvs
parents: 155
diff changeset
196 (if (null key-slot) ; If no slot for the key, add it.
5a88923fcbfe Import from CVS: tag r20-3b9
cvs
parents: 155
diff changeset
197 (progn
5a88923fcbfe Import from CVS: tag r20-3b9
cvs
parents: 155
diff changeset
198 (setq key-slot (list key))
5a88923fcbfe Import from CVS: tag r20-3b9
cvs
parents: 155
diff changeset
199 (setcdr lang-slot (cons key-slot (cdr lang-slot)))))
155
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
200 ;; Setup menu.
197
acd284d43ca1 Import from CVS: tag r20-3b25
cvs
parents: 187
diff changeset
201 (cond ((eq key 'documentation)
207
e45d5e7c476e Import from CVS: tag r20-4b2
cvs
parents: 203
diff changeset
202 ;; (define-key-after
e45d5e7c476e Import from CVS: tag r20-4b2
cvs
parents: 203
diff changeset
203 ;; (if (consp info)
e45d5e7c476e Import from CVS: tag r20-4b2
cvs
parents: 203
diff changeset
204 ;; (prog1 (symbol-value (cdr info))
e45d5e7c476e Import from CVS: tag r20-4b2
cvs
parents: 203
diff changeset
205 ;; (setq info (car info)))
e45d5e7c476e Import from CVS: tag r20-4b2
cvs
parents: 203
diff changeset
206 ;; describe-language-environment-map)
165
5a88923fcbfe Import from CVS: tag r20-3b9
cvs
parents: 155
diff changeset
207 ;; (vector (intern language-name))
207
e45d5e7c476e Import from CVS: tag r20-4b2
cvs
parents: 203
diff changeset
208 ;; (cons language-name 'describe-specified-language-support)
165
5a88923fcbfe Import from CVS: tag r20-3b9
cvs
parents: 155
diff changeset
209 ;; t)
207
e45d5e7c476e Import from CVS: tag r20-4b2
cvs
parents: 203
diff changeset
210 (if (consp info)
e45d5e7c476e Import from CVS: tag r20-4b2
cvs
parents: 203
diff changeset
211 (setq info (car info)))
165
5a88923fcbfe Import from CVS: tag r20-3b9
cvs
parents: 155
diff changeset
212 (eval-after-load "x-menubar"
207
e45d5e7c476e Import from CVS: tag r20-4b2
cvs
parents: 203
diff changeset
213 `(add-menu-button
e45d5e7c476e Import from CVS: tag r20-4b2
cvs
parents: 203
diff changeset
214 '("Mule" "Describe Language Support")
e45d5e7c476e Import from CVS: tag r20-4b2
cvs
parents: 203
diff changeset
215 (vector ,language-name
e45d5e7c476e Import from CVS: tag r20-4b2
cvs
parents: 203
diff changeset
216 '(describe-language-environment ,language-name)
e45d5e7c476e Import from CVS: tag r20-4b2
cvs
parents: 203
diff changeset
217 t)))
165
5a88923fcbfe Import from CVS: tag r20-3b9
cvs
parents: 155
diff changeset
218 )
5a88923fcbfe Import from CVS: tag r20-3b9
cvs
parents: 155
diff changeset
219 ((eq key 'setup-function)
207
e45d5e7c476e Import from CVS: tag r20-4b2
cvs
parents: 203
diff changeset
220 ;; (define-key-after
e45d5e7c476e Import from CVS: tag r20-4b2
cvs
parents: 203
diff changeset
221 ;; (if (consp info)
e45d5e7c476e Import from CVS: tag r20-4b2
cvs
parents: 203
diff changeset
222 ;; (prog1 (symbol-value (cdr info))
e45d5e7c476e Import from CVS: tag r20-4b2
cvs
parents: 203
diff changeset
223 ;; (setq info (car info)))
e45d5e7c476e Import from CVS: tag r20-4b2
cvs
parents: 203
diff changeset
224 ;; setup-language-environment-map)
165
5a88923fcbfe Import from CVS: tag r20-3b9
cvs
parents: 155
diff changeset
225 ;; (vector (intern language-name))
207
e45d5e7c476e Import from CVS: tag r20-4b2
cvs
parents: 203
diff changeset
226 ;; (cons language-name 'setup-specified-language-environment)
165
5a88923fcbfe Import from CVS: tag r20-3b9
cvs
parents: 155
diff changeset
227 ;; t)
207
e45d5e7c476e Import from CVS: tag r20-4b2
cvs
parents: 203
diff changeset
228 (if (consp info)
e45d5e7c476e Import from CVS: tag r20-4b2
cvs
parents: 203
diff changeset
229 (setq info (car info)))
165
5a88923fcbfe Import from CVS: tag r20-3b9
cvs
parents: 155
diff changeset
230 (eval-after-load "x-menubar"
207
e45d5e7c476e Import from CVS: tag r20-4b2
cvs
parents: 203
diff changeset
231 `(add-menu-button
e45d5e7c476e Import from CVS: tag r20-4b2
cvs
parents: 203
diff changeset
232 '("Mule" "Set Language Environment")
e45d5e7c476e Import from CVS: tag r20-4b2
cvs
parents: 203
diff changeset
233 (vector ,language-name
e45d5e7c476e Import from CVS: tag r20-4b2
cvs
parents: 203
diff changeset
234 '(set-language-environment ,language-name)
e45d5e7c476e Import from CVS: tag r20-4b2
cvs
parents: 203
diff changeset
235 t)))
165
5a88923fcbfe Import from CVS: tag r20-3b9
cvs
parents: 155
diff changeset
236 ))
207
e45d5e7c476e Import from CVS: tag r20-4b2
cvs
parents: 203
diff changeset
237
e45d5e7c476e Import from CVS: tag r20-4b2
cvs
parents: 203
diff changeset
238 (setcdr key-slot info)
155
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
239 ))
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
240
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
241 (defun set-language-info-alist (language-name alist)
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
242 "Set for LANGUAGE-NAME the information in ALIST.
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
243 ALIST is an alist of KEY and INFO. See the documentation of
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
244 `set-langauge-info' for the meanings of KEY and INFO."
197
acd284d43ca1 Import from CVS: tag r20-3b25
cvs
parents: 187
diff changeset
245 (if (symbolp language-name)
acd284d43ca1 Import from CVS: tag r20-3b25
cvs
parents: 187
diff changeset
246 (setq language-name (symbol-name language-name)))
155
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
247 (while alist
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
248 (set-language-info language-name (car (car alist)) (cdr (car alist)))
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
249 (setq alist (cdr alist))))
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
250
197
acd284d43ca1 Import from CVS: tag r20-3b25
cvs
parents: 187
diff changeset
251 (defun read-language-name (key prompt &optional default)
acd284d43ca1 Import from CVS: tag r20-3b25
cvs
parents: 187
diff changeset
252 "Read language name which has information for KEY, prompting with PROMPT.
acd284d43ca1 Import from CVS: tag r20-3b25
cvs
parents: 187
diff changeset
253 DEFAULT is the default choice of language.
acd284d43ca1 Import from CVS: tag r20-3b25
cvs
parents: 187
diff changeset
254 This returns a language name as a string."
155
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
255 (let* ((completion-ignore-case t)
165
5a88923fcbfe Import from CVS: tag r20-3b9
cvs
parents: 155
diff changeset
256 (name (completing-read prompt
5a88923fcbfe Import from CVS: tag r20-3b9
cvs
parents: 155
diff changeset
257 language-info-alist
5a88923fcbfe Import from CVS: tag r20-3b9
cvs
parents: 155
diff changeset
258 (function (lambda (elm) (assq key elm)))
207
e45d5e7c476e Import from CVS: tag r20-4b2
cvs
parents: 203
diff changeset
259 t nil default)))
197
acd284d43ca1 Import from CVS: tag r20-3b25
cvs
parents: 187
diff changeset
260 (if (and (> (length name) 0)
acd284d43ca1 Import from CVS: tag r20-3b25
cvs
parents: 187
diff changeset
261 (get-language-info name key))
acd284d43ca1 Import from CVS: tag r20-3b25
cvs
parents: 187
diff changeset
262 name)))
155
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
263
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
264 ;;; Multilingual input methods.
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
265
197
acd284d43ca1 Import from CVS: tag r20-3b25
cvs
parents: 187
diff changeset
266 (defconst leim-list-file-name "leim-list.el"
acd284d43ca1 Import from CVS: tag r20-3b25
cvs
parents: 187
diff changeset
267 "Name of LEIM list file.
acd284d43ca1 Import from CVS: tag r20-3b25
cvs
parents: 187
diff changeset
268 This file contains a list of libraries of Emacs input methods (LEIM)
acd284d43ca1 Import from CVS: tag r20-3b25
cvs
parents: 187
diff changeset
269 in the format of Lisp expression for registering each input method.
acd284d43ca1 Import from CVS: tag r20-3b25
cvs
parents: 187
diff changeset
270 Emacs loads this file at startup time.")
acd284d43ca1 Import from CVS: tag r20-3b25
cvs
parents: 187
diff changeset
271
acd284d43ca1 Import from CVS: tag r20-3b25
cvs
parents: 187
diff changeset
272 (defvar leim-list-header (format "\
acd284d43ca1 Import from CVS: tag r20-3b25
cvs
parents: 187
diff changeset
273 ;;; %s -- list of LEIM (Library of Emacs Input Method)
acd284d43ca1 Import from CVS: tag r20-3b25
cvs
parents: 187
diff changeset
274 ;;
acd284d43ca1 Import from CVS: tag r20-3b25
cvs
parents: 187
diff changeset
275 ;; This file contains a list of LEIM (Library of Emacs Input Method)
acd284d43ca1 Import from CVS: tag r20-3b25
cvs
parents: 187
diff changeset
276 ;; in the same directory as this file. Loading this file registeres
acd284d43ca1 Import from CVS: tag r20-3b25
cvs
parents: 187
diff changeset
277 ;; the whole input methods in Emacs.
acd284d43ca1 Import from CVS: tag r20-3b25
cvs
parents: 187
diff changeset
278 ;;
acd284d43ca1 Import from CVS: tag r20-3b25
cvs
parents: 187
diff changeset
279 ;; Each entry has the form:
acd284d43ca1 Import from CVS: tag r20-3b25
cvs
parents: 187
diff changeset
280 ;; (register-input-method
acd284d43ca1 Import from CVS: tag r20-3b25
cvs
parents: 187
diff changeset
281 ;; INPUT-METHOD LANGUAGE-NAME ACTIVATE-FUNC
acd284d43ca1 Import from CVS: tag r20-3b25
cvs
parents: 187
diff changeset
282 ;; TITLE DESCRIPTION
acd284d43ca1 Import from CVS: tag r20-3b25
cvs
parents: 187
diff changeset
283 ;; ARG ...)
acd284d43ca1 Import from CVS: tag r20-3b25
cvs
parents: 187
diff changeset
284 ;; See the function `register-input-method' for the meanings of arguments.
acd284d43ca1 Import from CVS: tag r20-3b25
cvs
parents: 187
diff changeset
285 ;;
acd284d43ca1 Import from CVS: tag r20-3b25
cvs
parents: 187
diff changeset
286 ;; If this directory is included in load-path, Emacs automatically
acd284d43ca1 Import from CVS: tag r20-3b25
cvs
parents: 187
diff changeset
287 ;; loads this file at startup time.
acd284d43ca1 Import from CVS: tag r20-3b25
cvs
parents: 187
diff changeset
288
acd284d43ca1 Import from CVS: tag r20-3b25
cvs
parents: 187
diff changeset
289 "
acd284d43ca1 Import from CVS: tag r20-3b25
cvs
parents: 187
diff changeset
290 leim-list-file-name)
acd284d43ca1 Import from CVS: tag r20-3b25
cvs
parents: 187
diff changeset
291 "Header to be inserted in LEIM list file.")
acd284d43ca1 Import from CVS: tag r20-3b25
cvs
parents: 187
diff changeset
292
acd284d43ca1 Import from CVS: tag r20-3b25
cvs
parents: 187
diff changeset
293 (defvar leim-list-entry-regexp "^(register-input-method"
acd284d43ca1 Import from CVS: tag r20-3b25
cvs
parents: 187
diff changeset
294 "Regexp matching head of each entry in LEIM list file.
acd284d43ca1 Import from CVS: tag r20-3b25
cvs
parents: 187
diff changeset
295 See also the variable `leim-list-header'")
acd284d43ca1 Import from CVS: tag r20-3b25
cvs
parents: 187
diff changeset
296
acd284d43ca1 Import from CVS: tag r20-3b25
cvs
parents: 187
diff changeset
297 (defvar update-leim-list-functions
acd284d43ca1 Import from CVS: tag r20-3b25
cvs
parents: 187
diff changeset
298 '(quail-update-leim-list-file)
acd284d43ca1 Import from CVS: tag r20-3b25
cvs
parents: 187
diff changeset
299 "List of functions to call to update LEIM list file.
acd284d43ca1 Import from CVS: tag r20-3b25
cvs
parents: 187
diff changeset
300 Each function is called with one arg, LEIM directory name.")
acd284d43ca1 Import from CVS: tag r20-3b25
cvs
parents: 187
diff changeset
301
acd284d43ca1 Import from CVS: tag r20-3b25
cvs
parents: 187
diff changeset
302 (defun update-leim-list-file (&rest dirs)
acd284d43ca1 Import from CVS: tag r20-3b25
cvs
parents: 187
diff changeset
303 "Update LEIM list file in directories DIRS."
acd284d43ca1 Import from CVS: tag r20-3b25
cvs
parents: 187
diff changeset
304 (let ((functions update-leim-list-functions))
acd284d43ca1 Import from CVS: tag r20-3b25
cvs
parents: 187
diff changeset
305 (while functions
acd284d43ca1 Import from CVS: tag r20-3b25
cvs
parents: 187
diff changeset
306 (apply (car functions) dirs)
acd284d43ca1 Import from CVS: tag r20-3b25
cvs
parents: 187
diff changeset
307 (setq functions (cdr functions)))))
acd284d43ca1 Import from CVS: tag r20-3b25
cvs
parents: 187
diff changeset
308
155
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
309 (defvar current-input-method nil
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
310 "The current input method for multilingual text.
197
acd284d43ca1 Import from CVS: tag r20-3b25
cvs
parents: 187
diff changeset
311 If nil, that means no input method is activated now.")
155
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
312 (make-variable-buffer-local 'current-input-method)
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
313 (put 'current-input-method 'permanent-local t)
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
314
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
315 (defvar current-input-method-title nil
197
acd284d43ca1 Import from CVS: tag r20-3b25
cvs
parents: 187
diff changeset
316 "Title string of the current input method shown in mode line.")
155
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
317 (make-variable-buffer-local 'current-input-method-title)
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
318 (put 'current-input-method-title 'permanent-local t)
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
319
197
acd284d43ca1 Import from CVS: tag r20-3b25
cvs
parents: 187
diff changeset
320 (defcustom default-input-method nil
acd284d43ca1 Import from CVS: tag r20-3b25
cvs
parents: 187
diff changeset
321 "*Default input method for multilingual text.
acd284d43ca1 Import from CVS: tag r20-3b25
cvs
parents: 187
diff changeset
322 This is the input method activated automatically by the command
acd284d43ca1 Import from CVS: tag r20-3b25
cvs
parents: 187
diff changeset
323 `toggle-input-method' (\\[toggle-input-method])."
acd284d43ca1 Import from CVS: tag r20-3b25
cvs
parents: 187
diff changeset
324 :group 'mule)
155
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
325
197
acd284d43ca1 Import from CVS: tag r20-3b25
cvs
parents: 187
diff changeset
326 (defvar input-method-history nil
acd284d43ca1 Import from CVS: tag r20-3b25
cvs
parents: 187
diff changeset
327 "History list for some commands that read input methods.")
acd284d43ca1 Import from CVS: tag r20-3b25
cvs
parents: 187
diff changeset
328 (make-variable-buffer-local 'input-method-history)
acd284d43ca1 Import from CVS: tag r20-3b25
cvs
parents: 187
diff changeset
329 (put 'input-method-history 'permanent-local t)
155
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
330
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
331 (defvar inactivate-current-input-method-function nil
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
332 "Function to call for inactivating the current input method.
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
333 Every input method should set this to an appropriate value when activated.
197
acd284d43ca1 Import from CVS: tag r20-3b25
cvs
parents: 187
diff changeset
334 This function is called with no argument.
acd284d43ca1 Import from CVS: tag r20-3b25
cvs
parents: 187
diff changeset
335
acd284d43ca1 Import from CVS: tag r20-3b25
cvs
parents: 187
diff changeset
336 This function should never change the value of `current-input-method'.
acd284d43ca1 Import from CVS: tag r20-3b25
cvs
parents: 187
diff changeset
337 It is set to nil by the function `inactivate-input-method'.")
155
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
338 (make-variable-buffer-local 'inactivate-current-input-method-function)
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
339 (put 'inactivate-current-input-method-function 'permanent-local t)
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
340
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
341 (defvar describe-current-input-method-function nil
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
342 "Function to call for describing the current input method.
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
343 This function is called with no argument.")
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
344 (make-variable-buffer-local 'describe-current-input-method-function)
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
345 (put 'describe-current-input-method-function 'permanent-local t)
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
346
197
acd284d43ca1 Import from CVS: tag r20-3b25
cvs
parents: 187
diff changeset
347 (defvar input-method-alist nil
acd284d43ca1 Import from CVS: tag r20-3b25
cvs
parents: 187
diff changeset
348 "Alist of input method names vs the corresponding information to use it.
acd284d43ca1 Import from CVS: tag r20-3b25
cvs
parents: 187
diff changeset
349 Each element has the form:
acd284d43ca1 Import from CVS: tag r20-3b25
cvs
parents: 187
diff changeset
350 (INPUT-METHOD LANGUAGE-NAME ACTIVATE-FUNC TITLE DESCRIPTION ...)
acd284d43ca1 Import from CVS: tag r20-3b25
cvs
parents: 187
diff changeset
351 See the function `register-input-method' for the meanings of each elements.")
acd284d43ca1 Import from CVS: tag r20-3b25
cvs
parents: 187
diff changeset
352
acd284d43ca1 Import from CVS: tag r20-3b25
cvs
parents: 187
diff changeset
353 (defun register-input-method (input-method language-name &rest args)
acd284d43ca1 Import from CVS: tag r20-3b25
cvs
parents: 187
diff changeset
354 "Register INPUT-METHOD as an input method for LANGUAGE-NAME.
acd284d43ca1 Import from CVS: tag r20-3b25
cvs
parents: 187
diff changeset
355 INPUT-METHOD and LANGUAGE-NAME are symbols or strings.
acd284d43ca1 Import from CVS: tag r20-3b25
cvs
parents: 187
diff changeset
356 The remaining arguments are:
acd284d43ca1 Import from CVS: tag r20-3b25
cvs
parents: 187
diff changeset
357 ACTIVATE-FUNC, TITLE, DESCRIPTION, and ARG ...
acd284d43ca1 Import from CVS: tag r20-3b25
cvs
parents: 187
diff changeset
358 where,
acd284d43ca1 Import from CVS: tag r20-3b25
cvs
parents: 187
diff changeset
359 ACTIVATE-FUNC is a function to call for activating this method.
acd284d43ca1 Import from CVS: tag r20-3b25
cvs
parents: 187
diff changeset
360 TITLE is a string shown in mode-line while this method is active,
acd284d43ca1 Import from CVS: tag r20-3b25
cvs
parents: 187
diff changeset
361 DESCRIPTION is a string describing about this method,
acd284d43ca1 Import from CVS: tag r20-3b25
cvs
parents: 187
diff changeset
362 Arguments to ACTIVATE-FUNC are INPUT-METHOD and ARGs."
acd284d43ca1 Import from CVS: tag r20-3b25
cvs
parents: 187
diff changeset
363 (if (symbolp language-name)
acd284d43ca1 Import from CVS: tag r20-3b25
cvs
parents: 187
diff changeset
364 (setq language-name (symbol-name language-name)))
acd284d43ca1 Import from CVS: tag r20-3b25
cvs
parents: 187
diff changeset
365 (if (symbolp input-method)
acd284d43ca1 Import from CVS: tag r20-3b25
cvs
parents: 187
diff changeset
366 (setq input-method (symbol-name input-method)))
acd284d43ca1 Import from CVS: tag r20-3b25
cvs
parents: 187
diff changeset
367 (let ((info (cons language-name args))
acd284d43ca1 Import from CVS: tag r20-3b25
cvs
parents: 187
diff changeset
368 (slot (assoc input-method input-method-alist)))
acd284d43ca1 Import from CVS: tag r20-3b25
cvs
parents: 187
diff changeset
369 (if slot
acd284d43ca1 Import from CVS: tag r20-3b25
cvs
parents: 187
diff changeset
370 (setcdr slot info)
acd284d43ca1 Import from CVS: tag r20-3b25
cvs
parents: 187
diff changeset
371 (setq slot (cons input-method info))
acd284d43ca1 Import from CVS: tag r20-3b25
cvs
parents: 187
diff changeset
372 (setq input-method-alist (cons slot input-method-alist)))))
acd284d43ca1 Import from CVS: tag r20-3b25
cvs
parents: 187
diff changeset
373
acd284d43ca1 Import from CVS: tag r20-3b25
cvs
parents: 187
diff changeset
374 (defun read-input-method-name (prompt &optional default inhibit-null)
acd284d43ca1 Import from CVS: tag r20-3b25
cvs
parents: 187
diff changeset
375 "Read a name of input method from a minibuffer prompting with PROMPT.
acd284d43ca1 Import from CVS: tag r20-3b25
cvs
parents: 187
diff changeset
376 If DEFAULT is non-nil, use that as the default,
acd284d43ca1 Import from CVS: tag r20-3b25
cvs
parents: 187
diff changeset
377 and substitute it into PROMPT at the first `%s'.
acd284d43ca1 Import from CVS: tag r20-3b25
cvs
parents: 187
diff changeset
378 If INHIBIT-NULL is non-nil, null input signals an error.
155
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
379
197
acd284d43ca1 Import from CVS: tag r20-3b25
cvs
parents: 187
diff changeset
380 The return value is a string."
acd284d43ca1 Import from CVS: tag r20-3b25
cvs
parents: 187
diff changeset
381 (if default
acd284d43ca1 Import from CVS: tag r20-3b25
cvs
parents: 187
diff changeset
382 (setq prompt (format prompt default)))
acd284d43ca1 Import from CVS: tag r20-3b25
cvs
parents: 187
diff changeset
383 (let* ((completion-ignore-case t)
acd284d43ca1 Import from CVS: tag r20-3b25
cvs
parents: 187
diff changeset
384 ;; This binding is necessary because input-method-history is
acd284d43ca1 Import from CVS: tag r20-3b25
cvs
parents: 187
diff changeset
385 ;; buffer local.
acd284d43ca1 Import from CVS: tag r20-3b25
cvs
parents: 187
diff changeset
386 (input-method (completing-read prompt input-method-alist
acd284d43ca1 Import from CVS: tag r20-3b25
cvs
parents: 187
diff changeset
387 nil t nil 'input-method-history)
acd284d43ca1 Import from CVS: tag r20-3b25
cvs
parents: 187
diff changeset
388 ;;default)
acd284d43ca1 Import from CVS: tag r20-3b25
cvs
parents: 187
diff changeset
389 ))
acd284d43ca1 Import from CVS: tag r20-3b25
cvs
parents: 187
diff changeset
390 (if (> (length input-method) 0)
acd284d43ca1 Import from CVS: tag r20-3b25
cvs
parents: 187
diff changeset
391 input-method
207
e45d5e7c476e Import from CVS: tag r20-4b2
cvs
parents: 203
diff changeset
392 (if inhibit-null
e45d5e7c476e Import from CVS: tag r20-4b2
cvs
parents: 203
diff changeset
393 (error "No valid input method is specified")))))
155
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
394
197
acd284d43ca1 Import from CVS: tag r20-3b25
cvs
parents: 187
diff changeset
395 (defun activate-input-method (input-method)
acd284d43ca1 Import from CVS: tag r20-3b25
cvs
parents: 187
diff changeset
396 "Turn INPUT-METHOD on.
acd284d43ca1 Import from CVS: tag r20-3b25
cvs
parents: 187
diff changeset
397 If some input method is already on, turn it off at first."
acd284d43ca1 Import from CVS: tag r20-3b25
cvs
parents: 187
diff changeset
398 (if (symbolp input-method)
acd284d43ca1 Import from CVS: tag r20-3b25
cvs
parents: 187
diff changeset
399 (setq input-method (symbol-name input-method)))
acd284d43ca1 Import from CVS: tag r20-3b25
cvs
parents: 187
diff changeset
400 (if (and current-input-method
acd284d43ca1 Import from CVS: tag r20-3b25
cvs
parents: 187
diff changeset
401 (not (string= current-input-method input-method)))
acd284d43ca1 Import from CVS: tag r20-3b25
cvs
parents: 187
diff changeset
402 (inactivate-input-method))
acd284d43ca1 Import from CVS: tag r20-3b25
cvs
parents: 187
diff changeset
403 (unless current-input-method
acd284d43ca1 Import from CVS: tag r20-3b25
cvs
parents: 187
diff changeset
404 (let ((slot (assoc input-method input-method-alist)))
acd284d43ca1 Import from CVS: tag r20-3b25
cvs
parents: 187
diff changeset
405 (if (null slot)
acd284d43ca1 Import from CVS: tag r20-3b25
cvs
parents: 187
diff changeset
406 (error "Can't activate input method `%s'" input-method))
acd284d43ca1 Import from CVS: tag r20-3b25
cvs
parents: 187
diff changeset
407 (apply (nth 2 slot) input-method (nthcdr 5 slot))
acd284d43ca1 Import from CVS: tag r20-3b25
cvs
parents: 187
diff changeset
408 (setq current-input-method input-method)
acd284d43ca1 Import from CVS: tag r20-3b25
cvs
parents: 187
diff changeset
409 (setq current-input-method-title (nth 3 slot))
acd284d43ca1 Import from CVS: tag r20-3b25
cvs
parents: 187
diff changeset
410 (run-hooks 'input-method-activate-hook))))
155
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
411
197
acd284d43ca1 Import from CVS: tag r20-3b25
cvs
parents: 187
diff changeset
412 (defun inactivate-input-method ()
acd284d43ca1 Import from CVS: tag r20-3b25
cvs
parents: 187
diff changeset
413 "Turn off the current input method."
acd284d43ca1 Import from CVS: tag r20-3b25
cvs
parents: 187
diff changeset
414 (when current-input-method
acd284d43ca1 Import from CVS: tag r20-3b25
cvs
parents: 187
diff changeset
415 (if input-method-history
acd284d43ca1 Import from CVS: tag r20-3b25
cvs
parents: 187
diff changeset
416 (unless (string= current-input-method (car input-method-history))
acd284d43ca1 Import from CVS: tag r20-3b25
cvs
parents: 187
diff changeset
417 (setq input-method-history
acd284d43ca1 Import from CVS: tag r20-3b25
cvs
parents: 187
diff changeset
418 (cons current-input-method
acd284d43ca1 Import from CVS: tag r20-3b25
cvs
parents: 187
diff changeset
419 (delete current-input-method input-method-history))))
acd284d43ca1 Import from CVS: tag r20-3b25
cvs
parents: 187
diff changeset
420 (setq input-method-history (list current-input-method)))
acd284d43ca1 Import from CVS: tag r20-3b25
cvs
parents: 187
diff changeset
421 (unwind-protect
acd284d43ca1 Import from CVS: tag r20-3b25
cvs
parents: 187
diff changeset
422 (funcall inactivate-current-input-method-function)
acd284d43ca1 Import from CVS: tag r20-3b25
cvs
parents: 187
diff changeset
423 (unwind-protect
acd284d43ca1 Import from CVS: tag r20-3b25
cvs
parents: 187
diff changeset
424 (run-hooks 'input-method-inactivate-hook)
acd284d43ca1 Import from CVS: tag r20-3b25
cvs
parents: 187
diff changeset
425 (setq current-input-method nil
acd284d43ca1 Import from CVS: tag r20-3b25
cvs
parents: 187
diff changeset
426 current-input-method-title nil)))))
acd284d43ca1 Import from CVS: tag r20-3b25
cvs
parents: 187
diff changeset
427
acd284d43ca1 Import from CVS: tag r20-3b25
cvs
parents: 187
diff changeset
428 (defun select-input-method (input-method)
acd284d43ca1 Import from CVS: tag r20-3b25
cvs
parents: 187
diff changeset
429 "Select and turn on INPUT-METHOD.
acd284d43ca1 Import from CVS: tag r20-3b25
cvs
parents: 187
diff changeset
430 This sets the default input method to what you specify,
acd284d43ca1 Import from CVS: tag r20-3b25
cvs
parents: 187
diff changeset
431 and turn it on for the current buffer."
acd284d43ca1 Import from CVS: tag r20-3b25
cvs
parents: 187
diff changeset
432 (interactive
acd284d43ca1 Import from CVS: tag r20-3b25
cvs
parents: 187
diff changeset
433 (let* ((default (or (car input-method-history) default-input-method)))
acd284d43ca1 Import from CVS: tag r20-3b25
cvs
parents: 187
diff changeset
434 (list (read-input-method-name
acd284d43ca1 Import from CVS: tag r20-3b25
cvs
parents: 187
diff changeset
435 (if default "Select input method (default %s): " "Select input method: ")
acd284d43ca1 Import from CVS: tag r20-3b25
cvs
parents: 187
diff changeset
436 default t))))
acd284d43ca1 Import from CVS: tag r20-3b25
cvs
parents: 187
diff changeset
437 (activate-input-method input-method)
acd284d43ca1 Import from CVS: tag r20-3b25
cvs
parents: 187
diff changeset
438 (setq default-input-method input-method))
155
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
439
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
440 (defun toggle-input-method (&optional arg)
197
acd284d43ca1 Import from CVS: tag r20-3b25
cvs
parents: 187
diff changeset
441 "Turn on or off a multilingual text input method for the current buffer.
acd284d43ca1 Import from CVS: tag r20-3b25
cvs
parents: 187
diff changeset
442
acd284d43ca1 Import from CVS: tag r20-3b25
cvs
parents: 187
diff changeset
443 With arg, read an input method from minibuffer and turn it on.
acd284d43ca1 Import from CVS: tag r20-3b25
cvs
parents: 187
diff changeset
444
acd284d43ca1 Import from CVS: tag r20-3b25
cvs
parents: 187
diff changeset
445 Without arg, if some input method is currently activated, turn it off,
acd284d43ca1 Import from CVS: tag r20-3b25
cvs
parents: 187
diff changeset
446 else turn on an input method selected last time
acd284d43ca1 Import from CVS: tag r20-3b25
cvs
parents: 187
diff changeset
447 or the default input method (see `default-input-method').
acd284d43ca1 Import from CVS: tag r20-3b25
cvs
parents: 187
diff changeset
448
acd284d43ca1 Import from CVS: tag r20-3b25
cvs
parents: 187
diff changeset
449 When there's no input method to turn on, turn on what read from minibuffer."
155
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
450 (interactive "P")
197
acd284d43ca1 Import from CVS: tag r20-3b25
cvs
parents: 187
diff changeset
451 (let* ((default (or (car input-method-history) default-input-method)))
acd284d43ca1 Import from CVS: tag r20-3b25
cvs
parents: 187
diff changeset
452 (if (and current-input-method (not arg))
acd284d43ca1 Import from CVS: tag r20-3b25
cvs
parents: 187
diff changeset
453 (inactivate-input-method)
acd284d43ca1 Import from CVS: tag r20-3b25
cvs
parents: 187
diff changeset
454 (activate-input-method
acd284d43ca1 Import from CVS: tag r20-3b25
cvs
parents: 187
diff changeset
455 (if (or arg (not default))
acd284d43ca1 Import from CVS: tag r20-3b25
cvs
parents: 187
diff changeset
456 (read-input-method-name
acd284d43ca1 Import from CVS: tag r20-3b25
cvs
parents: 187
diff changeset
457 (if default "Input method (default %s): " "Input method: " )
acd284d43ca1 Import from CVS: tag r20-3b25
cvs
parents: 187
diff changeset
458 default t)
acd284d43ca1 Import from CVS: tag r20-3b25
cvs
parents: 187
diff changeset
459 default))
acd284d43ca1 Import from CVS: tag r20-3b25
cvs
parents: 187
diff changeset
460 (or default-input-method
acd284d43ca1 Import from CVS: tag r20-3b25
cvs
parents: 187
diff changeset
461 (setq default-input-method current-input-method)))))
155
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
462
197
acd284d43ca1 Import from CVS: tag r20-3b25
cvs
parents: 187
diff changeset
463 (defun describe-input-method (input-method)
acd284d43ca1 Import from CVS: tag r20-3b25
cvs
parents: 187
diff changeset
464 "Describe input method INPUT-METHOD."
acd284d43ca1 Import from CVS: tag r20-3b25
cvs
parents: 187
diff changeset
465 (interactive
acd284d43ca1 Import from CVS: tag r20-3b25
cvs
parents: 187
diff changeset
466 (list (read-input-method-name
acd284d43ca1 Import from CVS: tag r20-3b25
cvs
parents: 187
diff changeset
467 "Describe input method (default, current choice): ")))
acd284d43ca1 Import from CVS: tag r20-3b25
cvs
parents: 187
diff changeset
468 (if (and input-method (symbolp input-method))
acd284d43ca1 Import from CVS: tag r20-3b25
cvs
parents: 187
diff changeset
469 (setq input-method (symbol-name input-method)))
acd284d43ca1 Import from CVS: tag r20-3b25
cvs
parents: 187
diff changeset
470 (if (null input-method)
acd284d43ca1 Import from CVS: tag r20-3b25
cvs
parents: 187
diff changeset
471 (describe-current-input-method)
acd284d43ca1 Import from CVS: tag r20-3b25
cvs
parents: 187
diff changeset
472 (with-output-to-temp-buffer "*Help*"
acd284d43ca1 Import from CVS: tag r20-3b25
cvs
parents: 187
diff changeset
473 (let ((elt (assoc input-method input-method-alist)))
acd284d43ca1 Import from CVS: tag r20-3b25
cvs
parents: 187
diff changeset
474 (princ (format "Input method: %s (`%s' in mode line) for %s\n %s\n"
acd284d43ca1 Import from CVS: tag r20-3b25
cvs
parents: 187
diff changeset
475 input-method (nth 3 elt) (nth 1 elt) (nth 4 elt)))))))
acd284d43ca1 Import from CVS: tag r20-3b25
cvs
parents: 187
diff changeset
476
acd284d43ca1 Import from CVS: tag r20-3b25
cvs
parents: 187
diff changeset
477 (defun describe-current-input-method ()
acd284d43ca1 Import from CVS: tag r20-3b25
cvs
parents: 187
diff changeset
478 "Describe the input method currently in use."
155
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
479 (if current-input-method
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
480 (if (and (symbolp describe-current-input-method-function)
165
5a88923fcbfe Import from CVS: tag r20-3b9
cvs
parents: 155
diff changeset
481 (fboundp describe-current-input-method-function))
155
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
482 (funcall describe-current-input-method-function)
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
483 (message "No way to describe the current input method `%s'"
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
484 (cdr current-input-method))
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
485 (ding))
197
acd284d43ca1 Import from CVS: tag r20-3b25
cvs
parents: 187
diff changeset
486 (error "No input method is activated now")))
155
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
487
165
5a88923fcbfe Import from CVS: tag r20-3b9
cvs
parents: 155
diff changeset
488 (defun read-multilingual-string (prompt &optional initial-input
197
acd284d43ca1 Import from CVS: tag r20-3b25
cvs
parents: 187
diff changeset
489 input-method)
165
5a88923fcbfe Import from CVS: tag r20-3b9
cvs
parents: 155
diff changeset
490 "Read a multilingual string from minibuffer, prompting with string PROMPT.
5a88923fcbfe Import from CVS: tag r20-3b9
cvs
parents: 155
diff changeset
491 The input method selected last time is activated in minibuffer.
197
acd284d43ca1 Import from CVS: tag r20-3b25
cvs
parents: 187
diff changeset
492 If optional second arg INITIAL-INPUT is non-nil, insert it in the minibuffer
acd284d43ca1 Import from CVS: tag r20-3b25
cvs
parents: 187
diff changeset
493 initially.
acd284d43ca1 Import from CVS: tag r20-3b25
cvs
parents: 187
diff changeset
494 Optional 3rd argument INPUT-METHOD specifies the input method
acd284d43ca1 Import from CVS: tag r20-3b25
cvs
parents: 187
diff changeset
495 to be activated instead of the one selected last time. It is a symbol
acd284d43ca1 Import from CVS: tag r20-3b25
cvs
parents: 187
diff changeset
496 or a string."
acd284d43ca1 Import from CVS: tag r20-3b25
cvs
parents: 187
diff changeset
497 (setq input-method
acd284d43ca1 Import from CVS: tag r20-3b25
cvs
parents: 187
diff changeset
498 (or input-method
acd284d43ca1 Import from CVS: tag r20-3b25
cvs
parents: 187
diff changeset
499 default-input-method
acd284d43ca1 Import from CVS: tag r20-3b25
cvs
parents: 187
diff changeset
500 (read-input-method-name "Input method: " nil t)))
acd284d43ca1 Import from CVS: tag r20-3b25
cvs
parents: 187
diff changeset
501 (if (and input-method (symbolp input-method))
acd284d43ca1 Import from CVS: tag r20-3b25
cvs
parents: 187
diff changeset
502 (setq input-method (symbol-name input-method)))
acd284d43ca1 Import from CVS: tag r20-3b25
cvs
parents: 187
diff changeset
503 (let ((current-input-method input-method))
207
e45d5e7c476e Import from CVS: tag r20-4b2
cvs
parents: 203
diff changeset
504 ;; FSFmacs
e45d5e7c476e Import from CVS: tag r20-4b2
cvs
parents: 203
diff changeset
505 ;; (read-string prompt initial-input nil nil t)))
e45d5e7c476e Import from CVS: tag r20-4b2
cvs
parents: 203
diff changeset
506 (read-string prompt initial-input nil)))
155
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
507
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
508 ;; Variables to control behavior of input methods. All input methods
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
509 ;; should react to these variables.
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
510
197
acd284d43ca1 Import from CVS: tag r20-3b25
cvs
parents: 187
diff changeset
511 (defcustom input-method-verbose-flag t
acd284d43ca1 Import from CVS: tag r20-3b25
cvs
parents: 187
diff changeset
512 "*If this flag is non-nil, input methods give extra guidance.
acd284d43ca1 Import from CVS: tag r20-3b25
cvs
parents: 187
diff changeset
513
acd284d43ca1 Import from CVS: tag r20-3b25
cvs
parents: 187
diff changeset
514 The extra guidance is done by showing list of available keys in echo
acd284d43ca1 Import from CVS: tag r20-3b25
cvs
parents: 187
diff changeset
515 area.
155
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
516
197
acd284d43ca1 Import from CVS: tag r20-3b25
cvs
parents: 187
diff changeset
517 For complex input methods such as `chinese-py' and `japanese',
acd284d43ca1 Import from CVS: tag r20-3b25
cvs
parents: 187
diff changeset
518 when you use the input method in the minibuffer, the guidance is
acd284d43ca1 Import from CVS: tag r20-3b25
cvs
parents: 187
diff changeset
519 shown at the bottom short window (split from the existing window).
acd284d43ca1 Import from CVS: tag r20-3b25
cvs
parents: 187
diff changeset
520 For simple input methods, guidance is not shown
acd284d43ca1 Import from CVS: tag r20-3b25
cvs
parents: 187
diff changeset
521 when you are in the minibuffer."
acd284d43ca1 Import from CVS: tag r20-3b25
cvs
parents: 187
diff changeset
522 :type 'boolean
acd284d43ca1 Import from CVS: tag r20-3b25
cvs
parents: 187
diff changeset
523 :group 'mule)
acd284d43ca1 Import from CVS: tag r20-3b25
cvs
parents: 187
diff changeset
524
acd284d43ca1 Import from CVS: tag r20-3b25
cvs
parents: 187
diff changeset
525 (defcustom input-method-highlight-flag t
acd284d43ca1 Import from CVS: tag r20-3b25
cvs
parents: 187
diff changeset
526 "*If this flag is non-nil, input methods highlight partially-entered text.
acd284d43ca1 Import from CVS: tag r20-3b25
cvs
parents: 187
diff changeset
527 For instance, while you are in the middle of a Quail input method sequence,
acd284d43ca1 Import from CVS: tag r20-3b25
cvs
parents: 187
diff changeset
528 the text inserted so far is temporarily underlined.
acd284d43ca1 Import from CVS: tag r20-3b25
cvs
parents: 187
diff changeset
529 The underlining goes away when you finish or abort the input method sequence."
acd284d43ca1 Import from CVS: tag r20-3b25
cvs
parents: 187
diff changeset
530 :type 'boolean
acd284d43ca1 Import from CVS: tag r20-3b25
cvs
parents: 187
diff changeset
531 :group 'mule)
155
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
532
165
5a88923fcbfe Import from CVS: tag r20-3b9
cvs
parents: 155
diff changeset
533 (defvar input-method-activate-hook nil
197
acd284d43ca1 Import from CVS: tag r20-3b25
cvs
parents: 187
diff changeset
534 "Normal hook run just after an input method is activated.
acd284d43ca1 Import from CVS: tag r20-3b25
cvs
parents: 187
diff changeset
535
acd284d43ca1 Import from CVS: tag r20-3b25
cvs
parents: 187
diff changeset
536 The variable `current-input-method' keeps the input method name
acd284d43ca1 Import from CVS: tag r20-3b25
cvs
parents: 187
diff changeset
537 just activated.")
155
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
538
165
5a88923fcbfe Import from CVS: tag r20-3b9
cvs
parents: 155
diff changeset
539 (defvar input-method-inactivate-hook nil
197
acd284d43ca1 Import from CVS: tag r20-3b25
cvs
parents: 187
diff changeset
540 "Normal hook run just after an input method is inactivated.
acd284d43ca1 Import from CVS: tag r20-3b25
cvs
parents: 187
diff changeset
541
acd284d43ca1 Import from CVS: tag r20-3b25
cvs
parents: 187
diff changeset
542 The variable `current-input-method' still keeps the input method name
acd284d43ca1 Import from CVS: tag r20-3b25
cvs
parents: 187
diff changeset
543 just inacitvated.")
155
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
544
165
5a88923fcbfe Import from CVS: tag r20-3b9
cvs
parents: 155
diff changeset
545 (defvar input-method-after-insert-chunk-hook nil
5a88923fcbfe Import from CVS: tag r20-3b9
cvs
parents: 155
diff changeset
546 "Normal hook run just after an input method insert some chunk of text.")
155
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
547
197
acd284d43ca1 Import from CVS: tag r20-3b25
cvs
parents: 187
diff changeset
548 (defvar input-method-exit-on-invalid-key nil
acd284d43ca1 Import from CVS: tag r20-3b25
cvs
parents: 187
diff changeset
549 "This flag controls the behaviour of an input method on invalid key input.
acd284d43ca1 Import from CVS: tag r20-3b25
cvs
parents: 187
diff changeset
550 Usually, when a user types a key which doesn't start any character
acd284d43ca1 Import from CVS: tag r20-3b25
cvs
parents: 187
diff changeset
551 handled by the input method, the key is handled by turning off the
acd284d43ca1 Import from CVS: tag r20-3b25
cvs
parents: 187
diff changeset
552 input method temporalily. After the key is handled, the input method is
acd284d43ca1 Import from CVS: tag r20-3b25
cvs
parents: 187
diff changeset
553 back on.
acd284d43ca1 Import from CVS: tag r20-3b25
cvs
parents: 187
diff changeset
554 But, if this flag is non-nil, the input method is never back on.")
acd284d43ca1 Import from CVS: tag r20-3b25
cvs
parents: 187
diff changeset
555
155
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
556
207
e45d5e7c476e Import from CVS: tag r20-4b2
cvs
parents: 203
diff changeset
557 (defun setup-specified-language-environment ()
e45d5e7c476e Import from CVS: tag r20-4b2
cvs
parents: 203
diff changeset
558 "Set up multi-lingual environment convenient for the specified language."
e45d5e7c476e Import from CVS: tag r20-4b2
cvs
parents: 203
diff changeset
559 (interactive)
e45d5e7c476e Import from CVS: tag r20-4b2
cvs
parents: 203
diff changeset
560 (let (language-name)
e45d5e7c476e Import from CVS: tag r20-4b2
cvs
parents: 203
diff changeset
561 (if (and (symbolp last-command-event)
e45d5e7c476e Import from CVS: tag r20-4b2
cvs
parents: 203
diff changeset
562 (or (not (eq last-command-event 'Default))
e45d5e7c476e Import from CVS: tag r20-4b2
cvs
parents: 203
diff changeset
563 (setq last-command-event 'English))
e45d5e7c476e Import from CVS: tag r20-4b2
cvs
parents: 203
diff changeset
564 (setq language-name (symbol-name last-command-event)))
e45d5e7c476e Import from CVS: tag r20-4b2
cvs
parents: 203
diff changeset
565 (set-language-environment language-name)
e45d5e7c476e Import from CVS: tag r20-4b2
cvs
parents: 203
diff changeset
566 (error "Bogus calling sequence"))))
e45d5e7c476e Import from CVS: tag r20-4b2
cvs
parents: 203
diff changeset
567
e45d5e7c476e Import from CVS: tag r20-4b2
cvs
parents: 203
diff changeset
568 (defvar current-language-environment "English"
e45d5e7c476e Import from CVS: tag r20-4b2
cvs
parents: 203
diff changeset
569 "The last language environment specified with `set-language-environment'.")
e45d5e7c476e Import from CVS: tag r20-4b2
cvs
parents: 203
diff changeset
570
e45d5e7c476e Import from CVS: tag r20-4b2
cvs
parents: 203
diff changeset
571 (defun set-language-environment (language-name)
e45d5e7c476e Import from CVS: tag r20-4b2
cvs
parents: 203
diff changeset
572 "Set up multi-lingual environment for using LANGUAGE-NAME.
e45d5e7c476e Import from CVS: tag r20-4b2
cvs
parents: 203
diff changeset
573 This sets the coding system priority and the default input method
e45d5e7c476e Import from CVS: tag r20-4b2
cvs
parents: 203
diff changeset
574 and sometimes other things."
e45d5e7c476e Import from CVS: tag r20-4b2
cvs
parents: 203
diff changeset
575 (interactive (list (read-language-name 'setup-function
e45d5e7c476e Import from CVS: tag r20-4b2
cvs
parents: 203
diff changeset
576 "Set language environment: ")))
e45d5e7c476e Import from CVS: tag r20-4b2
cvs
parents: 203
diff changeset
577 (if language-name
e45d5e7c476e Import from CVS: tag r20-4b2
cvs
parents: 203
diff changeset
578 (if (symbolp language-name)
e45d5e7c476e Import from CVS: tag r20-4b2
cvs
parents: 203
diff changeset
579 (setq language-name (symbol-name language-name)))
e45d5e7c476e Import from CVS: tag r20-4b2
cvs
parents: 203
diff changeset
580 (setq language-name "English"))
e45d5e7c476e Import from CVS: tag r20-4b2
cvs
parents: 203
diff changeset
581 (if (null (get-language-info language-name 'setup-function))
e45d5e7c476e Import from CVS: tag r20-4b2
cvs
parents: 203
diff changeset
582 (error "Language environment not defined: %S" language-name))
e45d5e7c476e Import from CVS: tag r20-4b2
cvs
parents: 203
diff changeset
583 (funcall (get-language-info language-name 'setup-function))
e45d5e7c476e Import from CVS: tag r20-4b2
cvs
parents: 203
diff changeset
584 (setq current-language-environment language-name)
e45d5e7c476e Import from CVS: tag r20-4b2
cvs
parents: 203
diff changeset
585 (force-mode-line-update t))
155
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
586
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
587 ;; Print all arguments with `princ', then print "\n".
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
588 (defsubst princ-list (&rest args)
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
589 (while args (princ (car args)) (setq args (cdr args)))
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
590 (princ "\n"))
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
591
207
e45d5e7c476e Import from CVS: tag r20-4b2
cvs
parents: 203
diff changeset
592 ;; Print a language specific information such as input methods,
e45d5e7c476e Import from CVS: tag r20-4b2
cvs
parents: 203
diff changeset
593 ;; charsets, and coding systems. This function is intended to be
e45d5e7c476e Import from CVS: tag r20-4b2
cvs
parents: 203
diff changeset
594 ;; called from the menu:
e45d5e7c476e Import from CVS: tag r20-4b2
cvs
parents: 203
diff changeset
595 ;; [menu-bar mule describe-language-environment LANGUAGE]
e45d5e7c476e Import from CVS: tag r20-4b2
cvs
parents: 203
diff changeset
596 ;; and should not run it by `M-x describe-current-input-method-function'.
e45d5e7c476e Import from CVS: tag r20-4b2
cvs
parents: 203
diff changeset
597 (defun describe-specified-language-support ()
e45d5e7c476e Import from CVS: tag r20-4b2
cvs
parents: 203
diff changeset
598 "Describe how Emacs supports the specified language environment."
e45d5e7c476e Import from CVS: tag r20-4b2
cvs
parents: 203
diff changeset
599 (interactive)
e45d5e7c476e Import from CVS: tag r20-4b2
cvs
parents: 203
diff changeset
600 (let (language-name)
e45d5e7c476e Import from CVS: tag r20-4b2
cvs
parents: 203
diff changeset
601 (if (not (and (symbolp last-command-event)
e45d5e7c476e Import from CVS: tag r20-4b2
cvs
parents: 203
diff changeset
602 (setq language-name (symbol-name last-command-event))))
e45d5e7c476e Import from CVS: tag r20-4b2
cvs
parents: 203
diff changeset
603 (error "Bogus calling sequence"))
e45d5e7c476e Import from CVS: tag r20-4b2
cvs
parents: 203
diff changeset
604 (describe-language-environment language-name)))
165
5a88923fcbfe Import from CVS: tag r20-3b9
cvs
parents: 155
diff changeset
605
207
e45d5e7c476e Import from CVS: tag r20-4b2
cvs
parents: 203
diff changeset
606 (defun describe-language-environment (language-name)
e45d5e7c476e Import from CVS: tag r20-4b2
cvs
parents: 203
diff changeset
607 "Describe how Emacs supports language environment LANGUAGE-NAME."
e45d5e7c476e Import from CVS: tag r20-4b2
cvs
parents: 203
diff changeset
608 (interactive
e45d5e7c476e Import from CVS: tag r20-4b2
cvs
parents: 203
diff changeset
609 (list (read-language-name
e45d5e7c476e Import from CVS: tag r20-4b2
cvs
parents: 203
diff changeset
610 'documentation
e45d5e7c476e Import from CVS: tag r20-4b2
cvs
parents: 203
diff changeset
611 "Describe language environment (default, current choise): ")))
e45d5e7c476e Import from CVS: tag r20-4b2
cvs
parents: 203
diff changeset
612 (if (null language-name)
e45d5e7c476e Import from CVS: tag r20-4b2
cvs
parents: 203
diff changeset
613 (setq language-name current-language-environment))
e45d5e7c476e Import from CVS: tag r20-4b2
cvs
parents: 203
diff changeset
614 (if (or (null language-name)
e45d5e7c476e Import from CVS: tag r20-4b2
cvs
parents: 203
diff changeset
615 (null (get-language-info language-name 'documentation)))
e45d5e7c476e Import from CVS: tag r20-4b2
cvs
parents: 203
diff changeset
616 (error "No documentation for the specified language"))
e45d5e7c476e Import from CVS: tag r20-4b2
cvs
parents: 203
diff changeset
617 (if (symbolp language-name)
e45d5e7c476e Import from CVS: tag r20-4b2
cvs
parents: 203
diff changeset
618 (setq language-name (symbol-name language-name)))
e45d5e7c476e Import from CVS: tag r20-4b2
cvs
parents: 203
diff changeset
619 (let ((doc (get-language-info language-name 'documentation)))
e45d5e7c476e Import from CVS: tag r20-4b2
cvs
parents: 203
diff changeset
620 (with-output-to-temp-buffer "*Help*"
165
5a88923fcbfe Import from CVS: tag r20-3b9
cvs
parents: 155
diff changeset
621 (if (stringp doc)
207
e45d5e7c476e Import from CVS: tag r20-4b2
cvs
parents: 203
diff changeset
622 (progn
e45d5e7c476e Import from CVS: tag r20-4b2
cvs
parents: 203
diff changeset
623 (princ-list doc)
e45d5e7c476e Import from CVS: tag r20-4b2
cvs
parents: 203
diff changeset
624 (terpri)))
e45d5e7c476e Import from CVS: tag r20-4b2
cvs
parents: 203
diff changeset
625 (let ((str (get-language-info language-name 'sample-text)))
e45d5e7c476e Import from CVS: tag r20-4b2
cvs
parents: 203
diff changeset
626 (if (stringp str)
e45d5e7c476e Import from CVS: tag r20-4b2
cvs
parents: 203
diff changeset
627 (progn
e45d5e7c476e Import from CVS: tag r20-4b2
cvs
parents: 203
diff changeset
628 (princ "Sample text:\n")
e45d5e7c476e Import from CVS: tag r20-4b2
cvs
parents: 203
diff changeset
629 (princ-list " " str)
e45d5e7c476e Import from CVS: tag r20-4b2
cvs
parents: 203
diff changeset
630 (terpri))))
e45d5e7c476e Import from CVS: tag r20-4b2
cvs
parents: 203
diff changeset
631 (princ "Input methods:\n")
e45d5e7c476e Import from CVS: tag r20-4b2
cvs
parents: 203
diff changeset
632 (let ((l input-method-alist))
e45d5e7c476e Import from CVS: tag r20-4b2
cvs
parents: 203
diff changeset
633 (while l
e45d5e7c476e Import from CVS: tag r20-4b2
cvs
parents: 203
diff changeset
634 (if (string= language-name (nth 1 (car l)))
e45d5e7c476e Import from CVS: tag r20-4b2
cvs
parents: 203
diff changeset
635 (princ-list " " (car (car l))
e45d5e7c476e Import from CVS: tag r20-4b2
cvs
parents: 203
diff changeset
636 (format " (`%s' in mode line)" (nth 3 (car l)))))
e45d5e7c476e Import from CVS: tag r20-4b2
cvs
parents: 203
diff changeset
637 (setq l (cdr l))))
e45d5e7c476e Import from CVS: tag r20-4b2
cvs
parents: 203
diff changeset
638 (terpri)
e45d5e7c476e Import from CVS: tag r20-4b2
cvs
parents: 203
diff changeset
639 (princ "Character sets:\n")
e45d5e7c476e Import from CVS: tag r20-4b2
cvs
parents: 203
diff changeset
640 (let ((l (get-language-info language-name 'charset)))
e45d5e7c476e Import from CVS: tag r20-4b2
cvs
parents: 203
diff changeset
641 (if (null l)
e45d5e7c476e Import from CVS: tag r20-4b2
cvs
parents: 203
diff changeset
642 (princ-list " nothing specific to " language-name)
e45d5e7c476e Import from CVS: tag r20-4b2
cvs
parents: 203
diff changeset
643 (while l
e45d5e7c476e Import from CVS: tag r20-4b2
cvs
parents: 203
diff changeset
644 (princ-list " " (car l) ": "
e45d5e7c476e Import from CVS: tag r20-4b2
cvs
parents: 203
diff changeset
645 (charset-description (car l)))
e45d5e7c476e Import from CVS: tag r20-4b2
cvs
parents: 203
diff changeset
646 (setq l (cdr l)))))
e45d5e7c476e Import from CVS: tag r20-4b2
cvs
parents: 203
diff changeset
647 (terpri)
e45d5e7c476e Import from CVS: tag r20-4b2
cvs
parents: 203
diff changeset
648 (princ "Coding systems:\n")
e45d5e7c476e Import from CVS: tag r20-4b2
cvs
parents: 203
diff changeset
649 (let ((l (get-language-info language-name 'coding-system)))
e45d5e7c476e Import from CVS: tag r20-4b2
cvs
parents: 203
diff changeset
650 (if (null l)
e45d5e7c476e Import from CVS: tag r20-4b2
cvs
parents: 203
diff changeset
651 (princ-list " nothing specific to " language-name)
e45d5e7c476e Import from CVS: tag r20-4b2
cvs
parents: 203
diff changeset
652 (while l
e45d5e7c476e Import from CVS: tag r20-4b2
cvs
parents: 203
diff changeset
653 (princ ; (format " %s (`%c' in mode line):\n\t%s\n"
e45d5e7c476e Import from CVS: tag r20-4b2
cvs
parents: 203
diff changeset
654 ;; In XEmacs, `coding-system-mnemonic' returns string.
e45d5e7c476e Import from CVS: tag r20-4b2
cvs
parents: 203
diff changeset
655 (format " %s (`%s' in mode line):\n\t%s\n"
e45d5e7c476e Import from CVS: tag r20-4b2
cvs
parents: 203
diff changeset
656 (car l)
e45d5e7c476e Import from CVS: tag r20-4b2
cvs
parents: 203
diff changeset
657 (coding-system-mnemonic (car l))
e45d5e7c476e Import from CVS: tag r20-4b2
cvs
parents: 203
diff changeset
658 (coding-system-doc-string (car l))))
e45d5e7c476e Import from CVS: tag r20-4b2
cvs
parents: 203
diff changeset
659 (setq l (cdr l))))))))
155
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
660
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
661 ;;; Charset property
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
662
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
663 ;; (defsubst get-charset-property (charset propname)
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
664 ;; "Return the value of CHARSET's PROPNAME property.
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
665 ;; This is the last value stored with
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
666 ;; `(put-charset-property CHARSET PROPNAME VALUE)'."
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
667 ;; (plist-get (charset-plist charset) propname))
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
668
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
669 ;; (defsubst put-charset-property (charset propname value)
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
670 ;; "Store CHARSETS's PROPNAME property with value VALUE.
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
671 ;; It can be retrieved with `(get-charset-property CHARSET PROPNAME)'."
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
672 ;; (set-charset-plist charset
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
673 ;; (plist-put (charset-plist charset) propname value)))
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
674
207
e45d5e7c476e Import from CVS: tag r20-4b2
cvs
parents: 203
diff changeset
675 (defvar char-code-property-table
e45d5e7c476e Import from CVS: tag r20-4b2
cvs
parents: 203
diff changeset
676 (make-char-table 'generic)
e45d5e7c476e Import from CVS: tag r20-4b2
cvs
parents: 203
diff changeset
677 "Char-table containing a property list of each character code.
155
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
678 ;;
207
e45d5e7c476e Import from CVS: tag r20-4b2
cvs
parents: 203
diff changeset
679 See also the documentation of `get-char-code-property' and
e45d5e7c476e Import from CVS: tag r20-4b2
cvs
parents: 203
diff changeset
680 `put-char-code-property'")
e45d5e7c476e Import from CVS: tag r20-4b2
cvs
parents: 203
diff changeset
681 ;; (let ((plist (aref char-code-property-table char)))
e45d5e7c476e Import from CVS: tag r20-4b2
cvs
parents: 203
diff changeset
682 (defun get-char-code-property (char propname)
e45d5e7c476e Import from CVS: tag r20-4b2
cvs
parents: 203
diff changeset
683 "Return the value of CHAR's PROPNAME property in `char-code-property-table'."
e45d5e7c476e Import from CVS: tag r20-4b2
cvs
parents: 203
diff changeset
684 (let ((plist (get-char-table char char-code-property-table)))
e45d5e7c476e Import from CVS: tag r20-4b2
cvs
parents: 203
diff changeset
685 (if (listp plist)
e45d5e7c476e Import from CVS: tag r20-4b2
cvs
parents: 203
diff changeset
686 (car (cdr (memq propname plist))))))
155
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
687
207
e45d5e7c476e Import from CVS: tag r20-4b2
cvs
parents: 203
diff changeset
688 (defun put-char-code-property (char propname value)
e45d5e7c476e Import from CVS: tag r20-4b2
cvs
parents: 203
diff changeset
689 "Store CHAR's PROPNAME property with VALUE in `char-code-property-table'.
e45d5e7c476e Import from CVS: tag r20-4b2
cvs
parents: 203
diff changeset
690 It can be retrieved with `(get-char-code-property CHAR PROPNAME)'."
e45d5e7c476e Import from CVS: tag r20-4b2
cvs
parents: 203
diff changeset
691 (let ((plist (get-char-table char char-code-property-table)))
e45d5e7c476e Import from CVS: tag r20-4b2
cvs
parents: 203
diff changeset
692 (if plist
e45d5e7c476e Import from CVS: tag r20-4b2
cvs
parents: 203
diff changeset
693 (let ((slot (memq propname plist)))
e45d5e7c476e Import from CVS: tag r20-4b2
cvs
parents: 203
diff changeset
694 (if slot
e45d5e7c476e Import from CVS: tag r20-4b2
cvs
parents: 203
diff changeset
695 (setcar (cdr slot) value)
e45d5e7c476e Import from CVS: tag r20-4b2
cvs
parents: 203
diff changeset
696 (nconc plist (list propname value))))
e45d5e7c476e Import from CVS: tag r20-4b2
cvs
parents: 203
diff changeset
697 (put-char-table char (list propname value) char-code-property-table)
e45d5e7c476e Import from CVS: tag r20-4b2
cvs
parents: 203
diff changeset
698 )))
155
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
699 ;; (setcar (cdr slot) value)
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
700 ;; (nconc plist (list propname value))))
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
701 ;; (aset char-code-property-table char (list propname value)))))
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
702
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
703 ;;; mule-cmds.el ends here