]> code.delx.au - gnu-emacs/blobdiff - lisp/international/mule-cmds.el
Merged from miles@gnu.org--gnu-2005 (patch 469)
[gnu-emacs] / lisp / international / mule-cmds.el
index bb69dbda1550ae353aa8cf1e3b59ba3ddf275425..3ff436723cadb5b768543d72f29591a4f523ad5c 100644 (file)
   t)
 (define-key-after set-coding-system-map [set-terminal-coding-system]
   '(menu-item "For Terminal" set-terminal-coding-system
-             :enable (null (memq window-system '(x w32 mac)))
+             :enable (null (memq initial-window-system '(x w32 mac)))
              :help "How to encode terminal output")
   t)
 (define-key-after set-coding-system-map [separator-3]
@@ -1740,7 +1740,7 @@ The default status is as follows:
 
 (reset-language-environment)
 
-(defun set-display-table-and-terminal-coding-system (language-name &optional coding-system)
+(defun set-display-table-and-terminal-coding-system (language-name &optional coding-system display)
   "Set up the display table and terminal coding system for LANGUAGE-NAME."
   (let ((coding (get-language-info language-name 'unibyte-display)))
     (if coding
@@ -1754,7 +1754,7 @@ The default status is as follows:
        (dotimes (i 128)
          (aset standard-display-table (+ i 128) nil))))
     (or (eq window-system 'pc)
-       (set-terminal-coding-system (or coding-system coding)))))
+       (set-terminal-coding-system (or coding-system coding) display))))
 
 (defun set-language-environment (language-name)
   "Set up multi-lingual environment for using LANGUAGE-NAME.
@@ -2348,7 +2348,7 @@ is returned.  Thus, for instance, if charset \"ISO8859-2\",
 ;; too, for setting things such as calendar holidays, ps-print paper
 ;; size, spelling dictionary.
 
-(defun set-locale-environment (&optional locale-name)
+(defun set-locale-environment (&optional locale-name display)
   "Set up multi-lingual environment for using LOCALE-NAME.
 This sets the language environment, the coding system priority,
 the default input method and sometimes other things.
@@ -2369,6 +2369,11 @@ directory named `/usr/share/locale' or `/usr/lib/locale'.  LOCALE-NAME
 will be translated according to the table specified by
 `locale-translation-file-name'.
 
+If DISPLAY is non-nil, only set the keyboard coding system and
+the terminal coding system for the given display, and don't touch
+session-global parameters like the language environment.  DISPLAY
+may be a display id or a frame.
+
 See also `locale-charset-language-names', `locale-language-names',
 `locale-preferred-coding-systems' and `locale-coding-system'."
   (interactive "sSet environment for locale: ")
@@ -2457,28 +2462,34 @@ See also `locale-charset-language-names', `locale-language-names',
 
          ;; Set up for this character set.  This is now the right way
          ;; to do it for both unibyte and multibyte modes.
-         (set-language-environment language-name)
+         (unless display
+           (set-language-environment language-name))
 
          ;; If 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
            (set-display-table-and-terminal-coding-system
-            language-name coding-system))
+            language-name coding-system display))
 
          ;; Set the `keyboard-coding-system' if appropriate (tty
          ;; only).  At least X and MS Windows can generate
          ;; multilingual input.
-         (unless window-system
-           (let ((kcs (or coding-system
-                          (car (get-language-info language-name
-                                                  'coding-system)))))
-             (if kcs (set-keyboard-coding-system kcs))))
-
-         (setq locale-coding-system
-               (car (get-language-info language-name 'coding-priority))))
-
-       (when (and coding-system
+         ;; XXX This was disabled unless `window-system', but that
+         ;; leads to buggy behaviour when a tty frame is opened
+         ;; later.  Setting the keyboard coding system has no adverse
+         ;; effect on X, so let's do it anyway. -- Lorentey
+         (let ((kcs (or coding-system
+                        (car (get-language-info language-name
+                                                'coding-system)))))
+           (if kcs (set-keyboard-coding-system kcs display)))
+
+         (unless display
+           (setq locale-coding-system
+                 (car (get-language-info language-name 'coding-priority)))))
+
+       (when (and (not display)
+                  coding-system
                   (not (coding-system-equal coding-system
                                             locale-coding-system)))
          (prefer-coding-system coding-system)
@@ -2490,9 +2501,9 @@ See also `locale-charset-language-names', `locale-language-names',
     (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)
-         (setq locale-coding-system code-page-coding)
-         (set-keyboard-coding-system code-page-coding)
-         (set-terminal-coding-system code-page-coding))))
+         (unless display (setq locale-coding-system code-page-coding))
+         (set-keyboard-coding-system code-page-coding display)
+         (set-terminal-coding-system code-page-coding display))))
 
     (when (eq system-type 'darwin)
       ;; On Darwin, file names are always encoded in utf-8, no matter
@@ -2507,32 +2518,33 @@ See also `locale-charset-language-names', `locale-language-names',
 
     ;; Default to A4 paper if we're not in a C, POSIX or US locale.
     ;; (See comments in Flocale_info.)
-    (let ((locale locale)
-         (paper (locale-info 'paper)))
-      (if paper
-         ;; This will always be null at the time of writing.
-         (cond
-          ((equal paper '(216 279))
-           (setq ps-paper-type 'letter))
-          ((equal paper '(210 297))
-           (setq ps-paper-type 'a4)))
-       (let ((vars '("LC_ALL" "LC_PAPER" "LANG")))
-         (while (and vars (= 0 (length locale)))
-           (setq locale (getenv (pop vars)))))
-       (when locale
-         ;; As of glibc 2.2.5, these are the only US Letter locales,
-         ;; and the rest are A4.
-         (setq ps-paper-type
-               (or (locale-name-match locale '(("c$" . letter)
-                                               ("posix$" . letter)
-                                               (".._us" . letter)
-                                               (".._pr" . letter)
-                                               (".._ca" . letter)
-                                               ("enu$" . letter) ; Windows
-                                               ("esu$" . letter)
-                                               ("enc$" . letter)
-                                               ("frc$" . letter)))
-                   'a4))))))
+    (unless display
+      (let ((locale locale)
+           (paper (locale-info 'paper)))
+       (if paper
+           ;; This will always be null at the time of writing.
+           (cond
+            ((equal paper '(216 279))
+             (setq ps-paper-type 'letter))
+            ((equal paper '(210 297))
+             (setq ps-paper-type 'a4)))
+         (let ((vars '("LC_ALL" "LC_PAPER" "LANG")))
+           (while (and vars (= 0 (length locale)))
+             (setq locale (getenv (pop vars)))))
+         (when locale
+           ;; As of glibc 2.2.5, these are the only US Letter locales,
+           ;; and the rest are A4.
+           (setq ps-paper-type
+                 (or (locale-name-match locale '(("c$" . letter)
+                                                 ("posix$" . letter)
+                                                 (".._us" . letter)
+                                                 (".._pr" . letter)
+                                                 (".._ca" . letter)
+                                                 ("enu$" . letter) ; Windows
+                                                 ("esu$" . letter)
+                                                 ("enc$" . letter)
+                                                 ("frc$" . letter)))
+                     'a4)))))))
   nil)
 \f
 ;;; Charset property