Sometimes, I reach the limit of what I can do with a line of find | grep | sed
and all the \/\/$.*()\/\/
that goes in… Write once, never come back. It almost look like perl sometimes…
Few days ago, I’ve just realized that emacs has a batch mode: you write your function (leveraging all the existing emacs functions), put it in a file and you can apply it on a bunch of files:
emacs -batch myfile.cc \ -l the-lisp-file.el \ -f the-function
Not necessarily the fastest or the most portable, but if you happen to have the right emacs function around, that’s invaluable. For example, I wouldn’t be too sure how to grep/sed to do this:
(defun apply-style () (c-set-style "stroustrup") (indent-region (point-min) (point-max) nil) (save-buffer))