1 ;;; mule-cmds.el --- Commands for mulitilingual environment
3 ;; Copyright (C) 1995 Electrotechnical Laboratory, JAPAN.
4 ;; Licensed to the Free Software Foundation.
6 ;; Keywords: mule, multilingual
8 ;; This file is part of GNU Emacs.
10 ;; GNU Emacs is free software; you can redistribute it and/or modify
11 ;; it under the terms of the GNU General Public License as published by
12 ;; the Free Software Foundation; either version 2, or (at your option)
15 ;; GNU Emacs is distributed in the hope that it will be useful,
16 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
17 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 ;; GNU General Public License for more details.
20 ;; You should have received a copy of the GNU General Public License
21 ;; along with GNU Emacs; see the file COPYING. If not, write to the
22 ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
23 ;; Boston, MA 02111-1307, USA.
27 ;;; MULE related key bindings and menus.
29 (defvar mule-keymap
(make-sparse-keymap)
30 "Keymap for MULE (Multilingual environment) specific commands.")
32 ;; Keep "C-x C-m ..." for mule specific commands.
33 (define-key ctl-x-map
"\C-m" mule-keymap
)
35 (define-key mule-keymap
"f" 'set-buffer-file-coding-system
)
36 (define-key mule-keymap
"t" 'set-terminal-coding-system
)
37 (define-key mule-keymap
"k" 'set-keyboard-coding-system
)
38 (define-key mule-keymap
"p" 'set-buffer-process-coding-system
)
39 (define-key mule-keymap
"x" 'set-selection-coding-system
)
40 (define-key mule-keymap
"X" 'set-next-selection-coding-system
)
41 (define-key mule-keymap
"\C-\\" 'set-input-method
)
42 (define-key mule-keymap
"c" 'universal-coding-system-argument
)
43 (define-key mule-keymap
"l" 'set-language-environment
)
45 (define-key help-map
"\C-L" 'describe-language-environment
)
46 (define-key help-map
"L" 'describe-language-environment
)
47 (define-key help-map
"\C-\\" 'describe-input-method
)
48 (define-key help-map
"I" 'describe-input-method
)
49 (define-key help-map
"C" 'describe-coding-system
)
50 (define-key help-map
"h" 'view-hello-file
)
52 (defvar mule-menu-keymap
(make-sparse-keymap "Mule")
53 "Keymap for MULE (Multilingual environment) menu specific commands.")
55 (define-key global-map
[menu-bar mule
]
56 `(menu-item "Mule" ,mule-menu-keymap
57 :visible default-enable-multibyte-characters
))
59 (setq menu-bar-final-items
(cons 'mule menu-bar-final-items
))
61 (defvar describe-language-environment-map
62 (make-sparse-keymap "Describe Language Environment"))
64 (defvar setup-language-environment-map
65 (make-sparse-keymap "Set Language Environment"))
67 (defvar set-coding-system-map
68 (make-sparse-keymap "Set Coding System"))
70 (define-key-after mule-menu-keymap
[describe-language-environment
]
71 (cons "Describe Language Environment" describe-language-environment-map
)
73 (define-key-after mule-menu-keymap
[set-language-environment
]
74 (cons "Set Language Environment" setup-language-environment-map
)
76 (define-key-after mule-menu-keymap
[mouse-set-font
]
77 '("Set Font/Fontset" . mouse-set-font
)
79 (define-key-after mule-menu-keymap
[separator-mule
]
82 (define-key-after mule-menu-keymap
[toggle-input-method
]
83 '("Toggle Input Method" . toggle-input-method
)
85 (define-key-after mule-menu-keymap
[set-input-method
]
86 '("Select Input Method" . set-input-method
)
88 (define-key-after mule-menu-keymap
[describe-input-method
]
89 '("Describe Input Method" . describe-input-method
)
91 (define-key-after mule-menu-keymap
[separator-input-method
]
94 (define-key-after mule-menu-keymap
[describe-coding-system
]
95 '("Describe Coding Systems" . describe-coding-system
)
97 (define-key-after mule-menu-keymap
[set-various-coding-system
]
98 (cons "Set Coding System" set-coding-system-map
)
100 (define-key-after mule-menu-keymap
[separator-coding-system
]
103 (define-key-after mule-menu-keymap
[mule-diag
]
104 '("Show All of MULE Status" . mule-diag
)
106 (define-key-after mule-menu-keymap
[view-hello-file
]
107 '("Show Script Examples" . view-hello-file
)
110 (define-key-after set-coding-system-map
[set-buffer-file-coding-system
]
111 '("Buffer File" . set-buffer-file-coding-system
)
113 (define-key-after set-coding-system-map
[universal-coding-system-argument
]
114 '("Next Command" . universal-coding-system-argument
)
116 (define-key-after set-coding-system-map
[set-terminal-coding-system
]
117 '("Terminal" . set-terminal-coding-system
)
119 (define-key-after set-coding-system-map
[set-keyboard-coding-system
]
120 '("Keyboard" . set-keyboard-coding-system
)
122 (define-key-after set-coding-system-map
[set-buffer-process-coding-system
]
123 '("Buffer Process" . set-buffer-process-coding-system
)
125 (define-key-after set-coding-system-map
[set-selection-coding-system
]
126 '("X Selection" . set-selection-coding-system
)
128 (define-key-after set-coding-system-map
[set-next-selection-coding-system
]
129 '("Next X Selection" . set-next-selection-coding-system
)
131 (define-key setup-language-environment-map
132 [Default] '("Default" . setup-specified-language-environment))
134 ;; These are meaningless when running under X and W32.
135 (put 'set-terminal-coding-system 'menu-enable
136 '(or (not window-system) (eq window-system 'pc)))
137 (put 'set-keyboard-coding-system 'menu-enable
138 '(or (not window-system) (eq window-system 'pc)))
139 ;; This is meaningless when the current buffer has no process.
140 (put 'set-buffer-process-coding-system 'menu-enable
141 '(get-buffer-process (current-buffer)))
142 ;; These are meaningless when running under terminal.
143 (put 'set-selection-coding-system 'menu-enable
145 (put 'set-next-selection-coding-system 'menu-enable
148 ;; This should be a single character key binding because users use it
149 ;; very frequently while editing multilingual text. Now we can use
150 ;; only two such keys: "\C-\\" and "\C-^", but the latter is not
151 ;; convenient because it requires shifting on most keyboards. An
152 ;; alternative is "\C-\]" which is now bound to `abort-recursive-edit'
153 ;; but it won't be used that frequently.
154 (define-key global-map "\C-\\" 'toggle-input-method)
156 ;;; This is no good because people often type Shift-SPC
157 ;;; meaning to type SPC. -- rms.
158 ;;; ;; Here's an alternative key binding for X users (Shift-SPACE).
159 ;;; (define-key global-map [?\S- ] 'toggle-input-method)
161 (defun toggle-enable-multibyte-characters (&optional arg)
162 "Change whether this buffer uses multibyte characters.
163 With arg, use multibyte characters if the arg is positive.
165 Note that this command does not convert the byte contents of
166 the buffer; it only changes the way those bytes are interpreted.
167 In general, therefore, this command *changes* the sequence of
168 characters that the current buffer contains.
170 We suggest you avoid using use this command unless you know what you
171 are doing. If you use it by mistake, and the buffer is now displayed
172 wrong, use this command again to toggle back to the right mode."
175 (if (null arg) (null enable-multibyte-characters)
176 (> (prefix-numeric-value arg) 0))))
177 (set-buffer-multibyte new-flag))
178 (force-mode-line-update))
180 (defun view-hello-file ()
181 "Display the HELLO file which list up many languages and characters."
183 ;; We have to decode the file in any environment.
184 (let ((default-enable-multibyte-characters t)
185 (coding-system-for-read 'iso-2022-7bit))
186 (find-file-read-only (expand-file-name "HELLO" data-directory))))
188 (defun universal-coding-system-argument ()
189 "Execute an I/O command using the specified coding system."
191 (let* ((default (and buffer-file-coding-system
192 (not (eq (coding-system-type buffer-file-coding-system)
194 buffer-file-coding-system))
195 (coding-system (read-coding-system
197 (format "Coding system for following command (default, %s): " default)
198 "Coding system for following command: ")
200 (keyseq (read-key-sequence
201 (format "Command to execute with %s:" coding-system)))
202 (cmd (key-binding keyseq)))
203 (let ((coding-system-for-read coding-system)
204 (coding-system-for-write coding-system))
206 (call-interactively cmd))))
208 (defun set-default-coding-systems (coding-system)
209 "Set default value of various coding systems to CODING-SYSTEM.
210 This sets the following coding systems:
211 o coding system of a newly created buffer
212 o default coding system for subprocess I/O
213 This also sets the following values:
214 o default value used as file-name-coding-system for converting file names.
215 o default value for the command `set-terminal-coding-system' (not on MSDOS)
216 o default value for the command `set-keyboard-coding-system'."
217 (check-coding-system coding-system)
218 (setq-default buffer-file-coding-system coding-system)
219 (if default-enable-multibyte-characters
220 (setq default-file-name-coding-system coding-system))
221 ;; If coding-system is nil, honor that on MS-DOS as well, so
222 ;; that they could reset the terminal coding system.
223 (unless (and (eq window-system 'pc) coding-system)
224 (setq default-terminal-coding-system coding-system))
225 (setq default-keyboard-coding-system coding-system)
226 (setq default-process-coding-system (cons coding-system coding-system)))
228 (defalias 'update-iso-coding-systems 'update-coding-systems-internal)
229 (make-obsolete 'update-iso-coding-systems 'update-coding-systems-internal)
231 (defun prefer-coding-system (coding-system)
232 "Add CODING-SYSTEM at the front of the priority list for automatic detection.
233 This also sets the following coding systems:
234 o coding system of a newly created buffer
235 o default coding system for subprocess I/O
236 This also sets the following values:
237 o default value used as file-name-coding-system for converting file names.
238 o default value for the command `set-terminal-coding-system' (not on MSDOS)
239 o default value for the command `set-keyboard-coding-system'
241 If CODING-SYSTEM specifies a certain type of EOL conversion, the coding
242 systems set by this function will use that type of EOL conversion.
244 This command does not change the default value of terminal coding system
245 for MS-DOS terminal, because DOS terminals only support a single coding
246 system, and Emacs automatically sets the default to that coding system at
248 (interactive "zPrefer coding system: ")
249 (if (not (and coding-system (coding-system-p coding-system)))
250 (error "Invalid coding system `%s'" coding-system))
251 (let ((coding-category (coding-system-category coding-system))
252 (base (coding-system-base coding-system))
253 (eol-type (coding-system-eol-type coding-system)))
254 (if (not coding-category)
255 ;; CODING-SYSTEM is no-conversion or undecided.
256 (error "Can't prefer the coding system `%s'" coding-system))
257 (set coding-category (or base coding-system))
258 (update-coding-systems-internal)
259 (if (not (eq coding-category (car coding-category-list)))
260 ;; We must change the order.
261 (setq coding-category-list
262 (cons coding-category
263 (delq coding-category coding-category-list))))
264 (if (and base (interactive-p))
265 (message "Highest priority is set to %s (base of %s)"
267 ;; If they asked for specific EOL conversion, honor that.
268 (if (memq eol-type '(0 1 2))
270 (coding-system-change-eol-conversion base eol-type))
271 (setq coding-system base))
272 (set-default-coding-systems coding-system)))
274 (defun find-coding-systems-region-subset-p (list1 list2)
275 "Return non-nil if all elements in LIST1 are included in LIST2.
276 Comparison done with EQ."
279 (or (memq (car list1) list2)
281 (setq list1 (cdr list1)))
284 (defun find-coding-systems-region (from to)
285 "Return a list of proper coding systems to encode a text between FROM and TO.
286 All coding systems in the list can safely encode any multibyte characters
289 If the text contains no multibyte characters, return a list of a single
290 element `undecided'."
291 (find-coding-systems-for-charsets (find-charset-region from to)))
293 (defun find-coding-systems-string (string)
294 "Return a list of proper coding systems to encode STRING.
295 All coding systems in the list can safely encode any multibyte characters
298 If STRING contains no multibyte characters, return a list of a single
299 element `undecided'."
300 (find-coding-systems-for-charsets (find-charset-string string)))
302 (defun find-coding-systems-for-charsets (charsets)
303 "Return a list of proper coding systems to encode characters of CHARSETS.
304 CHARSETS is a list of character sets."
305 (if (or (null charsets)
306 (and (= (length charsets) 1)
307 (eq 'ascii (car charsets))))
309 (setq charsets (delq 'composition charsets))
310 (let ((l (coding-system-list 'base-only))
311 (charset-prefered-codings
316 (get-charset-property x 'prefered-coding-system))))
318 (priorities (mapcar (function (lambda (x) (symbol-value x)))
319 coding-category-list))
321 (if (memq 'unknown charsets)
322 ;; The region contains invalid multibyte characters.
323 (setq l '(raw-text)))
325 (setq coding (car l) l (cdr l))
326 (if (and (setq safe (coding-system-get coding 'safe-charsets))
328 (find-coding-systems-region-subset-p charsets safe)))
329 ;; We put the higher priority to coding systems included
330 ;; in CHARSET-PREFERED-CODINGS, and within them, put the
331 ;; higher priority to coding systems which support smaller
332 ;; number of charsets.
334 (+ (if (coding-system-get coding 'mime-charset) 4096 0)
335 (lsh (length (memq coding priorities)) 7)
336 (if (memq coding charset-prefered-codings) 64 0)
337 (if (> (coding-system-type coding) 0) 32 0)
338 (if (consp safe) (- 32 (length safe)) 0))))
339 (setq codings (cons (cons priority coding) codings)))))
341 (sort codings (function (lambda (x y) (> (car x) (car y))))))
344 (defun find-multibyte-characters (from to &optional maxcount excludes)
345 "Find multibyte characters in the region specified by FROM and TO.
346 If FROM is a string, find multibyte characters in the string.
347 The return value is an alist of the following format:
348 ((CHARSET COUNT CHAR ...) ...)
350 CHARSET is a character set,
351 COUNT is a number of characters,
352 CHARs are found characters of the character set.
353 Optional 3rd arg MAXCOUNT limits how many CHARs are put in the above list.
354 Optional 4th arg EXCLUDE is a list of character sets to be ignored.
356 For invalid characters, CHARs are actually strings."
361 (while (setq idx (string-match "[^\000-\177]" from idx))
362 (setq char (aref from idx)
363 charset (char-charset char))
364 (if (eq charset 'unknown)
365 (setq char (match-string 0)))
366 (if (or (eq charset 'unknown)
367 (not (or (eq excludes t) (memq charset excludes))))
368 (let ((slot (assq charset chars)))
370 (if (not (memq char (nthcdr 2 slot)))
371 (let ((count (nth 1 slot)))
372 (setcar (cdr slot) (1+ count))
373 (if (or (not maxcount) (< count maxcount))
374 (nconc slot (list char)))))
375 (setq chars (cons (list charset 1 char) chars)))))
376 (setq idx (1+ idx))))
379 (while (re-search-forward "[^\000-\177]" to t)
380 (setq char (preceding-char)
381 charset (char-charset char))
382 (if (eq charset 'unknown)
383 (setq char (match-string 0)))
384 (if (or (eq charset 'unknown)
385 (not (or (eq excludes t) (memq charset excludes))))
386 (let ((slot (assq charset chars)))
388 (if (not (member char (nthcdr 2 slot)))
389 (let ((count (nth 1 slot)))
390 (setcar (cdr slot) (1+ count))
391 (if (or (not maxcount) (< count maxcount))
392 (nconc slot (list char)))))
393 (setq chars (cons (list charset 1 char) chars))))))))
396 (defvar last-coding-system-specified nil
397 "Most recent coding system explicitly specified by the user when asked.
398 This variable is set whenever Emacs asks the user which coding system
399 to use in order to write a file. If you set it to nil explicitly,
400 then call `write-region', then afterward this variable will be non-nil
401 only if the user was explicitly asked and specified a coding system.")
403 (defun select-safe-coding-system (from to &optional default-coding-system)
404 "Ask a user to select a safe coding system from candidates.
405 The candidates of coding systems which can safely encode a text
406 between FROM and TO are shown in a popup window.
408 Optional arg DEFAULT-CODING-SYSTEM specifies a coding system to be
409 checked at first. If omitted, buffer-file-coding-system of the
410 current buffer is used.
412 If the text can be encoded safely by DEFAULT-CODING-SYSTEM, it is
413 returned without any user interaction.
415 Kludgy feature: if FROM is a string, the string is the target text,
417 (or default-coding-system
418 (setq default-coding-system buffer-file-coding-system))
419 (let* ((charsets (if (stringp from) (find-charset-string from)
420 (find-charset-region from to)))
421 (safe-coding-systems (find-coding-systems-for-charsets charsets)))
422 (if (or (not enable-multibyte-characters)
423 (eq (car safe-coding-systems) 'undecided)
424 (eq default-coding-system 'no-conversion)
425 (and default-coding-system
426 (memq (coding-system-base default-coding-system)
427 safe-coding-systems)))
428 default-coding-system
430 ;; At first, change each coding system to the corresponding
431 ;; mime-charset name if it is also a coding system.
432 (let ((l safe-coding-systems)
435 (setq mime-charset (coding-system-get (car l) 'mime-charset))
436 (if (and mime-charset (coding-system-p mime-charset))
437 (setcar l mime-charset))
440 (let ((non-safe-chars (find-multibyte-characters
442 (and default-coding-system
443 (coding-system-get default-coding-system
447 ;; Highlight characters that default-coding-system can't encode.
448 (when (integerp from)
451 (while (and (not found)
452 (re-search-forward "[^\000-\177]" to t))
453 (setq found (assq (char-charset (preceding-char))
456 (set-window-start (selected-window) (point))
458 (while (re-search-forward "[^\000-\177]" to t)
459 (let* ((char (preceding-char))
460 (charset (char-charset char)))
461 (when (assq charset non-safe-chars)
462 (setq overlays (cons (make-overlay (1- (point)) (point))
464 (overlay-put (car overlays) 'face 'highlight))))))
466 ;; At last, ask a user to select a proper coding system.
468 (save-window-excursion
469 ;; At first, show a helpful message.
470 (with-output-to-temp-buffer "*Warning*"
472 (set-buffer standard-output)
473 (insert "The target text contains the following non ASCII character(s):\n")
474 (let ((len (length non-safe-chars))
476 (while (and non-safe-chars (< shown 3))
477 (when (> (length (car non-safe-chars)) 2)
478 (setq shown (1+ shown))
479 (insert (format "%25s: " (car (car non-safe-chars))))
480 (let ((l (nthcdr 2 (car non-safe-chars))))
482 (if (or (stringp (car l)) (char-valid-p (car l)))
485 (if (> (nth 1 (car non-safe-chars)) 3)
488 (setq non-safe-chars (cdr non-safe-chars)))
490 (insert (format "%27s\n" "..."))))
492 These can't be encoded safely by the coding system %s.
494 Please select one from the following safe coding systems:\n"
495 default-coding-system))
498 (mapcar (function (lambda (x) (princ " ") (princ x)))
500 (fill-region-as-paragraph pos (point)))))
502 ;; Read a coding system.
503 (let* ((safe-names (mapcar (lambda (x) (list (symbol-name x)))
504 safe-coding-systems))
505 (name (completing-read
506 (format "Select coding system (default %s): "
507 (car safe-coding-systems))
508 safe-names nil t nil nil
509 (car (car safe-names)))))
510 (setq last-coding-system-specified (intern name))
511 (if (integerp (coding-system-eol-type default-coding-system))
512 (setq last-coding-system-specified
513 (coding-system-change-eol-conversion
514 last-coding-system-specified
515 (coding-system-eol-type default-coding-system))))
516 last-coding-system-specified))
517 (kill-buffer "*Warning*")
519 (delete-overlay (car overlays))
520 (setq overlays (cdr overlays)))))))))
522 (setq select-safe-coding-system-function 'select-safe-coding-system)
524 (defun select-message-coding-system ()
525 "Return a coding system to encode the outgoing message of the current buffer.
526 It at first tries the first coding system found in these variables
528 (1) local value of `buffer-file-coding-system'
529 (2) value of `sendmail-coding-system'
530 (3) value of `default-buffer-file-coding-system'
531 (4) value of `default-sendmail-coding-system'
532 If the found coding system can't encode the current buffer,
533 or none of them are bound to a coding system,
534 it asks the user to select a proper coding system."
535 (let ((coding (or (and (local-variable-p 'buffer-file-coding-system)
536 buffer-file-coding-system)
537 sendmail-coding-system
538 default-buffer-file-coding-system
539 default-sendmail-coding-system)))
540 (if (eq coding 'no-conversion)
541 ;; We should never use no-conversion for outgoing mails.
543 (if (fboundp select-safe-coding-system-function)
544 (funcall select-safe-coding-system-function
545 (point-min) (point-max) coding)
548 ;;; Language support stuff.
550 (defvar language-info-alist nil
551 "Alist of language environment definitions.
552 Each element looks like:
553 (LANGUAGE-NAME . ((KEY . INFO) ...))
554 where LANGUAGE-NAME is a string, the name of the language environment,
555 KEY is a symbol denoting the kind of information, and
556 INFO is the data associated with KEY.
557 Meaningful values for KEY include
559 documentation value is documentation of what this language environment
560 is meant for, and how to use it.
561 charset value is a list of the character sets used by this
562 language environment.
563 sample-text value is one line of text,
564 written using those character sets,
565 appropriate for this language environment.
566 setup-function value is a function to call to switch to this
567 language environment.
568 exit-function value is a function to call to leave this
569 language environment.
570 coding-system value is a list of coding systems that are good
571 for saving text written in this language environment.
572 This list serves as suggestions to the user;
573 in effect, as a kind of documentation.
574 coding-priority value is a list of coding systems for this language
575 environment, in order of decreasing priority.
576 This is used to set up the coding system priority
577 list when you switch to this language environment.
579 value is a translation table to be set in the
580 variable `nonascii-translation-table' in this
581 language environment, or a character set from
582 which `nonascii-insert-offset' is calculated.
584 value is an alist to be set in the variable
585 `charset-origin-alist' in this language environment.
586 input-method value is a default input method for this language
588 features value is a list of features requested in this
589 language environment.
591 The following keys take effect only when multibyte characters are
592 globally disabled, i.e. the value of `default-enable-multibyte-characters'
595 unibyte-syntax value is a library name to load to set
596 unibyte 8-bit character syntaxes for this
597 language environment.
599 unibyte-display value is a coding system to encode characters
600 for the terminal. Characters in the range
601 of 160 to 255 display not as octal escapes,
602 but as non-ASCII characters in this language
605 (defun get-language-info (lang-env key)
606 "Return information listed under KEY for language environment LANG-ENV.
607 KEY is a symbol denoting the kind of information.
608 For a list of useful values for KEY and their meanings,
609 see `language-info-alist'."
610 (if (symbolp lang-env)
611 (setq lang-env (symbol-name lang-env)))
612 (let ((lang-slot (assoc-ignore-case lang-env language-info-alist)))
614 (cdr (assq key (cdr lang-slot))))))
616 (defun set-language-info (lang-env key info)
617 "Modify part of the definition of language environment LANG-ENV.
618 Specifically, this stores the information INFO under KEY
619 in the definition of this language environment.
620 KEY is a symbol denoting the kind of information.
621 INFO is the value for that information.
623 For a list of useful values for KEY and their meanings,
624 see `language-info-alist'."
625 (if (symbolp lang-env)
626 (setq lang-env (symbol-name lang-env)))
627 (let (lang-slot key-slot)
628 (setq lang-slot (assoc lang-env language-info-alist))
629 (if (null lang-slot) ; If no slot for the language, add it.
630 (setq lang-slot (list lang-env)
631 language-info-alist (cons lang-slot language-info-alist)))
632 (setq key-slot (assq key lang-slot))
633 (if (null key-slot) ; If no slot for the key, add it.
635 (setq key-slot (list key))
636 (setcdr lang-slot (cons key-slot (cdr lang-slot)))))
637 (setcdr key-slot info)))
639 (defun set-language-info-alist (lang-env alist &optional parents)
640 "Store ALIST as the definition of language environment LANG-ENV.
641 ALIST is an alist of KEY and INFO values. See the documentation of
642 `set-language-info' for the meanings of KEY and INFO.
644 Optional arg PARENTS is a list of parent menu names; it specifies
645 where to put this language environment in the
646 Describe Language Environment and Set Language Environment menus.
647 For example, (\"European\") means to put this language environment
648 in the European submenu in each of those two menus."
649 (if (symbolp lang-env)
650 (setq lang-env (symbol-name lang-env)))
651 (let ((describe-map describe-language-environment-map)
652 (setup-map setup-language-environment-map))
655 map parent-symbol parent)
657 (if (symbolp (setq parent-symbol (car l)))
658 (setq parent (symbol-name parent))
659 (setq parent parent-symbol parent-symbol (intern parent)))
660 (setq map (lookup-key describe-map (vector parent-symbol)))
663 (setq map (intern (format "describe-%s-environment-map"
665 (define-prefix-command map)
666 (define-key-after describe-map (vector parent-symbol)
667 (cons parent map) t)))
668 (setq describe-map (symbol-value map))
669 (setq map (lookup-key setup-map (vector parent-symbol)))
672 (setq map (intern (format "setup-%s-environment-map"
674 (define-prefix-command map)
675 (define-key-after setup-map (vector parent-symbol)
676 (cons parent map) t)))
677 (setq setup-map (symbol-value map))
680 ;; Set up menu items for this language env.
681 (let ((doc (assq 'documentation alist)))
683 (define-key-after describe-map (vector (intern lang-env))
684 (cons lang-env 'describe-specified-language-support) t)))
685 (define-key-after setup-map (vector (intern lang-env))
686 (cons lang-env 'setup-specified-language-environment) t)
689 (set-language-info lang-env (car (car alist)) (cdr (car alist)))
690 (setq alist (cdr alist)))))
692 (defun read-language-name (key prompt &optional default)
693 "Read a language environment name which has information for KEY.
694 If KEY is nil, read any language environment.
695 Prompt with PROMPT. DEFAULT is the default choice of language environment.
696 This returns a language environment name as a string."
697 (let* ((completion-ignore-case t)
698 (name (completing-read prompt
701 (function (lambda (elm) (assq key elm))))
703 (if (and (> (length name) 0)
705 (get-language-info name key)))
708 ;;; Multilingual input methods.
710 (defconst leim-list-file-name "leim-list.el"
711 "Name of LEIM list file.
712 This file contains a list of libraries of Emacs input methods (LEIM)
713 in the format of Lisp expression for registering each input method.
714 Emacs loads this file at startup time.")
716 (defvar leim-list-header (format "\
717 ;;; %s -- list of LEIM (Library of Emacs Input Method)
719 ;; This file contains a list of LEIM (Library of Emacs Input Method)
720 ;; in the same directory as this file. Loading this file registers
721 ;; the whole input methods in Emacs.
723 ;; Each entry has the form:
724 ;; (register-input-method
725 ;; INPUT-METHOD LANGUAGE-NAME ACTIVATE-FUNC
728 ;; See the function `register-input-method' for the meanings of arguments.
730 ;; If this directory is included in load-path, Emacs automatically
731 ;; loads this file at startup time.
735 "Header to be inserted in LEIM list file.")
737 (defvar leim-list-entry-regexp "^(register-input-method"
738 "Regexp matching head of each entry in LEIM list file.
739 See also the variable `leim-list-header'")
741 (defvar update-leim-list-functions
742 '(quail-update-leim-list-file)
743 "List of functions to call to update LEIM list file.
744 Each function is called with one arg, LEIM directory name.")
746 (defun update-leim-list-file (&rest dirs)
747 "Update LEIM list file in directories DIRS."
748 (let ((functions update-leim-list-functions))
750 (apply (car functions) dirs)
751 (setq functions (cdr functions)))))
753 (defvar current-input-method nil
754 "The current input method for multilingual text.
755 If nil, that means no input method is activated now.")
756 (make-variable-buffer-local 'current-input-method)
757 (put 'current-input-method 'permanent-local t)
759 (defvar current-input-method-title nil
760 "Title string of the current input method shown in mode line.")
761 (make-variable-buffer-local 'current-input-method-title)
762 (put 'current-input-method-title 'permanent-local t)
764 (defcustom default-input-method nil
765 "*Default input method for multilingual text (a string).
766 This is the input method activated automatically by the command
767 `toggle-input-method' (\\[toggle-input-method])."
769 :type '(choice (const nil) string))
771 (defvar input-method-history nil
772 "History list for some commands that read input methods.")
773 (make-variable-buffer-local 'input-method-history)
774 (put 'input-method-history 'permanent-local t)
776 (defvar inactivate-current-input-method-function nil
777 "Function to call for inactivating the current input method.
778 Every input method should set this to an appropriate value when activated.
779 This function is called with no argument.
781 This function should never change the value of `current-input-method'.
782 It is set to nil by the function `inactivate-input-method'.")
783 (make-variable-buffer-local 'inactivate-current-input-method-function)
784 (put 'inactivate-current-input-method-function 'permanent-local t)
786 (defvar describe-current-input-method-function nil
787 "Function to call for describing the current input method.
788 This function is called with no argument.")
789 (make-variable-buffer-local 'describe-current-input-method-function)
790 (put 'describe-current-input-method-function 'permanent-local t)
792 (defvar input-method-alist nil
793 "Alist of input method names vs how to use them.
794 Each element has the form:
795 (INPUT-METHOD LANGUAGE-ENV ACTIVATE-FUNC TITLE DESCRIPTION ARGS...)
796 See the function `register-input-method' for the meanings of the elements.")
798 (defun register-input-method (input-method lang-env &rest args)
799 "Register INPUT-METHOD as an input method for language environment ENV.
800 INPUT-METHOD and LANG-ENV are symbols or strings.
802 The remaining arguments are:
803 ACTIVATE-FUNC, TITLE, DESCRIPTION, and ARGS...
804 ACTIVATE-FUNC is a function to call to activate this method.
805 TITLE is a string to show in the mode line when this method is active.
806 DESCRIPTION is a string describing this method and what it is good for.
807 The ARGS, if any, are passed as arguments to ACTIVATE-FUNC.
808 All told, the arguments to ACTIVATE-FUNC are INPUT-METHOD and the ARGS.
810 This function is mainly used in the file \"leim-list.el\" which is
811 created at building time of emacs, registering all quail input methods
812 contained in the emacs distribution.
814 In case you want to register a new quail input method by yourself, be
815 careful to use the same input method title as given in the third
816 parameter of `quail-define-package' (if the values are different, the
817 string specified in this function takes precedence).
819 The commands `describe-input-method' and `list-input-methods' need
820 this duplicated values to show some information about input methods
821 without loading the affected quail packages."
822 (if (symbolp lang-env)
823 (setq lang-env (symbol-name lang-env)))
824 (if (symbolp input-method)
825 (setq input-method (symbol-name input-method)))
826 (let ((info (cons lang-env args))
827 (slot (assoc input-method input-method-alist)))
830 (setq slot (cons input-method info))
831 (setq input-method-alist (cons slot input-method-alist)))))
833 (defun read-input-method-name (prompt &optional default inhibit-null)
834 "Read a name of input method from a minibuffer prompting with PROMPT.
835 If DEFAULT is non-nil, use that as the default,
836 and substitute it into PROMPT at the first `%s'.
837 If INHIBIT-NULL is non-nil, null input signals an error.
839 The return value is a string."
841 (setq prompt (format prompt default)))
842 (let* ((completion-ignore-case t)
843 ;; This binding is necessary because input-method-history is
845 (input-method (completing-read prompt input-method-alist
846 nil t nil 'input-method-history
848 (if (> (length input-method) 0)
851 (error "No valid input method is specified")))))
853 (defun activate-input-method (input-method)
854 "Switch to input method INPUT-METHOD for the current buffer.
855 If some other input method is already active, turn it off first.
856 If INPUT-METHOD is nil, deactivate any current input method."
857 (if (and input-method (symbolp input-method))
858 (setq input-method (symbol-name input-method)))
859 (if (and current-input-method
860 (not (string= current-input-method input-method)))
861 (inactivate-input-method))
862 (unless (or current-input-method (null input-method))
863 (let ((slot (assoc input-method input-method-alist)))
865 (error "Can't activate input method `%s'" input-method))
866 (let ((func (nth 2 slot)))
868 (apply (nth 2 slot) input-method (nthcdr 5 slot))
869 (if (and (consp func) (symbolp (car func)) (symbolp (cdr func)))
872 (apply (car func) input-method (nthcdr 5 slot)))
873 (error "Can't activate input method `%s'" input-method))))
874 (setq current-input-method input-method)
875 (setq current-input-method-title (nth 3 slot))
877 (run-hooks 'input-method-activate-hook)
878 (force-mode-line-update)))))
880 (defun inactivate-input-method ()
881 "Turn off the current input method."
882 (when current-input-method
883 (if input-method-history
884 (unless (string= current-input-method (car input-method-history))
885 (setq input-method-history
886 (cons current-input-method
887 (delete current-input-method input-method-history))))
888 (setq input-method-history (list current-input-method)))
890 (funcall inactivate-current-input-method-function)
892 (run-hooks 'input-method-inactivate-hook)
893 (setq current-input-method nil
894 current-input-method-title nil)
895 (force-mode-line-update)))))
897 (defun set-input-method (input-method)
898 "Select and activate input method INPUT-METHOD for the current buffer.
899 This also sets the default input method to the one you specify."
901 (let* ((default (or (car input-method-history) default-input-method)))
902 (list (read-input-method-name
903 (if default "Select input method (default %s): " "Select input method: ")
905 (activate-input-method input-method)
906 (setq default-input-method input-method))
908 (defun toggle-input-method (&optional arg)
909 "Turn on or off a multilingual text input method for the current buffer.
911 With no prefix argument, if some input method is currently activated,
912 turn it off. Otherwise, activate an input method--the one most recently used,
913 or the one specified in `default-input-method', or one read from the
916 With a prefix arg, read an input method from minibuffer and turn it on.
917 The default is the most recent input method specified
918 \(not including the currently active input method, if any).
920 When there's no input method to turn on, turn on what read from minibuffer."
922 (if (and current-input-method (not arg))
923 (inactivate-input-method)
924 (let ((default (or (car input-method-history) default-input-method)))
925 (if (and arg default (equal current-input-method default)
926 (> (length input-method-history) 1))
927 (setq default (nth 1 input-method-history)))
928 (activate-input-method
929 (if (or arg (not default))
931 (read-input-method-name
932 (if default "Input method (default %s): " "Input method: " )
935 (or default-input-method
936 (setq default-input-method current-input-method)))))
938 (defun describe-input-method (input-method)
939 "Describe input method INPUT-METHOD."
941 (list (read-input-method-name
942 "Describe input method (default, current choice): ")))
943 (if (and input-method (symbolp input-method))
944 (setq input-method (symbol-name input-method)))
945 (if (null input-method)
946 (describe-current-input-method)
947 (with-output-to-temp-buffer "*Help*"
948 (let ((elt (assoc input-method input-method-alist)))
949 (princ (format "Input method: %s (`%s' in mode line) for %s\n %s\n"
950 input-method (nth 3 elt) (nth 1 elt) (nth 4 elt)))))))
952 (defun describe-current-input-method ()
953 "Describe the input method currently in use."
954 (if current-input-method
955 (if (and (symbolp describe-current-input-method-function)
956 (fboundp describe-current-input-method-function))
957 (funcall describe-current-input-method-function)
958 (message "No way to describe the current input method `%s'"
959 (cdr current-input-method))
961 (error "No input method is activated now")))
963 (defun read-multilingual-string (prompt &optional initial-input input-method)
964 "Read a multilingual string from minibuffer, prompting with string PROMPT.
965 The input method selected last time is activated in minibuffer.
966 If optional second arg INITIAL-INPUT is non-nil, insert it in the minibuffer
968 Optional 3rd argument INPUT-METHOD specifies the input method
969 to be activated instead of the one selected last time. It is a symbol
975 (read-input-method-name "Input method: " nil t)))
976 (if (and input-method (symbolp input-method))
977 (setq input-method (symbol-name input-method)))
978 (let ((prev-input-method current-input-method))
981 (activate-input-method input-method)
982 (read-string prompt initial-input nil nil t))
983 (activate-input-method prev-input-method))))
985 ;; Variables to control behavior of input methods. All input methods
986 ;; should react to these variables.
988 (defcustom input-method-verbose-flag 'default
989 "*A flag to control extra guidance given by input methods.
990 The value should be nil, t, `complex-only', or `default'.
992 The extra guidance is done by showing list of available keys in echo
993 area. When you use the input method in the minibuffer, the guidance
994 is shown at the bottom short window (split from the existing window).
996 If the value is t, extra guidance is always given, if the value is
997 nil, extra guidance is always suppressed.
999 If the value is `complex-only', only complex input methods such as
1000 `chinese-py' and `japanese' give extra guidance.
1002 If the value is `default', complex input methods always give extra
1003 guidance, but simple input methods give it only when you are not in
1006 See also the variable `input-method-highlight-flag'."
1007 :type '(choice (const t) (const nil) (const complex-only) (const default))
1010 (defcustom input-method-highlight-flag t
1011 "*If this flag is non-nil, input methods highlight partially-entered text.
1012 For instance, while you are in the middle of a Quail input method sequence,
1013 the text inserted so far is temporarily underlined.
1014 The underlining goes away when you finish or abort the input method sequence.
1015 See also the variable `input-method-verbose-flag'."
1019 (defvar input-method-activate-hook nil
1020 "Normal hook run just after an input method is activated.
1022 The variable `current-input-method' keeps the input method name
1025 (defvar input-method-inactivate-hook nil
1026 "Normal hook run just after an input method is inactivated.
1028 The variable `current-input-method' still keeps the input method name
1031 (defvar input-method-after-insert-chunk-hook nil
1032 "Normal hook run just after an input method insert some chunk of text.")
1034 (defvar input-method-exit-on-first-char nil
1035 "This flag controls a timing when an input method returns.
1036 Usually, the input method does not return while there's a possibility
1037 that it may find a different translation if a user types another key.
1038 But, it this flag is non-nil, the input method returns as soon as
1039 the current key sequence gets long enough to have some valid translation.")
1041 (defvar input-method-use-echo-area nil
1042 "This flag controls how an input method shows an intermediate key sequence.
1043 Usually, the input method inserts the intermediate key sequence,
1044 or candidate translations corresponding to the sequence,
1045 at point in the current buffer.
1046 But, if this flag is non-nil, it displays them in echo area instead.")
1048 (defvar input-method-exit-on-invalid-key nil
1049 "This flag controls the behaviour of an input method on invalid key input.
1050 Usually, when a user types a key which doesn't start any character
1051 handled by the input method, the key is handled by turning off the
1052 input method temporarily. After that key, the input method is re-enabled.
1053 But, if this flag is non-nil, the input method is never back on.")
1056 (defvar set-language-environment-hook nil
1057 "Normal hook run after some language environment is set.
1059 When you set some hook function here, that effect usually should not
1060 be inherited to another language environment. So, you had better set
1061 another function in `exit-language-environment-hook' (which see) to
1062 cancel the effect.")
1064 (defvar exit-language-environment-hook nil
1065 "Normal hook run after exiting from some language environment.
1066 When this hook is run, the variable `current-language-environment'
1067 is still bound to the language environment being exited.
1069 This hook is mainly used for canceling the effect of
1070 `set-language-environment-hook' (which-see).")
1072 (put 'setup-specified-language-environment 'apropos-inhibit t)
1074 (defun setup-specified-language-environment ()
1075 "Switch to a specified language environment."
1077 (let (language-name)
1078 (if (and (symbolp last-command-event)
1079 (or (not (eq last-command-event 'Default))
1080 (setq last-command-event 'English))
1081 (setq language-name (symbol-name last-command-event)))
1082 (set-language-environment language-name)
1083 (error "Bogus calling sequence"))))
1085 (defcustom current-language-environment "English"
1086 "The last language environment specified with `set-language-environment'."
1087 :set (lambda (symbol value) (set-language-environment value))
1088 :initialize 'custom-initialize-default
1092 (defun reset-language-environment ()
1093 "Reset multilingual environment of Emacs to the default status.
1095 The default status is as follows:
1097 The default value of buffer-file-coding-system is nil.
1098 The default coding system for process I/O is nil.
1099 The default value for the command `set-terminal-coding-system' is nil.
1100 The default value for the command `set-keyboard-coding-system' is nil.
1102 The order of priorities of coding categories and the coding system
1103 bound to each category are as follows
1104 coding category coding system
1105 --------------------------------------------------
1106 coding-category-iso-8-2 iso-latin-1
1107 coding-category-iso-8-1 iso-latin-1
1108 coding-category-iso-7-tight iso-2022-jp
1109 coding-category-iso-7 iso-2022-7bit
1110 coding-category-iso-7-else iso-2022-7bit-lock
1111 coding-category-iso-8-else iso-2022-8bit-ss2
1112 coding-category-emacs-mule emacs-mule
1113 coding-category-raw-text raw-text
1114 coding-category-sjis japanese-shift-jis
1115 coding-category-big5 chinese-big5
1116 coding-category-ccl nil
1117 coding-category-binary no-conversion
1120 ;; This function formerly set default-enable-multibyte-characters to t,
1121 ;; but that is incorrect. It should not alter the unibyte/multibyte choice.
1123 (setq coding-category-iso-7-tight 'iso-2022-jp
1124 coding-category-iso-7 'iso-2022-7bit
1125 coding-category-iso-8-1 'iso-latin-1
1126 coding-category-iso-8-2 'iso-latin-1
1127 coding-category-iso-7-else 'iso-2022-7bit-lock
1128 coding-category-iso-8-else 'iso-2022-8bit-ss2
1129 coding-category-emacs-mule 'emacs-mule
1130 coding-category-raw-text 'raw-text
1131 coding-category-sjis 'japanese-shift-jis
1132 coding-category-big5 'chinese-big5
1133 coding-category-ccl nil
1134 coding-category-binary 'no-conversion)
1136 (set-coding-priority
1137 '(coding-category-iso-8-1
1138 coding-category-iso-8-2
1139 coding-category-iso-7-tight
1140 coding-category-iso-7
1141 coding-category-iso-7-else
1142 coding-category-iso-8-else
1143 coding-category-emacs-mule
1144 coding-category-raw-text
1145 coding-category-sjis
1146 coding-category-big5
1148 coding-category-binary))
1150 (update-coding-systems-internal)
1152 (set-default-coding-systems nil)
1153 ;; Don't alter the terminal and keyboard coding systems here.
1154 ;; The terminal still supports the same coding system
1155 ;; that it supported a minute ago.
1156 ;;; (set-terminal-coding-system-internal nil)
1157 ;;; (set-keyboard-coding-system-internal nil)
1159 (setq nonascii-translation-table nil
1160 nonascii-insert-offset 0))
1162 (defun set-language-environment (language-name)
1163 "Set up multi-lingual environment for using LANGUAGE-NAME.
1164 This sets the coding system priority and the default input method
1165 and sometimes other things. LANGUAGE-NAME should be a string
1166 which is the name of a language environment. For example, \"Latin-1\"
1167 specifies the character set for the major languages of Western Europe."
1168 (interactive (list (read-language-name
1170 "Set language environment (default, English): ")))
1172 (if (symbolp language-name)
1173 (setq language-name (symbol-name language-name)))
1174 (setq language-name "English"))
1175 (or (assoc-ignore-case language-name language-info-alist)
1176 (error "Language environment not defined: %S" language-name))
1177 (if current-language-environment
1178 (let ((func (get-language-info current-language-environment
1180 (run-hooks 'exit-language-environment-hook)
1181 (if (fboundp func) (funcall func))))
1182 (let ((default-eol-type (coding-system-eol-type
1183 default-buffer-file-coding-system)))
1184 (reset-language-environment)
1186 (setq current-language-environment language-name)
1187 (set-language-environment-coding-systems language-name default-eol-type))
1188 (let ((input-method (get-language-info language-name 'input-method)))
1190 (setq default-input-method input-method)
1191 (if input-method-history
1192 (setq input-method-history
1194 (delete input-method input-method-history))))))
1195 (let ((nonascii (get-language-info language-name 'nonascii-translation)))
1197 ((char-table-p nonascii)
1198 (setq nonascii-translation-table nonascii))
1199 ((eq window-system 'pc)
1200 ;; DOS terminals' default is to use a special non-ASCII translation
1201 ;; table as appropriate for the installed codepage.
1203 nonascii-translation-table (symbol-value
1207 "-nonascii-translation-table")))))
1208 ((charsetp nonascii)
1209 (setq nonascii-insert-offset (- (make-char nonascii) 128)))))
1211 (setq charset-origin-alist
1212 (get-language-info language-name 'charset-origin-alist))
1214 ;; Unibyte setups if necessary.
1215 (unless default-enable-multibyte-characters
1216 ;; Syntax and case table.
1217 (let ((syntax (get-language-info language-name 'unibyte-syntax)))
1219 (let ((set-case-syntax-set-multibyte nil))
1220 (load syntax nil t))
1221 ;; No information for syntax and case. Reset to the defaults.
1222 (let ((syntax-table (standard-syntax-table))
1223 (case-table (standard-case-table))
1224 (ch (if (eq window-system 'pc) 128 160)))
1226 (modify-syntax-entry ch " " syntax-table)
1227 (aset case-table ch ch)
1229 (set-char-table-extra-slot case-table 0 nil)
1230 (set-char-table-extra-slot case-table 1 nil)
1231 (set-char-table-extra-slot case-table 2 nil))
1232 (set-standard-case-table (standard-case-table))
1233 (let ((list (buffer-list)))
1235 (with-current-buffer (car list)
1236 (set-case-table (standard-case-table)))
1237 (setq list (cdr list))))))
1238 ;; Display table and coding system for terminal.
1239 (let ((coding (get-language-info language-name 'unibyte-display)))
1241 (standard-display-european-internal)
1242 (standard-display-default (if (eq window-system 'pc) 128 160) 255)
1243 (aset standard-display-table 146 nil))
1244 (or (eq window-system 'pc)
1245 (set-terminal-coding-system coding))))
1247 (let ((required-features (get-language-info language-name 'features)))
1248 (while required-features
1249 (require (car required-features))
1250 (setq required-features (cdr required-features))))
1251 (let ((func (get-language-info language-name 'setup-function)))
1254 (run-hooks 'set-language-environment-hook)
1255 (force-mode-line-update t))
1257 (defun standard-display-european-internal ()
1258 ;; Actually set up direct output of non-ASCII characters.
1259 (standard-display-8bit (if (eq window-system 'pc) 128 160) 255)
1260 ;; Unibyte Emacs on MS-DOS wants to display all 8-bit characters with
1261 ;; the native font, and codes 160 and 146 stand for something very
1263 (or (and (eq window-system 'pc) (not default-enable-multibyte-characters))
1265 ;; Make non-line-break space display as a plain space.
1266 ;; Most X fonts do the wrong thing for code 160.
1267 (aset standard-display-table 160 [32])
1268 ;; Most Windows programs send out apostrophe's as \222. Most X fonts
1269 ;; don't contain a character at that position. Map it to the ASCII
1271 (aset standard-display-table 146 [39]))))
1273 (defun set-language-environment-coding-systems (language-name
1275 "Do various coding system setups for language environment LANGUAGE-NAME.
1277 The optional arg EOL-TYPE specifies the eol-type of the default value
1278 of buffer-file-coding-system set by this function."
1279 (let* ((priority (get-language-info language-name 'coding-priority))
1280 (default-coding (car priority)))
1282 (let ((categories (mapcar 'coding-system-category priority)))
1283 (set-default-coding-systems
1284 (if (memq eol-type '(0 1 2 unix dos mac))
1285 (coding-system-change-eol-conversion default-coding eol-type)
1287 (setq default-sendmail-coding-system default-coding)
1288 (set-coding-priority categories)
1290 (set (car categories) (car priority))
1291 (setq priority (cdr priority) categories (cdr categories)))
1292 (update-coding-systems-internal)))))
1294 ;; Print all arguments with `princ', then print "\n".
1295 (defsubst princ-list (&rest args)
1296 (while args (princ (car args)) (setq args (cdr args)))
1299 (put 'describe-specified-language-support 'apropos-inhibit t)
1301 ;; Print a language specific information such as input methods,
1302 ;; charsets, and coding systems. This function is intended to be
1303 ;; called from the menu:
1304 ;; [menu-bar mule describe-language-environment LANGUAGE]
1305 ;; and should not run it by `M-x describe-current-input-method-function'.
1306 (defun describe-specified-language-support ()
1307 "Describe how Emacs supports the specified language environment."
1309 (let (language-name)
1310 (if (not (and (symbolp last-command-event)
1311 (setq language-name (symbol-name last-command-event))))
1312 (error "Bogus calling sequence"))
1313 (describe-language-environment language-name)))
1315 (defun describe-language-environment (language-name)
1316 "Describe how Emacs supports language environment LANGUAGE-NAME."
1318 (list (read-language-name
1320 "Describe language environment (default, current choice): ")))
1321 (if (null language-name)
1322 (setq language-name current-language-environment))
1323 (if (or (null language-name)
1324 (null (get-language-info language-name 'documentation)))
1325 (error "No documentation for the specified language"))
1326 (if (symbolp language-name)
1327 (setq language-name (symbol-name language-name)))
1328 (let ((doc (get-language-info language-name 'documentation)))
1329 (with-output-to-temp-buffer "*Help*"
1330 (princ-list language-name " language environment" "\n")
1335 (let ((str (get-language-info language-name 'sample-text)))
1338 (princ "Sample text:\n")
1339 (princ-list " " str)
1341 (let ((input-method (get-language-info language-name 'input-method))
1342 (l input-method-alist))
1343 (princ "Input methods")
1345 (princ (format " (default, %s)" input-method))
1346 (setq input-method (assoc input-method input-method-alist))
1347 (setq l (cons input-method (delete input-method l))))
1350 (if (string= language-name (nth 1 (car l)))
1351 (princ-list " " (car (car l))
1352 (format " (`%s' in mode line)" (nth 3 (car l)))))
1355 (princ "Character sets:\n")
1356 (let ((l (get-language-info language-name 'charset)))
1358 (princ-list " nothing specific to " language-name)
1360 (princ-list " " (car l) ": "
1361 (charset-description (car l)))
1364 (princ "Coding systems:\n")
1365 (let ((l (get-language-info language-name 'coding-system)))
1367 (princ-list " nothing specific to " language-name)
1369 (princ (format " %s (`%c' in mode line):\n\t%s\n"
1371 (coding-system-mnemonic (car l))
1372 (coding-system-doc-string (car l))))
1373 (let ((aliases (coding-system-get (car l) 'alias-coding-systems)))
1376 (princ (cons 'alias: (cdr aliases)))
1378 (setq l (cdr l))))))))
1380 ;;; Charset property
1382 (defun get-charset-property (charset propname)
1383 "Return the value of CHARSET's PROPNAME property.
1384 This is the last value stored with
1385 (put-charset-property CHARSET PROPNAME VALUE)."
1386 (and (not (eq charset 'composition))
1387 (plist-get (charset-plist charset) propname)))
1389 (defun put-charset-property (charset propname value)
1390 "Store CHARSETS's PROPNAME property with value VALUE.
1391 It can be retrieved with `(get-charset-property CHARSET PROPNAME)'."
1392 (or (eq charset 'composition)
1393 (set-charset-plist charset
1394 (plist-put (charset-plist charset) propname value))))
1396 ;;; Character code property
1397 (put 'char-code-property-table 'char-table-extra-slots 0)
1399 (defvar char-code-property-table
1400 (make-char-table 'char-code-property-table)
1401 "Char-table containing a property list of each character code.
1403 See also the documentation of `get-char-code-property' and
1404 `put-char-code-property'.")
1406 (defun get-char-code-property (char propname)
1407 "Return the value of CHAR's PROPNAME property in `char-code-property-table'."
1408 (let ((plist (aref char-code-property-table char)))
1410 (car (cdr (memq propname plist))))))
1412 (defun put-char-code-property (char propname value)
1413 "Store CHAR's PROPNAME property with VALUE in `char-code-property-table'.
1414 It can be retrieved with `(get-char-code-property CHAR PROPNAME)'."
1415 (let ((plist (aref char-code-property-table char)))
1417 (let ((slot (memq propname plist)))
1419 (setcar (cdr slot) value)
1420 (nconc plist (list propname value))))
1421 (aset char-code-property-table char (list propname value)))))
1423 ;;; mule-cmds.el ends here