aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKenichi Handa1998-08-10 06:29:02 +0000
committerKenichi Handa1998-08-10 06:29:02 +0000
commitddb5c0419c10ae1dd7f471649f7146df7ff345ca (patch)
treee9e1591a77bb1c26528c9e2802d15977a6754760
parent5b984695118f141774e7fa217ace4095cddc16c7 (diff)
downloademacs-ddb5c0419c10ae1dd7f471649f7146df7ff345ca.tar.gz
emacs-ddb5c0419c10ae1dd7f471649f7146df7ff345ca.zip
(language-info-alist): Doc-string modified.
(reset-language-environment): New function for the job that setup-english-environment used to do. (set-language-environment): Do more setups according to the info in language-info-alist. (read-language-name): Handle the case that the arg KEY is nil. * (describe-language-environment): Handle input-method property.
-rw-r--r--lisp/international/mule-cmds.el163
1 files changed, 146 insertions, 17 deletions
diff --git a/lisp/international/mule-cmds.el b/lisp/international/mule-cmds.el
index a9eab9e9f2f..abda95f64dd 100644
--- a/lisp/international/mule-cmds.el
+++ b/lisp/international/mule-cmds.el
@@ -507,15 +507,29 @@ Meaningful values for KEY include
507 environment, in order of decreasing priority. 507 environment, in order of decreasing priority.
508 This is used to set up the coding system priority 508 This is used to set up the coding system priority
509 list when you switch to this language environment. 509 list when you switch to this language environment.
510 510 nonascii-translation
511 nonascii-translation-table
512 value is a translation table to be set to the 511 value is a translation table to be set to the
513 variable `nonascii-translation-table' in this 512 variable `nonascii-translation-table' in this
514 language environment. 513 language environment.
515
516 charset-origin-alist 514 charset-origin-alist
517 value is an alist to be set to the variable 515 value is an alist to be set to the variable
518 `charset-origin-alist' in this language environment.") 516 `charset-origin-alist' in this language environment.
517 input-method value is a default input method for this language
518 environment.
519
520The following keys take effect only when multibyte characters are
521globally disabled, i.e. the value of `default-enable-multibyte-characters'
522is nil.
523
524 unibyte-syntax value is a library name to load to set
525 unibyte 8-bit charcater syntaxes for this
526 language environment.
527
528 unibyte-display value is a coding system to encode characters
529 for the terminal. Characters in the range
530 of 160 to 255 display not as octal escapes,
531 but as non-ASCII characters in this language
532 environment.")
519 533
520(defun get-language-info (lang-env key) 534(defun get-language-info (lang-env key)
521 "Return information listed under KEY for language environment LANG-ENV. 535 "Return information listed under KEY for language environment LANG-ENV.
@@ -608,15 +622,18 @@ in the European submenu in each of those two menus."
608 622
609(defun read-language-name (key prompt &optional default) 623(defun read-language-name (key prompt &optional default)
610 "Read a language environment name which has information for KEY. 624 "Read a language environment name which has information for KEY.
625If KEY is nil, read any language environment.
611Prompt with PROMPT. DEFAULT is the default choice of language environment. 626Prompt with PROMPT. DEFAULT is the default choice of language environment.
612This returns a language environment name as a string." 627This returns a language environment name as a string."
613 (let* ((completion-ignore-case t) 628 (let* ((completion-ignore-case t)
614 (name (completing-read prompt 629 (name (completing-read prompt
615 language-info-alist 630 language-info-alist
616 (function (lambda (elm) (assq key elm))) 631 (and key
632 (function (lambda (elm) (assq key elm))))
617 t nil nil default))) 633 t nil nil default)))
618 (if (and (> (length name) 0) 634 (if (and (> (length name) 0)
619 (get-language-info name key)) 635 (or (not key)
636 (get-language-info name key)))
620 name))) 637 name)))
621 638
622;;; Multilingual input methods. 639;;; Multilingual input methods.
@@ -984,6 +1001,74 @@ This hook is mainly used for cancelling the effect of
984 :group 'mule 1001 :group 'mule
985 :type 'string) 1002 :type 'string)
986 1003
1004(defun reset-language-environment ()
1005 "Reset multilingual environment of Emacs to the default status.
1006
1007The default status is as follows:
1008
1009 The default value of buffer-file-coding-system is nil.
1010 The default coding system for process I/O is nil.
1011 The default value for the command `set-terminal-coding-system' is nil.
1012 The default value for the command `set-keyboard-coding-system' is nil.
1013
1014 The order of priorities of coding categories and the coding system
1015 bound to each category are as follows
1016 coding category coding system
1017 --------------------------------------------------
1018 coding-category-iso-8-2 iso-latin-1
1019 coding-category-iso-8-1 iso-latin-1
1020 coding-category-iso-7-tight iso-2022-jp
1021 coding-category-iso-7 iso-2022-7bit
1022 coding-category-iso-7-else iso-2022-7bit-lock
1023 coding-category-iso-8-else iso-2022-8bit-ss2
1024 coding-category-emacs-mule emacs-mule
1025 coding-category-raw-text raw-text
1026 coding-category-sjis japanese-shift-jis
1027 coding-category-big5 chinese-big5
1028 coding-category-ccl nil
1029 coding-category-binarry no-conversion
1030"
1031 (interactive)
1032 ;; This function formerly set default-enable-multibyte-characters to t,
1033 ;; but that is incorrect. It should not alter the unibyte/multibyte choice.
1034
1035 (setq coding-category-iso-7-tight 'iso-2022-jp
1036 coding-category-iso-7 'iso-2022-7bit
1037 coding-category-iso-8-1 'iso-latin-1
1038 coding-category-iso-8-2 'iso-latin-1
1039 coding-category-iso-7-else 'iso-2022-7bit-lock
1040 coding-category-iso-8-else 'iso-2022-8bit-ss2
1041 coding-category-emacs-mule 'emacs-mule
1042 coding-category-raw-text 'raw-text
1043 coding-category-sjis 'japanese-shift-jis
1044 coding-category-big5 'chinese-big5
1045 coding-category-ccl nil
1046 coding-category-binary 'no-conversion)
1047
1048 (set-coding-priority
1049 '(coding-category-iso-8-1
1050 coding-category-iso-8-2
1051 coding-category-iso-7-tight
1052 coding-category-iso-7
1053 coding-category-iso-7-else
1054 coding-category-iso-8-else
1055 coding-category-emacs-mule
1056 coding-category-raw-text
1057 coding-category-sjis
1058 coding-category-big5
1059 coding-category-ccl
1060 coding-category-binary))
1061
1062 (set-default-coding-systems nil)
1063 ;; Don't alter the terminal and keyboard coding systems here.
1064 ;; The terminal still supports the same coding system
1065 ;; that it supported a minute ago.
1066;;; (set-terminal-coding-system-internal nil)
1067;;; (set-keyboard-coding-system-internal nil)
1068
1069 (setq nonascii-translation-table nil
1070 nonascii-insert-offset 0))
1071
987(defun set-language-environment (language-name) 1072(defun set-language-environment (language-name)
988 "Set up multi-lingual environment for using LANGUAGE-NAME. 1073 "Set up multi-lingual environment for using LANGUAGE-NAME.
989This sets the coding system priority and the default input method 1074This sets the coding system priority and the default input method
@@ -991,29 +1076,67 @@ and sometimes other things. LANGUAGE-NAME should be a string
991which is the name of a language environment. For example, \"Latin-1\" 1076which is the name of a language environment. For example, \"Latin-1\"
992specifies the character set for the major languages of Western Europe." 1077specifies the character set for the major languages of Western Europe."
993 (interactive (list (read-language-name 1078 (interactive (list (read-language-name
994 'setup-function 1079 nil
995 "Set language environment (default, English): "))) 1080 "Set language environment (default, English): ")))
996 (if language-name 1081 (if language-name
997 (if (symbolp language-name) 1082 (if (symbolp language-name)
998 (setq language-name (symbol-name language-name))) 1083 (setq language-name (symbol-name language-name)))
999 (setq language-name "English")) 1084 (setq language-name "English"))
1000 (if (null (get-language-info language-name 'setup-function)) 1085 (or (assoc-ignore-case language-name language-info-alist)
1001 (error "Language environment not defined: %S" language-name)) 1086 (error "Language environment not defined: %S" language-name))
1002 (if current-language-environment 1087 (if current-language-environment
1003 (let ((func (get-language-info current-language-environment 1088 (let ((func (get-language-info current-language-environment
1004 'exit-function))) 1089 'exit-function)))
1005 (run-hooks 'exit-language-environment-hook) 1090 (run-hooks 'exit-language-environment-hook)
1006 (if (fboundp func) (funcall func)))) 1091 (if (fboundp func) (funcall func))))
1007 (when (and (not default-enable-multibyte-characters) 1092 (reset-language-environment)
1008 (get-language-info language-name 'unibyte-syntax)) 1093
1009 (set-terminal-coding-system (intern (downcase language-name)))
1010 (standard-display-european-internal))
1011 (setq current-language-environment language-name) 1094 (setq current-language-environment language-name)
1012 (setq nonascii-translation-table 1095 (set-language-environment-coding-systems language-name)
1013 (get-language-info language-name 'nonascii-translation-table)) 1096 (let ((input-method (get-language-info language-name 'input-method)))
1097 (when input-method
1098 (setq default-input-method input-method)
1099 (if input-method-history
1100 (setq input-method-history
1101 (cons input-method
1102 (delete input-method input-method-history))))))
1103 (let ((nonascii (get-language-info language-name 'nonascii-translation)))
1104 (if (char-table-p nonascii)
1105 (setq nonascii-translation-table nonascii)
1106 (if (charsetp nonascii)
1107 (setq nonascii-insert-offset (- (make-char nonascii) 128)))))
1108
1014 (setq charset-origin-alist 1109 (setq charset-origin-alist
1015 (get-language-info language-name 'charset-origin-alist)) 1110 (get-language-info language-name 'charset-origin-alist))
1016 (funcall (get-language-info language-name 'setup-function)) 1111
1112 (unless default-enable-multibyte-characters
1113 ;; Unibyte setups.
1114 (let ((syntax (get-language-info language-name 'unibyte-syntax)))
1115 (if syntax
1116 (let ((set-case-syntax-set-multibyte nil))
1117 (load syntax nil t)
1118 (set-standard-case-table (standard-case-table))
1119 (let ((list (buffer-list)))
1120 (while list
1121 (with-current-buffer (car list)
1122 (set-case-table (standard-case-table)))
1123 (setq list (cdr list)))))))
1124 (let ((coding (get-language-info language-name 'unibyte-display)))
1125 (if coding
1126 (progn
1127 (standard-display-european-internal)
1128 (set-terminal-coding-system coding))
1129 (standard-display-default 160 255)
1130 (aset standard-display-table 146 nil)
1131 (set-terminal-coding-system nil))))
1132
1133 (let ((required-features (get-language-info language-name 'features)))
1134 (while required-features
1135 (require (car required-features))
1136 (setq required-features (cdr required-features))))
1137 (let ((func (get-language-info language-name 'setup-function)))
1138 (if (fboundp func)
1139 (funcall func)))
1017 (run-hooks 'set-language-environment-hook) 1140 (run-hooks 'set-language-environment-hook)
1018 (force-mode-line-update t)) 1141 (force-mode-line-update t))
1019 1142
@@ -1086,8 +1209,14 @@ specifies the character set for the major languages of Western Europe."
1086 (princ "Sample text:\n") 1209 (princ "Sample text:\n")
1087 (princ-list " " str) 1210 (princ-list " " str)
1088 (terpri)))) 1211 (terpri))))
1089 (princ "Input methods:\n") 1212 (let ((input-method (get-language-info language-name 'input-method))
1090 (let ((l input-method-alist)) 1213 (l input-method-alist))
1214 (princ "Input methods")
1215 (when input-method
1216 (princ (format " (default, %s)" input-method))
1217 (setq input-method (assoc input-method input-method-alist))
1218 (setq l (cons input-method (delete input-method l))))
1219 (princ ":\n")
1091 (while l 1220 (while l
1092 (if (string= language-name (nth 1 (car l))) 1221 (if (string= language-name (nth 1 (car l)))
1093 (princ-list " " (car (car l)) 1222 (princ-list " " (car (car l))