简体   繁体   English

Emacs python-mode

[英]Emacs python-mode

I'm trying to configure Emacs23.2 to work with python2.7.3, using the package python-mode.el-6.0.7 我正在尝试使用python-mode.el-6.0.7软件包配置Emacs23.2以使用python2.7.3

After adding to my .emacs file these LISP lines, as indicated in the INSTALL instructions,... 在我的.emacs文件中添加这些LISP行后,如INSTALL说明中所示,......

(add-to-list 'load-path "PATH/TO/PYTHON-MODE/") 
(setq py-install-directory "PATH/TO/PYTHON-MODE/")
(require 'python-mode)

... I open a file foo.py and until here its all OK: python is recognised, the syntax is highlighted and emacs is working well. ...我打开一个文件foo.py ,直到这里一切正常:python被识别,语法突出显示,emacs运行良好。

But I got the suspect I'm missing something or doing something wrong... Mainly, because in the python-mode package there is some more stuff to use with python&emacs, like pycomplete, pymacs, etc... which looks like they are not operating together when I open emacs & python. 但我怀疑我错过了什么或做错了什么......主要是因为在python-mode包中有更多的东西可以用于python和emacs,比如pycomplete,pymacs等...看起来像是当我打开emacs和python时不能一起操作。

Does anyone know how to configure this package in a proper way, to get everything together working right? 有没有人知道如何以适当的方式配置这个包,让一切工作正常?

Any (personal) suggestion is welcome, as I am not a pro with emacs...! 任何(个人)建议都是受欢迎的,因为我不是emacs的专业人士......!

(I imagine someone will provide a better answer, but...) (我想有人会提供更好的答案,但......)

The documentation for Python support on the EmacsWiki used to be pretty messy, in part because there were two different major modes to choose from, and information for each was all mixed into the same page. EmacsWiki上的Python支持文档过去非常混乱,部分原因是有两种不同的主要模式可供选择,每种模式的信息都混合到同一页面中。

It's clearly been cleaned up a great deal since I first encountered it, so hopefully it's not too confusing, and you'll find what you need at one of the following: 自从我第一次遇到它以来,它显然被清理了很多,所以希望它不会太混乱,你可以在以下某个地方找到你需要的东西:

current python-mode.el comes with an extended menu: PyEdit, PyExec etc. 当前的python-mode.el带有扩展菜单:PyEdit,PyExec等。

https://launchpad.net/python-mode/+download https://launchpad.net/python-mode/+download

See also in section doc commands-python-mode.org resp. 另请参见doc commands-python-mode.org resp。 commands-python-mode.rst 命令-蟒-mode.rst

Remaining questions might be filed in https://answers.launchpad.net/python-mode 其余问题可能会在https://answers.launchpad.net/python-mode中提交

This are the relevant lines from my init.el : 这是我的init.el的相关行:

(setq py-install-directory "~/.emacs.d/site-lisp/python-mode.el-6.1.1") (setq py-install-directory“〜/ .emacs.d / site-lisp / python-mode.el-6.1.1”)

(add-to-list 'load-path py-install-directory) (add-to-list'load-path py-install-directory)

(require 'python-mode) (需要'python-mode)

Download the latest version of python-mode from Launchpad and tell Emacs in your init.el where to find it. 从Launchpad下载最新版本的python-mode ,告诉init.el中的Emacs在哪里找到它。 (see above) (往上看)

If your Major-Mode says Py you are using pyhon-mode.el, if it says Python , then you are using the built-in python.el mode. 如果你的Major-Mode说Py你正在使用pyhon-mode.el,如果它说Python ,那么你正在使用内置的python.el模式。

For Auto-completion you should try Jedi , this is a very nice completion library for python. 对于自动完成,你应该尝试Jedi ,这是一个非常好的python完成库。

You can customize python-mode via the very comprehensive menu entries or via 您可以通过非常全面的菜单条目或通过自定义python模式

Mx customize-mode . Mx customize-mode

Among advanced features of the python-mode I'm only using 我只使用python-mode高级功能

(add-hook 'python-mode-hook (lambda ()
    (define-key python-mode-map (kbd "C-c |")
    'py-execute-region-ipython)))

send region to ipython with Cc | 使用Cc |将区域发送到ipython .

I can wholeheartedly recommend anaconda-mode . 我可以全心全意地推荐anaconda-mode It gives you auto completion, documentation lookup, jump to source++. 它为您提供自动完成,文档查找,跳转到源++。 Together with pyflakes, flymake, auto-complete-mode and projectile, it makes Emacs a great Python development environment. 与pyflakes,flymake,自动完成模式和抛射物一起,它使Emacs成为一个伟大的Python开发环境。

It's easy to set up too, you can start out with these two lines only: (add-hook 'python-mode-hook 'anaconda-mode) (add-hook 'python-mode-hook 'ac-anaconda-setup) 它也很容易设置,你可以从这两行开始:( (add-hook 'python-mode-hook 'anaconda-mode) (add-hook 'python-mode-hook 'ac-anaconda-setup)

I suggest use other python-el , such as 我建议使用其他python-el,比如

https://github.com/fgallina/python.el https://github.com/fgallina/python.el

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM