I’m editing a haskell source file. I want to run my main function in my inferior-haskell buffer (already opened in a different frame) and continue editing my source file. To do this, I do
C-c C-l, change frame, main<ret>, change back to original frame
This seems quite inefficient. I’d like an emacs function/key that does it one shot.
There is actually a function to do this already defined in
inf-haskell.el:inferior-haskell-load-and-run. This loads your current file and runs:main.You can bind it to a key in Haskell mode by adding a hook:
However, playing around with this for a bit, it seems to have an odd issue on my computer: sometimes, when it pops to the
*haskell*buffer, it doesn’t move the point to the end. I find this rather annoying. You can easily fix it by moving the point to the end yourself:I believe the
sleep-foris necessary because the Haskell command is run asynchronously and takes a little bit of time to return. This whole thing is something of a hack, but it seems to work.Also, you might want to customize exactly what the
inferior-haskell-run-commandis. By default, it’s:main. However, for me, I think justmainwould be better becausemainis affected by:set args ...where:mainisn’t.If you want to stay in your current Haskell buffer, you can just do this: