]> code.delx.au - gnu-emacs/blobdiff - lisp/international/mule-cmds.el
Merge from emacs--rel--22
[gnu-emacs] / lisp / international / mule-cmds.el
index 21985259e98745aa55c13d1061b153c5cc3fbb3c..77ef1f9cd40c384b684ee1652f18b8ae499dcc35 100644 (file)
@@ -13,7 +13,7 @@
 
 ;; GNU Emacs is free software; you can redistribute it and/or modify
 ;; it under the terms of the GNU General Public License as published by
-;; the Free Software Foundation; either version 2, or (at your option)
+;; the Free Software Foundation; either version 3, or (at your option)
 ;; any later version.
 
 ;; GNU Emacs is distributed in the hope that it will be useful,
@@ -445,11 +445,11 @@ non-nil, it is used to sort CODINGS instead."
                    (let ((base (coding-system-base x)))
                      ;; We calculate the priority number 0..255 by
                      ;; using the 8 bits PMMLCEII as this:
-                     ;; P: 1 iff most preferred.
-                     ;; MM: greater than 0 iff mime-charset.
-                     ;; L: 1 iff one of the current lang. env.'s codings.
-                     ;; C: 1 iff one of codings listed in the category list.
-                     ;; E: 1 iff not XXX-with-esc
+                     ;; P: 1 if most preferred.
+                     ;; MM: greater than 0 if mime-charset.
+                     ;; L: 1 if one of the current lang. env.'s codings.
+                     ;; C: 1 if one of codings listed in the category list.
+                     ;; E: 1 if not XXX-with-esc
                      ;; II: if iso-2022 based, 0..3, else 1.
                      (logior
                       (lsh (if (eq base most-preferred) 1 0) 7)
@@ -1492,6 +1492,9 @@ To deactivate it programmatically, use `inactivate-input-method'."
     (customize-mark-as-set 'default-input-method))
   default-input-method)
 
+(defvar toggle-input-method-active nil
+  "Non-nil inside `toggle-input-method'.")
+
 (defun toggle-input-method (&optional arg interactive)
   "Enable or disable multilingual text input method for the current buffer.
 Only one input method can be enabled at any time in a given buffer.
@@ -1511,9 +1514,12 @@ When called interactively, the optional arg INTERACTIVE is non-nil,
 which marks the variable `default-input-method' as set for Custom buffers."
 
   (interactive "P\np")
+  (if toggle-input-method-active
+      (error "Recursive use of `toggle-input-method'"))
   (if (and current-input-method (not arg))
       (inactivate-input-method)
-    (let ((default (or (car input-method-history) default-input-method)))
+    (let ((toggle-input-method-active t)
+         (default (or (car input-method-history) default-input-method)))
       (if (and arg default (equal current-input-method default)
               (> (length input-method-history) 1))
          (setq default (nth 1 input-method-history)))
@@ -2619,14 +2625,24 @@ See also `locale-charset-language-names', `locale-language-names',
          (setq locale-coding-system coding-system))))
 
     ;; On Windows, override locale-coding-system,
-    ;; keyboard-coding-system with system codepage.  Note:
-    ;; selection-coding-system is already set in w32select.c.
+    ;; default-file-name-coding-system, keyboard-coding-system,
+    ;; terminal-coding-system with system codepage.
     (when (boundp 'w32-ansi-code-page)
       (let ((code-page-coding (intern (format "cp%d" w32-ansi-code-page))))
        (when (coding-system-p code-page-coding)
          (unless frame (setq locale-coding-system code-page-coding))
          (set-keyboard-coding-system code-page-coding frame)
-         (set-terminal-coding-system code-page-coding frame))))
+         (set-terminal-coding-system code-page-coding frame)
+         ;; Set default-file-name-coding-system last, so that Emacs
+         ;; doesn't try to use cpNNNN when it defines keyboard and
+         ;; terminal encoding.  That's because the above two lines
+         ;; will want to load code-pages.el, where cpNNNN are
+         ;; defined; if default-file-name-coding-system were set to
+         ;; cpNNNN while these two lines run, Emacs will want to use
+         ;; it for encoding the file name it wants to load.  And that
+         ;; will fail, since cpNNNN is not yet usable until
+         ;; code-pages.el finishes loading.
+         (setq default-file-name-coding-system code-page-coding))))
 
     (when (eq system-type 'darwin)
       ;; On Darwin, file names are always encoded in utf-8, no matter