Friday, October 22, 2010

Calculator/spreadsheet tool for Acme

I got Plan9 from User Space and started messing with it in the hopes of getting a nice toolbench going with Acme. Since I wrote Ober, I've been interested in this idea. Now, I'll probably rewrite it in Go. I'm wondering if I can just use named pipes to mimic what Acme does with its 9p interface.

Anyway, I wrote a simplified version of the Calc tool I wrote for Ober and I put it, here. The calc tool searches an Acme window for variables and their values and some code at the bottom. Then, it executes the code, sending the variables and values to its stdin. The code is expected to output new values for some of the variables. Calc parses the output and replaces the new values into the window. I'm also including two wrappers that make it easy to write calc scripts in rc or Go, so you can say something like this:

Bob's age=30, he is yearsleft=0 years away from retirement (calc).

#!/usr/bin/env calcgo

yearsleft = 55 - age

If you middle-click "calc" in the text, it will update the window to show yearsleft=25.