绳索使用教程 [英] ropemacs USAGE tutorial

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

问题描述

有许多网站提供关于安装ropemacs 的说明,但到目前为止我找不到任何关于如何在安装后使用的说明.我已经安装了它,或者至少看起来是这样,Emacs 在它的顶部菜单栏中有Rope"菜单.怎么办?到目前为止,我只能使用显示文档"(默认为 C-c d).尝试使用代码辅助(我认为这是自动完成的?)只会导致 Emacs 在迷你缓冲区中询问Rope 项目根文件夹"(那是什么?),然后什么也不显示.

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 中有这个脚本并将闪烁的方块放在 here 并按下 this,它确实that"将是一个答案.

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

这将显示相​​关符号的文档字符串.

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 路径,以便自动完成功能也会查找这些符号.

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

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

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