Пример #1
0
 def _init_ropemacs(self):
     global_prefix = lisp.ropemacs_global_prefix.value()
     local_prefix = lisp.ropemacs_local_prefix.value()
     enable_shortcuts = lisp['ropemacs-enable-shortcuts'].value()
     for attrname in dir(self):
         attr = getattr(self, attrname)
         if not callable(attr):
             continue
         kind = getattr(attr, 'kind', None)
         name = decorators._lisp_name(attr)
         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,
                                      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'])
Пример #2
0
 def global_command(self, name, callback, key=None, prefix=False):
     globals()[name] = callback
     self._set_interaction(callback, prefix)
     if self.global_prefix and key:
         key = self._key_sequence(self.global_prefix + ' ' + key)
         lisp.global_set_key(key, lisp[_lisp_name(name)])
Пример #3
0
 def global_command(self, name, callback, key=None, prefix=False):
     globals()[name] = callback
     self._set_interaction(callback, prefix)
     if self.global_prefix and key:
         key = self._key_sequence(self.global_prefix + ' ' + key)
         lisp.global_set_key(key, lisp[_lisp_name(name)])