Thursday, April 06, 2006

Emacs + ZenTest = ZenMacs?

Good friends make you a better person. Because of the recent example of Ryan Davis, Eric Hodel and especially Pat Eyler, and the less recent example of Gus Mueller, I am a better programmer who does better things. The following is one of those things.

I have been learning Emacs and the ZenTest suite at the same time. This morning I came up with the following bit of goodness.



M-x autotest from a buffer whose current dir is the root of your project results in:



You now have a shell with autotest running in the bottom left pane, an eshell ready for your subversion commands in the bottom right pane and you can work with your project in the top pane.

This is due to a macro I wrote to create this setup for me automagically. The macro does the following: (*warning emacs speak*)

C-x 2, C-x o, C-x 3
M-x shell
autotest
M-x set-variable
comint-scroll-to-bottom-on-output
all
C-x o
M-x eshell
M-x set-variable
comint-scroll-to-bottom-on-output
all


I have included this little macro in my .emacs file with the following bit of elisp:

(fset 'autotest
[?\C-x ?2 ?\C-x ?o ?\C-x ?3 ?\M-x ?s ?h ?e ?l ?l ?\C-m ?a ?u ?t ?o ?t ?e ?s ?t ?\C-m ?\M-x ?s ?e ?t ?- ?v ?a ?r ?i ?a ?b ?l ?e ?\C-m ?c ?o ?m ?i ?n ?t ?- ?s ?c ?r ?o ?l ?l ?- ?t ?o ?- ?b ?o ?t ?t ?o ?m ?- ?o ?n ?- ?o ?u ?t ?p ?u ?t ?\C-m ?a ?l ?l ?\C-m ?\C-x ?o ?\M-x ?e ?s ?h ?e ?l ?l ?\C-m ?\M-x ?s ?e ?t ?- ?v ?a ?r ?i ?a ?b ?l ?e ?\C-m ?c ?o ?m ?i ?n ?t ?- ?s ?c ?r ?o ?l ?l ?- ?t ?o ?- ?b ?o ?t ?t ?o ?m ?- ?o ?n ?- ?o ?u ?t ?p ?u ?t ?\C-m ?a ?l ?l ?\C-m])


Enjoy and let me know if you can think of any improvements. In particular, I would like to prompt for a directory path at the beginning and I need to figure out how to handle pre-existing *shell* or *eshell* buffers. Still, as is, this does what I need.

1 Comments:

Anonymous Anonymous said...

(defun autotest ()
(interactive)
(let ((buffer (shell "autotest")))
(comint-send-string buffer "autotest\n")))

(defun autotest-switch ()
(interactive)
(if (equal "autotest" (buffer-name))
(previous-buffer)
(switch-to-buffer "autotest")))

; add to ruby mode hook:
(define-key ruby-mode-map "\C-c\C-a" 'autotest-switch)
(define-key shell-mode-map "\C-c\C-a" 'autotest-switch)

---

we'll be including this in the next release of ZenTest.

2:00 PM  

Post a Comment

<< Home