On Sun, Dec 4, 2011 at 8:01 PM, Kent Tenney <[email protected]> wrote:
> I can define a command which takes args if I use a @command node

[snip]

> When I use registerCommand, I don't see how I can specify arguments.

Do the same thing that the mod_scripting plugin does: bind the
arguments at the time you define a callback function.  Here is the
code from mod_scripting::

    def handleAtCommandNode (self,p):

        '''Handle @command name [@key[=]shortcut].'''

        trace = False and not g.app.unitTesting and not g.app.batchMode
        c = self.c ; k = c.keyHandler ; h = p.h
        if not h.strip(): return

        << get the commandName and optional shortcut >>
        args = self.getArgs(h)

        def atCommandCallback (event=None,args=args,c=c,p=p.copy()):
            # The 'end-of-script command messes up tabs.
            c.executeScript(args=args,p=p,silent=True)

        if trace: g.es('local @command',commandName,'',shortcut or '')
        k.registerCommand(commandName,shortcut,atCommandCallback,verbose=False)


HTH.

Edward

-- 
You received this message because you are subscribed to the Google Groups 
"leo-editor" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/leo-editor?hl=en.

Reply via email to