Anonymous avatar Anonymous committed 2175915

initializing local and global keys in the same place

Comments (0)

Files changed (1)

ropemacs/interface.py

 
         self._prepare_refactorings()
         self.autoimport = None
-        self._init_ropemacs_keymap()
+        self._init_ropemacs()
         lisp(MINOR_MODE)
 
     def init(self):
         """Initialize rope mode"""
+
+    def _init_ropemacs(self):
         global_prefix = lisp.ropemacs_global_prefix.value()
-        for attrname in dir(self):
-            attr = getattr(self, attrname)
-            if not callable(attr):
-                continue
-            kind = getattr(attr, 'kind', None)
-            if kind == 'global':
-                global_key = getattr(attr, 'global_key', None)
-                if global_key:
-                    key = self._key_sequence(global_prefix + ' ' + global_key)
-                    lisp.global_set_key(key, lisp[attr.lisp_name])
-            if kind == 'hook':
-                hook = getattr(attr, 'hook', None)
-                lisp.add_hook(lisp[hook], lisp[attr.lisp_name])
-        lisp.add_hook(lisp['python-mode-hook'], lisp['ropemacs-mode'])
-
-    def _init_ropemacs_keymap(self):
         local_prefix = lisp.ropemacs_local_prefix.value()
         enable_shortcuts = lisp['ropemacs-enable-shortcuts'].value()
         for attrname in dir(self):
                                          local_prefix + ' ' + local_key)
                 if enable_shortcuts and shortcut_key:
                     self._bind_local_key(attr.lisp_name, shortcut_key)
+            if kind == 'global':
+                global_key = getattr(attr, 'global_key', None)
+                if global_key:
+                    key = self._key_sequence(global_prefix + ' ' + global_key)
+                    lisp.global_set_key(key, lisp[attr.lisp_name])
+            if kind == 'hook':
+                hook = getattr(attr, 'hook', None)
+                lisp.add_hook(lisp[hook], lisp[attr.lisp_name])
+        lisp.add_hook(lisp['python-mode-hook'], lisp['ropemacs-mode'])
 
     def _prepare_refactorings(self):
         for name in dir(refactor):
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.