ropemacs使用教程 [英] ropemacs USAGE tutorial

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

问题描述

有很多站点都有安装 ropemacs的说明,但到目前为止,我没有找到任何有关如何在安装之后使用的说明。我已经安装了,或者至少看起来,Emacs的顶级菜单栏中有Rope菜单。怎么办?到目前为止,我只能使用显示文档(默认为C-c d)。尝试使用代码辅助(自动完成,我假定?)只会导致Emacs在minibuffer中询问绳索项目根文件夹(这是什么?),然后再显示任何内容。

There are many sites with instructions on installing ropemacs, but so far I couldn't find any with instructions on how to use it after it's already installed. I have it installed, or at least it seems so, Emacs has "Rope" menu in it's top menu bar. Now what? So far I could use only "Show documentation" (C-c d by default). An attempt to use code assist (which is auto-complete, I presume?) only causes Emacs to ask about "Rope project root folder" (what's that?) in the minibuffer and then showing nothing.

所以,一旦安装ropemacs,在一些简单的python脚本上看到它的步骤是什么?像如果你的emacs中有这个脚本,并在这里放置闪烁的方块,然后按这个,那么那个将是一个答案

So, once ropemacs is installed, what are the steps to see it in action on some simple python scripts? Something like "if you have this script in your emacs and put the blinking square here and press this, it does that" would be an answer.

(我一直在想,如果我应该问一段时间,因为没有人似乎有同样的问题)

(I've been thinking if I should ask this or not for some time, because nobody else seems to have the same problem)

推荐答案

嗯,你首先需要选择你的项目根文件夹。很简单,这是项目顶层的文件夹,如果您正在处理单个文件,则为当前文件夹。选择根文件夹后,其他选项将会起作用,例如代码辅助,显示文档,跳转到其他符号等。

Well, you first need to select your project root folder. Quite simply, this is the folder at the top level of your project, or the current folder if you're dealing with a single file. Once you've selected the root folder, then other options will work, such as code assist, showing documentation, jumping to other symbols, etc.

为了充分利用ropemacs我建议您将 autocomplete.el ,将其放在〜/ .emacs.d中,然后添加到您的.emacs

For full benefit of ropemacs, I suggest getting autocomplete.el, putting it in ~/.emacs.d, and then adding this to your .emacs

(add-to-list 'load-path "~/.emacs.d/")
(add-to-list 'load-path "~/.emacs.d/auto-complete-1.2")
(autoload 'python-mode "python-mode" "Python Mode." t)
(add-to-list 'auto-mode-alist '("\\.py\\'" . python-mode))
(add-to-list 'interpreter-mode-alist '("python" . python-mode))
(require 'python-mode)
(autoload 'pymacs-apply "pymacs")
(autoload 'pymacs-call "pymacs")
(autoload 'pymacs-eval "pymacs" nil t)
(autoload 'pymacs-exec "pymacs" nil t)
(autoload 'pymacs-load "pymacs" nil t)
(pymacs-load "ropemacs" "rope-")
(setq ropemacs-enable-autoimport t)

(require 'auto-complete)
(global-auto-complete-mode t)

这假定您在〜/ .emacs.d / auto-complete-1.2中安装自动完成。执行此操作后,您将在键入字符或符号的几个字符后自动完成。

This assumes you install autocomplete in ~/.emacs.d/auto-complete-1.2. After you do this, you will get autocomplete automatically after typing a few characters of a word or symbol.

您可以将ROOT / .ropeproject / config.py文件修改为添加更多目录到绳索查找路径,以便提供更好的自动完成。

You can modify your ROOT/.ropeproject/config.py file to add more directories to the rope lookup path, in order to provide better autocomplete.

编辑:我最重要的功能之一是查找文档并直接跳转到功能定义。这取决于如上所述为您的项目正确设置绳索查找路径。

Two of the most important functions for me are looking up documentation and jumping directly to a function definition. This is dependent on setting the rope lookup path correctly for your project as mentioned above.

文档:将光标放在一个符号(函数名称,类名等),然后执行以下操作:

Documentation: Put the cursor over a symbol (function name, class name, etc), and do:

C-c d

这将显示有关符号的docstring。

This will show you the docstring for the symbol in question.

跳转到定义:将光标放在一个符号(函数名,类名等)上,然后执行以下操作:

Jumping to definition:Put the cursor over a symbol (function name, class name, etc), and do:

C-c g

这将立即打开符号所在的文件,并跳转到定​​义的开头。这对文档稀疏的时候很好,你想看到实际的代码。

This will immediately open the file where the symbol resides and jump to the beginning of the definition. This is great for times when the documentation is sparse and you want to see the actual code. Also, it's really nice for navigating around inside your own code.

查找发生

C-c f

在整个项目中智能搜索光标上的符号。

Smart search in your entire project for the symbol at the cursor.

代码辅助

M-/

只需键入函数,类等的第一个字符,这将显示可能的完成列表。请注意,由于python的性质,它并不总是完整的列表。

Just type the first characters of a function, class, etc, and this will show a list of possible completions. Note that due to python's nature, it will not always be a complete list.

重构
有很多选项在Rope-> Refactor下。这些是更好地组织您的代码。如何使用它们应该大体上是不言自明的;一般来说,选择要重构的代码区域,然后选择命令。

Refactorings: There are quite a few options under Rope->Refactor. These are to organize your code better. How to use them should be mostly self-explanatory; in general, select the region of code you want to refactor, then choose the command.

修改
回应在下面的评论中,正是如何添加其他路径到您的python路径,所以autocomplete也将寻找这些符号。

Edit: In response to a comment below, here's exactly how to add other paths to your python path so autocomplete will look for those symbols as well.

prefs.add('python_path', '~/path/to/virtualenv/lib/python2.6/site-packages')

这在 .ropeproject / config.py

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

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