On Saturday, May 16, 2015 at 6:26:17 PM UTC-5, Edward K. Ream wrote:
> I think you have solved all the problems...
No, it doesn't work. In leo/commands/helpCommands I replaced:
def cmd(name):
'''Command decorator for the helpCommands class.'''
return g.new_cmd_decorator(name,['c','helpCommands',])
with cmd = g.cmd where g.cmd is defined as you suggest, except it makes
entries in g.global_commands_dict. I also added traces.
# Use as function/method decorator
def cmd(*command_names):
class Decorator:
def __init__(self, func):
self.func = func
g.trace(command_names,str(func))
try: # Python3
self.isMethod = '.' in func.__qualname__
except AttributeError: # Python2
self.isMethod = 'instance' in str(func)
for command_name in command_names:
global_commands_dict[command_name] = self.__call__
def __call__(self, *args, **kwargs):
g.trace('func: %s\narg: %s\nkwargs: %s' % (self.func,args,kwargs
))
if self.isMethod:
return self.func(args[0], *args, **kwargs)
else:
return self.func(*args, **kwargs)
return Decorator
Here are the traces when Leo loads:
...
reading settings in C:\leo.repo\leo-editor\leo\config\leoSettings.leo
__init__ ('help',) <function help at 0x02C4FF70>
__init__ ('help-for-abbreviations',) <function helpForAbbreviations at
0x02C53070>
__init__ ('help-for-autocompletion',) <function helpForAutocompletion at
0x02C53130>
__init__ ('help-for-bindings',) <function helpForBindings at 0x02C531F0>
__init__ ('help-for-command',) <function helpForCommand at 0x02C532B0>
__init__ ('help-for-creating-external-files',) <function
helpForCreatingExternalFiles at 0x02C53430>
__init__ ('help-for-debugging-commands',) <function
helpForDebuggingCommands at 0x02C53530>
__init__ ('help-for-drag-and-drop',) <function helpForDragAndDrop at
0x02C535B0>
__init__ ('help-for-dynamic-abbreviations',) <function
helpForDynamicAbbreviations at 0x02C53670>
__init__ ('help-for-find-commands',) <function helpForFindCommands at
0x02C53730>
__init__ ('help-for-minibuffer',) <function helpForMinibuffer at 0x02C537F0>
__init__ ('help-for-regular-expressions',) <function
helpForRegularExpressions at 0x02C538B0>
__init__ ('help-for-scripting',) <function helpForScripting at 0x02C53970>
__init__ ('print-settings',) <function printSettings at 0x02C53A30>
__init__ ('help-for-python',) <function pythonHelp at 0x02C53AF0>
reading settings in c:\Users\edreamleo\.leo\myLeoSettings.leo
reading settings in C:\Users\edreamleo\ekr.leo
...
As you can see, everything is a function. Naturually, this causes a code
crash when the init method executes. For example, F12 (python-help) gives:
exception executing command
Traceback (most recent call last):
File "c:\leo.repo\leo-editor\leo\core\leoCommands.py", line 6886, in
doCommand
val = command(event)
File "c:\leo.repo\leo-editor\leo\core\leoGlobals.py", line 1452, in
__call__
return self.func(*args, **kwargs)
File "c:\leo.repo\leo-editor\leo\commands\helpCommands.py", line 1114, in
pythonHelp
k.getArg(event,tag,1,self.pythonHelp)
AttributeError: LeoKeyEvent instance has no attribute 'pythonHelp'
Maybe I'm misunderstanding something. Reinhard, the ball is in your court.
Edward
--
You received this message because you are subscribed to the Google Groups
"leo-editor" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/leo-editor.
For more options, visit https://groups.google.com/d/optout.