Emacs 的 Python 模式比较 [英] Comparison of Python modes for Emacs

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

问题描述

所以我有 Emacs 24.3,它附带了一个相当新的 python.el 文件,提供了用于编辑的 Python 模式.

So I have Emacs 24.3 and with it comes a quite recent python.el file providing a Python mode for editing.

但我一直读到 Launchpad,对比两个文件,我发现前者在4000行以下,而后者在20000行左右.这表明后者功能更丰富.

But I keep reading that there is a python-mode.el on Launchpad, and comparing the two files it jumps out to me that the former is under 4000 lines, while the latter is almost 20000. This suggests that the latter is much more feature-rich.

而且我找不到任何关于它们的在线功能比较、文档,或者至少是关于它们每个功能的列表.是的,有语法高亮和嵌入式解释器,但是 shell 缓冲区中的完成、源文件缓冲区中的完成、自动缩进、重新缩进等呢?

And I can't find any online feature comparison about them, documentation, or at least a list about the features for each of them. Yep, there is syntax highlighting and embedded interpreter, but what about completion in shell buffer, completion in source file buffer, autoindent, reindent etc.

那么这些模式的重要特点是什么?(或您推荐的任何其他适用于 Emacs 的 Python 模式.)请提供详细答案.

So what are the important features of these modes? (Or any other Python mode for Emacs which you recommend.) Please provide detailed answers.

推荐答案

我曾经是 python-mode.el 用户,但一年前不再使用它,因为我觉得它的开发方式组织得不好.这是我当时记笔记的清单.但我需要提醒你,从那时起已经过去了将近一年,所以情况可能会有所改变.

I was python-mode.el user once but quit using it a year ago because I felt the way it was developed was not well organized. Here is a list from the note I took at that time. But I need to warn you that almost a year is passed since then so the situation may be changed.

  1. 许多复制和粘贴功能.
  2. 许多意外运行的代码.例如,不传递变量而是使用隐式绑定.这会产生许多编译错误(如果您将其更改为词法范围,则不会起作用).
  3. 提交的粗略粒度.我发送了一个补丁,并提交了一些无关的更改.

我喜欢 python-mode.el 的一件事是它带有自动化测试集(尽管我从未运行过它).python.el 还没有测试集.但是我知道python.el的作者现在正在写它.

One thing I like about python-mode.el is it comes with automated test set (although I've never run it). python.el does not have a test set yet. But I know the author of python.el is writing it now.

虽然 python.el 很紧凑,但这并不意味着你的功能很差.它更像是保持核心很小,并通过提供简洁的 API 来让其他人扩展它.python.el 的同一作者写了 python-django.el 为 django 项目扩展 python.el.我为 Python 编写了名为 Jedi.el 的自动完成插件和名为 EIN.与 python-mode.el 相比,它们都对 python.el 有更好的支持(不过,那是因为我不使用 python-mode.el).

While python.el is compact, it does not mean you get poor functionality. It is more like keeping core small and let others to extend it by providing concise API. Same author of python.el wrote python-django.el to extend python.el for django projects. I wrote auto-completion plugin for Python called Jedi.el and advanced IPython plugin called EIN. Both of them have better support for python.el than python-mode.el (well, that's because I don't use python-mode.el, though).

我首先从 python-mode.el 中遗漏了一些东西,但它们很快在 python.el 中修复(当然,这可能意味着我没有在 python-mode.el 中使用这么多功能).

I had a few thing I missed from python-mode.el first, but they are quickly fixed in python.el (Of course, this probably means that I was not using so much functionality in python-mode.el).

shell 缓冲区中的补全、源文件缓冲区中的补全、自动缩进、重新缩进等等.

what about completion in shell buffer, completion in source file buffer, autoindent, reindent etc.

  • 在 shell 缓冲区中完成:它在 python.el 和 python-mode.el 中都有效.但有时如果 Emacs 版本和 python(-mode).el 版本的组合不好,它就不起作用.所以可能 python.el 以这种方式更安全.但如果你想要更好的解决方案,请使用 EIN :)

    在源文件缓冲区中完成:只需使用 Jedi.el :)

    completion in source file buffer: Just use Jedi.el :)

    自动缩进/重新缩进:我不知道哪一个在性能方面更好.但是,返回的键绑定彼此不同.在 python-mode.el 中,如果你输入 RET 你会自动缩进.在 python.el 中,RET 不会给你缩进,你应该使用 C-j 来代替.实际上,换行+缩进的 C-j 是 Emacs 中的普遍行为.所以如果你用其他语言编程,python.el 会更好.

    autoindent/reindent: I don't know which one is better in performance-wise. However, keybind for return differs one to the other. In python-mode.el, if you type RET you get autoindent. In python.el, RET does not give you indentation and you should use C-j instead. Actually C-j for newline+indentation is universal behavior in Emacs. So python.el is better if you do programming in other languages.

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

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