Anonymous avatar Anonymous committed c25ffb4

ropemacs: added rope-rename-current-module

Comments (0)

Files changed (2)

 =========================
 
 Using rope in emacs.
+
+
+Setting Up
+==========
+
+After installing pymacs add these lines to your ``~/.emacs`` file::
+
+  (load-library "pymacs")
+  (pymacs-load "rope.contrib.ropemacs" "rope-")
+  (rope-init)
+
+
+Keybinding
+==========
+
+Uses the same keybinding as in rope.

rope/contrib/ropemacs.py

                       lisp.rope_exiting_actions)
         lisp.global_set_key('\x03g', lisp.rope_goto_definition)
         lisp.global_set_key('\x03rr', lisp.rope_rename)
+        lisp.global_set_key('\x03r1r', lisp.rope_rename_current_module)
         lisp.global_set_key('\x03rl', lisp.rope_extract_variable)
         lisp.global_set_key('\x03rm', lisp.rope_extract_method)
         lisp.global_set_key('\x03ri', lisp.rope_inline)
         self.project.close()
         self.project = None
 
-    @interactive('sNew Name: ')
-    def rename(self, newname):
+    def do_rename(self, newname, module=False):
         self._check_project()
         lisp.save_some_buffers()
         resource, offset = self._get_location()
+        if module:
+            offset = None
         renamer = rope.refactor.rename.Rename(self.project, resource, offset)
         changes = renamer.get_changes(newname, docs=True)
         self._perform(changes)
 
+    @interactive('sNew Name: ')
+    def rename(self, newname):
+        self.do_rename(newname)
+
+    @interactive('sNew Module Name: ')
+    def rename_current_module(self, newname):
+        self.do_rename(newname, module=True)
+
     def _do_extract(self, extractor, newname):
         self._check_project()
         lisp.save_buffer()
     def _perform(self, changes):
         self.project.do(changes)
         self._reload_buffers(changes.get_changed_resources())
+        lisp.message(str(changes.description) + ' finished')
 
     def _get_region(self):
         offset1 = self._get_offset()
             self.project, lisp.buffer_string(), offset, resource)
         if definition[0]:
             lisp.find_file(definition[0].real_path)
-        lisp.goto_line(definition[1])
+        if definition[1]:
+            lisp.goto_line(definition[1])
 
     def _get_location(self):
         resource = self._get_resource()
 close_project = interface.close_project
 
 rename = interface.rename
+rename_current_module = interface.rename_current_module
 extract_variable = interface.extract_variable
 extract_method = interface.extract_method
 inline = interface.inline
 exiting_actions = interface.exiting_actions
 
 goto_definition = interface.goto_definition
-
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.