Relapse into emacs for macro re-indulgence
Old blog post recovered from 2005
Personal

I found myself faced with having to manually re-indent a couple of hundred lines worth of HTML, checking it while I went. As always, I fire up gedit to start doing it, but then I realise that this job would be so much easier if I could M-x C-( and define a sequence of keystrokes that performed a common operation, then C-u C-x e to fire it off a load of times (or just keep doing C-x e). It didn’t take too long before I had to fire up emacs for about 30mins to get the job done. It would have taken me at least an hour doing the same thing by hand in gedit.

I thought about filing a ‘feature request’ against gedit, but I decided to think first about how I might implement it if I were to do it myself. I figured that it would just be a case of recording a sequence of events such as keypresses and button clicks etc. Presumably, these are already modelled somehow in Gtk+, so it should just be a case of having these events set to callback the application when ‘Record’ is selected (and ignored/reset when stopped), and have a Play function that attempts to feed the events back in, and bombing out on an exception (if the macro can’t be fully played back for some reason).

When I started thinking ‘application’ instead of ‘gedit’, I then thought about the possibility for a ’libgtkmacro’, which could be linked into just about any Gtk+/GNOME application (although it would probably only be really useful in a few cases).

I recall that you used to be able to record/playback events (across applications too) in Win95 back in ’the day’, so it’s not a new concept. I wonder why this kind of feature never made it beyond Win95?