• Home
  • History
  • Annotate
  • Raw
  • Download
  • only in /macosx-10.10/emacs-93/emacs/lisp/international/

Lines Matching +defs:default +defs:file +defs:name +defs:coding +defs:system

1 ;;; mule-cmds.el --- commands for mulitilingual environment -*-coding: iso-2022-7bit -*-
12 ;; This file is part of GNU Emacs.
25 ;; along with GNU Emacs; see the file COPYING. If not, write to the
37 (defvar mac-system-coding-system)
38 (defvar mac-system-locale)
48 (define-key mule-keymap "f" 'set-buffer-file-coding-system)
49 (define-key mule-keymap "r" 'revert-buffer-with-coding-system)
50 (define-key mule-keymap "F" 'set-file-name-coding-system)
51 (define-key mule-keymap "t" 'set-terminal-coding-system)
52 (define-key mule-keymap "k" 'set-keyboard-coding-system)
53 (define-key mule-keymap "p" 'set-buffer-process-coding-system)
54 (define-key mule-keymap "x" 'set-selection-coding-system)
55 (define-key mule-keymap "X" 'set-next-selection-coding-system)
57 (define-key mule-keymap "c" 'universal-coding-system-argument)
70 (defvar set-coding-system-map
89 (define-key-after mule-menu-keymap [set-various-coding-system]
90 (list 'menu-item "Set Coding Systems" set-coding-system-map
91 :enable 'default-enable-multibyte-characters))
92 (define-key-after mule-menu-keymap [view-hello-file]
93 '(menu-item "Show Multi-lingual Text" view-hello-file
94 :enable (file-readable-p
95 (expand-file-name "HELLO" data-directory))
96 :help "Display file which says HELLO in many languages")
98 (define-key-after mule-menu-keymap [separator-coding-system]
110 (define-key-after mule-menu-keymap [describe-coding-system]
111 '(menu-item "Describe Coding System..." describe-coding-system)
121 (define-key-after set-coding-system-map [universal-coding-system-argument]
122 '(menu-item "For Next Command" universal-coding-system-argument
123 :help "Coding system to be used by next command")
125 (define-key-after set-coding-system-map [separator-1]
128 (define-key-after set-coding-system-map [set-buffer-file-coding-system]
129 '(menu-item "For Saving This Buffer" set-buffer-file-coding-system
132 (define-key-after set-coding-system-map [revert-buffer-with-coding-system]
133 '(menu-item "For Reverting This File Now" revert-buffer-with-coding-system
134 :enable buffer-file-name
135 :help "Revisit this file immediately using specified coding system")
137 (define-key-after set-coding-system-map [set-file-name-coding-system]
138 '(menu-item "For File Name" set-file-name-coding-system
139 :help "How to decode/encode file names")
141 (define-key-after set-coding-system-map [separator-2]
145 (define-key-after set-coding-system-map [set-keyboard-coding-system]
146 '(menu-item "For Keyboard" set-keyboard-coding-system
149 (define-key-after set-coding-system-map [set-terminal-coding-system]
150 '(menu-item "For Terminal" set-terminal-coding-system
151 :enable (null (memq window-system '(x w32 mac)))
154 (define-key-after set-coding-system-map [separator-3]
157 (define-key-after set-coding-system-map [set-selection-coding-system]
158 '(menu-item "For X Selections/Clipboard" set-selection-coding-system
162 (define-key-after set-coding-system-map [set-next-selection-coding-system]
163 '(menu-item "For Next X Selection" set-next-selection-coding-system
167 (define-key-after set-coding-system-map [set-buffer-process-coding-system]
168 '(menu-item "For I/O with Subprocess" set-buffer-process-coding-system
197 "\\(coding system\\)\\|"
205 (defun coding-system-change-eol-conversion (coding-system eol-type)
206 "Return a coding system which differs from CODING-SYSTEM in eol conversion.
207 The returned coding system converts end-of-line by EOL-TYPE
210 If EOL-TYPE is nil, the returned coding system detects
220 ;; We call `coding-system-base' before `coding-system-eol-type',
221 ;; because the coding-system may not be initialized until then.
222 (let* ((base (coding-system-base coding-system))
223 (orig-eol-type (coding-system-eol-type coding-system)))
226 coding-system
231 coding-system)
232 ((progn (setq orig-eol-type (coding-system-eol-type base))
236 (defun coding-system-change-text-conversion (coding-system coding)
237 "Return a coding system which differs from CODING-SYSTEM in text conversion.
238 The returned coding system converts text by CODING
240 If CODING is nil, the returned coding system detects
242 (let ((eol-type (coding-system-eol-type coding-system)))
243 (coding-system-change-eol-conversion
244 (if coding coding 'undecided)
266 (defun view-hello-file ()
267 "Display the HELLO file which list up many languages and characters."
269 ;; We have to decode the file in any environment.
270 (let ((default-enable-multibyte-characters t)
271 (coding-system-for-read 'iso-2022-7bit))
272 (view-file (expand-file-name "HELLO" data-directory))))
274 (defun universal-coding-system-argument (coding-system)
275 "Execute an I/O command using the specified coding system."
277 (let ((default (and buffer-file-coding-system
278 (not (eq (coding-system-type buffer-file-coding-system)
280 buffer-file-coding-system)))
281 (list (read-coding-system
282 (if default
283 (format "Coding system for following command (default %s): " default)
284 "Coding system for following command: ")
285 default))))
287 (format "Command to execute with %s:" coding-system)))
316 (let ((coding-system-for-read coding-system)
317 (coding-system-for-write coding-system)
318 (coding-system-require-warning t)
323 (defun set-default-coding-systems (coding-system)
324 "Set default value of various coding systems to CODING-SYSTEM.
325 This sets the following coding systems:
326 o coding system of a newly created buffer
327 o default coding system for subprocess I/O
329 o default value used as `file-name-coding-system' for converting file names
331 o default value for the command `set-terminal-coding-system' (not on MSDOS)
332 o default value for the command `set-keyboard-coding-system'
334 (check-coding-system coding-system)
335 (setq-default buffer-file-coding-system coding-system)
338 (or (local-variable-p 'buffer-file-coding-system buffer)
341 (if (eq system-type 'darwin)
342 ;; The file-name coding system on Darwin systems is always utf-8.
343 (setq default-file-name-coding-system 'utf-8)
344 (if (and default-enable-multibyte-characters
345 (or (not coding-system)
346 (not (coding-system-get coding-system 'ascii-incompatible))))
347 (setq default-file-name-coding-system coding-system)))
348 ;; If coding-system is nil, honor that on MS-DOS as well, so
349 ;; that they could reset the terminal coding system.
350 (unless (and (eq window-system 'pc) coding-system)
351 (setq default-terminal-coding-system coding-system))
352 (if (or (not coding-system)
353 (not (coding-system-get coding-system 'ascii-incompatible)))
354 (setq default-keyboard-coding-system coding-system))
355 ;; Preserve eol-type from existing default-process-coding-systems.
360 (let ((output-coding
361 (coding-system-change-text-conversion
362 (car default-process-coding-system) coding-system))
363 (input-coding
364 (coding-system-change-text-conversion
365 (cdr default-process-coding-system) coding-system)))
366 (setq default-process-coding-system
367 (cons output-coding input-coding))))
369 (defun prefer-coding-system (coding-system)
371 This also sets the following coding systems:
372 o coding system of a newly created buffer
373 o default coding system for subprocess I/O
375 o default value used as `file-name-coding-system' for converting file names.
376 o default value for the command `set-terminal-coding-system' (not on MSDOS)
377 o default value for the command `set-keyboard-coding-system'
379 If CODING-SYSTEM specifies a certain type of EOL conversion, the coding
382 This command does not change the default value of terminal coding system
383 for MS-DOS terminal, because DOS terminals only support a single coding
384 system, and Emacs automatically sets the default to that coding system at
387 A coding system that requires automatic detection of text
390 See also `coding-category-list' and `coding-system-category'."
391 (interactive "zPrefer coding system: ")
392 (if (not (and coding-system (coding-system-p coding-system)))
393 (error "Invalid coding system `%s'" coding-system))
394 (let ((coding-category (coding-system-category coding-system))
395 (base (coding-system-base coding-system))
396 (eol-type (coding-system-eol-type coding-system)))
397 (if (not coding-category)
399 (error "Can't prefer the coding system `%s'" coding-system))
400 (set coding-category (or base coding-system))
401 ;; Changing the binding of a coding category requires this call.
402 (update-coding-systems-internal)
403 (or (eq coding-category (car coding-category-list))
405 (set-coding-priority (list coding-category)))
408 base coding-system))
411 (setq coding-system
412 (coding-system-change-eol-conversion base eol-type))
413 (setq coding-system base))
414 (set-default-coding-systems coding-system)))
416 (defvar sort-coding-systems-predicate nil
417 "If non-nil, a predicate function to sort coding systems.
419 It is called with two coding systems, and should return t if the first
422 The function `sort-coding-systems' use it.")
424 (defun sort-coding-systems (codings)
425 "Sort coding system list CODINGS by a priority of each coding system.
428 If a coding system is most preferred, it has the highest priority.
429 Otherwise, a coding system corresponds to some MIME charset has higher
430 priorities. Among them, a coding system included in `coding-system'
434 If the variable `sort-coding-systems-predicate' (which see) is
436 (if sort-coding-systems-predicate
437 (sort codings sort-coding-systems-predicate)
439 coding-category-list))
442 'coding-system))
445 (let ((base (coding-system-base x)))
457 (let ((mime (coding-system-get base 'mime-charset)))
458 ;; Prefer coding systems corresponding to a
465 (symbol-name mime))
467 ((string-match "^x-" (symbol-name mime))
475 (symbol-name base))
477 (if (eq (coding-system-type base) 2)
478 ;; For ISO based coding systems, prefer
480 (let ((flags (coding-system-flags base)))
493 (defun find-coding-systems-region (from to)
494 "Return a list of proper coding systems to encode a text between FROM and TO.
495 If FROM is a string, find coding systems in that instead of the buffer.
496 All coding systems in the list can safely encode any multibyte characters
501 (let ((codings (find-coding-systems-region-internal from to)))
503 ;; The text contains only ASCII characters. Any coding
507 (sort-coding-systems (copy-sequence codings)))))
509 (defun find-coding-systems-string (string)
510 "Return a list of proper coding systems to encode STRING.
511 All coding systems in the list can safely encode any multibyte characters
516 (find-coding-systems-region string nil))
518 (defun find-coding-systems-for-charsets (charsets)
519 "Return a list of proper coding systems to encode characters of CHARSETS.
523 contain a coding system that can't encode all characters of the charset."
549 (setq l (find-coding-systems-string str))
613 (defun search-unencodable-char (coding-system)
615 It asks which coding system to check.
622 (list (let ((default (or buffer-file-coding-system 'us-ascii)))
623 (read-coding-system
624 (format "Coding-system (default %s): " default)
625 default))))
626 (let ((pos (unencodable-char-position (point) (point-max) coding-system)))
629 (message "All following characters are encodable by %s" coding-system))
633 (defvar last-coding-system-specified nil
634 "Most recent coding system explicitly specified by the user when asked.
635 This variable is set whenever Emacs asks the user which coding system
636 to use in order to write a file. If you set it to nil explicitly,
638 only if the user was explicitly asked and specified a coding system.")
640 (defvar select-safe-coding-system-accept-default-p nil
641 "If non-nil, a function to control the behavior of coding system selection.
643 function `select-safe-coding-system' (which see). This variable
646 (defun select-safe-coding-system-interactively (from to codings unsafe
647 &optional rejected default)
648 "Select interactively a coding system for the region FROM ... TO.
650 CODINGS is the list of base coding systems known to be safe for this region,
651 typically obtained with `find-coding-systems-region'.
652 UNSAFE is a list of coding systems known to be unsafe for this region.
653 REJECTED is a list of coding systems which were safe but for some reason
655 DEFAULT is the coding system to use by default in the query."
663 (mapcar #'(lambda (coding)
664 (cons coding
669 0 (length from) coding
674 from to coding 11)))))
677 ;; Change each safe coding system to the corresponding
678 ;; mime-charset name if it is also a coding system. Such a name
683 (setq mime-charset (coding-system-get (car l) 'mime-charset))
684 (if (and mime-charset (coding-system-p mime-charset))
692 (unless (or (eq 'coding-category-iso-7-else
693 (coding-system-category elt))
694 (eq 'coding-category-iso-8-else
695 (coding-system-category elt)))
707 (bufname (buffer-name))
708 coding-system)
721 (insert "No default coding systems to try for "
726 "These default coding systems were tried to encode"
747 (insert (if rejected "The other coding systems"
750 (dolist (coding unsafe)
751 (insert (format " %s cannot encode these:" (car coding)))
759 #'(lambda (bufname pos coding)
765 (search-unencodable-char coding)
767 (dolist (elt (cdr coding))
788 (car coding)))))
797 one of the safe coding systems listed below,\n\
800 or specify any other coding system (and risk losing\n\
809 ;; Read a coding system.
810 (setq coding-system
811 (read-coding-system
812 (format "Select coding system (default %s): " default)
813 default))
814 (setq last-coding-system-specified coding-system))
818 coding-system))
820 (defun select-safe-coding-system (from to &optional default-coding-system
821 accept-default-p file)
822 "Ask a user to select a safe coding system from candidates.
823 The candidates of coding systems which can safely encode a text
825 proper one is suggested as the default.
827 The list of `buffer-file-coding-system' of the current buffer,
828 the `default-buffer-file-coding-system', and the
829 most preferred coding system (if it corresponds to a MIME charset) is
830 treated as the default coding system list. Among them, the first one
833 `prefer-coding-system'.
835 However, the user is queried if the chosen coding system is
836 inconsistent with what would be selected by `find-auto-coding' from
837 coding cookies &c. if the contents of the region were read from a
838 file. (That could lead to data corruption in a file subsequently
841 Optional 3rd arg DEFAULT-CODING-SYSTEM specifies a coding system or a
842 list of coding systems to be prepended to the default coding system
844 element is t, the cdr part is used as the default coding system list,
845 i.e. `buffer-file-coding-system', `default-buffer-file-coding-system',
846 and the most preferred coding system are not used.
849 determine the acceptability of the silently selected coding system.
850 It is called with that coding system, and should return nil if it
853 Optional 5th arg FILE is the file name to use for this purpose.
854 That is different from `buffer-file-name' when handling `write-region'
857 The variable `select-safe-coding-system-accept-default-p', if
862 (if (and default-coding-system
863 (not (listp default-coding-system)))
864 (setq default-coding-system (list default-coding-system)))
868 (unless (or (stringp from) find-file-literally)
869 ;; Find an auto-coding that is specified for the the current
870 ;; buffer and file from the region FROM and TO.
875 (setq auto-cs (find-auto-coding (or file buffer-file-name "")
878 (if (coding-system-p (car auto-cs))
883 Invalid coding system `%s' is specified
884 for the current buffer/file by the %s.
885 It is highly recommended to fix it before writing to a file."
887 (if (eq (cdr auto-cs) :coding) ":coding tag"
893 (if (eq (car default-coding-system) t)
895 default-coding-system (cdr default-coding-system)))
897 ;; Change elements of the list to (coding . base-coding).
898 (setq default-coding-system
899 (mapcar (function (lambda (x) (cons x (coding-system-base x))))
900 default-coding-system))
903 ;; If the file has a coding cookie, try to use it before anything
904 ;; else (i.e. before default-coding-system which will typically come
905 ;; from file-coding-system-alist).
906 (let ((base (coding-system-base auto-cs)))
908 (rassq base default-coding-system)
909 (push (cons auto-cs base) default-coding-system))))
912 ;; If buffer-file-coding-system is not nil nor undecided, append it
914 (if buffer-file-coding-system
915 (let ((base (coding-system-base buffer-file-coding-system)))
917 (rassq base default-coding-system)
918 (setq default-coding-system
919 (append default-coding-system
920 (list (cons buffer-file-coding-system base)))))))
922 ;; If default-buffer-file-coding-system is not nil nor undecided,
924 (if default-buffer-file-coding-system
925 (let ((base (coding-system-base default-buffer-file-coding-system)))
927 (rassq base default-coding-system)
928 (setq default-coding-system
929 (append default-coding-system
930 (list (cons default-buffer-file-coding-system
933 ;; If the most preferred coding system has the property mime-charset,
935 (let ((tail coding-category-list)
939 (and (coding-system-p preferred)
940 (setq base (coding-system-base preferred))
941 (coding-system-get preferred 'mime-charset)
942 (not (rassq base default-coding-system))
943 (setq default-coding-system
944 (append default-coding-system
947 (if select-safe-coding-system-accept-default-p
948 (setq accept-default-p select-safe-coding-system-accept-default-p))
950 ;; Decide the eol-type from the top of the default codings,
951 ;; buffer-file-coding-system, or
952 ;; default-buffer-file-coding-system.
953 (if default-coding-system
954 (let ((default-eol-type (coding-system-eol-type
955 (caar default-coding-system))))
956 (if (and (vectorp default-eol-type) buffer-file-coding-system)
957 (setq default-eol-type (coding-system-eol-type
958 buffer-file-coding-system)))
959 (if (and (vectorp default-eol-type) default-buffer-file-coding-system)
960 (setq default-eol-type (coding-system-eol-type
961 default-buffer-file-coding-system)))
962 (if (and default-eol-type (not (vectorp default-eol-type)))
963 (dolist (elt default-coding-system)
964 (setcar elt (coding-system-change-eol-conversion
965 (car elt) default-eol-type))))))
967 (let ((codings (find-coding-systems-region from to))
968 (coding-system nil)
971 ;; Any coding system is ok.
972 (setq coding-system (caar default-coding-system))
975 (setq default-coding-system (nreverse default-coding-system))
978 (dolist (elt default-coding-system)
980 (if (and (functionp accept-default-p)
981 (not (funcall accept-default-p (cdr elt))))
986 (setq coding-system (car safe))))
989 (when (not coding-system)
990 (setq coding-system (select-safe-coding-system-interactively
993 ;; Check we're not inconsistent with what `coding:' spec &c would
994 ;; give when file is re-read.
996 ;; by using `find-file-literally'.
999 coding-system
1000 (memq (coding-system-type coding-system) '(0 5)))))
1001 ;; Merge coding-system and auto-cs as far as possible.
1002 (if (not coding-system)
1003 (setq coding-system auto-cs)
1005 (setq auto-cs coding-system)
1006 (let ((eol-type-1 (coding-system-eol-type coding-system))
1007 (eol-type-2 (coding-system-eol-type auto-cs)))
1008 (if (eq (coding-system-base coding-system) 'undecided)
1009 (setq coding-system (coding-system-change-text-conversion
1010 coding-system auto-cs))
1011 (if (eq (coding-system-base auto-cs) 'undecided)
1012 (setq auto-cs (coding-system-change-text-conversion
1013 auto-cs coding-system))))
1016 (setq coding-system (coding-system-change-eol-conversion
1017 coding-system eol-type-2)))
1019 (setq auto-cs (coding-system-change-eol-conversion
1023 ;; Don't barf if writing a compressed file, say.
1026 (not (auto-coding-alist-lookup (or file buffer-file-name "")))
1027 (not (coding-system-equal coding-system auto-cs)))
1030 %s specified by file contents. Really save (else edit coding cookies \
1031 and try again)? " coding-system auto-cs))
1033 coding-system)))
1035 (setq select-safe-coding-system-function 'select-safe-coding-system)
1037 (defun select-message-coding-system ()
1038 "Return a coding system to encode the outgoing message of the current buffer.
1039 It at first tries the first coding system found in these variables
1041 (1) local value of `buffer-file-coding-system'
1042 (2) value of `sendmail-coding-system'
1043 (3) value of `default-sendmail-coding-system'
1044 (4) value of `default-buffer-file-coding-system'
1045 If the found coding system can't encode the current buffer,
1046 or none of them are bound to a coding system,
1047 it asks the user to select a proper coding system."
1048 (let ((coding (or (and (local-variable-p 'buffer-file-coding-system)
1049 buffer-file-coding-system)
1050 sendmail-coding-system
1051 default-sendmail-coding-system
1052 default-buffer-file-coding-system)))
1053 (if (eq coding 'no-conversion)
1055 (setq coding nil))
1056 (if (fboundp select-safe-coding-system-function)
1057 (setq coding
1058 (funcall select-safe-coding-system-function
1059 (point-min) (point-max) coding
1061 (coding-system-get x 'mime-charset))))))
1062 (if coding
1064 (setq coding (coding-system-change-eol-conversion coding 'unix))
1065 ;; No coding system is decided. Usually this is the case that
1068 (setq coding 'iso-8859-1-unix))
1069 coding))
1078 where LANGUAGE-NAME is a string, the name of the language environment,
1094 coding-system value is a list of coding systems that are good
1098 coding-priority value is a list of coding systems for this language
1100 This is used to set up the coding system priority
1107 input-method value is a default input method for this language
1119 globally disabled, i.e. the value of `default-enable-multibyte-characters'
1122 unibyte-syntax value is a library name to load to set
1126 unibyte-display value is a coding system to encode characters
1138 (setq lang-env (symbol-name lang-env)))
1153 (setq lang-env (symbol-name lang-env)))
1156 (cond ((eq key 'coding-priority)
1157 (set-language-environment-coding-systems lang-env))
1166 ((and (not default-enable-multibyte-characters)
1202 (setq lang-env (symbol-name lang-env)))
1210 (setq parent (symbol-name parent))
1249 (defun read-language-name (key prompt &optional default)
1250 "Read a language environment name which has information for KEY.
1252 Prompt with PROMPT. DEFAULT is the default choice of language environment.
1253 This returns a language environment name as a string."
1255 (name (completing-read prompt
1259 t nil nil default)))
1260 (if (and (> (length name) 0)
1262 (get-language-info name key)))
1263 name)))
1271 (defconst leim-list-file-name "leim-list.el"
1272 "Name of LEIM list file.
1273 This file contains a list of libraries of Emacs input methods (LEIM)
1275 Emacs loads this file at startup time.")
1278 ";;; %s -- list of LEIM (Library of Emacs Input Method) -*-coding: iso-2022-7bit;-*-
1280 ;; This file contains a list of LEIM (Library of Emacs Input Method)
1281 ;; methods in the same directory as this file. Loading this file
1292 ;; loads this file at startup time.
1295 leim-list-file-name)
1296 "Header to be inserted in LEIM list file.")
1299 "Regexp matching head of each entry in LEIM list file.
1303 '(quail-update-leim-list-file)
1304 "List of functions to call to update LEIM list file.
1305 Each function is called with one arg, LEIM directory name.")
1307 (defun update-leim-list-file (&rest dirs)
1308 "Update LEIM list file in directories DIRS."
1325 (defcustom default-input-method nil
1377 This function is mainly used in the file \"leim-list.el\" which is
1391 (setq lang-env (symbol-name lang-env)))
1393 (setq input-method (symbol-name input-method)))
1401 (defun read-input-method-name (prompt &optional default inhibit-null)
1402 "Read a name of input method from a minibuffer prompting with PROMPT.
1403 If DEFAULT is non-nil, use that as the default,
1408 (if default
1409 (setq prompt (format prompt default)))
1419 default)))
1421 (setq input-method (symbol-name input-method)))
1432 (setq input-method (symbol-name input-method)))
1476 This also sets the default input method to the one you specify.
1478 also causes you to be prompted for a name of an input method the next
1481 which marks the variable `default-input-method' as set for Custom buffers.
1486 (let* ((default (or (car input-method-history) default-input-method)))
1487 (list (read-input-method-name
1488 (if default "Select input method (default %s): " "Select input method: ")
1489 default t)
1492 (setq default-input-method input-method)
1494 (customize-mark-as-set 'default-input-method))
1495 default-input-method)
1504 recently used, or the one specified by `default-input-method', or
1505 as a last resort by reading the name of an input method in the
1508 With a prefix argument, read an input method name with the minibuffer
1509 and enable that one. The default is the most recent input method specified
1513 which marks the variable `default-input-method' as set for Custom buffers."
1518 (let ((default (or (car input-method-history) default-input-method)))
1519 (if (and arg default (equal current-input-method default)
1521 (setq default (nth 1 input-method-history)))
1523 (if (or arg (not default))
1525 (read-input-method-name
1526 (if default "Input method (default %s): " "Input method: " )
1527 default t))
1528 default))
1529 (unless default-input-method
1531 (setq default-input-method current-input-method)
1533 (customize-mark-as-set 'default-input-method)))))))
1538 (list (read-input-method-name
1539 "Describe input method (default current choice): ")))
1541 (setq input-method (symbol-name input-method)))
1588 default-input-method
1589 (read-input-method-name "Input method: " nil t)))
1591 (setq input-method (symbol-name input-method)))
1602 (defcustom input-method-verbose-flag 'default
1604 The value should be nil, t, `complex-only', or `default'.
1616 If the value is `default', complex input methods always give extra
1622 (const complex-only) (const default))
1637 The variable `current-input-method' keeps the input method name
1643 The variable `current-input-method' still keeps the input method name
1693 (let (language-name)
1697 (setq language-name (symbol-name last-command-event)))
1699 (set-language-environment language-name)
1712 (symbol-name current-language-environment)
1723 :initialize 'custom-initialize-default
1727 "Reset multilingual environment of Emacs to the default status.
1729 The default status is as follows:
1731 The default value of `buffer-file-coding-system' is nil.
1732 The default coding system for process I/O is nil.
1733 The default value for the command `set-terminal-coding-system' is nil.
1734 The default value for the command `set-keyboard-coding-system' is nil.
1736 The order of priorities of coding categories and the coding system
1738 coding category coding system
1740 coding-category-iso-8-1 iso-latin-1
1741 coding-category-iso-8-2 iso-latin-1
1742 coding-category-utf-8 mule-utf-8
1743 coding-category-utf-16-be mule-utf-16be-with-signature
1744 coding-category-utf-16-le mule-utf-16le-with-signature
1745 coding-category-iso-7-tight iso-2022-jp
1746 coding-category-iso-7 iso-2022-7bit
1747 coding-category-iso-7-else iso-2022-7bit-lock
1748 coding-category-iso-8-else iso-2022-8bit-ss2
1749 coding-category-emacs-mule emacs-mule
1750 coding-category-raw-text raw-text
1751 coding-category-sjis japanese-shift-jis
1752 coding-category-big5 chinese-big5
1753 coding-category-ccl nil
1754 coding-category-binary no-conversion"
1756 ;; This function formerly set default-enable-multibyte-characters to t,
1759 (setq coding-category-iso-7-tight 'iso-2022-jp
1760 coding-category-iso-7 'iso-2022-7bit
1761 coding-category-iso-8-1 'iso-latin-1
1762 coding-category-iso-8-2 'iso-latin-1
1763 coding-category-iso-7-else 'iso-2022-7bit-lock
1764 coding-category-iso-8-else 'iso-2022-8bit-ss2
1765 coding-category-emacs-mule 'emacs-mule
1766 coding-category-raw-text 'raw-text
1767 coding-category-sjis 'japanese-shift-jis
1768 coding-category-big5 'chinese-big5
1769 coding-category-utf-16-be 'mule-utf-16be-with-signature
1770 coding-category-utf-16-le 'mule-utf-16le-with-signature
1771 coding-category-utf-8 'mule-utf-8
1772 coding-category-ccl nil
1773 coding-category-binary 'no-conversion)
1775 (set-coding-priority
1776 '(coding-category-iso-8-1
1777 coding-category-iso-8-2
1778 coding-category-utf-8
1779 coding-category-utf-16-be
1780 coding-category-utf-16-le
1781 coding-category-iso-7-tight
1782 coding-category-iso-7
1783 coding-category-iso-7-else
1784 coding-category-iso-8-else
1785 coding-category-emacs-mule
1786 coding-category-raw-text
1787 coding-category-sjis
1788 coding-category-big5
1789 coding-category-ccl
1790 coding-category-binary))
1792 ;; Changing the binding of a coding category requires this call.
1793 (update-coding-systems-internal)
1795 (set-default-coding-systems nil)
1796 (setq default-sendmail-coding-system 'iso-latin-1)
1797 ;; On Darwin systems, this should be utf-8, but when this file is loaded
1799 (setq default-file-name-coding-system 'iso-latin-1)
1800 ;; Preserve eol-type from existing default-process-coding-systems.
1805 (let ((output-coding
1806 ;; When bootstrapping, coding-systems are not defined yet, so
1807 ;; we need to catch the error from check-coding-system.
1809 (coding-system-change-text-conversion
1810 (car default-process-coding-system) 'undecided)
1811 (coding-system-error 'undecided)))
1812 (input-coding
1814 (coding-system-change-text-conversion
1815 (cdr default-process-coding-system) 'iso-latin-1)
1816 (coding-system-error 'iso-latin-1))))
1817 (setq default-process-coding-system
1818 (cons output-coding input-coding)))
1820 ;; Don't alter the terminal and keyboard coding systems here.
1821 ;; The terminal still supports the same coding system
1823 ;; (set-terminal-coding-system-internal nil)
1824 ;; (set-keyboard-coding-system-internal nil)
1836 (defun set-display-table-and-terminal-coding-system (language-name &optional coding-system)
1837 "Set up the display table and terminal coding system for LANGUAGE-NAME."
1838 (let ((coding (get-language-info language-name 'unibyte-display)))
1839 (if (and coding
1840 (or (not coding-system)
1841 (coding-system-equal coding coding-system)))
1851 (or (eq window-system 'pc)
1852 (set-terminal-coding-system (or coding-system coding)))))
1854 (defun set-language-environment (language-name)
1856 This sets the coding system priority and the default input method
1858 which is the name of a language environment. For example, \"Latin-1\"
1860 (interactive (list (read-language-name
1862 "Set language environment (default English): ")))
1863 (if language-name
1864 (if (symbolp language-name)
1865 (setq language-name (symbol-name language-name)))
1866 (setq language-name "English"))
1867 (let ((slot (assoc-string language-name language-info-alist t)))
1869 (error "Language environment not defined: %S" language-name))
1870 (setq language-name (car slot)))
1878 ;; The features might set up coding systems.
1879 (let ((required-features (get-language-info language-name 'features)))
1884 (setq current-language-environment language-name)
1886 (set-language-environment-coding-systems language-name)
1887 (set-language-environment-input-method language-name)
1888 (set-language-environment-nonascii-translation language-name)
1889 (set-language-environment-charset language-name)
1890 (set-language-environment-fontset language-name)
1892 (unless default-enable-multibyte-characters
1893 (set-language-environment-unibyte language-name))
1895 (let ((func (get-language-info language-name 'setup-function)))
1904 (standard-display-8bit (if (eq window-system 'pc) 128 160) 255)
1908 (or (and (eq window-system 'pc) (not default-enable-multibyte-characters))
1911 (unless (and (eq window-system 'x)
1924 ;; proper windows-1252 coding system. --fx]
1927 (defun set-language-environment-coding-systems (language-name)
1928 "Do various coding system setups for language environment LANGUAGE-NAME."
1929 (let* ((priority (get-language-info language-name 'coding-priority))
1930 (default-coding (car priority))
1931 (eol-type (coding-system-eol-type default-buffer-file-coding-system)))
1933 (let ((categories (mapcar 'coding-system-category priority)))
1934 (set-default-coding-systems
1936 (coding-system-change-eol-conversion default-coding eol-type)
1937 default-coding))
1938 (setq default-sendmail-coding-system default-coding)
1939 (set-coding-priority categories)
1943 ;; Changing the binding of a coding category requires this call.
1944 (update-coding-systems-internal)))))
1946 (defun set-language-environment-input-method (language-name)
1948 (let ((input-method (get-language-info language-name 'input-method)))
1950 (setq default-input-method input-method)
1956 (defun set-language-environment-nonascii-translation (language-name)
1958 (let ((nonascii (get-language-info language-name 'nonascii-translation))
1960 (if (eq window-system 'pc)
1966 ((and (eq window-system 'pc) (boundp dos-table))
1967 ;; DOS terminals' default is to use a special non-ASCII translation
1973 (defun set-language-environment-charset (language-name)
1976 (not (eq utf-translate-cjk-lang-env language-name))
1978 (dolist (charset (get-language-info language-name 'charset))
1984 (defun set-language-environment-fontset (language-name)
1990 (get-language-info language-name 'overriding-fontspec))))
1992 (defun set-language-environment-unibyte (language-name)
1995 (let ((syntax (get-language-info language-name 'unibyte-syntax)))
2003 (ch (if (eq window-system 'pc) 128 160)))
2018 (set-display-table-and-terminal-coding-system language-name))
2028 ;; charsets, and coding systems. This function is intended to be
2035 (let (language-name)
2039 (setq language-name (symbol-name last-command-event))))
2041 (describe-language-environment language-name)))
2043 (defun describe-language-environment (language-name)
2046 (list (read-language-name
2048 "Describe language environment (default current choice): ")))
2049 (if (null language-name)
2050 (setq language-name current-language-environment))
2051 (if (or (null language-name)
2052 (null (get-language-info language-name 'documentation)))
2054 (if (symbolp language-name)
2055 (setq language-name (symbol-name language-name)))
2056 (dolist (feature (get-language-info language-name 'features))
2058 (let ((doc (get-language-info language-name 'documentation)))
2059 (help-setup-xref (list #'describe-language-environment language-name)
2064 (insert language-name " language environment\n\n")
2068 (let ((str (eval (get-language-info language-name 'sample-text))))
2072 (let ((input-method (get-language-info language-name 'input-method))
2076 (insert " (default " input-method ")")
2081 (when (string= language-name (nth 1 (car l)))
2094 (let ((l (get-language-info language-name 'charset)))
2096 (insert " nothing specific to " language-name "\n")
2098 (insert " " (symbol-name (car l)))
2099 (search-backward (symbol-name (car l)))
2106 (let ((l (get-language-info language-name 'coding-system)))
2108 (insert " nothing specific to " language-name "\n")
2110 (insert " " (symbol-name (car l)))
2111 (search-backward (symbol-name (car l)))
2112 (help-xref-button 0 'help-coding-system (car l))
2115 (coding-system-mnemonic (car l))
2117 (coding-system-doc-string (car l))
2119 (let ((aliases (coding-system-get (car l)
2120 'alias-coding-systems)))
2124 (insert " " (symbol-name (car aliases)))
2132 (defvar locale-translation-file-name nil
2133 "File name for the system's file of locale-name aliases, or nil if none.")
2351 "Alist of locale regexps vs the corresponding languages and coding systems.
2377 specifies the language name whose charset corresponds to that locale.
2378 This language name is used if the locale is not listed in
2381 (defconst locale-preferred-coding-systems
2400 ;; GB-2312, we setup the default coding system to gb2312.
2403 ;; BIG5, we setup the default coding system to big5.
2411 "List of pairs of locale regexps and preferred coding systems.
2413 specifies the coding system to prefer when using that locale.
2414 This coding system is used if the locale specifies a specific charset.")
2416 (defun locale-name-match (key alist)
2436 "Coding system alist keyed on locale-style charset name.
2437 Used by `locale-charset-to-coding-system'.")
2439 (defun locale-charset-to-coding-system (charset)
2440 "Find coding system corresponding to CHARSET.
2441 CHARSET is any sort of non-Emacs charset name, such as might be used
2442 in a locale codeset, or elsewhere. It is matched to a coding system
2444 matches are looked for in the coding system list, treating case and
2445 the characters `-' and `_' as insignificant. The coding system base
2449 (let ((cs coding-system-alist)
2455 (if c (coding-system-base c)))))
2461 (defun set-locale-environment (&optional locale-name)
2463 This sets the language environment, the coding system priority,
2464 the default input method and sometimes other things.
2466 LOCALE-NAME should be a string which is the name of a locale supported
2467 by the system. Often it is of the form xx_XX.CODE, where xx is a
2469 coding system. For example, the locale name \"ja_JP.EUC\" might name
2471 coding-system. The name may also have a modifier suffix, e.g. `@euro'
2477 The locale names supported by your system can typically be found in a
2480 `locale-translation-file-name'.
2483 `locale-preferred-coding-systems' and `locale-coding-system'."
2487 ;; to a system without X.
2488 (setq locale-translation-file-name
2495 ;; The following name appears after the X-related names above,
2499 (while (and files (not (file-exists-p (car files))))
2503 (let ((locale locale-name))
2522 (unless (or locale (not (boundp 'mac-system-locale)))
2523 (setq locale mac-system-locale))
2528 ;; using the translation file that many systems have.
2529 (when locale-translation-file-name
2531 (insert-file-contents locale-translation-file-name)
2536 ;; Leave the system locales alone if the caller did not specify
2537 ;; an explicit locale name, as their defaults are set from
2540 (when locale-name
2541 (setq system-messages-locale locale)
2542 (setq system-time-locale locale))
2546 (let ((language-name
2547 (locale-name-match locale locale-language-names))
2548 (charset-language-name
2549 (locale-name-match locale locale-charset-language-names))
2550 (default-eol-type (coding-system-eol-type
2551 default-buffer-file-coding-system))
2552 (coding-system
2553 (or (locale-name-match locale locale-preferred-coding-systems)
2556 (locale-charset-to-coding-system
2558 (and (eq system-type 'macos) mac-system-coding-system))))
2560 (if (consp language-name)
2561 ;; locale-language-names specify both lang-env and coding.
2562 ;; But, what specified in locale-preferred-coding-systems
2564 (setq coding-system (or coding-system
2565 (nth 1 language-name))
2566 language-name (car language-name))
2569 (if (not language-name)
2570 (setq language-name charset-language-name)))
2572 ;; If a specific EOL conversion was specified in the default
2573 ;; buffer-file-coding-system, preserve it in the coding system
2575 (if (and (memq default-eol-type '(0 1 2 unix dos mac))
2576 coding-system
2577 (coding-system-p coding-system))
2578 (setq coding-system (coding-system-change-eol-conversion
2579 coding-system default-eol-type)))
2581 (when language-name
2585 (set-language-environment language-name)
2587 ;; If default-enable-multibyte-characters is nil,
2589 ;; so the display table and terminal coding system are irrelevant.
2590 (when default-enable-multibyte-characters
2591 (set-display-table-and-terminal-coding-system
2592 language-name coding-system))
2594 ;; Set the `keyboard-coding-system' if appropriate (tty
2597 (unless window-system
2598 (let ((kcs (or coding-system
2599 (car (get-language-info language-name
2600 'coding-system)))))
2601 (if kcs (set-keyboard-coding-system kcs))))
2603 (setq locale-coding-system
2604 (car (get-language-info language-name 'coding-priority))))
2606 (when (and coding-system
2607 (not (coding-system-equal coding-system
2608 locale-coding-system)))
2609 (prefer-coding-system coding-system)
2610 ;; Fixme: perhaps prefer-coding-system should set this too.
2612 (setq default-sendmail-coding-system coding-system)
2613 (setq locale-coding-system coding-system))))
2615 ;; On Windows, override locale-coding-system,
2616 ;; keyboard-coding-system with system codepage. Note:
2617 ;; selection-coding-system is already set in w32select.c.
2619 (let ((code-page-coding (intern (format "cp%d" w32-ansi-code-page))))
2620 (when (coding-system-p code-page-coding)
2621 (setq locale-coding-system code-page-coding)
2622 (set-keyboard-coding-system code-page-coding)
2623 (set-terminal-coding-system code-page-coding))))
2625 (when (eq system-type 'darwin)
2626 ;; On Darwin, file names are always encoded in utf-8, no matter
2628 (setq default-file-name-coding-system 'utf-8)
2629 ;; Mac OS X's Terminal.app by default uses utf-8 regardless of
2631 (when (and (null window-system)
2633 (set-terminal-coding-system 'utf-8)
2634 (set-keyboard-coding-system 'utf-8)))
2654 (or (locale-name-match locale '(("c$" . letter)
2723 (defun encoded-string-description (str coding-system)
2727 (if (and coding-system (eq (coding-system-type coding-system) 2))
2734 (defun encode-coding-char (char coding-system)
2739 (safe-chars (and coding-system
2740 (coding-system-get coding-system 'safe-chars)))
2753 (setq enc1 (encode-coding-string str1 coding-system)
2755 enc2 (encode-coding-string str2 coding-system)