From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 25952 invoked from network); 13 Jul 1998 17:47:35 -0000 Received: from math.gatech.edu (list@130.207.146.50) by ns1.primenet.com.au with SMTP; 13 Jul 1998 17:47:35 -0000 Received: (from list@localhost) by math.gatech.edu (8.8.5/8.8.5) id NAA21075; Mon, 13 Jul 1998 13:41:37 -0400 (EDT) Resent-Date: Mon, 13 Jul 1998 13:37:07 -0400 (EDT) From: "Bart Schaefer" Message-Id: <980713103758.ZM2098@candle.brasslantern.com> Date: Mon, 13 Jul 1998 10:37:58 -0700 In-Reply-To: Comments: In reply to Heinz Deinhart "completion & read, vared" (Jul 13, 1:10pm) References: X-Mailer: Z-Mail (4.0b.820 20aug96) To: Heinz Deinhart , zsh-users@math.gatech.edu Subject: Re: completion & read, vared MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Resent-Message-ID: <"J63gA1.0.C65._Magr"@math> Resent-From: zsh-users@math.gatech.edu X-Mailing-List: archive/latest/1670 X-Loop: zsh-users@math.gatech.edu X-Loop: zsh-workers@math.gatech.edu Precedence: list Resent-Sender: zsh-workers-request@math.gatech.edu On Jul 13, 1:10pm, Heinz Deinhart wrote: } Subject: completion & read, vared } } is there a way to use completion with any realine-like function ? Not directly; "read" inputs characters one at a time, for some reason, even when not in raw mode. } vared uses completion, but i cant figure out how to change its behaviour. Change its behavior how? Try the following; it should work exactly like the "read" builtin, except that when reading in the "ordinary" way from a terminal, it uses vared to provide access to completion and history. Note that this means you can't end the loop with an EOF character (ctrl-D) because vared doesn't interpret EOFs (it attempts completion instead). So you have to end the loop with an interrupt (ctrl-C), which in turn means it's not possible to interrupt any surrounding script or function when the vared is in progress. (There's probably some bindkey foolery that would fix this up.) The cryptic "${${(M)1%%\?*}#\?}" is peeling off the ?PROMPT part of the first NAME?PROMPT parameter (see the zsh doc for the "read" builtin). function zleread { emulate zsh setopt localoptions local input opt ropt n=0 ropt=() while getopts :AEe opt do case $opt in [?]) read $*; return $?;; *) ropt=($ropt -$opt); ((++n)); esac done if [[ -t 0 ]] then shift $n vared -hp "${${(M)1%%\?*}#\?}" input print -r $input | read $ropt ${1%%\?*} $*[2,-1] return $? fi read $* } I did notice one oddity while playing with this. From the PS1 prompt, read -eu0k1 reads a line from the terminal and echoes back the first character. However, if instead I redirect input to read like so: repeat 3 print x y z | read -eu0k1 then nothing is read. I have to use repeat 3 print x y z | read -eu0k 1 to get the desired behavior. Why does the source of the input affect the option parsing? -- Bart Schaefer Brass Lantern Enterprises http://www.well.com/user/barts http://www.brasslantern.com