Skip to content

Instantly share code, notes, and snippets.

@grimradical
Created February 20, 2014 21:02
Show Gist options
  • Save grimradical/9123149 to your computer and use it in GitHub Desktop.
Save grimradical/9123149 to your computer and use it in GitHub Desktop.
#!/bin/bash
for f in $*; do
echo $f
emacs -batch "$f" -l ~/.emacs -l ~/local/bin/emacs-format-file -f emacs-format-function
done
$ cat ~/local/bin/emacs-format-file
(defun align-buffer ()
"Align expressions in the whole buffer"
(end-of-buffer)
(beginning-of-line)
(setq morelines t)
(while morelines
(condition-case exc
(align-cljlet)
('error nil)
)
(setq morelines (= 0 (forward-line -1)))))
(defun emacs-format-function ()
"Format the whole buffer."
(clojure-mode)
(indent-region (point-min) (point-max))
(align-buffer)
(untabify (point-min) (point-max))
(delete-trailing-whitespace)
(save-buffer))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment