Emacs animations

From this neat post on Sacha Chua’s blog, I discovered M-x animate-birthday-present, and spent some time on this lovely site. The latter link is a set of tutorials that starts with Lisp basics and very quickly dives into ASCII animations in Emacs.

Here’s a neat example: Paste the following code in a scratch buffer and evaluate it with C-x C-e.

(defun follow-sine ()
(dotimes (y 70)
(erase-buffer)
(newline (round (+ 10 (* 10 (sin (/ y 10.0))))))
(dotimes (over y)
(insert " "))
(insert "*")
(sit-for 0.1)))

Then run it in an empty buffer with this:

M-: (follow-sine)

You will get an asterisk moving across the screen in a pretty sine wave :)

More importantly, this is the first hands-on look I’ve had at how playing with Emacs Lisp functions can move stuff around on the screen. Well worth a look.