Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Setup and teardown functions #16

Open
LFDM opened this issue Feb 15, 2014 · 2 comments
Open

Setup and teardown functions #16

LFDM opened this issue Feb 15, 2014 · 2 comments

Comments

@LFDM
Copy link
Contributor

LFDM commented Feb 15, 2014

Feature proposal mentioned in #13

To build really powerful submodes it would be nice to be able to register setup and teardown functions that get called on_entering and on_leaving. I know that especially the setup part can be achieved with a workaround (defining a rhs command in the enter_with function), but that's a little hacky, as I am pretty sure you didn't intend this feature to work this way. I assume it would be enough to implement two dictionaries where the submode's name is the key and the value is an array of funcrefs to be called in the respective parts.
Possible use cases would be to activate/deactivate different highlightings or opening/closing a split window that holds additional information you could use during your submode's activity etc etc.

@kana
Copy link
Owner

kana commented Feb 25, 2014

Since enter_with has an optional {rhs}. When are setup functions called? Before {rhs}? After {rhs}? It depends on purposes. So we have to support both.

@LFDM
Copy link
Contributor Author

LFDM commented Feb 25, 2014

I always think of the optional {rhs} as the first command that should be called INSIDE the submode. Taking a pseudo-example

submode movement enter_with '<esc> j', '5j'
submode movement map 'j', '5j'

5j is the rhs here, which is also the regular submode mapping for j, which I already want to be called when I trigger the submode.

A setup function would be called before it, before the rhs is executed, as it just sets up the submode.
What purpose do you have in mind for calling it after the rhs?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants