#!/bin/sh
# File: my-indent
# Opens a file in emacs and executes the emacs-format-function.
# Assumes the function named emacs-format-function is defined in the
# file named emacs-format-file.
if [ $# != 1 ]
then
   echo "my-indent requires exactly one argument." 1>&2
   echo "Usage: my-indent file-to-indent" 1>&2
   exit 1
fi
if [ -d $1 ]
then
   echo "Argument of my-indent 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 "my-indent: $1 not found." 1>&2
   exit 1
fi
# echo Indenting $1
emacs -batch $1 -l emacs-format-file -f emacs-format-function
