#!/bin/sh
#
# emacsen-remove for tdtd, Adam Di Carlo <aph@debian.org>
#
# parts borrowed from gnus's emacsen-install,
#  by Manoj Srivastava <srivasta@tiamat.datasync.com>
#
# This file is free software under the terms of the GNU
# Public License, version 2 or higher.

set -e

FLAVOR=$1
PACKAGE=tdtd

if [ -z "$FLAVOR" ]; then
    echo need argument to determine FLAVOR of emacs
    exit 1
fi

if [ -z "$PACKAGE" ]; then
    echo internal error: need package name
    exit 1
fi

ELDIR=/usr/share/emacs/site-lisp/$PACKAGE
ELCDIR=/usr/share/$FLAVOR/site-lisp/$PACKAGE
STARTFILE=/etc/$FLAVOR/site-start.d/50$PACKAGE.el

case "$FLAVOR" in
    emacs19 | emacs20 | xemacs20 | xemacs21)
	echo -n "remove/$PACKAGE: removing for $FLAVOR..."
	if [ -d $ELCDIR ]; then
	    rm -rf $ELCDIR
        else
            echo
            echo -n "warning: no dir $ELCDIR, continuing..."
	fi
	if [ -L $STARTFILE ]; then
	    rm -f $STARTFILE
	fi

	echo "done."
	;;
    *)
	echo "remove/$PACKAGE: ignoring emacsen flavor $FLAVOR."
	;;
esac

exit 0
