Closed droundy closed 4 years ago
If you have CommandContext("test")
then the contact will be activated and deactivated by the "enable test" and "disable test" commands IIRC
I was thinking to set
test_context = CommandContext("test")
and then have a Function(lambda: test_context.disable())
attached to a rule.
Yes, that should work and is almost exactly what the enable and disable commands do.
One thing to note with this though is that the object you call disable
on must be the exact same object you pass to context=
. It's not enough to call CommandContext
in two places with the same argument. (If you're familiar with pointers in other languages then this will make sense)
I'm wondering whether within a CCR it is effective to disable/enable a CommandContext? I'm thinking of using this to enable changes between text and math modes for latex, but am unsure of the implications of such a trick. If there is a better approach for such a "mode switching" grammar I'd love to hear about it.