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