update
[poppyer.git] / init / 04-chinese-init.el_bak
blobf87777adffcb02876b6eeb7a82358ac23f6435f8
1 ;;(require 'un-define)                                  ;; xemacs need it for utf-8
2 ;; the order MULE-CUS need to convert utf8 back
3 ;; NOT WORKING in emacs 22 without mule-ucs & mule-gbk,
4 ;; it will auto matically get from LC_CTYPE & current-lanuage-environment
6 ;; the following 3 lines for GBK
7 ;; (require 'mule-gbk)
8 ;; (set-language-environment 'Chinese-GBK)              ;; let emacs to use gbk to read source file?
9 ;; (load "subst-gbk")
11 ;; (setq utf-translate-cjk-charsets
12 ;;         '(chinese-gb2312
13 ;;           chinese-big5-1 chinese-big5-2
14 ;;           chinese-cns11643-5
15 ;;           chinese-cns11643-6
16 ;;           chinese-cns11643-7
17 ;;           japanese-jisx0208 japanese-jisx0212
18 ;;           katakana-jisx0201
19 ;;           korean-ksc5601))
21 (defun gb-first()
22   (interactive)
23   (load "subst-gb2312")
24 ;  (load "subst2-gbk")  
25 ;  (un-define-change-charset-order '(ascii chinese-gb2312 chinese-big5-1 chinese-big5-2))
27 (defun big5-first()
28   (interactive)
29   (load "subst-big5")
30 ;;  (un-define-change-charset-order '(ascii chinese-big5-1 chinese-big5-2 chinese-gb2312))
32 (gb-first)                      ;; seems not working with emacs22
35 ;; startup slow in LC_CTYPE=zh_CN.utf8 probably no font?
36 (set-keyboard-coding-system 'utf-8)             ;; but x is utf8
37 ;;(set-buffer-file-coding-system 'utf-8)
38 ;;(set-terminal-coding-system 'utf-8)
39 ;;(setq-default enable-multibyte-characters t)
41   (prefer-coding-system 'utf-8)
45 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
46 ;; some settings for coding systems are not yet correct
47 ;; after 'set-language-environment', especially not in UTF-8 locales, fix this:
48 (let* ((tmp (shell-command-to-string "locale charmap"))
49        (tmp (substring tmp 0 (string-match "\[ \t\n\]" tmp)))
50        (tmp (downcase tmp)))
51   (when (or (and (fboundp 'find-coding-system) ; XEmacs only
52                   (find-coding-system (intern tmp)))
53                 ;; Emacs:
54                 (coding-system-p (intern tmp)))
55     ;; set the coding system priorities:
56     ;; (this is also important to make XIM in utf-8 work for XEmacs
57     ;; because XEmacs has no variable/function to set the
58     ;; coding-system for XIM, it is just autodetected which
59     ;; will work correctly only when the coding-system priorities
60     ;; are OK.)
61     (if (not (and (string-match "XEmacs" emacs-version)
62                     (string-match "utf-8" tmp)))
63         (prefer-coding-system (intern tmp))
64       ;; it's strange, but (prefer-coding-system 'utf-8) doesn't
65       ;; work in XEmacs.
66       ;; use 'set-coding-priority-list instead, which achieves
67       ;; the same and works for 'utf-8 as well:
68       (set-coding-priority-list (list (intern tmp)))
69       (set-coding-category-system (intern tmp) (intern tmp)))
70     (set-default-coding-systems (intern tmp))
71     (set-keyboard-coding-system (intern tmp))
72     (set-terminal-coding-system (intern tmp))
73     (when (and (string-match "XEmacs" emacs-version) 
74                       (locate-library "lookup")
75                              (string-match "utf-8" tmp))
76       ;; It seems that lookup must loaded before the
77       ;; lookup-process-coding-system can be changed.
78       (require 'lookup)
79       (setq lookup-process-coding-system 'utf-8))))