#!/bin/bash
#
# File:        getEmacsSettings.sh
# Author:      Nick Nielsen <nick@nielsenhome.net>
# Time-stamp:  <Last changed 29-01-2009 15:11:20 by root, root>

# Description: This script will retrieve emacs files from my website,
#              and describe the changes necessary to integrate them.

echo "Creating $HOME/emacs"
mkdir -p $HOME/emacs

echo "Grabbing files from nielsenhome.net"
cd $HOME/emacs

# Always retrieve the latest dotemacs file.
rm -f dotemacs
wget 'http://www.nielsenhome.net/emacs/dotemacs'

if [ ! -f "global-5.7.4.tar.gz" ] ; then
    wget 'http://www.nielsenhome.net/emacs/global-5.7.4.tar.gz'
    tar zxvf global*
    cd global*
    ./configure
    make
    make install
    cp *.el $HOME/emacs
    cd ..
fi

cd $HOME/emacs

if [ ! -f "tramp-2.1.15.tar.gz" ] ; then
    wget 'http://www.nielsenhome.net/emacs/tramp-2.1.15.tar.gz'
    tar zxvf tramp*
    cd tramp*
    ./configure --with-contrib
    make
    make install
    cd ..
fi

cd $HOME/emacs

if [ ! -f "highlight-80+.el" ] ; then
    wget 'http://www.nielsenhome.net/emacs/highlight-80+.el'
fi

if [ ! -f "psvn.el" ] ; then
    wget 'http://www.nielsenhome.net/emacs/psvn.el'
fi

if [ -f "$HOME/.emacs" ] ; then
    TIME=`date +%y%m%d_%H%M%S`
    echo "Backing up your $HOME/.emacs file to $HOME/.emacs.$TIME"
    mv $HOME/.emacs $HOME/.emacs.$TIME
fi

echo "Creating new $HOME/.emacs from the one just downloaded."
cp $HOME/emacs/dotemacs $HOME/.emacs

