当前位置: 技术问答>linux和unix
emacs中输入中文乱码
来源: 互联网 发布时间:2015-03-05
本文导语: 我是在windows下安装了NT版本的emacs21.1 ,当输入中文后,出现乱码,总要用鼠标全选一下,然后单击旁边空白处,才能显示正确的中文,虽然能显示中文,但这样很不方便,请问谁能有更好的办法帮我永久性的解除烦恼...
我是在windows下安装了NT版本的emacs21.1 ,当输入中文后,出现乱码,总要用鼠标全选一下,然后单击旁边空白处,才能显示正确的中文,虽然能显示中文,但这样很不方便,请问谁能有更好的办法帮我永久性的解除烦恼?多谢!
|
我试过了,可以的。
;; (global-set-key [f6] 'toggle-input-method)
;; Here's a sample .emacs file that might help you along the way. Just
;; copy this region and paste it into your .emacs file. You may want to
;; change some of the actual values.
(defconst my-c-style
'((c-tab-always-indent . t)
(c-comment-only-line-offset . 4)
(c-hanging-braces-alist . ((substatement-open after)
(brace-list-open)))
(c-hanging-colons-alist . ((member-init-intro before)
(inher-intro)
(case-label after)
(label after)
(access-label after)))
(c-cleanup-list . (scope-operator
empty-defun-braces
defun-close-semi))
(c-offsets-alist . ((arglist-close . c-lineup-arglist)
(substatement-open . 0)
(case-label . 4)
(block-open . 0)
(knr-argdecl-intro . -)))
(c-echo-syntactic-information-p . t)
)
"My C Programming Style")
;; offset customizations not in my-c-style
(setq c-offsets-alist '((member-init-intro . ++)))
;; Customizations for all modes in CC Mode.
(defun my-c-mode-common-hook ()
;; add my personal style and set it for the current buffer
(c-add-style "PERSONAL" my-c-style t)
;(c-set-style "stroustrup")
;; other customizations
(setq tab-width 4
;; this will make sure spaces are used instead of tabs
indent-tabs-mode nil)
;; we like auto-newline and hungry-delete
;(c-toggle-auto-hungry-state 1)
(c-toggle-hungry-state 1)
;; key bindings for all supported languages. We can put these in
;; c-mode-base-map because c-mode-map, c++-mode-map, objc-mode-map,
;; java-mode-map, idl-mode-map, and pike-mode-map inherit from it.
(define-key c-mode-base-map "C-m" 'c-context-line-break)
)
(add-hook 'c-mode-common-hook 'my-c-mode-common-hook)
(setq auto-mode-alist (cons '("\.c$" . c-mode) auto-mode-alist))
(setq auto-mode-alist (cons '("\.h$" . c++-mode) auto-mode-alist))
(setq auto-mode-alist (cons '("\.cpp$" . c++-mode) auto-mode-alist))
(setq auto-mode-alist (cons '("\.java$" . java-mode) auto-mode-alist))
;(setq auto-mode-alist (cons '("\.pl$" . cperl-mode) auto-mode-alist)
;;---------------------------------------------------------------------------
(custom-set-variables
;; custom-set-variables was added by Custom -- don't edit or cut/paste it!
;; Your init file should contain only one such instance.
'(auto-save-default nil)
'(case-fold-search t)
'(current-language-environment "Chinese-GB")
'(default-input-method "chinese-py-punct")
'(global-font-lock-mode t nil (font-lock))
'(show-paren-mode t nil (paren))
'(transient-mark-mode t)
'(w32-pass-alt-to-system t)
)
;;----------------------------------------------------------------------------
(set-keyboard-coding-system 'chinese-iso-8bit-dos) ; input
(set-selection-coding-system 'chinese-iso-8bit-dos) ; copy/paste
(if window-system
(setq w32-enable-italics t)
(setq w32-enable-synthesized-fonts t)
(create-fontset-from-fontset-spec
"-*-MS Song-bold-r-*-*-19-*-*-*-c-*-gb2312-*1
-*-Courier New-normal-r-*-*-14-*-*-*-c-*-fontset-chinese,
chinese-gb2312:-*-宋体-*-*-*-*-16-*-*-*-c-*-gb2312*-*,
chinese-big5-1:-*-MingLiU-normal-r-*-*-16-*-*-*-c-*-big5*-*,
chinese-big5-2:-*-MingLiU-normal-r-*-*-16-*-*-*-c-*-big5*-*" t)
(setq default-frame-alist
'((top . 0)(left . 320)(width . 82)(height . 52)
(font . "fontset-chinese")))
)
(set-default-font "-*-MS Song-bold-r-*-*-19-*-*-*-c-*-gb2312-*1")
;(set-default-font "chinese-gb2312:-*-宋体-*-*-*-*-16-*-*-*-c-*-gb2312*-*")
;(set-default-font "-*-Courier New-normal--r-*-*-14-*-*-*-c-*-fontset-chinese")
;(set-default-font "-raster-Terminal-normal-r-normal-normal-20-150-96-96-c-100-gb2312")
(set-frame-height (selected-frame) 34)
(set-frame-width (selected-frame) 81)
;(set-frame-height (selected-frame) 36)
;(set-frame-width (selected-frame) 88)
(custom-set-faces
;; custom-set-faces was added by Custom -- don't edit or cut/paste it!
;; Your init file should contain only one such instance.
)
(put 'upcase-region 'disabled nil)
;; (global-set-key [f6] 'toggle-input-method)
;; Here's a sample .emacs file that might help you along the way. Just
;; copy this region and paste it into your .emacs file. You may want to
;; change some of the actual values.
(defconst my-c-style
'((c-tab-always-indent . t)
(c-comment-only-line-offset . 4)
(c-hanging-braces-alist . ((substatement-open after)
(brace-list-open)))
(c-hanging-colons-alist . ((member-init-intro before)
(inher-intro)
(case-label after)
(label after)
(access-label after)))
(c-cleanup-list . (scope-operator
empty-defun-braces
defun-close-semi))
(c-offsets-alist . ((arglist-close . c-lineup-arglist)
(substatement-open . 0)
(case-label . 4)
(block-open . 0)
(knr-argdecl-intro . -)))
(c-echo-syntactic-information-p . t)
)
"My C Programming Style")
;; offset customizations not in my-c-style
(setq c-offsets-alist '((member-init-intro . ++)))
;; Customizations for all modes in CC Mode.
(defun my-c-mode-common-hook ()
;; add my personal style and set it for the current buffer
(c-add-style "PERSONAL" my-c-style t)
;(c-set-style "stroustrup")
;; other customizations
(setq tab-width 4
;; this will make sure spaces are used instead of tabs
indent-tabs-mode nil)
;; we like auto-newline and hungry-delete
;(c-toggle-auto-hungry-state 1)
(c-toggle-hungry-state 1)
;; key bindings for all supported languages. We can put these in
;; c-mode-base-map because c-mode-map, c++-mode-map, objc-mode-map,
;; java-mode-map, idl-mode-map, and pike-mode-map inherit from it.
(define-key c-mode-base-map "C-m" 'c-context-line-break)
)
(add-hook 'c-mode-common-hook 'my-c-mode-common-hook)
(setq auto-mode-alist (cons '("\.c$" . c-mode) auto-mode-alist))
(setq auto-mode-alist (cons '("\.h$" . c++-mode) auto-mode-alist))
(setq auto-mode-alist (cons '("\.cpp$" . c++-mode) auto-mode-alist))
(setq auto-mode-alist (cons '("\.java$" . java-mode) auto-mode-alist))
;(setq auto-mode-alist (cons '("\.pl$" . cperl-mode) auto-mode-alist)
;;---------------------------------------------------------------------------
(custom-set-variables
;; custom-set-variables was added by Custom -- don't edit or cut/paste it!
;; Your init file should contain only one such instance.
'(auto-save-default nil)
'(case-fold-search t)
'(current-language-environment "Chinese-GB")
'(default-input-method "chinese-py-punct")
'(global-font-lock-mode t nil (font-lock))
'(show-paren-mode t nil (paren))
'(transient-mark-mode t)
'(w32-pass-alt-to-system t)
)
;;----------------------------------------------------------------------------
(set-keyboard-coding-system 'chinese-iso-8bit-dos) ; input
(set-selection-coding-system 'chinese-iso-8bit-dos) ; copy/paste
(if window-system
(setq w32-enable-italics t)
(setq w32-enable-synthesized-fonts t)
(create-fontset-from-fontset-spec
"-*-MS Song-bold-r-*-*-19-*-*-*-c-*-gb2312-*1
-*-Courier New-normal-r-*-*-14-*-*-*-c-*-fontset-chinese,
chinese-gb2312:-*-宋体-*-*-*-*-16-*-*-*-c-*-gb2312*-*,
chinese-big5-1:-*-MingLiU-normal-r-*-*-16-*-*-*-c-*-big5*-*,
chinese-big5-2:-*-MingLiU-normal-r-*-*-16-*-*-*-c-*-big5*-*" t)
(setq default-frame-alist
'((top . 0)(left . 320)(width . 82)(height . 52)
(font . "fontset-chinese")))
)
(set-default-font "-*-MS Song-bold-r-*-*-19-*-*-*-c-*-gb2312-*1")
;(set-default-font "chinese-gb2312:-*-宋体-*-*-*-*-16-*-*-*-c-*-gb2312*-*")
;(set-default-font "-*-Courier New-normal--r-*-*-14-*-*-*-c-*-fontset-chinese")
;(set-default-font "-raster-Terminal-normal-r-normal-normal-20-150-96-96-c-100-gb2312")
(set-frame-height (selected-frame) 34)
(set-frame-width (selected-frame) 81)
;(set-frame-height (selected-frame) 36)
;(set-frame-width (selected-frame) 88)
(custom-set-faces
;; custom-set-faces was added by Custom -- don't edit or cut/paste it!
;; Your init file should contain only one such instance.
)
(put 'upcase-region 'disabled nil)
|
update to emacs21.2 or emacs 21.3