From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 23605 invoked from network); 4 Mar 2000 19:32:24 -0000 Received: from sunsite.auc.dk (130.225.51.30) by ns1.primenet.com.au with SMTP; 4 Mar 2000 19:32:24 -0000 Received: (qmail 9833 invoked by alias); 4 Mar 2000 19:32:18 -0000 Mailing-List: contact zsh-workers-help@sunsite.auc.dk; run by ezmlm Precedence: bulk X-No-Archive: yes X-Seq: 9992 Received: (qmail 9814 invoked from network); 4 Mar 2000 19:32:16 -0000 From: "Bart Schaefer" Message-Id: <1000304193210.ZM24987@candle.brasslantern.com> Date: Sat, 4 Mar 2000 19:32:10 +0000 X-Mailer: Z-Mail (5.0.0 30July97) To: zsh-workers@sunsite.auc.dk Subject: PATCH: Tweaking predict-on MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii If you really want to pound on the completion system, enable predict-on for a while. Having completion attempted on every keystroke shows up all kinds of things; in particular I've gotten the undo system into a very bad state by cut'n'pasting a function definition during predict-on and then trying to undo my way out of the resulting chaos. Not reliably repeatable, though. I'm wondering if it would be worthwhile for ZLE and completion widgets to be able to do some sort of FIONREAD test and react differently when there is typeahead ... it won't work everywhere, but ... Of course that may go slightly less haywire after this patch, so if you're interested in debugging "undo" you may want an older predict-on. This patch changes: * Remove "emulate -L zsh" for benefit of the completion system. * Add test of whether we're inside a multi-line buffer, and don't attempt predictive typing in that case. * Reformat a long line. Index: Functions/Zle/predict-on =================================================================== @@ -36,10 +36,15 @@ zle -A .backward-delete-char backward-delete-char } insert-and-predict () { - emulate -L zsh - if [[ ${RBUFFER[1]} = ${KEYS[-1]} ]] + setopt localoptions noshwordsplit noksharrays + if [[ $LBUFFER = *$'\012'* ]] then - # same as what's typed, just move on + # Editing a multiline buffer, it's unlikely prediction is wanted + zle .$WIDGET "$@" + return + elif [[ ${RBUFFER[1]} = ${KEYS[-1]} ]] + then + # Same as what's typed, just move on ((++CURSOR)) else LBUFFER="$LBUFFER$KEYS" @@ -92,12 +97,15 @@ return 0 } delete-backward-and-predict() { - emulate -L zsh if [[ -n "$LBUFFER" ]] then + setopt localoptions noshwordsplit noksharrays + if [[ $LBUFFER = *$'\012'* ]] then + # Editing a multiline buffer, it's unlikely prediction is wanted + zle .$WIDGET "$@" # If the last widget was e.g. a motion, then probably the intent is # to actually edit the line, not change the search prefix. - if [[ $LASTWIDGET == (self-insert|magic-space|backward-delete-char) ]] + elif [[ $LASTWIDGET == (self-insert|magic-space|backward-delete-char) ]] then ((--CURSOR)) zle .history-beginning-search-forward || RBUFFER="" @@ -118,7 +126,8 @@ predict-limit-list() { if (( compstate[list_lines]+BUFFERLINES > LINES || - ( compstate[list_max] != 0 && compstate[nmatches] > compstate[list_max] ) )) + ( compstate[list_max] != 0 && + compstate[nmatches] > compstate[list_max] ) )) then compstate[list]='' compstate[force_list]=yes -- Bart Schaefer Brass Lantern Enterprises http://www.well.com/user/barts http://www.brasslantern.com