annotate lisp/mule/mule-cmds.el @ 155:43dd3413c7c7 r20-3b4

Import from CVS: tag r20-3b4
author cvs
date Mon, 13 Aug 2007 09:39:39 +0200
parents
children 5a88923fcbfe
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
155
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
1 ;;; mule-cmds.el --- Commands for mulitilingual environment
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 Free Software Foundation, Inc.
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
4 ;; Copyright (C) 1995 Electrotechnical Laboratory, JAPAN.
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 (fset 'mule-prefix mule-keymap)
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
33
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
34 ;; Keep "C-x C-k ..." for mule specific commands.
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
35 (define-key ctl-x-map "\C-k" 'mule-prefix)
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
36
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
37 (defvar mule-describe-language-support-map
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
38 (make-sparse-keymap "Describe Language Support"))
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
39 (fset 'mule-describe-language-support-prefix
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
40 mule-describe-language-support-map)
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
41
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
42 (defvar mule-set-language-environment-map
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
43 (make-sparse-keymap "Set Language Environment"))
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
44 (fset 'mule-set-language-environment-prefix
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
45 mule-set-language-environment-map)
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
46
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
47 (define-key mule-keymap "f" 'set-buffer-file-coding-system)
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
48 (define-key mule-keymap "F" 'set-default-buffer-file-coding-system) ; XEmacs
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
49 (define-key mule-keymap "t" 'set-terminal-coding-system)
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
50 (define-key mule-keymap "k" 'set-keyboard-coding-system)
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
51 (define-key mule-keymap "p" 'set-current-process-coding-system)
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
52 (define-key mule-keymap "P" 'set-default-process-coding-system) ; XEmacs
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
53 (define-key mule-keymap "i" 'select-input-method)
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
54 (define-key mule-keymap "c" 'list-coding-system-briefly) ; XEmacs
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
55 (define-key mule-keymap "C" 'list-coding-system) ; XEmacs
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
56 (define-key mule-keymap "r" 'toggle-display-direction) ; XEmacs
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
57
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
58 (define-key help-map "\C-L" 'describe-language-support)
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
59 (define-key help-map "\C-\\" 'describe-input-method)
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
60 (define-key help-map "C" 'describe-current-coding-system)
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
61 (define-key help-map "h" 'view-hello-file)
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
62
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
63 ;; Menu for XEmacs were moved to x11/x-menubar.el.
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
64
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
65
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
66 ;; This should be a single character key binding because users use it
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
67 ;; very frequently while editing multilingual text. Now we can use
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
68 ;; only two such keys: "\C-\\" and "\C-^", but the latter is not
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
69 ;; convenient because it requires shifting on most keyboards. An
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
70 ;; alternative is "\C-\]" which is now bound to `abort-recursive-edit'
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
71 ;; but it won't be used that frequently.
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
72 (define-key global-map "\C-\\" 'toggle-input-method)
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
73
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
74 (defun view-hello-file ()
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
75 "Display the HELLO file which list up many languages and characters."
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
76 (interactive)
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
77 (find-file-read-only (expand-file-name "HELLO" data-directory)))
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
78
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
79
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
80 ;;; Language support staffs.
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
81
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
82 (defvar primary-language "English"
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
83 "Name of a user's primary language.
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
84 Emacs provide various language supports based on this variable.")
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
85
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
86 (defvar language-info-alist nil
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
87 "Alist of language names vs the corresponding information of various kind.
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
88 Each element looks like:
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
89 (LANGUAGE-NAME . ((KEY . INFO) ...))
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
90 where LANGUAGE-NAME is a string,
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
91 KEY is a symbol denoting the kind of information,
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
92 INFO is any Lisp object which contains the actual information related
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
93 to KEY.")
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
94
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
95 (defun get-language-info (language-name key)
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
96 "Return the information for LANGUAGE-NAME of the kind KEY.
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
97 LANGUAGE-NAME is a string.
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
98 KEY is a symbol denoting the kind of required information."
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
99 (let ((lang-slot (assoc language-name language-info-alist)))
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
100 (if lang-slot
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
101 (cdr (assq key (cdr lang-slot))))))
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
102
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
103 ;; Return a lambda form which calls `describe-language-support' with
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
104 ;; argument LANG.
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
105 (defun build-describe-language-support-function (lang)
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
106 `(lambda ()
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
107 (interactive)
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
108 (describe-language-support ,lang)))
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
109
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
110 ;; Return a lambda form which calls `set-language-environment' with
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
111 ;; argument LANG.
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
112 (defun build-set-language-environment-function (lang)
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
113 `(lambda ()
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
114 (interactive)
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
115 (set-language-environment ,lang)))
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
116
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
117 (defun set-language-info (language-name key info)
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
118 "Set for LANGUAGE-NAME the information INFO under KEY.
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
119 LANGUAGE-NAME is a string
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
120 KEY is a symbol denoting the kind of information.
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
121 INFO is any Lisp object which contains the actual information.
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
122
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
123 Currently, the following KEYs are used by Emacs:
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
124 charset: list of symbols whose values are charsets specific to the language.
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
125 coding-system: list of coding systems specific to the langauge.
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
126 setup-function: see the documentation of `set-language-environment'.
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
127 tutorial: a tutorial file name written in the language.
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
128 sample-text: one line short text containing characters of the language.
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
129 documentation: a docstring describing how the language is supported,
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
130 or a fuction to call to describe it,
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
131 or t which means call `describe-language-support' to describe it.
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
132 input-method: alist of input method names for the language vs information
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
133 for activating them. Use `register-input-method' (which see)
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
134 to add a new input method to the alist.
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
135
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
136 Emacs will use more KEYs in the future. To avoid the conflition, users
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
137 should use prefix \"user-\" in the name of KEY."
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
138 (let (lang-slot key-slot)
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
139 (setq lang-slot (assoc language-name language-info-alist))
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
140 (if (null lang-slot) ; If no slot for the language, add it.
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
141 (setq lang-slot (list language-name)
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
142 language-info-alist (cons lang-slot language-info-alist)))
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
143 (setq key-slot (assq key lang-slot))
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
144 (if (null key-slot) ; If no slot for the key, add it.
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
145 (progn
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
146 (setq key-slot (list key))
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
147 (setcdr lang-slot (cons key-slot (cdr lang-slot)))))
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
148 (setcdr key-slot info)
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
149 ;; Setup menu.
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
150 (cond ((eq key 'documentation)
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
151 (define-key mule-describe-language-support-map
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
152 (vector (intern language-name))
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
153 (cons language-name
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
154 (build-describe-language-support-function language-name))))
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
155 ((eq key 'setup-function)
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
156 (define-key mule-set-language-environment-map
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
157 (vector (intern language-name))
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
158 (cons language-name
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
159 (build-set-language-environment-function language-name)))))
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
160 ))
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
161
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
162 (defun set-language-info-alist (language-name alist)
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
163 "Set for LANGUAGE-NAME the information in ALIST.
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
164 ALIST is an alist of KEY and INFO. See the documentation of
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
165 `set-langauge-info' for the meanings of KEY and INFO."
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
166 (while alist
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
167 (set-language-info language-name (car (car alist)) (cdr (car alist)))
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
168 (setq alist (cdr alist))))
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
169
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
170 (defun read-language-name (key prompt &optional initial-input)
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
171 "Read language name which has information for KEY, prompting with PROMPT."
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
172 (let* ((completion-ignore-case t)
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
173 (name (completing-read prompt
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
174 language-info-alist
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
175 (function (lambda (elm) (assq key elm)))
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
176 t
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
177 initial-input)))
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
178 (and (> (length name) 0)
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
179 (car (assoc-ignore-case (downcase name) language-info-alist)))))
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
180
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
181 ;;; Multilingual input methods.
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
182
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
183 (defvar current-input-method nil
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
184 "The current input method for multilingual text.
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
185 The value is a cons of language name and input method name.
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
186 If nil, it means no input method is activated now.")
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
187 (make-variable-buffer-local 'current-input-method)
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
188 (put 'current-input-method 'permanent-local t)
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
189
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
190 (defvar current-input-method-title nil
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
191 "Title string of the current input method shown in mode line.
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
192 Every input method should set this an appropriate value when activated.")
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
193 (make-variable-buffer-local 'current-input-method-title)
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
194 (put 'current-input-method-title 'permanent-local t)
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
195
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
196 (defvar default-input-method nil
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
197 "Default input method.
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
198 The default input method is the one activated automatically by the command
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
199 `toggle-input-method' (\\[toggle-input-method]).
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
200 The value is a cons of language name and input method name.")
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
201
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
202 (defvar default-input-method-title nil
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
203 "Title string of the default input method.")
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
204
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
205 (defvar previous-input-method nil
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
206 "Input method selected previously.
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
207 This is the one selected before the current input method is selected.
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
208 See also the documentation of `default-input-method'.")
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
209
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
210 (defvar inactivate-current-input-method-function nil
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
211 "Function to call for inactivating the current input method.
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
212 Every input method should set this to an appropriate value when activated.
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
213 This function is called with no argument.")
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
214 (make-variable-buffer-local 'inactivate-current-input-method-function)
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
215 (put 'inactivate-current-input-method-function 'permanent-local t)
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
216
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
217 (defvar describe-current-input-method-function nil
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
218 "Function to call for describing the current input method.
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
219 This function is called with no argument.")
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
220 (make-variable-buffer-local 'describe-current-input-method-function)
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
221 (put 'describe-current-input-method-function 'permanent-local t)
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
222
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
223 (defun register-input-method (language-name input-method)
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
224 "Register INPUT-METHOD as an input method of LANGUAGE-NAME.
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
225 LANGUAGE-NAME is a string.
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
226 INPUT-METHOD is a list of the form:
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
227 (METHOD-NAME ACTIVATE-FUNC ARG ...)
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
228 where METHOD-NAME is the name of this method,
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
229 ACTIVATE-FUNC is the function to call for activating this method.
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
230 Arguments for the function are METHOD-NAME and ARGs."
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
231 (let ((slot (get-language-info language-name 'input-method))
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
232 method-slot)
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
233 (if (null slot)
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
234 (set-language-info language-name 'input-method (list input-method))
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
235 (setq method-slot (assoc (car input-method) slot))
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
236 (if method-slot
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
237 (setcdr method-slot (cdr input-method))
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
238 (set-language-info language-name 'input-method
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
239 (cons input-method slot))))))
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 read-language-and-input-method-name ()
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
242 "Read a language names and the corresponding input method from a minibuffer.
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
243 Return a cons of those names."
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
244 (let ((language-name (read-language-name
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
245 'input-method
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
246 "Language: "
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
247 (if previous-input-method
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
248 (cons (car previous-input-method) 0)))))
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
249 (if (null language-name)
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
250 (error "No input method for the specified language"))
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
251 (let* ((completion-ignore-case t)
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
252 (key-slot (cdr (assq 'input-method
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
253 (assoc language-name language-info-alist))))
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
254 (method-name
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
255 (completing-read "Input method: " key-slot nil t
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
256 (if (and previous-input-method
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
257 (string= language-name
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
258 (car previous-input-method)))
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
259 (cons (cdr previous-input-method) 0)))))
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
260 (if (= (length method-name) 0)
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
261 (error "No input method specified"))
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
262 (list language-name
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
263 (car (assoc-ignore-case (downcase method-name) key-slot))))))
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
264
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
265 (defun set-default-input-method (language-name method-name)
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
266 "Set the default input method to METHOD-NAME for inputting LANGUAGE-NAME.
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
267 The default input method is the one activated automatically by the command
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
268 `toggle-input-method' (\\[toggle-input-method]).
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
269 This doesn't affect the currently activated input method."
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
270 (interactive (read-language-and-input-method-name))
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
271 (let* ((key-slot (get-language-info language-name 'input-method))
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
272 (method-slot (assoc method-name key-slot)))
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
273 (if (null method-slot)
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
274 (error "No input method `%s' for %s" method-name language-name))
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
275 (setq default-input-method (cons language-name method-name))))
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
276
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
277 (defun select-input-method (language-name method-name)
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
278 "Select and activate input method METHOD-NAME for inputting LANGUAGE-NAME.
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
279 The information for activating METHOD-NAME is stored
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
280 in `language-info-alist' under the key 'input-method.
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
281 The format of the information has the form:
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
282 ((METHOD-NAME ACTIVATE-FUNC ARG ...) ...)
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
283 where ACTIVATE-FUNC is a function to call for activating this method.
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
284 Arguments for the function are METHOD-NAME and ARGs."
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
285 (interactive (read-language-and-input-method-name))
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
286 (let* ((key-slot (get-language-info language-name 'input-method))
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
287 (method-slot (assoc method-name key-slot)))
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
288 (if (null method-slot)
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
289 (error "No input method `%s' for %s" method-name language-name))
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
290 (if current-input-method
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
291 (progn
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
292 (if (not (equal previous-input-method current-input-method))
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
293 (setq previous-input-method current-input-method))
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
294 (funcall inactivate-current-input-method-function)))
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
295 (setq method-slot (cdr method-slot))
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
296 (apply (car method-slot) method-name (cdr method-slot))
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
297 (setq default-input-method
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
298 (setq current-input-method (cons language-name method-name)))
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
299 (setq default-input-method-title current-input-method-title)
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
300 (setq current-input-method default-input-method)))
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
301
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
302 (defun toggle-input-method (&optional arg)
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
303 "Toggle whether a multilingual input method is activated in this buffer.
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
304 With arg, activate an input method specified interactively.
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
305 Without arg, the method being activated is the one selected most recently,
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
306 but if no input method has ever been selected, select one interactively."
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
307 (interactive "P")
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
308 (if arg
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
309 (call-interactively 'select-input-method)
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
310 (if (null current-input-method)
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
311 (if default-input-method
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
312 (select-input-method (car default-input-method)
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
313 (cdr default-input-method))
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
314 (call-interactively 'select-input-method))
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
315 (funcall inactivate-current-input-method-function)
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
316 (setq current-input-method nil))))
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
317
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
318 (defun describe-input-method ()
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
319 "Describe the current input method."
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
320 (interactive)
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
321 (if current-input-method
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
322 (if (and (symbolp describe-current-input-method-function)
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
323 (fboundp describe-current-input-method-function))
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
324 (funcall describe-current-input-method-function)
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
325 (message "No way to describe the current input method `%s'"
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
326 (cdr current-input-method))
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
327 (ding))
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
328 (message "No input method is activated now")
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
329 (ding)))
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
330
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
331 ;; (defun read-multilingual-string (prompt &optional initial-input
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
332 ;; language-name method-name)
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
333 ;; "Read a multilingual string from minibuffer, prompting with string PROMPT.
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
334 ;; The input method selected last time is activated in minibuffer.
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
335 ;; If non-nil, second arg INITIAL-INPUT is a string to insert before reading.
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
336 ;; Optional 3rd and 4th arguments LANGUAGE-NAME and METHOD-NAME specify
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
337 ;; the input method to be activated instead of the one selected last time."
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
338 ;; (let ((minibuffer-setup-hook '(toggle-input-method))
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
339 ;; (default-input-method default-input-method))
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
340 ;; (if (and language-name method-name)
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
341 ;; (set-default-input-method language-name method-name))
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
342 ;; (read-string prompt initial-input)))
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
343
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
344 ;; Variables to control behavior of input methods. All input methods
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
345 ;; should react to these variables.
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
346
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
347 (defvar input-method-tersely-flag nil
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
348 "*If this flag is non-nil, input method works rather tersely.
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
349
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
350 For instance, Quail input method does not show guidance buffer while
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
351 inputting at minibuffer if this flag is t.")
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
352
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
353 ;; (defvar input-method-activate-hook nil
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
354 ;; "Normal hook run just after an input method is activated.")
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
355
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
356 ;; (defvar input-method-inactivate-hook nil
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
357 ;; "Normal hook run just after an input method is inactivated.")
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
358
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
359 ;; (defvar input-method-after-insert-chunk-hook nil
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
360 ;; "Normal hook run just after an input method insert some chunk of text.")
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
361
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
362
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
363 ;;; Language specific setup functions.
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
364 ;; (defun set-language-environment (language-name)
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
365 ;; "Setup a user's environment for LANGUAGE-NAME.
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
366 ;;
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
367 ;; To setup, a fucntion returned by:
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
368 ;; (get-language-info LANGUAGE-NAME 'setup-function)
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
369 ;; is called."
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
370 ;; (interactive (list (read-language-name 'setup-function "Language: ")))
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
371 ;; (let (func)
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
372 ;; (if (or (null language-name)
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
373 ;; (null (setq func
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
374 ;; (get-language-info language-name 'setup-function))))
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
375 ;; (error "No way to setup environment for the specified language"))
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
376 ;; (funcall func)))
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
377
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
378 ;; Print all arguments with `princ', then print "\n".
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
379 (defsubst princ-list (&rest args)
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
380 (while args (princ (car args)) (setq args (cdr args)))
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
381 (princ "\n"))
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
382
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
383 (defun describe-language-support (language-name)
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
384 "Show documentation about how Emacs supports LANGUAGE-NAME."
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
385 (interactive (list (read-language-name 'documentation "Language: ")))
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
386 (let (doc)
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
387 (if (or (null language-name)
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
388 (null (setq doc
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
389 (get-language-info language-name 'documentation))))
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
390 (error "No documentation for the specified language"))
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
391 (with-output-to-temp-buffer "*Help*"
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
392 (if (not (eq doc t))
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
393 (cond ((stringp doc)
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
394 (princ doc))
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
395 ((and (symbolp doc) (fboundp doc))
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
396 (funcall doc))
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
397 (t
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
398 (error "Invalid documentation data for %s" language-name)))
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
399 (princ-list "List of items specific to "
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
400 language-name
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
401 " environment")
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
402 (princ "-----------------------------------------------------------\n")
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
403 (let ((str (get-language-info language-name 'sample-text)))
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
404 (if (stringp str)
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
405 (progn
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
406 (princ "<sample text>\n")
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
407 (princ-list " " str))))
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
408 (princ "<input methods>\n")
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
409 (let ((l (get-language-info language-name 'input-method)))
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
410 (while l
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
411 (princ-list " " (car (car l)))
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
412 (setq l (cdr l))))
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
413 (princ "<character sets>\n")
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
414 (let ((l (get-language-info language-name 'charset)))
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
415 (if (null l)
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
416 (princ-list " nothing specific to " language-name)
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
417 (while l
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
418 (princ-list " " (car l)
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
419 (format ":%3d:\n\t" (charset-id (car l)))
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
420 (charset-description (car l)))
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
421 (setq l (cdr l)))))
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
422 (princ "<coding systems>\n")
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
423 (let ((l (get-language-info language-name 'coding-system)))
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
424 (if (null l)
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
425 (princ-list " nothing specific to " language-name)
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
426 (while l
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
427 (princ-list " " (car l) ":\n\t"
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
428 (coding-system-docstring (car l)))
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
429 (setq l (cdr l)))))))))
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
430
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
431 ;;; Charset property
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
432
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
433 ;; (defsubst get-charset-property (charset propname)
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
434 ;; "Return the value of CHARSET's PROPNAME property.
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
435 ;; This is the last value stored with
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
436 ;; `(put-charset-property CHARSET PROPNAME VALUE)'."
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
437 ;; (plist-get (charset-plist charset) propname))
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
438
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
439 ;; (defsubst put-charset-property (charset propname value)
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
440 ;; "Store CHARSETS's PROPNAME property with value VALUE.
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
441 ;; It can be retrieved with `(get-charset-property CHARSET PROPNAME)'."
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
442 ;; (set-charset-plist charset
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
443 ;; (plist-put (charset-plist charset) propname value)))
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
444
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
445 ;;; Character code property
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
446 ;; (put 'char-code-property-table 'char-table-extra-slots 0)
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
447
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
448 ;; (defvar char-code-property-table
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
449 ;; (make-char-table 'char-code-property-table)
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
450 ;; "Char-table containing a property list of each character code.
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
451 ;;
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
452 ;; See also the documentation of `get-char-code-property' and
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
453 ;; `put-char-code-property'")
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
454
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
455 ;; (defun get-char-code-property (char propname)
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
456 ;; "Return the value of CHAR's PROPNAME property in `char-code-property-table'."
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
457 ;; (let ((plist (aref char-code-property-table char)))
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
458 ;; (if (listp plist)
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
459 ;; (car (cdr (memq propname plist))))))
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
460
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
461 ;; (defun put-char-code-property (char propname value)
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
462 ;; "Store CHAR's PROPNAME property with VALUE in `char-code-property-table'.
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
463 ;; It can be retrieved with `(get-char-code-property CHAR PROPNAME)'."
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
464 ;; (let ((plist (aref char-code-property-table char)))
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
465 ;; (if plist
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
466 ;; (let ((slot (memq propname plist)))
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
467 ;; (if slot
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
468 ;; (setcar (cdr slot) value)
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
469 ;; (nconc plist (list propname value))))
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
470 ;; (aset char-code-property-table char (list propname value)))))
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
471
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
472 (provide 'mule-cmds)
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
473
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents:
diff changeset
474 ;;; mule-cmds.el ends here