]> code.delx.au - gnu-emacs/blobdiff - lisp/international/mule-cmds.el
* international/mule-cmds.el (ucs-names): Exclude new "Enclosed
[gnu-emacs] / lisp / international / mule-cmds.el
index 465c3efecf59e7130514fbfe5a92cc2bc7153116..5ae8290687e3dac6a64dd1b9fca5d2e91f9d77e0 100644 (file)
@@ -31,6 +31,8 @@
 
 ;;; Code:
 
+(eval-when-compile (require 'cl))      ; letf
+
 (defvar dos-codepage)
 (autoload 'widget-value "wid-edit")
 
 
 ;;; MULE related key bindings and menus.
 
-(defvar mule-keymap (make-sparse-keymap)
+(defvar mule-keymap
+  (let ((map (make-sparse-keymap)))
+    (define-key map "f" 'set-buffer-file-coding-system)
+    (define-key map "r" 'revert-buffer-with-coding-system)
+    (define-key map "F" 'set-file-name-coding-system)
+    (define-key map "t" 'set-terminal-coding-system)
+    (define-key map "k" 'set-keyboard-coding-system)
+    (define-key map "p" 'set-buffer-process-coding-system)
+    (define-key map "x" 'set-selection-coding-system)
+    (define-key map "X" 'set-next-selection-coding-system)
+    (define-key map "\C-\\" 'set-input-method)
+    (define-key map "c" 'universal-coding-system-argument)
+    (define-key map "l" 'set-language-environment)
+    map)
   "Keymap for Mule (Multilingual environment) specific commands.")
 
 ;; Keep "C-x C-m ..." for mule specific commands.
 (define-key ctl-x-map "\C-m" mule-keymap)
 
-(define-key mule-keymap "f" 'set-buffer-file-coding-system)
-(define-key mule-keymap "r" 'revert-buffer-with-coding-system)
-(define-key mule-keymap "F" 'set-file-name-coding-system)
-(define-key mule-keymap "t" 'set-terminal-coding-system)
-(define-key mule-keymap "k" 'set-keyboard-coding-system)
-(define-key mule-keymap "p" 'set-buffer-process-coding-system)
-(define-key mule-keymap "x" 'set-selection-coding-system)
-(define-key mule-keymap "X" 'set-next-selection-coding-system)
-(define-key mule-keymap "\C-\\" 'set-input-method)
-(define-key mule-keymap "c" 'universal-coding-system-argument)
-(define-key mule-keymap "l" 'set-language-environment)
-
-(defvar mule-menu-keymap
-  (make-sparse-keymap "Mule (Multilingual Environment)")
-  "Keymap for Mule (Multilingual environment) menu specific commands.")
-
 (defvar describe-language-environment-map
-  (make-sparse-keymap "Describe Language Environment"))
+  (let ((map (make-sparse-keymap "Describe Language Environment")))
+    (define-key map
+      [Default] '(menu-item "Default" describe-specified-language-support))
+    map))
 
 (defvar setup-language-environment-map
-  (make-sparse-keymap "Set Language Environment"))
+  (let ((map (make-sparse-keymap "Set Language Environment")))
+    (define-key map
+      [Default] '(menu-item "Default" setup-specified-language-environment))
+    map))
 
 (defvar set-coding-system-map
-  (make-sparse-keymap "Set Coding System"))
-
-(define-key-after mule-menu-keymap [set-language-environment]
-  (list 'menu-item  "Set Language Environment" setup-language-environment-map))
-(define-key-after mule-menu-keymap [separator-mule]
-  '("--")
-  t)
-(define-key-after mule-menu-keymap [toggle-input-method]
-  '(menu-item "Toggle Input Method" toggle-input-method)
-  t)
-(define-key-after mule-menu-keymap [set-input-method]
-  '(menu-item "Select Input Method..." set-input-method)
-  t)
-(define-key-after mule-menu-keymap [describe-input-method]
-  '(menu-item "Describe Input Method"  describe-input-method))
-(define-key-after mule-menu-keymap [separator-input-method]
-  '("--")
-  t)
-(define-key-after mule-menu-keymap [set-various-coding-system]
-  (list 'menu-item "Set Coding Systems" set-coding-system-map
-       :enable 'default-enable-multibyte-characters))
-(define-key-after mule-menu-keymap [view-hello-file]
-  '(menu-item "Show Multi-lingual Text" view-hello-file
-             :enable (file-readable-p
-                      (expand-file-name "HELLO" data-directory))
-             :help "Display file which says HELLO in many languages")
-  t)
-(define-key-after mule-menu-keymap [separator-coding-system]
-  '("--")
-  t)
-(define-key-after mule-menu-keymap [describe-language-environment]
-  (list 'menu-item "Describe Language Environment"
-       describe-language-environment-map
-       :help "Show multilingual settings for a specific language")
-  t)
-(define-key-after mule-menu-keymap [describe-input-method]
-  '(menu-item "Describe Input Method..." describe-input-method
-             :help "Keyboard layout for a specific input method")
-  t)
-(define-key-after mule-menu-keymap [describe-coding-system]
-  '(menu-item "Describe Coding System..." describe-coding-system)
-  t)
-(define-key-after mule-menu-keymap [list-character-sets]
-  '(menu-item "List Character Sets" list-character-sets
-             :help "Show table of available character sets"))
-(define-key-after mule-menu-keymap [mule-diag]
-  '(menu-item "Show All of Mule Status" mule-diag
-             :help "Display multilingual environment settings")
-  t)
-
-(define-key-after set-coding-system-map [universal-coding-system-argument]
-  '(menu-item "For Next Command" universal-coding-system-argument
-             :help "Coding system to be used by next command")
-  t)
-(define-key-after set-coding-system-map [separator-1]
-  '("--")
-  t)
-(define-key-after set-coding-system-map [set-buffer-file-coding-system]
-  '(menu-item "For Saving This Buffer" set-buffer-file-coding-system
-             :help "How to encode this buffer when saved")
-  t)
-(define-key-after set-coding-system-map [revert-buffer-with-coding-system]
-  '(menu-item "For Reverting This File Now" revert-buffer-with-coding-system
-             :enable buffer-file-name
-             :help "Revisit this file immediately using specified coding system")
-  t)
-(define-key-after set-coding-system-map [set-file-name-coding-system]
-  '(menu-item "For File Name" set-file-name-coding-system
-             :help "How to decode/encode file names")
-  t)
-(define-key-after set-coding-system-map [separator-2]
-  '("--")
-  t)
-
-(define-key-after set-coding-system-map [set-keyboard-coding-system]
-  '(menu-item "For Keyboard" set-keyboard-coding-system
-             :help "How to decode keyboard input")
-  t)
-(define-key-after set-coding-system-map [set-terminal-coding-system]
-  '(menu-item "For Terminal" set-terminal-coding-system
-             :enable (null (memq initial-window-system '(x w32 ns)))
-             :help "How to encode terminal output")
-  t)
-(define-key-after set-coding-system-map [separator-3]
-  '("--")
-  t)
-(define-key-after set-coding-system-map [set-selection-coding-system]
-  '(menu-item "For X Selections/Clipboard" set-selection-coding-system
-             :visible (display-selections-p)
-             :help "How to en/decode data to/from selection/clipboard")
-  t)
-(define-key-after set-coding-system-map [set-next-selection-coding-system]
-  '(menu-item "For Next X Selection" set-next-selection-coding-system
-             :visible (display-selections-p)
-             :help "How to en/decode next selection/clipboard operation")
-  t)
-(define-key-after set-coding-system-map [set-buffer-process-coding-system]
-  '(menu-item "For I/O with Subprocess" set-buffer-process-coding-system
-             :visible (fboundp 'start-process)
-             :enable (get-buffer-process (current-buffer))
-             :help "How to en/decode I/O from/to subprocess connected to this buffer")
-  t)
-
-
-(define-key setup-language-environment-map
-  [Default] '(menu-item "Default" setup-specified-language-environment))
-
-(define-key describe-language-environment-map
-  [Default] '(menu-item "Default" describe-specified-language-support))
+  (let ((map (make-sparse-keymap "Set Coding System")))
+    (define-key-after map [universal-coding-system-argument]
+      '(menu-item "For Next Command" universal-coding-system-argument
+        :help "Coding system to be used by next command"))
+    (define-key-after map [separator-1] '("--"))
+    (define-key-after map [set-buffer-file-coding-system]
+      '(menu-item "For Saving This Buffer" set-buffer-file-coding-system
+        :help "How to encode this buffer when saved"))
+    (define-key-after map [revert-buffer-with-coding-system]
+      '(menu-item "For Reverting This File Now"
+        revert-buffer-with-coding-system
+        :enable buffer-file-name
+        :help "Revisit this file immediately using specified coding system"))
+    (define-key-after map [set-file-name-coding-system]
+      '(menu-item "For File Name" set-file-name-coding-system
+        :help "How to decode/encode file names"))
+    (define-key-after map [separator-2] '("--"))
+
+    (define-key-after map [set-keyboard-coding-system]
+      '(menu-item "For Keyboard" set-keyboard-coding-system
+        :help "How to decode keyboard input"))
+    (define-key-after map [set-terminal-coding-system]
+      '(menu-item "For Terminal" set-terminal-coding-system
+        :enable (null (memq initial-window-system '(x w32 ns)))
+        :help "How to encode terminal output"))
+    (define-key-after map [separator-3] '("--"))
+
+    (define-key-after map [set-selection-coding-system]
+      '(menu-item "For X Selections/Clipboard" set-selection-coding-system
+        :visible (display-selections-p)
+        :help "How to en/decode data to/from selection/clipboard"))
+    (define-key-after map [set-next-selection-coding-system]
+      '(menu-item "For Next X Selection" set-next-selection-coding-system
+        :visible (display-selections-p)
+        :help "How to en/decode next selection/clipboard operation"))
+    (define-key-after map [set-buffer-process-coding-system]
+      '(menu-item "For I/O with Subprocess" set-buffer-process-coding-system
+        :visible (fboundp 'start-process)
+        :enable (get-buffer-process (current-buffer))
+        :help "How to en/decode I/O from/to subprocess connected to this buffer"))
+    map))
+
+(defvar mule-menu-keymap
+  (let ((map (make-sparse-keymap "Mule (Multilingual Environment)")))
+    (define-key-after map [set-language-environment]
+      `(menu-item  "Set Language Environment" ,setup-language-environment-map))
+    (define-key-after map [separator-mule] '("--"))
+
+    (define-key-after map [toggle-input-method]
+      '(menu-item "Toggle Input Method" toggle-input-method))
+    (define-key-after map [set-input-method]
+      '(menu-item "Select Input Method..." set-input-method))
+    (define-key-after map [describe-input-method]
+      '(menu-item "Describe Input Method"  describe-input-method))
+    (define-key-after map [separator-input-method] '("--"))
+
+    (define-key-after map [set-various-coding-system]
+      `(menu-item "Set Coding Systems" ,set-coding-system-map
+                 :enable (default-value 'enable-multibyte-characters)))
+    (define-key-after map [view-hello-file]
+      '(menu-item "Show Multi-lingual Text" view-hello-file
+        :enable (file-readable-p
+                 (expand-file-name "HELLO" data-directory))
+        :help "Display file which says HELLO in many languages"))
+    (define-key-after map [separator-coding-system] '("--"))
+
+    (define-key-after map [describe-language-environment]
+      (list 'menu-item "Describe Language Environment"
+            describe-language-environment-map
+            :help "Show multilingual settings for a specific language"))
+    (define-key-after map [describe-input-method]
+      '(menu-item "Describe Input Method..." describe-input-method
+        :help "Keyboard layout for a specific input method"))
+    (define-key-after map [describe-coding-system]
+      '(menu-item "Describe Coding System..." describe-coding-system))
+    (define-key-after map [list-character-sets]
+      '(menu-item "List Character Sets" list-character-sets
+        :help "Show table of available character sets"))
+    (define-key-after map [mule-diag]
+      '(menu-item "Show All of Mule Status" mule-diag
+        :help "Display multilingual environment settings"))
+    map)
+  "Keymap for Mule (Multilingual environment) menu specific commands.")
 
 ;; This should be a single character key binding because users use it
 ;; very frequently while editing multilingual text.  Now we can use
@@ -243,6 +222,44 @@ how text is formatted automatically while decoding."
      (if coding coding 'undecided)
      (if (numberp eol-type) (aref [unix dos mac] eol-type)))))
 
+;; Canonicalize the coding system name NAME by removing some prefixes
+;; and delimiter characters.  Support function of
+;; coding-system-from-name.
+(defun canonicalize-coding-system-name (name)
+  (if (string-match "^iso[-_ ]?[0-9]" name)
+      ;; "iso-8859-1" -> "8859-1", "iso-2022-jp" ->"2022-jp"
+      (setq name (substring name (1- (match-end 0)))))
+  (let ((idx (string-match "[-_ /]" name)))
+    ;; Delete "-", "_", " ", "/" but do distinguish "16-be" and "16be".
+    (while idx
+      (if (and (>= idx 2)
+              (eq (string-match "16-[lb]e$" name (- idx 2))
+                  (- idx 2)))
+         (setq idx (string-match "[-_ /]" name (match-end 0)))
+       (setq name (concat (substring name 0 idx) (substring name (1+ idx)))
+             idx (string-match "[-_ /]" name idx))))
+    name))
+
+(defun coding-system-from-name (name)
+  "Return a coding system whose name matches with NAME (string or symbol)."
+  (let (sym)
+    (if (stringp name) (setq sym (intern name))
+      (setq sym name name (symbol-name name)))
+    (if (coding-system-p sym)
+       sym
+      (let ((eol-type
+            (if (string-match "-\\(unix\\|dos\\|mac\\)$" name)
+                (prog1 (intern (match-string 1 name))
+                  (setq name (substring name 0 (match-beginning 0)))))))
+       (setq name (canonicalize-coding-system-name (downcase name)))
+       (catch 'tag
+         (dolist (elt (coding-system-list))
+           (if (string= (canonicalize-coding-system-name (symbol-name elt))
+                        name)
+               (throw 'tag (if eol-type (coding-system-change-eol-conversion
+                                         elt eol-type)
+                             elt)))))))))
+
 (defun toggle-enable-multibyte-characters (&optional arg)
   "Change whether this buffer uses multibyte characters.
 With ARG, use multibyte characters if the ARG is positive.
@@ -266,9 +283,9 @@ wrong, use this command again to toggle back to the right mode."
   "Display the HELLO file, which lists many languages and characters."
   (interactive)
   ;; We have to decode the file in any environment.
-  (let ((default-enable-multibyte-characters t)
-       (coding-system-for-read 'iso-2022-7bit))
-    (view-file (expand-file-name "HELLO" data-directory))))
+  (letf (((default-value 'enable-multibyte-characters) t)
+        (coding-system-for-read 'iso-2022-7bit))
+       (view-file (expand-file-name "HELLO" data-directory))))
 
 (defun universal-coding-system-argument (coding-system)
   "Execute an I/O command using the specified coding system."
@@ -330,7 +347,7 @@ This sets the following coding systems:
 This also sets the following values:
   o default value used as `file-name-coding-system' for converting file names
       if CODING-SYSTEM is ASCII-compatible
-  o default value for the command `set-terminal-coding-system' (not on MS-DOS)
+  o default value for the command `set-terminal-coding-system'
   o default value for the command `set-keyboard-coding-system'
       if CODING-SYSTEM is ASCII-compatible"
   (check-coding-system coding-system)
@@ -343,7 +360,7 @@ This also sets the following values:
   (if (eq system-type 'darwin)
       ;; The file-name coding system on Darwin systems is always utf-8.
       (setq default-file-name-coding-system 'utf-8)
-    (if (and default-enable-multibyte-characters
+    (if (and (default-value 'enable-multibyte-characters)
             (or (not coding-system)
                 (coding-system-get coding-system 'ascii-compatible-p)))
        (setq default-file-name-coding-system coding-system)))
@@ -370,17 +387,12 @@ This also sets the following coding systems:
   o default coding system for subprocess I/O
 This also sets the following values:
   o default value used as `file-name-coding-system' for converting file names
-  o default value for the command `set-terminal-coding-system' (not on MS-DOS)
+  o default value for the command `set-terminal-coding-system'
   o default value for the command `set-keyboard-coding-system'
 
 If CODING-SYSTEM specifies a certain type of EOL conversion, the coding
 systems set by this function will use that type of EOL conversion.
 
-This command does not change the default value of terminal coding system
-for MS-DOS terminal, because DOS terminals only support a single coding
-system, and Emacs automatically sets the default to that coding system at
-startup.
-
 A coding system that requires automatic detection of text+encoding
 \(e.g. undecided, unix) can't be preferred."
   (interactive "zPrefer coding system: ")
@@ -391,7 +403,7 @@ A coding system that requires automatic detection of text+encoding
   (let ((base (coding-system-base coding-system))
        (eol-type (coding-system-eol-type coding-system)))
     (set-coding-system-priority base)
-    (and (interactive-p)
+    (and (called-interactively-p 'interactive)
         (or (eq base coding-system)
             (message "Highest priority is set to %s (base of %s)"
                      base coding-system)))
@@ -803,7 +815,7 @@ between FROM and TO are shown in a popup window.  Among them, the most
 proper one is suggested as the default.
 
 The list of `buffer-file-coding-system' of the current buffer, the
-`default-buffer-file-coding-system', and the most preferred coding
+default `buffer-file-coding-system', and the most preferred coding
 system (if it corresponds to a MIME charset) is treated as the
 default coding system list.  Among them, the first one that safely
 encodes the text is normally selected silently and returned without
@@ -819,7 +831,7 @@ Optional 3rd arg DEFAULT-CODING-SYSTEM specifies a coding system or a
 list of coding systems to be prepended to the default coding system
 list.  However, if DEFAULT-CODING-SYSTEM is a list and the first
 element is t, the cdr part is used as the default coding system list,
-i.e. `buffer-file-coding-system', `default-buffer-file-coding-system',
+i.e. current `buffer-file-coding-system', default `buffer-file-coding-system',
 and the most preferred coding system are not used.
 
 Optional 4th arg ACCEPT-DEFAULT-P, if non-nil, is a function to
@@ -836,14 +848,13 @@ overrides ACCEPT-DEFAULT-P.
 
 Kludgy feature: if FROM is a string, the string is the target text,
 and TO is ignored."
-  (if (and default-coding-system
-          (not (listp default-coding-system)))
+  (if (not (listp default-coding-system))
       (setq default-coding-system (list default-coding-system)))
 
   (let ((no-other-defaults nil)
        auto-cs)
     (unless (or (stringp from) find-file-literally)
-      ;; Find an auto-coding that is specified for the the current
+      ;; Find an auto-coding that is specified for the current
       ;; buffer and file from the region FROM and TO.
       (save-excursion
        (save-restriction
@@ -897,44 +908,49 @@ It is highly recommended to fix it before writing to a file."
                      (append default-coding-system
                              (list (cons buffer-file-coding-system base)))))))
 
-      ;; If default-buffer-file-coding-system is not nil nor undecided,
-      ;; append it to the defaults.
-      (if default-buffer-file-coding-system
-         (let ((base (coding-system-base default-buffer-file-coding-system)))
-           (or (eq base 'undecided)
-               (rassq base default-coding-system)
-               (setq default-coding-system
-                     (append default-coding-system
-                             (list (cons default-buffer-file-coding-system
-                                         base)))))))
-
-      ;; If the most preferred coding system has the property mime-charset,
-      ;; append it to the defaults.
-      (let ((preferred (coding-system-priority-list t))
-           base)
-       (and (coding-system-p preferred)
-            (setq base (coding-system-base preferred))
-            (coding-system-get preferred :mime-charset)
-            (not (rassq base default-coding-system))
-            (setq default-coding-system
-                  (append default-coding-system
-                          (list (cons preferred base)))))))
+      (unless (and buffer-file-coding-system-explicit
+                  (cdr buffer-file-coding-system-explicit))
+       ;; If default buffer-file-coding-system is not nil nor undecided,
+       ;; append it to the defaults.
+       (when (default-value 'buffer-file-coding-system)
+          (let ((base (coding-system-base
+                       (default-value 'buffer-file-coding-system))))
+            (or (eq base 'undecided)
+                (rassq base default-coding-system)
+                (setq default-coding-system
+                      (append default-coding-system
+                              (list (cons (default-value
+                                            'buffer-file-coding-system)
+                                          base)))))))
+
+       ;; If the most preferred coding system has the property mime-charset,
+       ;; append it to the defaults.
+       (let ((preferred (coding-system-priority-list t))
+             base)
+         (and (coding-system-p preferred)
+              (setq base (coding-system-base preferred))
+              (coding-system-get preferred :mime-charset)
+              (not (rassq base default-coding-system))
+              (setq default-coding-system
+                    (append default-coding-system
+                            (list (cons preferred base))))))))
 
     (if select-safe-coding-system-accept-default-p
        (setq accept-default-p select-safe-coding-system-accept-default-p))
 
     ;; Decide the eol-type from the top of the default codings,
-    ;; buffer-file-coding-system, or
-    ;; default-buffer-file-coding-system.
+    ;; current buffer-file-coding-system, or default buffer-file-coding-system.
     (if default-coding-system
        (let ((default-eol-type (coding-system-eol-type
                                 (caar default-coding-system))))
          (if (and (vectorp default-eol-type) buffer-file-coding-system)
              (setq default-eol-type (coding-system-eol-type
                                      buffer-file-coding-system)))
-         (if (and (vectorp default-eol-type) default-buffer-file-coding-system)
-             (setq default-eol-type (coding-system-eol-type
-                                     default-buffer-file-coding-system)))
+         (if (and (vectorp default-eol-type)
+                   (default-value 'buffer-file-coding-system))
+             (setq default-eol-type
+                    (coding-system-eol-type
+                     (default-value 'buffer-file-coding-system))))
          (if (and default-eol-type (not (vectorp default-eol-type)))
              (dolist (elt default-coding-system)
                (setcar elt (coding-system-change-eol-conversion
@@ -942,7 +958,7 @@ It is highly recommended to fix it before writing to a file."
 
     (let ((codings (find-coding-systems-region from to))
          (coding-system nil)
-         (tick (if (not (stringp from)) (buffer-modified-tick)))
+         (tick (if (not (stringp from)) (buffer-chars-modified-tick)))
          safe rejected unsafe)
       (if (eq (car codings) 'undecided)
          ;; Any coding system is ok.
@@ -1008,7 +1024,7 @@ It is highly recommended to fix it before writing to a file."
 %s specified by file contents.  Really save (else edit coding cookies \
 and try again)? " coding-system auto-cs))
              (error "Save aborted"))))
-      (when (and tick (/= tick (buffer-modified-tick)))
+      (when (and tick (/= tick (buffer-chars-modified-tick)))
        (error "Cancelled because the buffer was modified"))
       coding-system)))
 
@@ -1021,7 +1037,7 @@ in this order:
   (1) local value of `buffer-file-coding-system'
   (2) value of `sendmail-coding-system'
   (3) value of `default-sendmail-coding-system'
-  (4) value of `default-buffer-file-coding-system'
+  (4) default value of `buffer-file-coding-system'
 If the found coding system can't encode the current buffer,
 or none of them are bound to a coding system,
 it asks the user to select a proper coding system."
@@ -1029,7 +1045,7 @@ it asks the user to select a proper coding system."
                          buffer-file-coding-system)
                     sendmail-coding-system
                     default-sendmail-coding-system
-                    default-buffer-file-coding-system)))
+                    (default-value 'buffer-file-coding-system))))
     (if (eq coding 'no-conversion)
        ;; We should never use no-conversion for outgoing mail.
        (setq coding nil))
@@ -1082,9 +1098,9 @@ Meaningful values for KEY include
                        in extended segments of CTEXT.  See the variable
                        `ctext-non-standard-encodings' for more detail.
 
-The following keys take effect only when multibyte characters are
-globally disabled, i.e. the value of `default-enable-multibyte-characters'
-is nil.
+The following key takes effect only when multibyte characters are
+globally disabled, i.e. the default value of `enable-multibyte-characters'
+is nil (which is an obsolete and deprecated use):
 
   unibyte-display    value is a coding system to encode characters for
                        the terminal.  Characters in the range of 160 to
@@ -1124,7 +1140,7 @@ see `language-info-alist'."
             (set-language-environment-nonascii-translation lang-env))
            ((eq key 'charset)
             (set-language-environment-charset lang-env))
-           ((and (not default-enable-multibyte-characters)
+           ((and (not (default-value 'enable-multibyte-characters))
                  (or (eq key 'unibyte-syntax) (eq key 'unibyte-display)))
             (set-language-environment-unibyte lang-env)))))
 
@@ -1180,7 +1196,7 @@ in the European submenu in each of those two menus."
                                            (downcase parent))))
                  (define-prefix-command map nil prompt)
                  (define-key-after describe-map (vector parent-symbol)
-                   (cons parent map) t)))
+                   (cons parent map))))
            (setq describe-map (symbol-value map))
            (setq map (lookup-key setup-map (vector parent-symbol)))
            (if (not map)
@@ -1189,7 +1205,7 @@ in the European submenu in each of those two menus."
                                            (downcase parent))))
                  (define-prefix-command map nil prompt)
                  (define-key-after setup-map (vector parent-symbol)
-                   (cons parent map) t)))
+                   (cons parent map))))
            (setq setup-map (symbol-value map))
            (setq l (cdr l)))))
 
@@ -1197,9 +1213,9 @@ in the European submenu in each of those two menus."
     (let ((doc (assq 'documentation alist)))
       (when doc
        (define-key-after describe-map (vector (intern lang-env))
-         (cons lang-env 'describe-specified-language-support) t)))
+         (cons lang-env 'describe-specified-language-support))))
     (define-key-after setup-map (vector (intern lang-env))
-      (cons lang-env 'setup-specified-language-environment) t)
+      (cons lang-env 'setup-specified-language-environment))
 
     (dolist (elt alist)
       (set-language-info-internal lang-env (car elt) (cdr elt)))
@@ -1235,7 +1251,9 @@ in the format of Lisp expression for registering each input method.
 Emacs loads this file at startup time.")
 
 (defvar leim-list-header (format
-";;; %s -- list of LEIM (Library of Emacs Input Method) -*-coding: iso-2022-7bit;-*-
+";;; %s -- list of LEIM (Library of Emacs Input Method) -*-coding: utf-8;-*-
+;;
+;; This file is automatically generated.
 ;;
 ;; This file contains a list of LEIM (Library of Emacs Input Method)
 ;; methods in the same directory as this file.  Loading this file
@@ -1248,7 +1266,7 @@ Emacs loads this file at startup time.")
 ;;    ARG ...)
 ;; See the function `register-input-method' for the meanings of the arguments.
 ;;
-;; If this directory is included in load-path, Emacs automatically
+;; If this directory is included in `load-path', Emacs automatically
 ;; loads this file at startup time.
 
 "
@@ -1324,6 +1342,8 @@ This function is called with no argument.")
 Each element has the form:
    (INPUT-METHOD LANGUAGE-ENV ACTIVATE-FUNC TITLE DESCRIPTION ARGS...)
 See the function `register-input-method' for the meanings of the elements.")
+;; Autoload if this file no longer dumped.
+(put 'input-method-alist 'risky-local-variable t)
 
 (defun register-input-method (input-method lang-env &rest args)
   "Register INPUT-METHOD as an input method for language environment LANG-ENV.
@@ -1510,7 +1530,7 @@ which marks the variable `default-input-method' as set for Custom buffers."
       (setq input-method (symbol-name input-method)))
   (help-setup-xref (list #'describe-input-method
                         (or input-method current-input-method))
-                  (interactive-p))
+                  (called-interactively-p 'interactive))
 
   (if (null input-method)
       (describe-current-input-method)
@@ -1524,7 +1544,7 @@ which marks the variable `default-input-method' as set for Custom buffers."
        (error
         (activate-input-method current)
         (help-setup-xref (list #'describe-input-method input-method)
-                         (interactive-p))
+                         (called-interactively-p 'interactive))
         (with-output-to-temp-buffer (help-buffer)
           (let ((elt (assoc input-method input-method-alist)))
             (princ (format
@@ -1758,6 +1778,12 @@ The default status is as follows:
     (setq default-process-coding-system
          (cons output-coding input-coding)))
 
+  ;; Put the highest priority to the charset iso-8859-1 to prefer the
+  ;; registry iso8859-1 over iso8859-2 in font selection.  It also
+  ;; makes unibyte-display-via-language-environment to use iso-8859-1
+  ;; as the unibyte charset.
+  (set-charset-priority 'iso-8859-1)
+
   ;; Don't alter the terminal and keyboard coding systems here.
   ;; The terminal still supports the same coding system
   ;; that it supported a minute ago.
@@ -1825,7 +1851,7 @@ specifies the character set for the major languages of Western Europe."
   (set-language-environment-nonascii-translation language-name)
   (set-language-environment-charset language-name)
   ;; Unibyte setups if necessary.
-  (unless default-enable-multibyte-characters
+  (unless (default-value 'enable-multibyte-characters)
     (set-language-environment-unibyte language-name))
 
   (let ((func (get-language-info language-name 'setup-function)))
@@ -1910,7 +1936,8 @@ See `set-language-info-alist' for use in programs."
   ;; Unibyte Emacs on MS-DOS wants to display all 8-bit characters with
   ;; the native font, and codes 160 and 146 stand for something very
   ;; different there.
-  (or (and (eq window-system 'pc) (not default-enable-multibyte-characters))
+  (or (and (eq window-system 'pc) (not (default-value
+                                        'enable-multibyte-characters)))
       (progn
        ;; Most X fonts used to do the wrong thing for latin-1 code 160.
        (unless (and (eq window-system 'x)
@@ -1933,7 +1960,23 @@ See `set-language-info-alist' for use in programs."
   "Do various coding system setups for language environment LANGUAGE-NAME."
   (let* ((priority (get-language-info language-name 'coding-priority))
         (default-coding (car priority))
-        (eol-type (coding-system-eol-type default-buffer-file-coding-system)))
+        ;; If the default buffer-file-coding-system is nil, don't use
+        ;; coding-system-eol-type, because it treats nil as
+        ;; `no-conversion'.  The default buffer-file-coding-system is set
+        ;; to nil by reset-language-environment, and in that case we
+        ;; want to have here the native EOL type for each platform.
+        ;; FIXME: there should be a common code that runs both on
+        ;; startup and here to set the default EOL type correctly.
+        ;; Right now, DOS/Windows platforms set this on dos-w32.el,
+        ;; which works only as long as the order of loading files at
+        ;; dump time and calling functions at startup is not modified
+        ;; significantly, i.e. as long as this function is called
+        ;; _after_ the default buffer-file-coding-system was set by
+        ;; dos-w32.el.
+        (eol-type
+          (coding-system-eol-type
+           (or (default-value 'buffer-file-coding-system)
+               (if (memq system-type '(windows-nt ms-dos)) 'dos 'unix)))))
     (when priority
       (set-default-coding-systems
        (if (memq eol-type '(0 1 2 unix dos mac))
@@ -1974,7 +2017,9 @@ See `set-language-info-alist' for use in programs."
   ;; coding systems of higher priorities in this environment.
   (let ((charsets (get-language-info language-name 'charset)))
     (dolist (coding (get-language-info language-name 'coding-priority))
-      (setq charsets (append charsets (coding-system-charset-list coding))))
+      (let ((list (coding-system-charset-list coding)))
+       (if (consp list)
+           (setq charsets (append charsets list)))))
     (if charsets
        (apply 'set-charset-priority charsets))))
 
@@ -2022,7 +2067,7 @@ See `set-language-info-alist' for use in programs."
     (require feature))
   (let ((doc (get-language-info language-name 'documentation)))
     (help-setup-xref (list #'describe-language-environment language-name)
-                    (interactive-p))
+                    (called-interactively-p 'interactive))
     (with-output-to-temp-buffer (help-buffer)
       (save-excursion
        (set-buffer standard-output)
@@ -2524,7 +2569,7 @@ See also `locale-charset-language-names', `locale-language-names',
            (charset-language-name
             (locale-name-match locale locale-charset-language-names))
            (default-eol-type (coding-system-eol-type
-                              default-buffer-file-coding-system))
+                              (default-value 'buffer-file-coding-system)))
            (coding-system
             (or (locale-name-match locale locale-preferred-coding-systems)
                 (when locale
@@ -2560,10 +2605,10 @@ See also `locale-charset-language-names', `locale-language-names',
          (unless frame
            (set-language-environment language-name))
 
-         ;; If default-enable-multibyte-characters is nil,
+         ;; If the default enable-multibyte-characters is nil,
          ;; we are using single-byte characters,
          ;; so the display table and terminal coding system are irrelevant.
-         (when default-enable-multibyte-characters
+         (when (default-value 'enable-multibyte-characters)
            (set-display-table-and-terminal-coding-system
             language-name coding-system frame))
 
@@ -2848,7 +2893,8 @@ on encoding."
                         (and (>= c #x3400 ) (<= c #x4dbf )) ; CJK Ideograph Extension A
                         (and (>= c #x4e00 ) (<= c #x9fff )) ; CJK Ideograph
                         (and (>= c #xd800 ) (<= c #xfaff )) ; Private/Surrogate
-                        (and (>= c #x20000) (<= c #x2ffff)) ; CJK Ideograph Extension B
+                        (and (>= c #x1f200) (<= c #x1f2ff)) ; Enclosed Ideographic Supplement
+                        (and (>= c #x20000) (<= c #x2ffff)) ; CJK Ideograph Extensions B, C
                         )
                  (if (setq name (get-char-code-property c 'name))
                      (setq names (cons (cons name c) names)))
@@ -2878,19 +2924,28 @@ for decimal.  Returns a character as a number."
      (t
       (cdr (assoc-string input (ucs-names) t))))))
 
-(defun ucs-insert (arg)
-  "Insert a character of the given Unicode code point.
+(defun ucs-insert (character &optional count inherit)
+  "Insert COUNT copies of CHARACTER of the given Unicode code point.
 Interactively, prompts for a Unicode character name or a hex number
-using `read-char-by-name'."
-  (interactive (list (read-char-by-name "Unicode (name or hex): ")))
-  (if (stringp arg)
-      (setq arg (string-to-number arg 16)))
+using `read-char-by-name'.
+The optional third arg INHERIT (non-nil when called interactively),
+says to inherit text properties from adjoining text, if those
+properties are sticky."
+  (interactive
+   (list (read-char-by-name "Unicode (name or hex): ")
+        (prefix-numeric-value current-prefix-arg)
+        t))
+  (unless count (setq count 1))
+  (if (stringp character)
+      (setq character (string-to-number character 16)))
   (cond
-   ((not (integerp arg))
-    (error "Not a Unicode character code: %S" arg))
-   ((or (< arg 0) (> arg #x10FFFF))
-    (error "Not a Unicode character code: 0x%X" arg)))
-  (insert-and-inherit arg))
+   ((not (integerp character))
+    (error "Not a Unicode character code: %S" character))
+   ((or (< character 0) (> character #x10FFFF))
+    (error "Not a Unicode character code: 0x%X" character)))
+  (if inherit
+      (dotimes (i count) (insert-and-inherit character))
+    (dotimes (i count) (insert character))))
 
 (define-key ctl-x-map "8\r" 'ucs-insert)