How about coding an emacs macro with your agent?

I actually don't have any representation at the moment..