From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 11902 invoked from network); 18 Jun 1999 15:24:20 -0000 Received: from sunsite.auc.dk (130.225.51.30) by ns1.primenet.com.au with SMTP; 18 Jun 1999 15:24:20 -0000 Received: (qmail 11891 invoked by alias); 18 Jun 1999 15:23:50 -0000 Mailing-List: contact zsh-workers-help@sunsite.auc.dk; run by ezmlm Precedence: bulk X-No-Archive: yes X-Seq: 6718 Received: (qmail 11880 invoked from network); 18 Jun 1999 15:23:48 -0000 Message-Id: <9906181455.AA20655@ibmth.df.unipi.it> To: "Zsh hackers list" Subject: Re: New completion - redefine widgets instead of rebinding keys RE: pws-22 In-Reply-To: "Peter Stephenson"'s message of "Wed, 16 Jun 1999 17:42:42 DFT." <9906161542.AA12356@ibmth.df.unipi.it> Date: Fri, 18 Jun 1999 16:55:11 +0200 From: Peter Stephenson Peter Stephenson wrote: > "Andrej Borsenkow" wrote: > > Since I've never seen any reply to this, I repeat it here. > > > > My suggestion was, that instead of rebinding keys (as is done currently) we > > should simply redefine corresponding widgets. > > This certainly looks like a good idea. I haven't had a problem with this, so here's the diff. compdef uses the `.' form of the completion widgets, though after the patch I sent that's no longer necessary. Now binding completion keys before or after compinit and in any keymap will work transparently. --- Completion/Core/compinit Wed Jun 9 09:28:57 1999 +++ /home/user2/pws/bin/comp/compinit Wed Jun 16 18:02:06 1999 @@ -215,7 +215,11 @@ fi # Define the widget. - zle -C "$func" "$1" "$func" + if [[ $1 = .* ]]; then + zle -C "$func" "$1" "$func" + else + zle -C "$func" ".$1" "$func" + fi shift # And bind the keys... @@ -335,6 +339,14 @@ fi fi + +# Rebind the standard widgets +for _i_line in complete-word delete-char-or-list expand-or-complete \ + expand-or-complete-prefix list-choices menu-complete \ + menu-expand-or-complete reverse-menu-complete; do + zle -C $_i_line .$_i_line _main_complete +done + _i_done='' # If we have a dump file, load it. @@ -368,23 +380,6 @@ esac done done - - bindkey | - while read -rA _i_line; do - case "$_i_line[2]" in - (complete-word) ;& - (delete-char-or-list) ;& - (expand-or-complete) ;& - (expand-or-complete-prefix) ;& - (list-choices) ;& - (menu-complete) ;& - (menu-expand-or-complete) ;& - (reverse-menu-complete) - zle -C _complete_$_i_line[2] $_i_line[2] _main_complete - bindkey "${_i_line[1][2,-2]}" _complete_$_i_line[2] - ;; - esac - done unset _i_dir _i_line _i_file _i_tag --- Completion/Core/compdump Wed Jun 9 09:28:56 1999 +++ /home/user2/pws/bin/comp/compdump Wed Jun 16 18:03:08 1999 @@ -44,11 +44,13 @@ # Now dump the key bindings. We dump all bindings for zle widgets # whose names start with a underscore. # We need both the zle -C's and the bindkey's to recreate. +# We can ignore any zle -C which rebinds a standard widget (second +# argument to zle does not begin with a `_'). _d_bks=() zle -lL | while read -rA _d_line; do - if [[ ${_d_line[5]} = _* ]]; then + if [[ ${_d_line[3]} = _* && ${_d_line[5]} = _* ]]; then print -r - ${_d_line} _d_bks=($_d_bks ${_d_line[3]}) fi --- Doc/Zsh/compsys.yo.bak Thu Jun 17 14:01:38 1999 +++ Doc/Zsh/compsys.yo Fri Jun 18 16:53:11 1999 @@ -59,6 +59,8 @@ start and finish), you can rerun tt(compinstall) and it will correctly locate and modify these lines. Note, however, that any code you add to this section by hand is likely to be lost if you rerun tt(compinstall). +The new code will take effect next time you start the shell, or run +tt(.zshrc) by hand. You can run it as `tt(source )var()tt(/compinstall)' or `tt(. )var()tt(/compinstall)', where var() is where the @@ -72,6 +74,11 @@ You can abort the installation any time you are being prompted for information, and your tt(.zshrc) will not be altered at all. + +After initialization all the builtin completion widgets such as +tt(expand-or-complete) will be redefined to use the new completion system. +Should you need to, you can still bind keys to the old functions by putting +a `tt(.)' in front, e.g. `tt(.expand-or-complete)'. subsect(Use of compinit) -- Peter Stephenson Tel: +39 050 844536 WWW: http://www.ifh.de/~pws/ Dipartimento di Fisica, Via Buonarroti 2, 56127 Pisa, Italy