Scripts: new elisp script

master
Pierre Neidhardt 2014-02-24 16:09:08 +01:00
parent 0ca94724c3
commit b923d2f6d6
1 changed files with 47 additions and 0 deletions

47
.scripts/elisp Executable file
View File

@ -0,0 +1,47 @@
#!/bin/sh
_printhelp ()
{
cat<<EOF
Usage: ${1##*/} [OPTIONS] SCRIPT
Run Emacs Lisp SCRIPT.
Options:
-b: Byte-compile before running.
-c: Remove byte code once finished.
EOF
}
OPT_BYTE=false
OPT_CLEAN=false
while getopts :bc OPT; do
case $OPT in
b)
OPT_BYTE=true ;;
c)
OPT_CLEAN=true ;;
?)
_printhelp "$0"
exit 1 ;;
esac
done
shift $(($OPTIND - 1))
if [ $# -eq 0 ]; then
_printhelp "$0"
exit 1
fi
if $OPT_BYTE && [ "${1##*.}" = "el" ]; then
script="${1%.*}.elc"
emacs -Q --batch -f batch-byte-compile "$1"
else
script="$1"
OPT_CLEAN=false
fi
emacs -Q --script "$script"
$OPT_CLEAN && rm "$script"