For example, I have a script to remove trailing whitespace from lines; I'd like to have it automatically run before saving a file.
Currently there's no straightforward way to do this in Quickscript.
One workaround is to write a quickscript that removes the trailing whitespaces and then saves the file (either by calling the correct method, or by automatically navigating the menus). I'm not sure if overloading the default Ctrl+s shortcut would work (worth a try), so maybe a different keybinding is needed.
That approach worked for this particular case (Though it won't just replace the existing Ctrl-S binding; had to use something else), but a more generic hook system would still be nice...
I certainly agree in principle. I'm wondering what the best approach would be though, as it doesn't seem like there's a unified approach to handle a number of events all at once. So I worry that each hook callback would have to be inserted manually at the point of interest, which sounds prone to problems and adds constraints (such as backward compatibility) on the hooked event.
If you have other hooks you're thinking, let me know. That would help me figure out what approach to take.
I'd just look at whatever emacs provides and pick out anything relevant to DrRacket.
The snapshot version of Racket (≥ v188.8.131.52) now features Quickscript hooks
Here's a first script (to install just like other quickscripts) that automatically removes trailing spaces on saving a file. Make sure to reload the scripts with
Scripts | Manage | Reload menu once the script is installed.
This is a first attempt and I might make breaking changes before the next official Racket release (8.11, probably). So now is a good time to test it and send feedback!