head	3.1;
branch	3.1.1;
access;
symbols;
locks;
comment	@# @;


3.1
date	96.10.30.23.41.13;	author hzoli;	state Exp;
branches
	3.1.0.0
	3.1.1.0;
next	3.0;

3.0
date	96.10.30.23.39.35;	author hzoli;	state Exp;
branches
	3.0.1.0;
next	;

3.0.1.0
date	96.10.30.23.40.21;	author hzoli;	state Exp;
branches;
next	;

3.1.0.0
date	96.10.30.23.41.58;	author hzoli;	state Exp;
branches;
next	;

3.1.1.0
date	96.12.21.02.35.24;	author hzoli;	state Exp;
branches;
next	;


desc
@@


3.1
log
@# branch point
@
text
@# zed():  Peter Stephenson <pws@@s-a.amtp.liv.ac.uk>
# No other shell could do this.
# Edit small files with the command line editor.
# Use ^X^W to save, ^C to abort.
# Option -f: edit shell functions.  (Also if called as fned.)
#
# Completion: use
# compctl -f -x 'w[1,-f]' -F -- zed

local var fun ctrl_W_bind="$(bindkey '^W')"
# We do not want timeout while we are editing a file
integer TMOUT=0

[[ $1 = -f || $0 = fned ]] && fun=1
[[ $1 = -(|-|f) ]] && shift

[[ -z "$1" ]] && echo 'Usage: "zed filename" or "zed -f function"' && return 1

# catch interrupts
cleanup () {
  bindkey "^M" accept-line
  bindkey "^X^W" undefined-key
  bindkey "^W" "$ctrl_W_bind"
  trap - INT
}

trap 'cleanup ; return 130' INT

# don't mangle !'s
setopt localoptions nobanghist

bindkey "^M" self-insert-unmeta
# Depending on your stty's, you may be able to use ^J as accept-line, else:
bindkey "^X^W" accept-line
bindkey "^W" kill-region

if ((fun)) then
  var="$(functions $1)"
  # If function is undefined but autoloadable, load it
  if [[ $var = undefined* ]] then
    local dir
    for dir in $fpath; do
      if [[ -f $dir/$1 ]] then
	var="$1() {
$(<$dir/$1)
}"
	break
      fi
    done
  elif [[ -z $var ]] then
    var="$1() {
}"
  fi
  vared var
  fun=$?
  cleanup
  (( fun == 0 )) && eval function "$var"
else
  [[ -f $1 ]] && var="$(<$1)"
  vared var
  fun=$?
  cleanup
  (( fun == 0 )) && print -r -- "$var" >| $1
fi

return 0

# End of zed
@


3.1.1.0
log
@#
@
text
@@


3.1.0.0
log
@# create 3.1.0 branch
@
text
@@


3.0
log
@# bounce the revision numbers to 3.0
@
text
@@


3.0.1.0
log
@# create 3.0.1 branch
@
text
@@
