基本配置
Emacs本身提供了python-mode,输入M-x python-mode,就可以进入python模式。相应地,会在菜单栏出现Python菜单。当然,一般来讲,如果是.py文件打开的话,也会自动进入该模式。
不过,默认的python模式功能上面用起来还是有点弱,而且许多地方做的并不好,最好下载第三方的python模式。python-mode是一个开源项目,可以在https://launchpad.net/python-mode进行下载。
1.安装 1).安装prog-modes:
aptitude install prolog-el
2).下载python-mode.el文件在项目主页上面。
3).编译:
C-x C-f /path/to/python-mode.el RET
M-x byte-compile-file RET
4).在.emacs中加入python-mode.el路径:
(setq load-path (cons "/dir/of/python-mode/" load-path))
检测扩展是否加载路径,测试方法:M-x locate-library RET python-mode RET
2.配置.emacs文件
(setq auto-mode-alist
(cons '("//.py$" . python-mode) auto-mode-alist))
(setq interpreter-mode-alist
(cons '("python" . python-mode)
interpreter-mode-alist))
(autoload 'python-mode "python-mode" "Python editing mode." t)
;;; add these lines if you like color-based syntax highlighting
(global-font-lock-mode t)
(setq font-lock-maximum-decoration t)
(set-language-environment 'Chinese-GB)
(set-keyboard-coding-system 'euc-cn)
(set-clipboard-coding-system