diff options
| author | Kenichi Handa | 1997-05-28 03:37:32 +0000 |
|---|---|---|
| committer | Kenichi Handa | 1997-05-28 03:37:32 +0000 |
| commit | 15b3e511e117d0c07a28afd0c40596a631a28e4f (patch) | |
| tree | dbd2233b54a82b8be95a0935a57085089f64c8f7 | |
| parent | ba114d2f466e749bf750cfd9049dbe143e2963b1 (diff) | |
| download | emacs-15b3e511e117d0c07a28afd0c40596a631a28e4f.tar.gz emacs-15b3e511e117d0c07a28afd0c40596a631a28e4f.zip | |
Delete defining "i" in mule-keymap.
(mule-menu-keymap): New variable. All menu items related to mule
are defined in this keymap.
(set-language-info): Change format of INFO for KEY documentation
and setup-function.
(setup-specified-language-environment): New function.
(setup-language-environment): Call the above function.
(describe-specified-language-support): New function.
(describe-language-support): Call the above function.
(universal-coding-system-argument): New function.
(read-language-and-input-method-name): Doc-string fixed. If
default-input-method is nil, use previous-input-method as the
default value.
(set-default-input-method): Deleted.
| -rw-r--r-- | lisp/international/mule-cmds.el | 411 |
1 files changed, 243 insertions, 168 deletions
diff --git a/lisp/international/mule-cmds.el b/lisp/international/mule-cmds.el index b8466796675..1aaea1d48f0 100644 --- a/lisp/international/mule-cmds.el +++ b/lisp/international/mule-cmds.el | |||
| @@ -26,78 +26,104 @@ | |||
| 26 | 26 | ||
| 27 | ;;; MULE related key bindings and menus. | 27 | ;;; MULE related key bindings and menus. |
| 28 | 28 | ||
| 29 | (defvar mule-keymap (make-sparse-keymap "MULE") | 29 | (defvar mule-keymap nil |
| 30 | "Keymap for MULE (Multilingual environment) specific commands.") | 30 | "Keymap for MULE (Multilingual environment) specific commands.") |
| 31 | (fset 'mule-prefix mule-keymap) | 31 | (define-prefix-command 'mule-keymap) |
| 32 | 32 | ||
| 33 | ;; Keep "C-x C-m ..." for mule specific commands. | 33 | ;; Keep "C-x C-m ..." for mule specific commands. |
| 34 | (define-key ctl-x-map "\C-m" 'mule-prefix) | 34 | (define-key ctl-x-map "\C-m" 'mule-keymap) |
| 35 | |||
| 36 | (define-key global-map [menu-bar mule] (cons "Mule" mule-keymap)) | ||
| 37 | |||
| 38 | (setq menu-bar-final-items (cons 'mule menu-bar-final-items)) | ||
| 39 | |||
| 40 | (defvar mule-describe-language-support-map | ||
| 41 | (make-sparse-keymap "Describe Language Support")) | ||
| 42 | (fset 'mule-describe-language-support-prefix | ||
| 43 | mule-describe-language-support-map) | ||
| 44 | |||
| 45 | (defvar mule-set-language-environment-map | ||
| 46 | (make-sparse-keymap "Set Language Environment")) | ||
| 47 | (fset 'mule-set-language-environment-prefix | ||
| 48 | mule-set-language-environment-map) | ||
| 49 | 35 | ||
| 50 | (define-key mule-keymap "m" 'toggle-enable-multibyte-characters) | 36 | (define-key mule-keymap "m" 'toggle-enable-multibyte-characters) |
| 51 | (define-key mule-keymap "f" 'set-buffer-file-coding-system) | 37 | (define-key mule-keymap "f" 'set-buffer-file-coding-system) |
| 52 | (define-key mule-keymap "t" 'set-terminal-coding-system) | 38 | (define-key mule-keymap "t" 'set-terminal-coding-system) |
| 53 | (define-key mule-keymap "k" 'encoded-kbd-set-coding-system) | 39 | (define-key mule-keymap "k" 'set-keyboard-coding-system) |
| 54 | (define-key mule-keymap "p" 'set-current-process-coding-system) | 40 | (define-key mule-keymap "p" 'set-buffer-process-coding-system) |
| 55 | (define-key mule-keymap "i" 'select-input-method) | ||
| 56 | (define-key mule-keymap "\C-\\" 'select-input-method) | 41 | (define-key mule-keymap "\C-\\" 'select-input-method) |
| 42 | (define-key mule-keymap "c" 'universal-coding-system-argument) | ||
| 57 | 43 | ||
| 58 | (define-key help-map "\C-L" 'describe-language-support) | 44 | (define-key help-map "\C-L" 'describe-language-support) |
| 59 | (define-key help-map "\C-\\" 'describe-input-method) | 45 | (define-key help-map "\C-\\" 'describe-input-method) |
| 60 | (define-key help-map "C" 'describe-current-coding-system) | 46 | (define-key help-map "C" 'describe-current-coding-system) |
| 61 | (define-key help-map "h" 'view-hello-file) | 47 | (define-key help-map "h" 'view-hello-file) |
| 62 | 48 | ||
| 63 | (define-key mule-keymap [view-hello-file] | 49 | (defvar mule-menu-keymap nil |
| 64 | '("Show many languages" . view-hello-file)) | 50 | "Keymap for MULE (Multilingual environment) menu specific commands.") |
| 65 | (define-key mule-keymap [mule-diag] | 51 | (define-prefix-command 'mule-menu-keymap) |
| 66 | '("Show diagnosis for MULE" . mule-diag)) | 52 | |
| 67 | (define-key mule-keymap [separator-coding-system] | 53 | (define-key global-map [menu-bar mule] (cons "Mule" mule-menu-keymap)) |
| 68 | '("--")) | 54 | |
| 69 | (define-key mule-keymap [set-process-coding-system] | 55 | (setq menu-bar-final-items (cons 'mule menu-bar-final-items)) |
| 70 | '("Set coding system of process" . set-current-process-coding-system)) | 56 | |
| 71 | (define-key mule-keymap [encoded-kbd-set-coding-system] | 57 | (defvar describe-language-support-map nil) |
| 72 | '("Set coding system for Encoded-kbd mode" . encoded-kbd-set-coding-system)) | 58 | (define-prefix-command 'describe-language-support-map) |
| 73 | (define-key mule-keymap [set-terminal-coding-system] | 59 | |
| 74 | '("Set coding system of terminal" . set-terminal-coding-system)) | 60 | (defvar setup-language-environment-map nil) |
| 75 | (define-key mule-keymap [set-buffer-file-coding-system] | 61 | (define-prefix-command 'setup-language-environment-map) |
| 76 | '("Set coding system of buffer file" . set-buffer-file-coding-system)) | 62 | |
| 77 | (define-key mule-keymap [describe-current-coding-system] | 63 | (defvar set-coding-system-map nil) |
| 78 | '("Describe current coding systems" . describe-current-coding-system)) | 64 | (define-prefix-command 'set-coding-system-map) |
| 79 | (define-key mule-keymap [separator-input-method] | 65 | |
| 80 | '("--")) | 66 | (define-key-after mule-menu-keymap [toggle-mule] |
| 81 | (define-key mule-keymap [describe-input-method] | 67 | '("Toggle MULE facility" . toggle-enable-multibyte-characters) |
| 82 | '("Describe input method" . describe-input-method)) | 68 | t) |
| 83 | (define-key mule-keymap [select-input-method] | 69 | (define-key-after mule-menu-keymap [describe-language-support] |
| 84 | '("Select input method" . select-input-method)) | 70 | '("Describe language support" . describe-language-support-map) |
| 85 | (define-key mule-keymap [toggle-input-method] | 71 | t) |
| 86 | '("Toggle input method" . toggle-input-method)) | 72 | (define-key-after mule-menu-keymap [set-language-environment] |
| 87 | (define-key mule-keymap [separator-mule] | 73 | '("Set language environment" . setup-language-environment-map) |
| 88 | '("--")) | 74 | t) |
| 89 | (define-key mule-keymap [set-language-environment] | 75 | (define-key-after mule-menu-keymap [separator-mule] |
| 90 | '("Set language environment" . mule-set-language-environment-prefix)) | 76 | '("--") |
| 91 | (define-key mule-keymap [describe-language-support] | 77 | t) |
| 92 | '("Describe language support" . mule-describe-language-support-prefix)) | 78 | (define-key-after mule-menu-keymap [toggle-input-method] |
| 93 | (define-key mule-keymap [toggle-mule] | 79 | '("Toggle input method" . toggle-input-method) |
| 94 | '("Disable/enable multibyte character" . toggle-enable-multibyte-characters)) | 80 | t) |
| 81 | (define-key-after mule-menu-keymap [select-input-method] | ||
| 82 | '("Select input method" . select-input-method) | ||
| 83 | t) | ||
| 84 | (define-key-after mule-menu-keymap [describe-input-method] | ||
| 85 | '("Describe input method" . describe-input-method) | ||
| 86 | t) | ||
| 87 | (define-key-after mule-menu-keymap [separator-input-method] | ||
| 88 | '("--") | ||
| 89 | t) | ||
| 90 | (define-key-after mule-menu-keymap [describe-current-coding-system] | ||
| 91 | '("Describe coding systems" . describe-current-coding-system) | ||
| 92 | t) | ||
| 93 | (define-key-after mule-menu-keymap [set-various-coding-system] | ||
| 94 | '("Set coding systems" . set-coding-system-map) | ||
| 95 | t) | ||
| 96 | (define-key-after mule-menu-keymap [separator-coding-system] | ||
| 97 | '("--") | ||
| 98 | t) | ||
| 99 | (define-key-after mule-menu-keymap [mule-diag] | ||
| 100 | '("Show diagnosis for MULE" . mule-diag) | ||
| 101 | t) | ||
| 102 | (define-key-after mule-menu-keymap [view-hello-file] | ||
| 103 | '("Show many languages" . view-hello-file) | ||
| 104 | t) | ||
| 105 | |||
| 106 | (define-key-after set-coding-system-map [set-buffer-file-coding-system] | ||
| 107 | '("Buffer file" . set-buffer-file-coding-system) | ||
| 108 | t) | ||
| 109 | (define-key-after set-coding-system-map [set-terminal-coding-system] | ||
| 110 | '("Terminal" . set-terminal-coding-system) | ||
| 111 | t) | ||
| 112 | (define-key-after set-coding-system-map [set-keyboard-coding-system] | ||
| 113 | '("Keyboard" . set-keyboard-coding-system) | ||
| 114 | t) | ||
| 115 | (define-key-after set-coding-system-map [set-buffer-process-coding-system] | ||
| 116 | '("Buffer process" . set-buffer-process-coding-system) | ||
| 117 | t) | ||
| 118 | |||
| 119 | (define-key setup-language-environment-map | ||
| 120 | [Default] '("Default" . setup-specified-language-environment)) | ||
| 95 | 121 | ||
| 96 | ;; These are meaningless when running under X. | 122 | ;; These are meaningless when running under X. |
| 97 | (put 'encoded-kbd-set-coding-system 'menu-enable | ||
| 98 | '(null window-system)) | ||
| 99 | (put 'set-terminal-coding-system 'menu-enable | 123 | (put 'set-terminal-coding-system 'menu-enable |
| 100 | '(null window-system)) | 124 | '(null window-system)) |
| 125 | (put 'set-keyboard-coding-system 'menu-enable | ||
| 126 | '(null window-system)) | ||
| 101 | 127 | ||
| 102 | ;; This should be a single character key binding because users use it | 128 | ;; This should be a single character key binding because users use it |
| 103 | ;; very frequently while editing multilingual text. Now we can use | 129 | ;; very frequently while editing multilingual text. Now we can use |
| @@ -124,6 +150,18 @@ With arg, make them enable iff arg is positive." | |||
| 124 | (coding-system-for-read 'iso-2022-7)) | 150 | (coding-system-for-read 'iso-2022-7)) |
| 125 | (find-file-read-only (expand-file-name "HELLO" data-directory)))) | 151 | (find-file-read-only (expand-file-name "HELLO" data-directory)))) |
| 126 | 152 | ||
| 153 | (defun universal-coding-system-argument () | ||
| 154 | "Execute an I/O command using the specified coding system." | ||
| 155 | (interactive) | ||
| 156 | (let* ((coding-system (read-coding-system "Coding system: ")) | ||
| 157 | (keyseq (read-key-sequence | ||
| 158 | (format "With coding system %s:" coding-system))) | ||
| 159 | (cmd (key-binding keyseq))) | ||
| 160 | (let ((coding-system-for-read coding-system) | ||
| 161 | (coding-system-for-write coding-system)) | ||
| 162 | (message "") | ||
| 163 | (call-interactively cmd)))) | ||
| 164 | |||
| 127 | 165 | ||
| 128 | ;;; Language support staffs. | 166 | ;;; Language support staffs. |
| 129 | 167 | ||
| @@ -144,8 +182,7 @@ to KEY.") | |||
| 144 | "Return the information for LANGUAGE-NAME of the kind KEY. | 182 | "Return the information for LANGUAGE-NAME of the kind KEY. |
| 145 | LANGUAGE-NAME is a string. | 183 | LANGUAGE-NAME is a string. |
| 146 | KEY is a symbol denoting the kind of required information." | 184 | KEY is a symbol denoting the kind of required information." |
| 147 | (let ((lang-slot (assoc-ignore-case | 185 | (let ((lang-slot (assoc-ignore-case language-name language-info-alist))) |
| 148 | (downcase language-name) language-info-alist))) | ||
| 149 | (if lang-slot | 186 | (if lang-slot |
| 150 | (cdr (assq key (cdr lang-slot)))))) | 187 | (cdr (assq key (cdr lang-slot)))))) |
| 151 | 188 | ||
| @@ -163,16 +200,22 @@ sample-text: one line short text containing characters of the language. | |||
| 163 | input-method: alist of input method names for the language vs information | 200 | input-method: alist of input method names for the language vs information |
| 164 | for activating them. Use `register-input-method' (which see) | 201 | for activating them. Use `register-input-method' (which see) |
| 165 | to add a new input method to the alist. | 202 | to add a new input method to the alist. |
| 166 | documentation: a string describing how Emacs supports the language, | 203 | documentation: t or a string describing how Emacs supports the language. |
| 167 | or a list of a string, or t. In the latter two cases, | 204 | If a string is specified, it is shown before any other information |
| 168 | the other detailed information is also shown by the command | 205 | of the language by the command describe-language-support. |
| 169 | describe-language-support. | ||
| 170 | setup-function: a function to call for setting up environment | 206 | setup-function: a function to call for setting up environment |
| 171 | convenient for the language. | 207 | convenient for a user of the language. |
| 208 | |||
| 209 | If KEY is documentation or setup-function, you can also specify | ||
| 210 | a cons cell as INFO, in which case, the car part should be | ||
| 211 | a normal value as INFO for KEY (as described above), | ||
| 212 | and the cdr part should be a symbol whose value is a menu keymap | ||
| 213 | in which an entry for the language is defined. But, only the car part | ||
| 214 | is actually set as the information. | ||
| 172 | 215 | ||
| 173 | Emacs will use more KEYs in the future. To avoid conflict, users | 216 | Emacs will use more KEYs in the future. To avoid conflict, users |
| 174 | should use prefix \"user-\" in the name of KEY if he wants to set | 217 | should use prefix \"user-\" in the name of KEY if he wants to set |
| 175 | different kind of information." | 218 | different kind of information for personal use." |
| 176 | (let (lang-slot key-slot) | 219 | (let (lang-slot key-slot) |
| 177 | (setq lang-slot (assoc language-name language-info-alist)) | 220 | (setq lang-slot (assoc language-name language-info-alist)) |
| 178 | (if (null lang-slot) ; If no slot for the language, add it. | 221 | (if (null lang-slot) ; If no slot for the language, add it. |
| @@ -183,18 +226,27 @@ different kind of information." | |||
| 183 | (progn | 226 | (progn |
| 184 | (setq key-slot (list key)) | 227 | (setq key-slot (list key)) |
| 185 | (setcdr lang-slot (cons key-slot (cdr lang-slot))))) | 228 | (setcdr lang-slot (cons key-slot (cdr lang-slot))))) |
| 186 | (setcdr key-slot info) | ||
| 187 | ;; Setup menu. | 229 | ;; Setup menu. |
| 188 | (cond ((eq key 'documentation) | 230 | (cond ((eq key 'documentation) |
| 189 | (define-key-after mule-describe-language-support-map | 231 | (define-key-after |
| 232 | (if (consp info) | ||
| 233 | (prog1 (symbol-value (cdr info)) | ||
| 234 | (setq info (car info))) | ||
| 235 | describe-language-support-map) | ||
| 190 | (vector (intern language-name)) | 236 | (vector (intern language-name)) |
| 191 | (cons language-name 'describe-specified-language-support) | 237 | (cons language-name 'describe-specified-language-support) |
| 192 | t)) | 238 | t)) |
| 193 | ((eq key 'setup-function) | 239 | ((eq key 'setup-function) |
| 194 | (define-key-after mule-set-language-environment-map | 240 | (define-key-after |
| 241 | (if (consp info) | ||
| 242 | (prog1 (symbol-value (cdr info)) | ||
| 243 | (setq info (car info))) | ||
| 244 | setup-language-environment-map) | ||
| 195 | (vector (intern language-name)) | 245 | (vector (intern language-name)) |
| 196 | (cons language-name info) | 246 | (cons language-name 'setup-specified-language-environment) |
| 197 | t))) | 247 | t))) |
| 248 | |||
| 249 | (setcdr key-slot info) | ||
| 198 | )) | 250 | )) |
| 199 | 251 | ||
| 200 | (defun set-language-info-alist (language-name alist) | 252 | (defun set-language-info-alist (language-name alist) |
| @@ -237,14 +289,20 @@ Every input method should set this to an appropriate value when activated.") | |||
| 237 | The default input method is the one activated automatically by the command | 289 | The default input method is the one activated automatically by the command |
| 238 | `toggle-input-method' (\\[toggle-input-method]). | 290 | `toggle-input-method' (\\[toggle-input-method]). |
| 239 | The value is a cons of language name and input method name.") | 291 | The value is a cons of language name and input method name.") |
| 292 | (make-variable-buffer-local 'default-input-method) | ||
| 293 | (put 'default-input-method 'permanent-local t) | ||
| 240 | 294 | ||
| 241 | (defvar default-input-method-title nil | 295 | (defvar default-input-method-title nil |
| 242 | "Title string of the default input method.") | 296 | "Title string of the default input method.") |
| 297 | (make-variable-buffer-local 'default-input-method-title) | ||
| 298 | (put 'default-input-method-title 'permanent-local t) | ||
| 243 | 299 | ||
| 244 | (defvar previous-input-method nil | 300 | (defvar previous-input-method nil |
| 245 | "Input method selected previously. | 301 | "Input method selected previously. |
| 246 | This is the one selected before the current input method is selected. | 302 | This is the one selected before the current input method is selected. |
| 247 | See also the documentation of `default-input-method'.") | 303 | See also the documentation of `default-input-method'.") |
| 304 | (make-variable-buffer-local 'previous-input-method) | ||
| 305 | (put 'previous-input-method 'permanent-local t) | ||
| 248 | 306 | ||
| 249 | (defvar inactivate-current-input-method-function nil | 307 | (defvar inactivate-current-input-method-function nil |
| 250 | "Function to call for inactivating the current input method. | 308 | "Function to call for inactivating the current input method. |
| @@ -278,43 +336,60 @@ Arguments for the function are METHOD-NAME and ARGs." | |||
| 278 | (cons input-method slot)))))) | 336 | (cons input-method slot)))))) |
| 279 | 337 | ||
| 280 | (defun read-language-and-input-method-name () | 338 | (defun read-language-and-input-method-name () |
| 281 | "Read a language names and the corresponding input method from a minibuffer. | 339 | "Read a language name and the corresponding input method from a minibuffer. |
| 282 | Return a cons of those names." | 340 | Return a list of those names." |
| 283 | (let ((language-name (read-language-name | 341 | (let* ((default-val (or previous-input-method default-input-method)) |
| 284 | 'input-method | 342 | (language-name (read-language-name |
| 285 | "Language: " | 343 | 'input-method "Language: " |
| 286 | (if previous-input-method | 344 | (if default-val (cons (car default-val) 0))))) |
| 287 | (cons (car previous-input-method) 0))))) | ||
| 288 | (if (null language-name) | 345 | (if (null language-name) |
| 289 | (error "No input method for the specified language")) | 346 | (error "No input method for the specified language")) |
| 347 | (if (not (string= language-name (car default-val))) | ||
| 348 | ;; Now the default value has no meaning. | ||
| 349 | (setq default-val nil)) | ||
| 290 | (let* ((completion-ignore-case t) | 350 | (let* ((completion-ignore-case t) |
| 291 | (key-slot (cdr (assq 'input-method | 351 | (key-slot (cdr (assq 'input-method |
| 292 | (assoc language-name language-info-alist)))) | 352 | (assoc language-name language-info-alist)))) |
| 293 | (method-name | 353 | (method-name |
| 294 | (completing-read "Input method: " key-slot nil t | 354 | (completing-read "Input method: " key-slot nil t |
| 295 | (if (and previous-input-method | 355 | (if default-val (cons (cdr default-val) 0))))) |
| 296 | (string= language-name | ||
| 297 | (car previous-input-method))) | ||
| 298 | (cons (cdr previous-input-method) 0))))) | ||
| 299 | (if (= (length method-name) 0) | 356 | (if (= (length method-name) 0) |
| 300 | (error "No input method specified")) | 357 | (error "No input method specified")) |
| 301 | (list language-name | 358 | (list language-name |
| 302 | (car (assoc-ignore-case (downcase method-name) key-slot)))))) | 359 | (car (assoc-ignore-case method-name key-slot)))))) |
| 303 | 360 | ||
| 304 | (defun set-default-input-method (language-name method-name) | 361 | ;; Actvate input method METHOD-NAME for langauge LANGUAGE-NAME. |
| 305 | "Set the default input method to METHOD-NAME for inputting LANGUAGE-NAME. | 362 | (defun activate-input-method (language-name method-name) |
| 306 | The default input method is the one activated automatically by the command | 363 | (if (and current-input-method |
| 307 | `toggle-input-method' (\\[toggle-input-method]). | 364 | (or (not (string= (car current-input-method) language-name)) |
| 308 | This doesn't affect the currently activated input method." | 365 | (not (string= (cdr current-input-method) method-name)))) |
| 309 | (interactive (read-language-and-input-method-name)) | 366 | (inactivate-input-method)) |
| 310 | (let* ((key-slot (get-language-info language-name 'input-method)) | 367 | (or current-input-method |
| 311 | (method-slot (assoc method-name key-slot))) | 368 | (let* ((key-slot (get-language-info language-name 'input-method)) |
| 312 | (if (null method-slot) | 369 | (method-slot (cdr (assoc method-name key-slot)))) |
| 313 | (error "No input method `%s' for %s" method-name language-name)) | 370 | (if (null method-slot) |
| 314 | (setq default-input-method (cons language-name method-name)))) | 371 | (error "Invalid input method `%s' for %s" |
| 372 | method-name language-name)) | ||
| 373 | (apply (car method-slot) method-name (cdr method-slot)) | ||
| 374 | (setq current-input-method (cons language-name method-name)) | ||
| 375 | (if (not (equal default-input-method current-input-method)) | ||
| 376 | (progn | ||
| 377 | (setq previous-input-method default-input-method) | ||
| 378 | (setq default-input-method current-input-method) | ||
| 379 | (setq default-input-method-title current-input-method-title)))))) | ||
| 380 | |||
| 381 | ;; Inactivate the current input method. | ||
| 382 | (defun inactivate-input-method () | ||
| 383 | (if current-input-method | ||
| 384 | (unwind-protect | ||
| 385 | (funcall inactivate-current-input-method-function) | ||
| 386 | (setq current-input-method nil)))) | ||
| 315 | 387 | ||
| 316 | (defun select-input-method (language-name method-name) | 388 | (defun select-input-method (language-name method-name) |
| 317 | "Select and activate input method METHOD-NAME for inputting LANGUAGE-NAME. | 389 | "Select and activate input method METHOD-NAME for inputting LANGUAGE-NAME. |
| 390 | Both the default and local values of default-input-method are | ||
| 391 | set to the selected input method. | ||
| 392 | |||
| 318 | The information for activating METHOD-NAME is stored | 393 | The information for activating METHOD-NAME is stored |
| 319 | in `language-info-alist' under the key 'input-method. | 394 | in `language-info-alist' under the key 'input-method. |
| 320 | The format of the information has the form: | 395 | The format of the information has the form: |
| @@ -322,38 +397,28 @@ The format of the information has the form: | |||
| 322 | where ACTIVATE-FUNC is a function to call for activating this method. | 397 | where ACTIVATE-FUNC is a function to call for activating this method. |
| 323 | Arguments for the function are METHOD-NAME and ARGs." | 398 | Arguments for the function are METHOD-NAME and ARGs." |
| 324 | (interactive (read-language-and-input-method-name)) | 399 | (interactive (read-language-and-input-method-name)) |
| 325 | (let* ((key-slot (get-language-info language-name 'input-method)) | 400 | (activate-input-method language-name method-name) |
| 326 | (method-slot (assoc method-name key-slot))) | 401 | (setq-default default-input-method default-input-method) |
| 327 | (if (null method-slot) | 402 | (setq-default default-input-method-title default-input-method-title)) |
| 328 | (error "No input method `%s' for %s" method-name language-name)) | ||
| 329 | (if current-input-method | ||
| 330 | (progn | ||
| 331 | (setq previous-input-method current-input-method) | ||
| 332 | (unwind-protect | ||
| 333 | (funcall inactivate-current-input-method-function) | ||
| 334 | (setq current-input-method nil)))) | ||
| 335 | (setq method-slot (cdr method-slot)) | ||
| 336 | (apply (car method-slot) method-name (cdr method-slot)) | ||
| 337 | (setq default-input-method | ||
| 338 | (setq current-input-method (cons language-name method-name))) | ||
| 339 | (setq default-input-method-title current-input-method-title) | ||
| 340 | (setq current-input-method default-input-method))) | ||
| 341 | 403 | ||
| 342 | (defun toggle-input-method (&optional arg) | 404 | (defun toggle-input-method (&optional arg) |
| 343 | "Toggle whether a multilingual input method is activated in this buffer. | 405 | "Turn on or off a multilingual text input method for the current buffer. |
| 344 | With arg, activate an input method specified interactively. | 406 | With arg, turn on an input method specified interactively. |
| 345 | Without arg, the method being activated is the one selected most recently, | 407 | Without arg, if some input method is currently activated, turn it off, |
| 346 | but if no input method has ever been selected, select one interactively." | 408 | else turn on default-input-method (which see). |
| 409 | In the latter case, if default-input-method is nil, select an input method | ||
| 410 | interactively." | ||
| 347 | (interactive "P") | 411 | (interactive "P") |
| 348 | (if arg | 412 | (if arg |
| 349 | (call-interactively 'select-input-method) | 413 | (let ((input-method (read-language-and-input-method-name))) |
| 350 | (if (null current-input-method) | 414 | (activate-input-method (car input-method) (nth 1 input-method))) |
| 351 | (if default-input-method | 415 | (if current-input-method |
| 352 | (select-input-method (car default-input-method) | 416 | (inactivate-input-method) |
| 417 | (if default-input-method | ||
| 418 | (activate-input-method (car default-input-method) | ||
| 353 | (cdr default-input-method)) | 419 | (cdr default-input-method)) |
| 354 | (call-interactively 'select-input-method)) | 420 | (let ((input-method (read-language-and-input-method-name))) |
| 355 | (funcall inactivate-current-input-method-function) | 421 | (activate-input-method (car input-method) (nth 1 input-method))))))) |
| 356 | (setq current-input-method nil)))) | ||
| 357 | 422 | ||
| 358 | (defun describe-input-method () | 423 | (defun describe-input-method () |
| 359 | "Describe the current input method." | 424 | "Describe the current input method." |
| @@ -372,14 +437,19 @@ Without arg, the method being activated is the one selected most recently, | |||
| 372 | language-name method-name) | 437 | language-name method-name) |
| 373 | "Read a multilingual string from minibuffer, prompting with string PROMPT. | 438 | "Read a multilingual string from minibuffer, prompting with string PROMPT. |
| 374 | The input method selected last time is activated in minibuffer. | 439 | The input method selected last time is activated in minibuffer. |
| 375 | If non-nil, second arg INITIAL-INPUT is a string to insert before reading. | 440 | If optional second arg INITIAL-INPUT is non-nil, insert it in the minibuffer |
| 441 | initially | ||
| 376 | Optional 3rd and 4th arguments LANGUAGE-NAME and METHOD-NAME specify | 442 | Optional 3rd and 4th arguments LANGUAGE-NAME and METHOD-NAME specify |
| 377 | the input method to be activated instead of the one selected last time." | 443 | the input method to be activated instead of the one selected last time." |
| 378 | (let ((minibuffer-setup-hook '(toggle-input-method)) | 444 | (let ((default-input-method default-input-method)) |
| 379 | (default-input-method default-input-method)) | ||
| 380 | (if (and language-name method-name) | 445 | (if (and language-name method-name) |
| 381 | (set-default-input-method language-name method-name)) | 446 | (setq default-input-method (cons language-name method-name)) |
| 382 | (read-string prompt initial-input))) | 447 | (or default-input-method |
| 448 | (let ((lang-and-input-method (read-language-and-input-method-name))) | ||
| 449 | (setq default-input-method (cons (car lang-and-input-method) | ||
| 450 | (nth 1 lang-and-input-method)))))) | ||
| 451 | (let ((minibuffer-setup-hook '(toggle-input-method))) | ||
| 452 | (read-string prompt initial-input)))) | ||
| 383 | 453 | ||
| 384 | ;; Variables to control behavior of input methods. All input methods | 454 | ;; Variables to control behavior of input methods. All input methods |
| 385 | ;; should react to these variables. | 455 | ;; should react to these variables. |
| @@ -400,20 +470,28 @@ inputting at minibuffer if this flag is t.") | |||
| 400 | "Normal hook run just after an input method insert some chunk of text.") | 470 | "Normal hook run just after an input method insert some chunk of text.") |
| 401 | 471 | ||
| 402 | 472 | ||
| 403 | ;;; Language specific setup functions. | 473 | (defun setup-specified-language-environment () |
| 404 | (defun set-language-environment (language-name) | 474 | "Setup multi-lingual environment convenient for the specified language." |
| 405 | "Setup multilingual environment convenient for LANGUAGE-NAME. | 475 | (interactive) |
| 476 | (let (language-name func) | ||
| 477 | (if (and (symbolp last-command-event) | ||
| 478 | (or (not (eq last-command-event 'Default)) | ||
| 479 | (setq last-command-event 'English)) | ||
| 480 | (setq language-name (symbol-name last-command-event)) | ||
| 481 | (setq func (get-language-info language-name 'setup-function))) | ||
| 482 | (progn | ||
| 483 | (funcall func) | ||
| 484 | (force-mode-line-update t)) | ||
| 485 | (error "Bogus calling sequence")))) | ||
| 406 | 486 | ||
| 407 | For that, a fucntion returned by: | 487 | (defun setup-language-environment (language-name) |
| 408 | (get-language-info LANGUAGE-NAME 'setup-function) | 488 | "Setup multi-lingual environment convenient for LANGUAGE-NAME users." |
| 409 | is called." | ||
| 410 | (interactive (list (read-language-name 'setup-function "Language: "))) | 489 | (interactive (list (read-language-name 'setup-function "Language: "))) |
| 411 | (let (func) | 490 | (if (or (null language-name) |
| 412 | (if (or (null language-name) | 491 | (null (get-language-info language-name 'setup-function))) |
| 413 | (null (setq func | 492 | (error "No way to setup environment for the specified language")) |
| 414 | (get-language-info language-name 'setup-function)))) | 493 | (let ((last-command-event (intern language-name))) |
| 415 | (error "No way to setup environment for the specified language")) | 494 | (setup-specified-language-environment))) |
| 416 | (funcall func))) | ||
| 417 | 495 | ||
| 418 | ;; Print all arguments with `princ', then print "\n". | 496 | ;; Print all arguments with `princ', then print "\n". |
| 419 | (defsubst princ-list (&rest args) | 497 | (defsubst princ-list (&rest args) |
| @@ -435,41 +513,38 @@ is called." | |||
| 435 | (error "Bogus calling sequence")) | 513 | (error "Bogus calling sequence")) |
| 436 | (with-output-to-temp-buffer "*Help*" | 514 | (with-output-to-temp-buffer "*Help*" |
| 437 | (if (stringp doc) | 515 | (if (stringp doc) |
| 438 | (princ-list doc) | 516 | (princ-list doc)) |
| 439 | (if (and (listp doc) | 517 | (princ "-----------------------------------------------------------\n") |
| 440 | (stringp (car doc))) | 518 | (princ-list "List of items specific to " |
| 441 | (princ-list (car doc))) | 519 | language-name |
| 442 | (princ "-----------------------------------------------------------\n") | 520 | " support") |
| 443 | (princ-list "List of items specific to " | 521 | (princ "-----------------------------------------------------------\n") |
| 444 | language-name | 522 | (let ((str (get-language-info language-name 'sample-text))) |
| 445 | " support") | 523 | (if (stringp str) |
| 446 | (princ "-----------------------------------------------------------\n") | 524 | (progn |
| 447 | (let ((str (get-language-info language-name 'sample-text))) | 525 | (princ "<sample text>\n") |
| 448 | (if (stringp str) | 526 | (princ-list " " str)))) |
| 449 | (progn | 527 | (princ "<input methods>\n") |
| 450 | (princ "<sample text>\n") | 528 | (let ((l (get-language-info language-name 'input-method))) |
| 451 | (princ-list " " str)))) | 529 | (while l |
| 452 | (princ "<input methods>\n") | 530 | (princ-list " " (car (car l))) |
| 453 | (let ((l (get-language-info language-name 'input-method))) | 531 | (setq l (cdr l)))) |
| 532 | (princ "<character sets>\n") | ||
| 533 | (let ((l (get-language-info language-name 'charset))) | ||
| 534 | (if (null l) | ||
| 535 | (princ-list " nothing specific to " language-name) | ||
| 536 | (while l | ||
| 537 | (princ-list " " (car l) ": " | ||
| 538 | (charset-description (car l))) | ||
| 539 | (setq l (cdr l))))) | ||
| 540 | (princ "<coding systems>\n") | ||
| 541 | (let ((l (get-language-info language-name 'coding-system))) | ||
| 542 | (if (null l) | ||
| 543 | (princ-list " nothing specific to " language-name) | ||
| 454 | (while l | 544 | (while l |
| 455 | (princ-list " " (car (car l))) | 545 | (princ-list " " (car l) ":\n\t" |
| 456 | (setq l (cdr l)))) | 546 | (coding-system-docstring (car l))) |
| 457 | (princ "<character sets>\n") | 547 | (setq l (cdr l)))))))) |
| 458 | (let ((l (get-language-info language-name 'charset))) | ||
| 459 | (if (null l) | ||
| 460 | (princ-list " nothing specific to " language-name) | ||
| 461 | (while l | ||
| 462 | (princ-list " " (car l) ": " | ||
| 463 | (charset-description (car l))) | ||
| 464 | (setq l (cdr l))))) | ||
| 465 | (princ "<coding systems>\n") | ||
| 466 | (let ((l (get-language-info language-name 'coding-system))) | ||
| 467 | (if (null l) | ||
| 468 | (princ-list " nothing specific to " language-name) | ||
| 469 | (while l | ||
| 470 | (princ-list " " (car l) ":\n\t" | ||
| 471 | (coding-system-docstring (car l))) | ||
| 472 | (setq l (cdr l))))))))) | ||
| 473 | 548 | ||
| 474 | (defun describe-language-support (language-name) | 549 | (defun describe-language-support (language-name) |
| 475 | "Describe how Emacs supports LANGUAGE-NAME." | 550 | "Describe how Emacs supports LANGUAGE-NAME." |