From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 26523 invoked from network); 3 Jul 2000 13:41:07 -0000 Received: from sunsite.auc.dk (130.225.51.30) by ns1.primenet.com.au with SMTP; 3 Jul 2000 13:41:07 -0000 Received: (qmail 24718 invoked by alias); 3 Jul 2000 13:40:27 -0000 Mailing-List: contact zsh-workers-help@sunsite.auc.dk; run by ezmlm Precedence: bulk X-No-Archive: yes X-Seq: 12140 Received: (qmail 24710 invoked from network); 3 Jul 2000 13:40:26 -0000 Date: Mon, 03 Jul 2000 14:39:57 +0100 From: Peter Stephenson Subject: PATCH: rebind tab to use complete-word To: zsh-workers@sunsite.auc.dk (Zsh hackers list) Message-id: <0FX4001PNJALXX@la-la.cambridgesiliconradio.com> Content-transfer-encoding: 7BIT This should be a fairly smooth way of getting tab rebound to complete-word if the completer uses _expand. compinstall now arranges for compinit to be called after styles are set up, and compinit checks that the default completer set (actually whatever definition is returned for the context ':completion:', because I couldn't think of anything better, although ':completion:::::' might have been) includes _expand, and if tab is bound to expand-or-complete it rebinds it to complete-word. compinstall put in any line which manipulated $fpath after the call to compinit: this was fairly obviously wrong. Index: Completion/Core/compinit =================================================================== RCS file: /cvsroot/zsh/zsh/Completion/Core/compinit,v retrieving revision 1.8 diff -u -r1.8 compinit --- Completion/Core/compinit 2000/06/23 08:05:41 1.8 +++ Completion/Core/compinit 2000/07/03 13:33:53 @@ -452,6 +452,15 @@ done zle -la menu-select && zle -C menu-select .menu-select _main_complete +# If the default completer set includes _expand, and tab is bound +# to expand-or-complete, rebind it to complete-word instead. +bindkey '^i' | read -A _i_line +if [[ ${_i_line[2]} = expand-or-complete ]] && + zstyle -a ':completion:' completer _i_line && + (( ${_i_line[(i)_expand]} <= ${#_i_line} )); then + bindkey '^i' complete-word +fi + unfunction compinit autoload -U compinit Index: Completion/Core/compinstall =================================================================== RCS file: /cvsroot/zsh/zsh/Completion/Core/compinstall,v retrieving revision 1.15 diff -u -r1.15 compinstall --- Completion/Core/compinstall 2000/06/26 16:17:52 1.15 +++ Completion/Core/compinstall 2000/07/03 13:33:54 @@ -1727,17 +1727,19 @@ # insert. # { print -r "$startline -autoload -U compinit -compinit" - - [[ -n $fpath_line ]] && print -r "$fpath_line" - - print -r "$output" +$output" if [[ -n $ifile ]]; then line="zstyle :compinstall filename ${(qq)ifile}" print -r "$line" eval "$line" fi + + [[ -n $fpath_line ]] && print -r "$fpath_line" + + print -r " +autoload -U compinit +compinit" + print -r "$endline" } >$tmpout Index: Doc/Zsh/compsys.yo =================================================================== RCS file: /cvsroot/zsh/zsh/Doc/Zsh/compsys.yo,v retrieving revision 1.81 diff -u -r1.81 compsys.yo --- Doc/Zsh/compsys.yo 2000/07/03 08:05:27 1.81 +++ Doc/Zsh/compsys.yo 2000/07/03 13:33:54 @@ -73,7 +73,10 @@ new system. If you use the tt(menu-select) widget, which is part of the tt(zsh/complist) module, you should make sure that that module is loaded before the call to tt(compinit) to make sure that that widget is also -re-defined. +re-defined. If completion styles (see below) are set up to perform +expansion as well as completion by default, and the TAB key is bound to +tt(expand-or-complete), tt(compinit) will rebind it to tt(complete-word); +this is necessary to use the correct form of expansion. Should you need to use the original completion commands, you can still bind keys to the old widgets by putting a `tt(.)' in front of the -- Peter Stephenson Cambridge Silicon Radio, Unit 300, Science Park, Milton Road, Cambridge, CB4 0XL, UK Tel: +44 (0)1223 392070