You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Functions not listening to events before the first load #845
So now since #1382 has shown up, there seems to be a need to allow event handlers to be added from the outside.
How should that look? Asking people to add something to config.fish is obviously not great, but the best I've come up with is adding an additional directory (called "events" or "hooks" or similar) that essentially contains functions that will either always be sourced or sourced on every event, but even that isn't exactly beautiful. funcsave could be modified to use this directory if the function has been defined as an event handler.
Another solution (which would also be useful for e.g. function descriptions) is to, on start, peak at the function definition part of any .fish file, but that's very specialized.
Or add special files named after the event (i.e. "fish_postexec.fish") that will be looked up when the event fires.
For example in Wahoo, we source any $WAHOO_CUSTOM/init.fish file during session start. This could easily be augmented to also source any $WAHOO_CUSTOM/events.fish file
Really, files are nicer to outsiders wishing to add event listeners. E.g. pantheon-terminal could just drop-in a file (that can be properly managed by the package manager) to do the notification stuff. Of course that also implies override-logic like for completions.
Activity
dag commentedon May 30, 2013
Quite so; I ran into this with an
--on-variablehandler. Fixing this without breaking on-demand loading of functions could be hard though.ridiculousfish commentedon Jun 2, 2013
Yes, not sure how this could be fixed.
wojtekerbetowski commentedon Jun 3, 2013
Too bad. What's the best workaround? To link function creation file in
config.fish then?
terlar commentedon Jun 3, 2013
For these kind of things I currently define the functions in the
config.fishor a file sourced by it.wojtekerbetowski commentedon Jun 3, 2013
Ok, thanks.
smidm commentedon Sep 16, 2014
This issue really confused me for a while. It should be mentioned in the funcsave or function command documentation.
bug workaround when saving an event handler
lilyball commentedon Sep 20, 2014
Noting this in the documentation of
funcsaveseems reasonable.languitar commentedon Jan 12, 2015
I also just stumbled across this. Some kind of fix or at least explanations in the doc would be great.
zanchey commentedon Jan 12, 2015
What wording would be helpful?
Document problems with event handlers and autoloading
faho commentedon Aug 17, 2015
So now since #1382 has shown up, there seems to be a need to allow event handlers to be added from the outside.
How should that look? Asking people to add something to config.fish is obviously not great, but the best I've come up with is adding an additional directory (called "events" or "hooks" or similar) that essentially contains functions that will either always be sourced or sourced on every event, but even that isn't exactly beautiful. funcsave could be modified to use this directory if the function has been defined as an event handler.
Another solution (which would also be useful for e.g. function descriptions) is to, on start, peak at the function definition part of any .fish file, but that's very specialized.
Or add special files named after the event (i.e. "fish_postexec.fish") that will be looked up when the event fires.
faho commentedon Aug 17, 2015
Really, files are nicer to outsiders wishing to add event listeners. E.g. pantheon-terminal could just drop-in a file (that can be properly managed by the package manager) to do the notification stuff. Of course that also implies override-logic like for completions.
zanchey commentedon Aug 27, 2015
A good solution to #1956 should enable this.
zanchey commentedon Aug 28, 2015
How do you mean, userland territory?
faho commentedon Aug 28, 2015
See e.g. #1382 - so that outside packages can drop in event handlers to enable additional features.