On Thursday, November 23, 2017 at 8:41:57 AM UTC-6, Edward K. Ream wrote:

Here is a slight variant of g.command that looks like it will suffice to 
> define commands as "bare" functions using @g.commander_command:
>

Here is a test (in a Leo script, not a file):

@others # Define commander_command

if not hasattr(c, 'save2'):

    @commander_command('save2')
    def save2(self, *args, **kwargs):
        g.trace('self', self, 'args', args, 'kwargs', kwargs)

c.save2()
c.k.simulateCommand('save2')

And here are the results, including a trace in k.simulateCommand:

save2 self Commander 149029168: 'C:\\Users\\edreamleo\\ekr.leo' args () 
kwargs {}
save2 self LeoKeyEvent:
{
    c: 'ekr.leo',
    char: '',
    event: None,
    stroke: None,
    w: None
} args () kwargs {}

This is why I say that tweaks will be needed to k.simulateCommand. In some 
cases it should pass k.c to the command handler rather than an event arg. I 
expect this can be done cleanly.  We shall see...

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 https://groups.google.com/group/leo-editor.
For more options, visit https://groups.google.com/d/optout.

Reply via email to