On Thu, Oct 20, 2011 at 10:31 AM, Edward K. Ream <[email protected]> wrote:
> On Wed, Oct 19, 2011 at 10:06 PM, rhh <[email protected]> wrote:
>
>> I have a perfectly good command (created in a plugin) that works from
>> the mini-buffer and as a button, but when called by a short-cut
>> (assigned in the settings file) it triggers this condition. What am I
>> missing?
>
> I can't answer without knowing exactly how your plugin creates the command.
>
> As you say, inCommand can be set to False to enable your command, but
> your command should, after it starts, set inCommand back to True.
>
> The world (probably) won't end if your command doesn't set inCommand
> to True, but the lockout code is there for a reason: it prevents a
> nasty freeze in unlikely circumstances.
I have also encountered this issue and here is my code:
def executeMinibufferCommands (c, cmds):
for cmd in cmds.strip().splitlines():
c.executeMinibufferCommand(cmd.strip())
@g.command("splice-insert")
def spliceInsert (event):
'''Inserts a new headline as a parent of the current headline'''
#c.inCommand = False
executeMinibufferCommands (event.get('c'), '''
contract-node
insert-node
goto-prev-sibling
move-outline-down
move-outline-right
goto-parent
edit-headline
''')
If I uncomment the 'c.inCommand=False' line, then I can call it
successfully from a keystroke. Hopefully I won't hit the 'nasty
freeze' alluded to by Edward.
I wrote this code years ago and am only just now using it. I didn't
realize what a headache I sidestepped by using minibuffer commands.
If I had tried to use positions and make outline modifications with
them, I would have met the great frustration I've had during the past
week with some other code I'm writing (partly alluded to these issues
in another thread--but I was able to resolve most on my own and
haven't posted about them).
Also, by using minibuffer commands, I get undo for free (though it
takes multiple steps to undo the splice-insert command).
Brian
--
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.