#! /bin/sh 
# 
export EE_LIB=/usr/lib/easyedit
export EE_RESUME_CMD=fg
GNUemacs=/usr/bin/emacs
# 
#
#	Run emacs in the "easy edit" mode
#
# 
#Easy-edit novice screen editor for Unix systems with GNU emacs
# 
# Copyright (C) 1992     Larry Broda
# 
#    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 1, 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.
# 
#       By Larry Broda
#       Department of Psychology
#       University of Illinois at Urbana-Champaign
#       Email: lbroda@s.psych.uiuc.edu
#       4/8/92
# 
#    GNU emacs information:
#    contact:
#    Free Software Foundation
#    675 Massachusetts Avenu
#    Cambridge, MA 02139
#    USA
#
# Contributions: 
#	6/30/93:  +option, csh/echo standardization: J"org Wunsch
#
# setup environmental variables used by easy-edit
#

ECHO=/bin/echo

export EASY_EL; EASY_EL=$EE_LIB/easyedit.el
if [ -f $EE_LIB/easyedit.elc ]
then
	export EASY_EL; EASY_EL=$EE_LIB/easyedit.elc
elif [ -f $EE_LIB/easyedit.el ]; then
	export EASY_EL; EASY_EL=$EE_LIB/easyedit.el
else
	$ECHO "Cannot find easyedit lisp library: $EE_LIB/easyedit.el[c]"
	exit 1
fi

export EASYEDIT_HELP; EASYEDIT_HELP=$EE_LIB/HELP-WINDOW
export EASYEDIT_MANUAL ; EASYEDIT_MANUAL=$EE_LIB/HELP-MANUAL
export HELP_LEVEL ; HELP_LEVEL=basic
export EE_HELP_OFF ; unset EE_HELP_OFF 
ME=$0
FILE=nofile$$
START_LINE=""

#
# process command line args
#
for ARG
do
	case $ARG in
		-e) export HELP_LEVEL; HELP_LEVEL=advanced ;;
		-[Zz]) export EE_HELP_OFF; EE_HELP_OFF=y ;;
		-*) $ECHO "Unrecognized option: $ARG" ;
		    $ECHO "Form: $ME [-e][-z] filename" ;
		    $ECHO "Options: -e - start with advanced HELP window"
		    $ECHO "         -z - start with no HELP window"
		    exit 1 ;;
		+[0-9][0-9]*)
		    START_LINE="$ARG"
		    ;;
		*) if [ "$FILE" != "nofile$$" ]; then
		         $ECHO "Form: $ME [-e] filename" 
		         exit 1 
			else
				FILE="$ARG"
			fi ;;
	esac
done

#
# check the file to edit, prompt for it if not on command line
#
if [ "$FILE" = "nofile$$" ]; then
#	$ECHO -n "File: "
	csh -c 'echo -n "File: "'
	read FILE
fi
if [ "$FILE" = "" ]; then
	$ECHO "You must call $0 with a filename or give a filename when asked"
	$ECHO " e.g.  $0 filename"
	exit 1
fi
if [ -d "$FILE" ]; then
	$ECHO "$FILE is a directory.  You cannot edit a directory."
	exit 1
fi

$GNUemacs -nw -no-init-file $START_LINE "$FILE" -l $EASY_EL 
