head	2.4;
access;
symbols
	3_0_1:2.4
	3_0_0:2.4
	3_0-pre6:2.4
	3_0-pre5:2.4
	3_0-pre4:2.2
	beta15:1.2
	beta14:1.2
	beta13:1.2
	beta12:1.2
	beta11:1.2
	beta10:1.2
	3_0-pre3:2.2
	3_0-pre2:2.2
	3_0-pre1:2.2
	beta21:2.2
	beta20:2.2
	beta19:2.2
	beta18:2.2
	beta17:2.2
	beta16:2.0;
locks;
comment	@# @;


2.4
date	96.07.29.14.44.25;	author hzoli;	state Exp;
branches;
next	2.3;

2.3
date	96.07.28.22.31.53;	author hzoli;	state Exp;
branches;
next	2.2;

2.2
date	96.05.05.00.35.52;	author hzoli;	state Exp;
branches;
next	2.1;

2.1
date	96.05.05.00.35.51;	author hzoli;	state Exp;
branches;
next	2.0;

2.0
date	96.05.02.22.57.04;	author hzoli;	state Exp;
branches;
next	1.2;

1.2
date	95.02.23.09.13.11;	author coleman;	state Exp;
branches;
next	1.1;

1.1
date	94.11.08.07.01.18;	author zsh;	state Exp;
branches;
next	;


desc
@@


2.4
log
@save/restore TMOUT fix
@
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
@


2.3
log
@some fixes
@
text
@d11 2
a12 1
integer tmout=TMOUT
a24 1
  TMOUT=tmout
a27 3

# We do not want timeout while we are editing a file
TMOUT=0
@


2.2
log
@Fix a stupid zed bug which I introduced
@
text
@d10 1
a10 1
local var fun
d19 1
a19 1
TRAPINT() {
d22 1
a24 1
  (($1 > 0)) && return $[128+$1]
d27 2
d38 1
d40 1
a40 1
if [[ $fun = 1 ]]; then
d43 1
a43 1
  if [[ $var = undefined* ]]; then
d46 1
a46 1
      if [[ -f $dir/$1 ]]; then
d53 1
a53 1
  elif [[ -z $var ]]; then
d58 3
a60 2
  TRAPINT 0
  eval function "$var"
d65 2
a66 2
  TRAPINT 0
  (( fun == 0 )) && print -R "$var" >| $1
@


2.1
log
@*** empty log message ***
@
text
@d55 1
a55 1
  # remember there\'s a memory leak in eval...
d60 1
a60 1
# Restore setup
d62 1
a62 1
  (( $? == 0 )) && print -R "$var" >! $1
@


2.0
log
@New maintainer: Zoltn Hidvgi <hzoli@@cs.elte.hu>
@
text
@d21 1
d60 2
a64 4
bindkey "^X^W" undefined-key

# Restore setup
TRAPINT 0
@


1.2
log
@*** empty log message ***
@
text
@@


1.1
log
@Initial revision
@
text
@d10 2
a11 1
local var nb fun
a20 1
  [[ $nb = 1 ]] || unsetopt nobanghist
d22 1
d26 3
d30 1
a30 2
[[ -o nobanghist ]] && nb=1
setopt nobanghist
@
