#!/bin/bash -e
#
# elisp remove file for Debian auctex package.
# $Id: remove.in,v 1.17 2004/09/09 15:15:51 salve Exp $
#
# Copyright (C) 1997, 98, 99, 2000, 01, 02, 03, 04 by Davide Giovanni
# Maria Salvetti.
#
# This program is free software; you can redistribute it and/or modify it
# under the terms of the GNU General Public License as published by the
# Free Software Foundation; either version 2 of the License, or (at your
# option) any later version.
#
# This program is distributed in the hope that it will be useful, but
# WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
# General Public License for more details.
#
# You should have received a copy of the GNU General Public License along
# with this program; if not, write to: The Free Software Foundation, Inc.,
# 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
#
# On Debian GNU/Linux System you can find a copy of the GNU General Public
# License in "/usr/share/common-licenses/GPL".

set -o posix

FLAVOR=${1}

undo_install () {
    echo >&2 -n "remove/auctex: Removing for ${FLAVOR}... "
    rm -f /etc/${FLAVOR}/site-start.d//50auctex.el
    rm -f /usr/share/${FLAVOR}/site-lisp/auctex//../tex-site.el
    rm -f /usr/share/${FLAVOR}/site-lisp/auctex//CompilationLog{,.gz}
    rm -f /usr/share/${FLAVOR}/site-lisp/auctex//*.elc
    rm -f /usr/share/${FLAVOR}/site-lisp/auctex//style//*.elc
    rm -f /usr/share/${FLAVOR}/site-lisp/auctex//style//.nosearch
    test -d /usr/share/${FLAVOR}/site-lisp/auctex//style/ && \
	rmdir --ignore-fail-on-non-empty \
	/usr/share/${FLAVOR}/site-lisp/auctex//style/
    test -d /usr/share/${FLAVOR}/site-lisp/auctex/ && \
	rmdir --ignore-fail-on-non-empty \
	/usr/share/${FLAVOR}/site-lisp/auctex/
    echo >&2 "done."
    return 0
}

undo_auto () {
    rm -rf /var/lib/auctex//${FLAVOR}/
    return 0
}

case "${FLAVOR}" in
    (emacs) : ;;
    (emacs21|emacs-snapshot)
        undo_auto
        undo_install ;;
    (*) echo >&2 "remove/auctex: Ignoring emacsen flavor ${FLAVOR}." ;;
esac

exit 0
