-
-
Save dch/8843139 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
;;; File: emacs-indent-erlang | |
;;; adapted from http://www.cslab.pepperdine.edu/warford/BatchIndentationEmacs.html | |
;; this has to be set to the real path on your system | |
(add-to-list 'load-path "~/.emacs.d/elpa/erlang-20131025.6") | |
(load-library "erlang") | |
;; comment out the call to untabify if you want the mixed tabs and spaces | |
(defun emacs-indent-function () | |
"Format the whole buffer." | |
(erlang-mode) | |
(indent-region (point-min) (point-max) nil) | |
(untabify (point-min) (point-max)) | |
(save-buffer) | |
) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
# File: erl-indent | |
# Opens a set of files in emacs and executes the emacs-indent-function. | |
# Assumes the function named emacs-indent-function is defined in the | |
# file named emacs-indent-file. | |
# | |
# adapted from http://www.cslab.pepperdine.edu/warford/BatchIndentationEmacs.html | |
if [ $# -eq 0 ] | |
then | |
echo "erl-indent requires at least one argument." 1>&2 | |
echo "Usage: erl-indent files-to-indent" 1>&2 | |
exit 1 | |
fi | |
while [ $# -ge 1 ] | |
do | |
if [ -d $1 ] | |
then | |
echo "Argument of erl-indent $1 cannot be a directory." 1>&2 | |
exit 1 | |
fi | |
# Check for existence of file: | |
ls $1 2> /dev/null | grep $1 > /dev/null | |
if [ $? != 0 ] | |
then | |
echo "erl-indent: $1 not found." 1>&2 | |
exit 1 | |
fi | |
echo "Indenting $1 with emacs in batch mode..." | |
emacs -batch $1 -l ~/bin/emacs-indent-erlang -f emacs-indent-function | |
echo | |
shift 1 | |
done | |
exit 0 | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment