Lunchtime Semaphore

from and to 372433 143758 48 N

Batch mode

March 16th, 2012 by

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 \
-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)

This entry was posted on Friday, March 16th, 2012 at 23:05 UTC and is filed under Emacs. You can follow any responses to this entry through the RSS 2.0 feed. You can leave a response, or trackback from your own site.

Loading Facebook Comments ...

Leave a Reply