From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 28580 invoked from network); 5 Aug 1999 14:38:45 -0000 Received: from sunsite.auc.dk (130.225.51.30) by ns1.primenet.com.au with SMTP; 5 Aug 1999 14:38:45 -0000 Received: (qmail 23241 invoked by alias); 5 Aug 1999 14:38:37 -0000 Mailing-List: contact zsh-workers-help@sunsite.auc.dk; run by ezmlm Precedence: bulk X-No-Archive: yes X-Seq: 7381 Received: (qmail 23234 invoked from network); 5 Aug 1999 14:38:37 -0000 Message-Id: <9908051407.AA36170@ibmth.df.unipi.it> To: zsh-workers@sunsite.auc.dk Subject: Re: configuration question In-Reply-To: "Wim Yedema"'s message of "05 Aug 1999 15:33:22 DFT." Date: Thu, 05 Aug 1999 16:07:31 +0200 From: Peter Stephenson Wim Yedema wrote: > I'd like replace self-insert with a function that automatically > does something like "history-beginning-search-backward" the problem > with this is that it beeps when nothing is found and that the current > history number changes, meaning that every time I type something I > go backwards in the history even if the character that I type suits > the current history event just fine. > > I tried something like this > > --- > insert-and-predict () { > LBUFFER="$LBUFFER$KEYS" > RBUFFER="" > zle history-beginning-search-backward > } > > autoload insert-and-predict > zle -N self-insert insert-and-predict > --- > > can someone stop the beep and give me the right behaviour? Turning the beep off should be easy: just stick `return 0' at the end of the function --- that only works from 3.1.6, however. The beep is triggered by the return status of the zle command. As for the other behaviour, I don't quite know what you're finally aiming at (how are you going to edit the line?), but I got the following to work by binding predict-on and predict-off: predict-on() { zle -N self-insert insert-and-predict; } zle -N predict-on predict-off() { zle -A self-insert .self-insert; } zle -N predict-off insert-and-predict () { if [[ ${RBUFFER[1]} = ${KEYS[-1]} ]]; then # same as what's typed, just move on zle forward-char else LBUFFER="$LBUFFER$KEYS" RBUFFER="" zle history-beginning-search-backward fi return 0 } zle -N insert-and-predict It's interesting what happens if you get predict-off wrong. Note that it's now possible to give arguments to `zle history-search-backwards' in a widget function, which might be another way of doing what you want. -- Peter Stephenson Tel: +39 050 844536 WWW: http://www.ifh.de/~pws/ Dipartimento di Fisica, Via Buonarroti 2, 56127 Pisa, Italy