Currently, eventMacro updates special variables in parse_command, which is triggered for many but not all macro commands. Most lines which include such commands do not use the special variables, however, so we should resolve them only when needed.
This change allows us to add more special variables without increasing the cost of commands which do not use any special variables.
As an additional enhancement, the resolution of special variables could be done via a hash with coderefs to make resolving them a constant-time operation instead of linear-time. I didn't do that because I believe the code is clearer this way and we don't (currently) have a lot of special variables.
Currently,
eventMacro
updates special variables inparse_command
, which is triggered for many but not all macro commands. Most lines which include such commands do not use the special variables, however, so we should resolve them only when needed.This change allows us to add more special variables without increasing the cost of commands which do not use any special variables.
As an additional enhancement, the resolution of special variables could be done via a hash with coderefs to make resolving them a constant-time operation instead of linear-time. I didn't do that because I believe the code is clearer this way and we don't (currently) have a lot of special variables.
This was tested with the following eventMacros:
... and the following command line: