Elisp: Support CLI arguments

master
Pierre Neidhardt 2014-09-13 14:53:42 +02:00
parent c8b8b373d7
commit af7bf794de
1 changed files with 9 additions and 5 deletions

View File

@ -3,7 +3,7 @@
_printhelp ()
{
cat<<EOF
Usage: ${1##*/} [OPTIONS] SCRIPT
Usage: ${1##*/} [OPTIONS] SCRIPT [ARGS...]
Run Emacs Lisp SCRIPT.
@ -34,14 +34,18 @@ if [ $# -eq 0 ]; then
exit 1
fi
if ! command -v emacs >/dev/null 2>&1; then
echo 'emacs not found in PATH. Exiting.' >&2
exit 1
fi
script="$1"
if $OPT_BYTE && [ "${1##*.}" = "el" ]; then
script="${1%.*}.elc"
emacs -Q --batch -f batch-byte-compile "$1"
else
script="$1"
OPT_CLEAN=false
fi
shift
emacs -Q --script "$script"
emacs -Q --script "$script" "$@"
$OPT_CLEAN && rm "$script"