zsh-users
 help / color / mirror / code / Atom feed
* Revised version of "promptnl"
@ 2000-08-27 17:02 Bart Schaefer
  2000-08-31 10:17 ` Completion doesn't work after upgrade Klaus Wacker
  0 siblings, 1 reply; 4+ messages in thread
From: Bart Schaefer @ 2000-08-27 17:02 UTC (permalink / raw)
  To: zsh-users

This fixes a couple of bugs:

1. Typeahead confused it.  This version attempts to consume all typeahead
   and pushes anything it gets onto the ZLE buffer stack, whence ZLE will
   fetch it again after the prompt is printed.  This still isn't quite the
   same as if ZLE read those bytes directly, and it's still possible to
   confuse it by typing continually so that your strokes get mixed into
   the cursor position string, but this should handle common cases.

2.  "read -t" doesn't set REPLY to the empty string when it fails, so it's
    necessary to test the result and only append to RECV on success.

---- 8< ---- cut here ---- 8< ----
#autoload
emulate -L zsh

# VT100 and ANSI terminals will report the cursor position when sent
# the sequence ESC [ 6 n -- it comes back as ESC [ column ; line R
# with of course no trailing newline.  Column and line are 1-based.

local RECV='' SEND='\e[6n' REPLY=X

# If you are on a very slow tty, you may need to increase WAIT here.
integer WAIT=1

# Make sure there's no typeahead, or it'll confuse things.  Remove
# this block entirely to use this function in 3.0.x at your own risk.
while read -t -k 1
do
    RECV=$RECV$REPLY
done
if [[ -n $RECV ]]
then
    print -z -r -- $RECV
    RECV=''
    REPLY=X
fi

# This is annoying, but zsh immediately resets it properly, so ...
stty -echo

# Output the SEND sequence and read back into RECV.  In case this is
# not a terminal that understands SEND, do a non-blocking read and
# retry for at most WAIT seconds before giving up.  Requires 3.1.9.
# For 3.0.x, remove "-t" but don't call this on the wrong terminal!

print -n $SEND

integer N=$SECONDS
while [[ $REPLY != R ]] && ((SECONDS - N <= WAIT))
do
    if read -t -k 1
    then
	((N=SECONDS))
	RECV=$RECV$REPLY
    fi
done

# If the cursor is not in the first column, emit EOLMARK and newline.

(( ${${RECV#*\;}%R} > 1 )) && print -P -- $EOLMARK

return 0
---- 8< ---- cut here ---- 8< ----

-- 
Bart Schaefer                                 Brass Lantern Enterprises
http://www.well.com/user/barts              http://www.brasslantern.com

Zsh: http://www.zsh.org | PHPerl Project: http://phperl.sourceforge.net   


^ permalink raw reply	[flat|nested] 4+ messages in thread
* Re: Completion doesn't work after upgrade
@ 2000-08-31 10:33 Sven Wischnowsky
  2000-08-31 11:14 ` Thomas Köhler
  0 siblings, 1 reply; 4+ messages in thread
From: Sven Wischnowsky @ 2000-08-31 10:33 UTC (permalink / raw)
  To: zsh-users; +Cc: Klaus Wacker


Klaus Wacker wrote:

> Dear Zsh, I just upgraded my notebook from Debian Linux 2.1 to 2.2,
> which brought with it an upgrade of zsh from 3.1.2-10 to
> 3.1.6.pws21-1. After the upgrade, TAB completion didn't work any more,
> i.e., hitting TAB when the cursor is at the end of an incomplete
> filename on the command line has no effect at all.
> 
> I found by accident that `compctl -L' will make it work again,
> although, according to man zshcomp, the existing behavior is not
> supposed to be changed by this option.
> 
> I traced the problem to the two statements:
> 
> bindkey -me
> bindkey '^[[2~' overwrite-mode
> 
> in my ~/.zshrc. If I omit both, the problem goes away. Either one of
> them or both will cause the problem to reappear.
> 
> I could of course put `compctl -L >/dev/null' into my .zshrc, but
> somehow I think that that is not the correct solution.

At least one of the betas had the bug that the compctl module
wasn't loaded automatically (and it was affected by autoloading of the
zle module). I'm pretty sure this is the problem you've discovered.

So, to make things work, you can either use the workaround you
discovered or upgrade to a newer version of zsh.

You can also have a look at the new completion system...


We apologise for the inconvenience.


Bye
 Sven

P.S.: This has been fixed quite some time ago, dunno why Debian 2.2
      comes with a version of zsh that has this bug.

--
Sven Wischnowsky                         wischnow@informatik.hu-berlin.de


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

end of thread, other threads:[~2000-08-31 11:47 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2000-08-27 17:02 Revised version of "promptnl" Bart Schaefer
2000-08-31 10:17 ` Completion doesn't work after upgrade Klaus Wacker
2000-08-31 10:33 Sven Wischnowsky
2000-08-31 11:14 ` Thomas Köhler

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).