Skip to main content

An emacs mode for using rope refactoring library

Project description

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

New Features

  • Find occurrences; C-c f

  • Lucky-assist; M-?

  • Setting many configs using batchset in dialogs

  • Showing the old value of a field in dialogs

  • New file/directory/module/package; C-x p n [fdmp]

  • Edit project config; C-x p c

  • Updating buffers with moved files after refactorings

  • Extracting similar pieces defaults to yes in extract refactorings

Setting Up

You can get pymacs from http://www.iro.umontreal.ca/~pinard/pymacs/. But version 0.22 does not work with Python 2.5 because of the lack of file encoding declarations. A simple patch is included: docs/pymacs_python25.patch.

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

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

Rope registers its local keys using python-mode hook. If you don’t want to use rope with python-mode you can add rope-register-local-keys lisp function to some other hook.

If you want to load ropemacs only when you really need it, you can use a function like this instead of that:

(defun load-ropemacs ()
  "Load pymacs and ropemacs"
  (interactive)
  (require 'pymacs)
  (pymacs-load "ropemacs" "rope-")
  (rope-init)
  ;; Automatically save project python buffers before refactorings
  (setq rope-confirm-saving 'nil)
)

And execute load-ropemacs whenever you want to use ropemacs. Also 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 '("/home/ali/projects/rope"
                         "/home/ali/projects/ropemacs"))

Project details


Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page