如何使用Emacs与Python [英] How to use Emacs with Python

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

问题描述

我很喜欢emacs,我想用emacs来开发python。我使用的是Ubuntu 9.10。我很沮丧地使用蟒蛇来工作。我使用GNU Emacs 23.1.50.1(x86_64-pc-linux-gnu,GTK + Version 2.18.0)。



这里我做了什么。
*



Emacs带有python模式,但令人困惑的是有两种类型的模式,一种是python-mode.el,另一种是python.el。我使用emacs 23,所以我的是python.el(我想)。我还需要python模式吗?当我按M-Tab,而不是窗口管理器工作时,代码完成不起作用。我试过Esc-Tab,但它说不匹配。如何启用代码完成?



之后我安装了ropemacs

  sudo aptitude install python-ropemacs 

然后我在〜/ .emacs $ b $中创建了.emacs文件b和我添加了以下内容.emacs文件

 (require'pymacs)
(pymacs-loadropemacs绳索 - )
(setq ropemacs-enable-autoimport t)

然后当我打M- /(Alt- /)它不起作用,当我从菜单中选择Rope-> Code帮助它打开一个文件对话框来选择根项目文件夹。我选择目前有一些python代码的文件夹。当我再次尝试从辅助菜单代码协助说
完成x:只是空集。如何使emacs python代码完成工作?



然后我下载了 anything.el ,anything-config,anything-match-plugin到〜/ .emacs.d文件夹然后我添加了以下行到.emacs文件



$ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $任何东西)
(全局设置键\C-ce'任何文件)

猜测它没有工作。我试过M-x任何东西,我没有得到匹配(我猜想可能我的组合C-ca(第一个控制 - 然后e)可能会工作,说它没有定义)。你可以解释python的代码完成与清楚的解释(一步一步)给我的虚拟人物。谢谢。
编辑:我可以使用与连接的python工作的emacs。感谢所有的回答

解决方案

我没有尝试任何东西,我没有运气与绳子导致我的emacs挂起任何文件保存)。相反,我发现默认的完成功能足以用于我的目的。



默认完成键绑定是 M - / 。它运行dabbrev-expand,将当前单词扩展为最前面的这个前缀词。这不完美:它不会解析类型,它不会搜索进口,但它在90%的情况下起作用。



(你必须停用绳索。)


I am new to emacs and I want to use emacs for python development. I am using Ubuntu 9.10. I frustrated to getting emacs work with python. I use GNU Emacs 23.1.50.1 (x86_64-pc-linux-gnu, GTK+ Version 2.18.0).

Here what I did. *

Emacs come with python mode but it is confusing there are two types of mode one is python-mode.el and other one is python.el. I use emacs 23 so mine is python.el (I think). Do I need python-mode too? Code completion does not work when I press M-Tab , instead of it window manager works. I tried Esc-Tab but it says "No match" . How can I enable code completion?

After that I installed ropemacs

sudo aptitude install python-ropemacs

Then I created .emacs file at ~/.emacs and I added followings to .emacs file

(require 'pymacs)   
(pymacs-load "ropemacs" "rope-")   
(setq ropemacs-enable-autoimport t)  

Then when I hit M-/ (Alt-/) it doesn't work when I cick from the menu Rope->Code assist it opens a file dialog for choosing root project folder. I choose current folder which has there are some python code. When I try again Code assist from menu it says "Completion for x: " nothing but empty set. How can make emacs python code completion work?

Then I downloaded anything.el, anything-config, anything-match-plugin to ~/.emacs.d folder Then I added following lines to .emacs file

(require 'anything-config)   
(require 'anything-match-plugin)   
(global-set-key "\C-ca" 'anything)   
(global-set-key "\C-ce" 'anything-for-files)   

Guess what it didnt work. I tried "M-x anything" again I get No match.(I guessed may me combination of C-ca (First control-a then e ) might work it says it isnt defined). Could you explain code completion for python with clear explanations (step by step) to someone dummy as me. Thanks. Edit: I able emacs work with python with the link. Thanks all for answering

解决方案

I haven't tried anything, and I haven't had much luck with rope (giant source tree causes my emacs to hang upon any file save). Instead, I find the default completion works well enough for my purposes.

The default completion keybinding is M-/. That runs dabbrev-expand which expands the current word to "the most recent, preceding word for which this is a prefix." It's not perfect: It won't parse types, and it won't search imports, but it works in 90% of the cases.

(You'll have to deactivate rope.)

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

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