Commits

Anonymous committed c07d183

Added ropemacs-local-prefix and ropemacs-global-prefix

These can be used to change key prefixes, local and global ropemacs
commands use.

Comments (0)

Files changed (1)

ropemacs/__init__.py

     def __init__(self):
         self.project = None
         self.old_content = None
+        lisp(DEFVARS)
+
         self.global_keys = [
-            ('C-x p o', lisp.rope_open_project),
-            ('C-x p k', lisp.rope_close_project),
-            ('C-x p u', lisp.rope_undo_refactoring),
-            ('C-x p r', lisp.rope_redo_refactoring),
-            ('C-x p f', lisp.rope_find_file),
-            ('C-x p c', lisp.rope_project_config),
-            ('C-x p n m', lisp.rope_create_module),
-            ('C-x p n p', lisp.rope_create_package),
-            ('C-x p n f', lisp.rope_create_file),
-            ('C-x p n d', lisp.rope_create_directory)]
+            ('o', lisp.rope_open_project),
+            ('k', lisp.rope_close_project),
+            ('u', lisp.rope_undo_refactoring),
+            ('r', lisp.rope_redo_refactoring),
+            ('f', lisp.rope_find_file),
+            ('c', lisp.rope_project_config),
+            ('n m', lisp.rope_create_module),
+            ('n p', lisp.rope_create_package),
+            ('n f', lisp.rope_create_file),
+            ('n d', lisp.rope_create_directory)]
 
         self.local_keys = [
             ('M-/', lisp.rope_code_assist),
             ('C-c g', lisp.rope_goto_definition),
             ('C-c C-d', lisp.rope_show_doc),
             ('C-c f', lisp.rope_find_occurrences)]
-
-        self._register_refactorings()
+        self._prepare_refactorings()
 
     @lispfunction
     def init(self):
         lisp.add_hook(lisp.kill_emacs_hook, lisp.rope_exiting_actions)
         lisp.add_hook(lisp.python_mode_hook, lisp.rope_register_local_keys)
 
-        lisp(DEFVARS)
+        prefix = lisp.ropemacs_global_prefix.value() + ' '
+        for key, callback in self.global_keys:
+            lisp.global_set_key(self._key_sequence(prefix + key), callback)
 
-        for key, callback in self.global_keys:
-            lisp.global_set_key(self._key_sequence(key), callback)
-
-    def _register_refactorings(self):
+    def _prepare_refactorings(self):
+        prefix = lisp.ropemacs_local_prefix.value() + ' '
         for name in dir(refactor):
             if not name.startswith('_') and name != 'Refactoring':
                 attr = getattr(refactor, name)
                     name = self._refactoring_name(attr)
                     setattr(self, name, do_refactor)
                     name = 'rope-' + name.replace('_', '-')
-                    self.local_keys.append(('C-c r ' + attr.key, lisp[name]))
+                    self.local_keys.append((prefix + attr.key, lisp[name]))
 
     def _refactoring_name(self, refactoring):
         return refactor.refactoring_name(refactoring)
 
 How many errors to fix, at most, when proposing code completions.")
 
+(defcustom ropemacs-local-prefix "C-c r"
+  "The prefix for ropemacs refactorings")
+
+(defcustom ropemacs-global-prefix "C-x p"
+  "The prefix for ropemacs project commands")
+
 (provide 'ropemacs)
 """
 
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.