Emacs和Python [英] Emacs and Python

查看:120
本文介绍了Emacs和Python的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我最近开始学习 Emacs 。我经历了教程,阅读了一些介绍性文章,迄今为止这么好。

I recently started learning Emacs. I went through the tutorial, read some introductory articles, so far so good.

现在我想用它来进行Python开发。根据我的理解,Emacs有两种独立的Python模式:python-mode.el,它是Python项目的一部分;和python.el,它是Emacs 22的一部分。

Now I want to use it for Python development. From what I understand, there are two separate Python modes for Emacs: python-mode.el, which is part of the Python project; and python.el, which is part of Emacs 22.

我阅读了所有可以找到的信息,但大部分内容似乎相当过时,我仍然感到困惑。

I read all information I could find but most of it seems fairly outdated and I'm still confused.

问题:


  1. 他们有什么区别?

  2. 我应该安装和使用哪种模式?

  3. 是否还有其他Emacs附加组件对Python开发至关重要?

相关链接:

  • EmacsEditor @ wiki.python.org
  • PythonMode @ emacswiki.org

推荐答案

如果您使用GNU Emacs 21或之前,或XEmacs,使用python-mode.el。 GNU Emacs 22 python.el将无法正常工作。在GNU Emacs 22上,python.el工作,并且更好地与GNU Emacs自己的符号解析和完成,ElDoc等联系起来。我自己使用XEmacs,所以我不使用它,我听说有人抱怨说它没有过去工作非常好,但是有更新可以解决一些问题(例如,在您链接的emacswiki页面上),你希望有些已经在上游集成了。如果我是GNU Emacs,我会使用python.el,直到我发现不具体的原因。

If you are using GNU Emacs 21 or before, or XEmacs, use python-mode.el. The GNU Emacs 22 python.el won't work on them. On GNU Emacs 22, python.el does work, and ties in better with GNU Emacs's own symbol parsing and completion, ElDoc, etc. I use XEmacs myself, so I don't use it, and I have heard people complain that it didn't work very nicely in the past, but there are updates available that fix some of the issues (for instance, on the emacswiki page you link), and you would hope some were integrated upstream by now. If I were the GNU Emacs kind, I would use python.el until I found specific reasons not to.

python-mode.el是我最大的问题已经看到,它不太了解三重引号的字符串。它将它们视为单引号,这意味着三重引号字符串中的单引号将抛出语法突出显示:它会认为字符串已经在那里结束。您可能还需要更改自动模式,以启用.py文件的python模式;我不记得如果还是这样,但是我的init.el已经设置了自动模式 - 主题多年了。

The python-mode.el's single biggest problem as far as I've seen is that it doesn't quite understand triple-quoted strings. It treats them as single-quoted, meaning that a single quote inside a triple-quoted string will throw off the syntax highlighting: it'll think the string has ended there. You may also need to change your auto-mode-alist to turn on python-mode for .py files; I don't remember if that's still the case but my init.el has been setting auto-mode-alist for many years now.

至于其他插件,没有我会考虑必不可少。 XEmacs的功能菜单有时是有用的,它为您提供了当前文件的一些功能/类浏览器菜单。我不记得GNU Emacs有什么类似的。我有一个rst-mode用于reStructuredText编辑,因为这在某些项目中使用。绑定到您使用的任何VC(如果有的话)可能对您有用,但内置的支持大多数和容易下载的.el文件为其他。

As for other addons, nothing I would consider 'essential'. XEmacs's func-menu is sometimes useful, it gives you a little function/class browser menu for the current file. I don't remember if GNU Emacs has anything similar. I have a rst-mode for reStructuredText editing, as that's used in some projects. Tying into whatever VC you use, if any, may be useful to you, but there is builtin support for most and easily downloaded .el files for the others.

这篇关于Emacs和Python的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆