zsh-workers
 help / color / mirror / code / Atom feed
* New zed and refresh bug
@ 1996-07-28 20:36 Zoltan Hidvegi
  1996-07-29 13:34 ` Peter Stephenson
  1996-07-29 15:11 ` New zed and refresh bug Geoff Wing
  0 siblings, 2 replies; 11+ messages in thread
From: Zoltan Hidvegi @ 1996-07-28 20:36 UTC (permalink / raw)
  To: Zsh hacking and development

The zed distributed with pre4 does not exit properli on ^C interrupt.
Below is a replacement for that.

It demonstrates a zle bug.  Just load this zed function, unset the BAUD
parameter (to get half-screen scrolls in zed), invoke zed -f zed, and use
the up-arrow to move to the top of the function.  On a 80x25 Linux console
with ncurses a bogous `if [[ -f $dir/$1 ]' appears on the 5th screen line
after the second half-screen scroll.

Zoltan


# 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')"
integer tmout=TMOUT

[[ $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
  TMOUT=tmout
}

trap 'cleanup ; return 130' INT

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

# 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


^ permalink raw reply	[flat|nested] 11+ messages in thread

end of thread, other threads:[~1996-08-04  2:04 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
1996-07-28 20:36 New zed and refresh bug Zoltan Hidvegi
1996-07-29 13:34 ` Peter Stephenson
1996-07-29 14:03   ` Zoltan Hidvegi
1996-07-29 14:21     ` Zoltan Hidvegi
1996-08-03 16:00       ` Bart Schaefer
1996-08-04  0:42         ` Zoltan Hidvegi
1996-08-04  1:41           ` Local variables and "typeset" Bart Schaefer
1996-07-29 15:11 ` New zed and refresh bug Geoff Wing
1996-07-29 17:21   ` Zoltan Hidvegi
1996-07-30  4:52     ` Geoff Wing
1996-07-30  6:20       ` zle_refresh.c patch (Was: New zed and refresh bug) Geoff Wing

Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/zsh/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).