#!/bin/sh
#
# Time-stamp: <2009/09/10 19:54:47 CEST luca@gismo.pca.it>
#
# Copyright 2007 Luca Capello <luca@pca.it>
# This file is part of the Debian StumpWM package and is licensed
# under the terms of the GNU GPL version 2 or later.  Check
# /usr/share/doc/stumpwm/copyright for more information.
#
# StumpWM startup file.  Check /usr/share/doc/stumpwm/README.Debian
# to know how to setup your ~/.stumpwmrc file to define the Common
# Lisp implementation StumpWM should use.


EVAL_LOAD="(clc:clc-require 'stumpwm)"
EVAL_RUN="(stumpwm:stumpwm)"

load_lisp() {
    case "$1" in
	cmucl)
	    lisp -eval "$EVAL_LOAD $EVAL_RUN"
	    ;;
	sbcl)
	    sbcl --eval "$EVAL_LOAD" --eval "$EVAL_RUN"
	    ;;
	clisp)
	    clisp -x "$EVAL_LOAD $EVAL_RUN"
	    ;;
	*)
	    echo "Unkown Common Lisp implementation."
	    exit 1
	    ;;
    esac
}

if [ -z "$LISP" ]; then
    LISP_STUMPWMRC_TMP="`grep debian= $HOME/.stumpwmrc`"
    LISP_STUMPWMRC=${LISP_STUMPWMRC_TMP##*=}
    LISP=${LISP_STUMPWMRC:-clisp}
fi

if ! which $LISP >/dev/null; then
    echo "CL implementation $LISP not found in your \$PATH."
    exit 1
fi

load_lisp $LISP

exit 0
