Skip to content
Jérôme Plumecoq edited this page May 11, 2017 · 8 revisions

Rope Refactorings

The rope library provides a lot of tools to perform refactorings.

Emacs-for-python will automatically open Rope projects in the current (.) and upper (..) directory.

If you havent created a rope project for your Python sources yet do it with C-x p o.

Thats also the shortcut for opening a project.

Useful Shortcuts

  • C-x p o - open rope project
  • C-x p f - find file in rope project
  • C-c d - python doc for module / method
  • C-c g - goto definition
  • C-c f - find occurencies
  • C-c r r - refactoring rename

for more shortcuts have a look at https://bitbucket.org/agr/rope/src/c4df5fe957fd/docs/overview.txt

Renaming

Renaming in ropemacs is quite intelligent all you have to do is to use it. All the renaming performed are project-wise and you can perform a rename on a lot of things:

  • variables
  • attributes
  • keyword parameters
  • modules

more info about actual examples: https://bitbucket.org/agr/rope/src/c4df5fe957fd/docs/overview.txt

Moving

Renaming renames method between the same class, Moving delegates the method/attribute to another class that's a component of the first.

Organize import

A pep-8 formatting utility

Use Function

It analyze the project and substitutes the function where it is usable, like

pow(a,b): return a**b

a**b -> it will be substituted automatically

if a**b is in another package it will import and substitute

Version Control Awareness

It will move file accordingly

Auto Importing

Have to describe it and to tune it up by default, otherwise it's almost unuseful

Restructurings

Complex stuff