Introducing navorski
TL;DR: Easy way to manage well defined terminals (github link)
One of the reasons I moved from Vim to Emacs was the fact that Emacs has better support for async processes and the facility to have a bash terminal running inside your editor. With those features in mind, I'm always looking for opportunities to make workflows more automated when terminals can help, like run programs each time I save a file, or run a repl of a language that doesn't have an inferior mode, etc.
After some time, I realized that I was writing the same code over and over again, so I decided to create this small utility library called navorski.el. This library defines common functions you may want to use to interact with a terminal that has a well established purpose. I think the best way to explain how this work is with a story of how I use it.
I started interacting with Scala not long ago, and one thing I really liked about it was SBT, specially the '~' operand that runs repeatedly a SBT command when I save a file that belongs to the SBT project. I wanted to have my tests running while I change the code, and also a scala repl active at all times[1].
sbt-mode could help me with this, but only half of the way because I can only have one of those two within a single sbt-mode buffer. My solution? Create a navorski profile that runs the SBT tests.
(nav/defterminal scala-sbt-tester :buffer-name "sbt-tester" :program-path "/usr/local/bin/sbt" :program-args "~ test" :modify-default-directory be/sbt-root-directory)
When this function gets evaluated it creates the following functions:
nav/scala-sbt-tester-pop-to-buffer
nav/scala-sbt-tester-send-string
nav/scala-sbt-tester-send-region
nav/scala-sbt-tester-kill-buffer
When I call M-x nav/scala-sbt-tester-pop-to-buffer it will automatically create a buffer that runs the program found in /usr/local/bin/sbt, with the argument '~ test'. This program is going to run in the directory path that the be/sbt-root-directory function returns[2]. I add a keybinding for the pop-to-buffer generated function and done, one keybinding away from having the runner running at all times.
This is a particular use case among many:
Persist running programs using GNU screen (check the :scree-session-name option)
Create terminals for remote connections (using SSH) (check the :remote-host option)
Create "inferior-mode" likes buffer easily by using the send-string and send-region functions.
etc...
If this sounds awesome, give it a try, and if you love living in your terminal, don't forget to star it on github.
[1] I have a Haskell/Clojure background, so yes, all the time!
[2] This function receives as parameter the current default-directory when executing the command, and returns a modified path where you want the program to run, in this particular example, is going to be the SBT root dir.









