Skip to Content.
Sympa Menu

sm-sorcery - [SM-Sorcery]patch for edit_file()

sm-sorcery AT lists.ibiblio.org

Subject: Discussion of Sorcery related topics

List archive

Chronological Thread  
  • From: Peter Schneider-Kamp <peter AT schneider-kamp.de>
  • To: sm-sorcery <sm-sorcery AT lists.ibiblio.org>
  • Subject: [SM-Sorcery]patch for edit_file()
  • Date: Sat, 31 Aug 2002 15:34:47 +0200


--
Peter Schneider-Kamp mailto:peter AT schneider-kamp.de
Deliusstrasse 9 http://schneider-kamp.de
D-52064 Aachen mobile phone: ++49 178 495 1040
? usr/sbin/cast.ideas
Index: usr/sbin/cast
===================================================================
RCS file: /cvsroot/sourcemage/sourcemage/sorcery/usr/sbin/cast,v
retrieving revision 1.23
diff -c -r1.23 cast
*** usr/sbin/cast 2002/08/26 01:57:32 1.23
--- usr/sbin/cast 2002/08/31 13:33:55
***************
*** 235,259 ****
cat /var/cache/config/$SPELL
fi
if query "Do you wish to add -- options to ./configure?" n ;
then
! if [[ $EDITOR ]]; then
! if [[ $EDITOR == /usr/bin/emacs ]] || \
! [[ $EDITOR == /usr/bin/vi ]] || \
! [[ $EDITOR == /usr/bin/jed ]] || \
! [[ $EDITOR == /usr/bin/ed ]] || \
! [[ $EDITOR == /usr/bin/vim ]] || \
! [[ $EDITOR == /usr/bin/nano ]] ; then
! if [ ! -x $EDITOR ]; then
! EDITOR=/usr/bin/nano
! fi
! else
! EDITOR=/usr/bin/nano
! fi
! else
! EDITOR=/usr/bin/nano
! fi
! $EDITOR /var/cache/config/$SPELL
! OPTS="$OPTS `cat /var/cache/config/$SPELL`"
! message "${MESSAGE_COLOR} OPTS= ${SPELL_COLOR}$OPTS"
fi
fi
fi
--- 235,243 ----
cat /var/cache/config/$SPELL
fi
if query "Do you wish to add -- options to ./configure?" n ;
then
! edit_file /var/cache/config/$SPELL
! OPTS="$OPTS `cat /var/cache/config/$SPELL`"
! message "${MESSAGE_COLOR} OPTS= ${SPELL_COLOR}$OPTS"
fi
fi
fi
Index: var/lib/sorcery/modules/libmisc
===================================================================
RCS file:
/cvsroot/sourcemage/sourcemage/sorcery/var/lib/sorcery/modules/libmisc,v
retrieving revision 1.12
diff -c -r1.12 libmisc
*** var/lib/sorcery/modules/libmisc 2002/08/25 02:28:16 1.12
--- var/lib/sorcery/modules/libmisc 2002/08/31 13:33:55
***************
*** 268,281 ****
#---------------------------------------------------------------------
##=item edit_file <filename>
##
! ## Runs the editor given by C<EDITOR> (or nano if C<EDITOR> is not set)
! ## on the file given in the first argument.
##
#---------------------------------------------------------------------
edit_file() {

- ${EDITOR:-nano} $1
-
}


--- 268,310 ----
#---------------------------------------------------------------------
##=item edit_file <filename>
##
! ## Runs the editor given by C<EDITOR> on the file given in the first
! ## argument if C<EDITOR> is set and points to one of the following
! ## editors: emacs, vi, jed, ed, vim.
! ## Otherwise nano is used.
##
#---------------------------------------------------------------------
edit_file() {
+ [[ $DEBUG ]] && echo "Entering edit_file() with EDITOR=$EDITOR" >> $DEBUG
+ if [[ ${EDITOR##*/} == emacs ]] || \
+ [[ ${EDITOR##*/} == vi ]] || \
+ [[ ${EDITOR##*/} == jed ]] || \
+ [[ ${EDITOR##*/} == ed ]] || \
+ [[ ${EDITOR##*/} == vim ]] ; then
+ [[ $DEBUG ]] && echo "Editor recognized as ${EDITOR##*/}" >> $DEBUG
+ else
+ [[ $DEBUG ]] && echo "Unrecognized editor ${EDITOR##*/} -- falling back
to nano" >> $DEBUG
+ if [ -x /usr/bin/nano ]; then
+ EDITOR=/usr/bin/nano
+ else
+ EDITOR=nano
+ fi
+ fi
+ which $EDITOR >> /dev/null
+ while [[ $? == 1 ]]; do
+ [[ $DEBUG ]] && echo "Could not locate editor $EDITOR -- asking user"
>> $DEBUG
+ echo -n "Please specify an editor [abort]: "
+ read -t $PROMPT_DELAY EDITOR
+ echo
+ if [ -z $EDITOR ]; then
+ [[ $$DEBUG ]] && echo "User abort on editor selection" >> $DEBUG
+ return
+ fi
+ which $EDITOR
+ done
+ [[ $DEBUG ]] && echo "Editing $1 with $EDITOR" >> $DEBUG
+ ${EDITOR} $1

}




  • [SM-Sorcery]patch for edit_file(), Peter Schneider-Kamp, 08/31/2002

Archive powered by MHonArc 2.6.24.

Top of Page