Anonymous avatar Anonymous committed ab757cd Draft

interface: converting names to lisp forms only when needed

Comments (0)

Files changed (2)

ropecommon/decorators.py

                     exceptions.ModuleSyntaxError,
                     exceptions.BadIdentifierError)
 
-def _lisp_name(func):
-    return 'rope-' + func.__name__.replace('_', '-')
-
 def _exception_handler(func):
     def newfunc(*args, **kwds):
         try:
 def rope_hook(hook):
     def decorator(func):
         func = lisphook(func)
-        func.lisp_name = _lisp_name(func)
+        func.name = func.__name__
         func.kind = 'hook'
         func.hook = hook
         return func
         func.local_key = key
         func.shortcut_key = shortcut
         if name is None:
-            name = _lisp_name(func)
-        func.lisp_name = name
+            name = func.__name__
+        func.name = name
         return func
     return decorator
 
         if interaction is not None:
             func.interaction = interaction
         func.global_key = key
-        func.lisp_name = _lisp_name(func)
+        func.name = func.__name__
         return func
     return decorator

ropecommon/interface.py

             if not callable(attr):
                 continue
             kind = getattr(attr, 'kind', None)
-            name = decorators._lisp_name(attr)
+            name = attr.__name__
             if kind == 'local':
                 local_key = getattr(attr, 'local_key', None)
                 shortcut_key = getattr(attr, 'shortcut_key', None)
                 if local_prefix is not None and local_key:
-                    self._bind_local_key(attr.lisp_name,
+                    self._bind_local_key(attr.name,
                                          local_prefix + ' ' + local_key)
                 if enable_shortcuts and shortcut_key:
-                    self._bind_local_key(attr.lisp_name, shortcut_key)
+                    self._bind_local_key(attr.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])
+                    lisp.global_set_key(key, lisp[_lisp_name(attr.name)])
             if kind == 'hook':
                 hook = getattr(attr, 'hook', None)
-                lisp.add_hook(lisp[hook], lisp[attr.lisp_name])
+                lisp.add_hook(lisp[hook], lisp[_lisp_name(attr.name)])
         lisp.add_hook(lisp['python-mode-hook'], lisp['ropemacs-mode'])
 
     def _prepare_refactorings(self):
                 attr = getattr(refactor, name)
                 if isinstance(attr, type) and \
                    issubclass(attr, refactor.Refactoring):
-                    ref_name = self._refactoring_name(attr)
-                    lisp_name = 'rope-' + ref_name.replace('_', '-')
-                    @decorators.local_command(attr.key, 'P', None, lisp_name)
+                    refname = self._refactoring_name(attr)
+                    @decorators.local_command(attr.key, 'P', None, refname)
                     def do_refactor(prefix, self=self, refactoring=attr):
                         initial_asking = prefix is None
                         refactoring(self, self.env).show(initial_asking=initial_asking)
-                    setattr(self, ref_name, do_refactor)
+                    setattr(self, refname, do_refactor)
 
     def _refactoring_name(self, refactoring):
         return refactor.refactoring_name(refactoring)
 
     def _bind_local_key(self, callback, key):
         lisp('(define-key ropemacs-local-keymap "%s" \'%s)' %
-             (self._key_sequence(key), callback))
+             (self._key_sequence(key), _lisp_name(callback)))
 
     @decorators.rope_hook('kill-emacs-hook')
     def exiting_actions(self):
                 self.project.pycore.is_python_file(resource))
 
 
+def _lisp_name(name):
+    return 'rope-' + name.replace('_', '-')
+
+
 class _CodeAssist(object):
 
     def __init__(self, interface, env):
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.