Chinaunix首页 | 论坛 | 博客
  • 博客访问: 489086
  • 博文数量: 137
  • 博客积分: 3874
  • 博客等级: 中校
  • 技术积分: 1475
  • 用 户 组: 普通用户
  • 注册时间: 2010-07-05 10:50
文章分类

全部博文(137)

文章存档

2011年(37)

2010年(100)

分类: LINUX

2010-10-30 18:47:07

emacs号称是编辑器之王,无所不能。可把他作为一个Python的集成开发环境

尽管那么的牛,但是从前用的多的还是简单的 。受不了吸引,决定开始使用Emacs进行Python的编程。

和中,对竟然没有太多的介绍,反而在另外一个网站上找到了一些 ,特别是 。

安装过程总结一下:

  1. 使用最新的emacs:大于21.1的XEmacsen,或者大于20.7的Emacsen.
  2. 确保安装了prog-modes这个包,在debian中很简单:
    apt-get install prolog-el
  3. 在项目中,下载python-mode.el

  4. 字节编译,在emacs中输入命令(警告信息可忽略):
    C-x C-f /path/to/python-mode.el RET

    M-x byte-compile-file RET
  5. 确保python-mode.el在加载路径中,测试方法:
    M-x locate-library RET python-mode RET
    如果没有,加入下行到自己的.emacs文件中:
    (setq load-path (cons "/dir/of/python-mode/" load-path))
  6. 文件关联,自动将py后缀的文件和pyhton-mod关联,在自己的.emacs文件中添加:
    (setq auto-mode-alist

    (cons '("\\.py$" . python-mode) auto-mode-alist))

    (setq interpreter-mode-alist

    (cons '("python" . python-mode)

    interpreter-mode-alist))
  7. 自动加载,将 python-mode 和文件 python-mode.elc关联,在自己的.emacs文件中添加:
    (autoload 'python-mode "python-mode" "Python editing mode." t)
  8. 语法加亮,这个功能可不能少哟:) 同样在自己的.emacs文件中添加:
    ;;; add these lines if you like color-based syntax highlighting

    (global-font-lock-mode t)

    (setq font-lock-maximum-decoration t)
  9. 支持中文,在.emacs中添加:

    (set-language-environment 'Chinese-GB)

    (set-keyboard-coding-system 'euc-cn)

    (set-clipboard-coding-system 'euc-cn)

    (set-terminal-coding-system 'euc-cn)

    (set-buffer-file-coding-system 'euc-cn)

    (set-selection-coding-system 'euc-cn)

    (modify-coding-system-alist 'process "*" 'euc-cn)

    (setq default-process-coding-system

    '(euc-cn . euc-cn))

    (setq-default pathname-coding-system 'euc-cn)

好了!进入emacs试验一下:

emacs abc.py

可以看到emacs的底部显示:Using the CPython shell。可以试着输入一些代码,加亮显示没有问题,支持自动缩进,支持自动括号匹配提示.... 使用C-h m你可以看到python模式的详细帮助文件,功能果然很强大!

阅读(5600) | 评论(1) | 转发(0) |
0

上一篇:ubuntu边栏误删

下一篇:总结&&计划

给主人留下些什么吧!~~

chinaunix网友2010-10-31 19:03:18

很好的, 收藏了 推荐一个博客,提供很多免费软件编程电子书下载: http://free-ebooks.appspot.com