annotate lisp/mule/mule-cmds.el @ 414:da8ed4261e83 r21-2-15

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