XEmacs 21.2.11
[chise/xemacs-chise.git.1] / lisp / mule / mule-init.el
1 ;; Mule default configuration file
2
3 ;; This file is part of XEmacs.
4
5 ;; XEmacs is free software; you can redistribute it and/or modify it
6 ;; under the terms of the GNU General Public License as published by
7 ;; the Free Software Foundation; either version 2, or (at your option)
8 ;; any later version.
9
10 ;; XEmacs is distributed in the hope that it will be useful, but
11 ;; WITHOUT ANY WARRANTY; without even the implied warranty of
12 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
13 ;; General Public License for more details.
14
15 ;; You should have received a copy of the GNU General Public License
16 ;; along with XEmacs; see the file COPYING.  If not, write to the 
17 ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
18 ;; Boston, MA 02111-1307, USA.
19
20 ;;; 87.6.9   created by K.handa
21 ;;; (Note: following comment obsolete -- mrb)
22
23 ;;; IMPORTANT NOTICE -- DON'T EDIT THIS FILE!!!
24 ;;;  Keep this file unmodified for further patches being applied successfully.
25 ;;;  All language specific basic environments are defined here.
26 ;;;  By default, Japanese is set as the primary environment.
27 ;;;  You can change primary environment in `./lisp/site-init.el by
28 ;;;  `set-primary-environment'.  For instance,
29 ;;;     (set-primary-environment 'chinese)
30 ;;;  makes Chinese the primary environment.
31 ;;;  If you are still not satisfied with the settings, you can
32 ;;;  override them after the above line.  For instance,
33 ;;;     (set-default-buffer-file-coding-system 'big5)
34 ;;;  makes big5 be used for file I/O by default.
35 ;;;  If you are not satisfied with other default settings in this file,
36 ;;;  override any of them also in `./lisp/site-init.el'.  For instance,
37 ;;;     (define-program-coding-system nil ".*mail.*" 'iso-8859-1)
38 ;;;  makes the coding-system 'iso-8859-1 be used in mail.
39
40
41 ;;;; GLOBAL ENVIRONMENT SETUP
42 (require 'cl)
43
44 \f
45 ;; (setq language-environment-list
46 ;;       (sort (language-environment-list) 'string-lessp))
47
48 ;; MULE keymap codes were moved to mule-cmds.el.
49
50 ;; Alternative key definitions
51 ;; Original mapping will be altered by set-keyboard-coding-system.
52 (define-key global-map [(meta \#)] 'ispell-word)        ;originally "$"
53 ;; (define-key global-map [(meta {)] 'insert-parentheses) ;originally "("
54
55 ;; Following line isn't mule-specific --mrb
56 ;;(setq-default modeline-buffer-identification '("XEmacs: %17b"))
57
58 ;; MULE keymap codes were moved to mule-cmds.el.
59
60 ;; (define-key help-map "T" 'help-with-tutorial-for-mule)
61
62 ;; (defvar help-with-tutorial-language-alist
63 ;;  '(("Japanese" . ".jp")
64 ;;    ("Korean"   . ".kr")
65 ;;    ("Thai"     . ".th")))
66
67 ;(defun help-with-tutorial-for-mule (language)
68 ;  "Select the Mule learn-by-doing tutorial."
69 ;  (interactive (list (let ((completion-ignore-case t)
70 ;                          lang)
71 ;                      (completing-read
72 ;                       "Language: "
73 ;                       help-with-tutorial-language-alist))))
74 ;  (setq language (cdr (assoc language help-with-tutorial-language-alist)))
75 ;  (help-with-tutorial (concat "mule/TUTORIAL" (or language ""))))
76
77 (defvar auto-language-alist
78   '(("^ja" . "Japanese")
79     ("^zh" . "Chinese")
80     ("^ko" . "Korean"))
81   "Alist of LANG patterns vs. corresponding language environment.
82 Each element looks like (REGEXP . LANGUAGE-ENVIRONMENT).
83 It the value of the environment variable LANG matches the regexp REGEXP,
84 then `set-language-environment' is called with LANGUAGE-ENVIRONMENT.")
85
86 (defun init-mule ()
87   "Initialize MULE environment at startup.  Don't call this."
88   (let ((lang (or (getenv "LC_ALL") (getenv "LC_MESSAGES") (getenv "LANG"))))
89     (unless (or (null lang) (string-equal "C" lang))
90       (let ((case-fold-search t))
91         (loop for elt in auto-language-alist
92               if (string-match (car elt) lang)
93               return (progn
94                        (setq lang (substring lang 0 (match-end 0)))
95                        (set-language-environment (cdr elt))
96                        )))
97       ;; Load a (localizable) locale-specific init file, if it exists.
98       (load (format "%s%s/locale-start"
99                     (locate-data-directory "start-files")
100                     lang) t t)))
101   
102   (when current-language-environment
103     ;; Translate remaining args on command line using file-name-coding-system
104     (loop for arg in-ref command-line-args-left do
105           (setf arg (decode-coding-string arg file-name-coding-system)))
106     
107     ;; rman seems to be incompatible with encoded text
108     (setq Manual-use-rosetta-man nil)
109
110     ;; Make sure ls -l output is readable by dired and encoded using
111     ;; file-name-coding-system
112     (add-hook
113      'dired-mode-hook
114      (lambda ()
115        (make-local-variable 'process-environment)
116        (setenv "LC_MESSAGES" "C")
117        (setenv "LC_TIME"     "C"))))
118   
119   ;; Register avairable input methods by loading LEIM list file.
120   (load "leim-list.el" 'noerror 'nomessage 'nosuffix)
121   )
122
123 (add-hook 'before-init-hook 'init-mule)
124
125 ;;;;; Enable the tm package by default
126 ;;(defun init-mule-tm ()
127 ;;  "Load MIME (TM) support for GNUS, VM, MH-E, and RMAIL."
128 ;;  (load "mime-setup"))
129
130 ;;(add-hook 'after-init-hook 'init-mule-tm)
131
132 ;;; mule-init.el ends here