完美支持中文编程的 Emacs 配置文件 .emacs

转载自http://my.oschina.net/freeblues/blog/105566

经过今天早晨的一番调试,终于完成这个比较通用的配置文件,使用该配置文件启动的 Emacs,具备如下特点:

1、完美支持中文;

2、支持自动补全,开启按键是(C-c a),需要把 Auto-complete 插件安装好;

3、支持暗色背景,让你的眼睛舒服一些,自己可以通过直接修改这句配置来调背景色:

 

1 (set-background-color "gray30")

 

4、支持语法高亮,当然这个本来就支持,不过做了点小改进,把左右括号单独拿出来上色,看起来更醒目一些;

5、支持显示行号;

6、支持切换 ccl 和 sbcl 

效果图在这里:

配置文件如下:

 1 ;(require 'cl)
 2 
 3 (custom-set-variables
 4 ;; custom-set-variables was added by Custom.
 5 ;; If you edit it by hand, you could mess it up, so be careful.
 6 ;; Your init file should contain only one such instance.
 7 ;; If there is more than one, they won't work right.
 8 '(current-language-environment "Chinese-GBK")
 9 '(uniquify-buffer-name-style (quote forward) nil (uniquify)))
10 (custom-set-faces
11 ;; custom-set-faces was added by Custom.
12 ;; If you edit it by hand, you could mess it up, so be careful.
13 ;; Your init file should contain only one such instance.
14 ;; If there is more than one, they won't work right.
15 )
16 ;;; =========
17 
18 (set-language-environment "utf-8")
19 
20 (add-to-list 'load-path "~/LispBox-0.92/ccl-1.8-darwinx86/")
21 (add-to-list 'load-path "~/LispBox-0.92/sbcl-1.0.55/")
22 
23 (add-to-list 'load-path "~/LispBox-0.92/slime-2012-11-13/")
24 (setq load-path (cons "~/LispBox-0.92/slime-2012-11-13/" load-path))
25 
26 ;(add-to-list 'load-path "~/.emacs.d/slime-2012-11-13/")
27 ;(setq load-path (cons "~/.emacs.d/slime-2012-11-13/" load-path))
28 
29 (global-font-lock-mode t)
30 
31 (font-lock-add-keywords 'lisp-mode '("[(]" "[)]"))
32 (font-lock-add-keywords 'emacs-lisp-mode '("[(]" "[)]"))
33 (font-lock-add-keywords 'lisp-interaction-mode '("[(]" "[)]"))
34 
35 (set-cursor-color "white")
36 (set-mouse-color "blue")
37 (set-foreground-color "green")
38 (set-background-color "gray30")
39 (set-border-color "lightgreen")
40 (set-face-foreground 'highlight "red")
41 (set-face-background 'highlight "lightblue")
42 (set-face-foreground 'region "darkcyan")
43 (set-face-background 'region "lightblue")
44 (set-face-foreground 'secondary-selection "skyblue")
45 (set-face-background 'secondary-selection "darkblue")
46 
47 (require 'linum)
48 (setq linum-format "%3d ")
49 (add-hook 'find-file-hooks (lambda () (linum-mode 1)))
50 
51 (add-to-list 'load-path "~/LispBox-0.92/auto-complete-1.3.1/")
52 (require 'auto-complete-config)
53 (add-to-list 'ac-dictionary-directories "~/LispBox-0.92/auto-complete-1.3.1/ac-dict")
54 (ac-config-default)
55 (add-hook 'lisp-mode-hook
56 '(lambda ()
57 (define-key lisp-mode-map "\C-ca" 'auto-complete-mode)))
58 
59 (add-to-list 'default-frame-alist '(width . 120))
60 (add-to-list 'default-frame-alist '(height . 50))
61 
62 (set-buffer-file-coding-system 'utf-8)
63 (set-terminal-coding-system 'utf-8)
64 (set-keyboard-coding-system 'utf-8)
65 (set-selection-coding-system 'utf-8)
66 (set-default-coding-systems 'utf-8)
67 (set-clipboard-coding-system 'utf-8) 
68 (setq ansi-color-for-comint-mode t)
69 (modify-coding-system-alist 'process "*" 'utf-8) 
70 (setq-default pathname-coding-system 'utf-8) 
71 (prefer-coding-system 'utf-8)
72 (setq default-process-coding-system '(utf-8 . utf-8)) 
73 (setq locale-coding-system 'utf-8)
74 (setq file-name-coding-system 'utf-8) 
75 (setq default-buffer-file-coding-system 'utf-8) 
76 (setq slime-net-coding-system 'utf-8-unix)
77 
78 ;;; =========
79 ;;; Note that if you save a heap image, the character
80 ;;; encoding specified on the command line will be preserved,
81 ;;; and you won't have to specify the -K utf-8 any more.
82 ;;; (setq inferior-lisp-program "/usr/local/bin/ccl64 -K utf-8")
83 
84 (setq inferior-lisp-program "dx86cl64 -K utf-8")
85 (setq inferior-lisp-program "sbcl -K utf-8")
86 
87 (setq slime-lisp-implementations
88 '((ccl ("/Users/admin/LispBox-0.92/ccl-1.8-darwinx86/dx86cl64") :coding-system utf-8-unix)
89 (sbcl ("/Users/admin/LispBox-0.92/sbcl-1.0.55/sbcl") :coding-system utf-8-unix)))
90 
91 (require 'slime-autoloads)
92 
93 (global-set-key "\C-cs" 'slime-selector)
94 
95 (slime-setup '(slime-fancy slime-asdf slime-banner))

内置了 ccl 和 sbcl 两种 Common Lisp 实现,直接启动 slime 的话会调用 ccl ,可以通过命令来选择调用哪种实现,具体操作如下:

1 启动方式:
2 M-- M-x slime
3 
4 说明一下,就是同时按住 ALT 键 和 - 键(减号),然后再同时按住 ALT 键和 x 键。
5 
6 接下来会提示你输入你要启动的 Lisp 实现:
7 输入 ccl 就是 ccl
8 输入 sbcl 就是 sbcl

 

posted @ 2013-07-27 23:41  静心のboke  阅读(741)  评论(0编辑  收藏  举报