Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/vedang/ropemacs

Fork of http://bitbucket/agr/ropemacs for my personal use
https://github.com/vedang/ropemacs

Last synced: about 2 months ago
JSON representation

Fork of http://bitbucket/agr/ropemacs for my personal use

Awesome Lists containing this project

README

        

=========================
ropemacs, rope in emacs
=========================

Ropemacs is an emacs mode that uses rope_ library to provide features
like python refactorings and code-assists. You should install rope_
library and pymacs_ before using ropemacs.

.. _rope: http://rope.sf.net/
.. _pymacs: http://pymacs.progiciels-bpi.ca/pymacs.html

New Features
============

``rope-find-occurrences`` sets ``next-error-function``. That means
compilation mode keys like ``C-x \``` work for occurrences buffer,
too.

Also there is a bug in pymacs 23 and 24-beta1 that makes python reach
maximum recursion after interrupting a pymacs command; a patch is
included in the docs folder.

Setting Up
==========

After installing pymacs, add these lines to your ``~/.emacs`` file::

(require 'pymacs)
(pymacs-load "ropemacs" "rope-")

Note that rope and ropemacs should be in your ``PYTHONPATH`` for this
to work.

Also note that ropemacs may redefine some standard Emacs and your custom key
bindings. To prevent this, put the following example lines to your
``~/.emacs`` *before* the lines presented above:

(setq ropemacs-enable-shortcuts nil)
(setq ropemacs-local-prefix "C-c C-p")

See keybinding_ and variables_ sections for more details.

Loading Lazily
--------------

If you want to load ropemacs only when you really need it, you can use
a function like this in your ``~/.emacs``::

(defun load-ropemacs ()
"Load pymacs and ropemacs"
(interactive)
(require 'pymacs)
(pymacs-load "ropemacs" "rope-")
;; Automatically save project python buffers before refactorings
(setq ropemacs-confirm-saving 'nil)
)
(global-set-key "\C-xpl" 'load-ropemacs)

And execute ``load-ropemacs`` (or use ``C-x p l``) whenever you want
to use ropemacs.

Not Installing
--------------

If you don't want to install rope library and ropemacs you can extract
them somewhere and add these lines to your ``.emacs``::

;; Add this before loading pymacs if you haven't installed rope and ropemacs
(setq pymacs-load-path '("/path/to/rope"
"/path/to/ropemacs"))

Multiple Python Versions
------------------------

Rope needs at least Python2.5. If you have older versions of Python
you can use ``PYMACS_PYTHON`` environment variable. You can add::

(setenv "PYMACS_PYTHON" "python2.5")

to force pymacs to use Python2.5.

Ropemacs Minor Mode
-------------------

Ropemacs registers its local keys when ``ropemacs-mode`` is enabled.
By default it is enabled using ``python-mode`` hook (this hook is
available if you are using Emacs' ``python.el`` or XEmacs'
``python-mode.el``). If you want to enable it in other major modes
either execute ``ropemacs-mode`` manually or call it in some other
hook.

Getting Started
===============

Refactoring Dialog
------------------

Ropemacs refactorings use a special kind of dialog. When you start a
refactoring, you'll be asked to confirm saving modified python
buffers; you can change it by using ``ropemacs-confirm-saving``
variable. Adding ``(setq ropemacs-confirm-saving 'nil)`` to your
``.emacs`` file, will make emacs save them without asking.

After that depending on the refactoring, you'll be asked about the
essential information a refactoring needs to know (like the new name
in rename refactoring). You can skip it by prefixing the refactoring;
this can be useful when using batchset command (described later).

Next you'll see the base prompt of a refactoring dialog that shows
something like "Choose what to do". By entering the name of a
refactoring option you can set its value. After setting each option
you'll be returned back to the base prompt. Finally, you can ask rope
to perform, preview or cancel the refactoring.

See keybinding_ section and try the refactorings yourself.

Finding Files
-------------

By using ``rope-find-file`` (``C-x p f`` by default), you can search
for files in your project. When you complete the minibuffer you'll
see all files in the project; files are shown as their reversed paths.
For instance ``projectroot/docs/todo.txt`` is shown like
``todo.txt