From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 10137 invoked from network); 15 Sep 1999 12:47:56 -0000 Received: from sunsite.auc.dk (130.225.51.30) by ns1.primenet.com.au with SMTP; 15 Sep 1999 12:47:56 -0000 Received: (qmail 27611 invoked by alias); 15 Sep 1999 12:47:47 -0000 Mailing-List: contact zsh-workers-help@sunsite.auc.dk; run by ezmlm Precedence: bulk X-No-Archive: yes X-Seq: 7840 Received: (qmail 27604 invoked from network); 15 Sep 1999 12:47:46 -0000 To: zsh-workers@sunsite.auc.dk Subject: PATCH: _tilde and _cd use compadd -d MIME-Version: 1.0 (generated by AKEMI 1.13.2 - =?ISO-2022-JP?B?Ig==?= =?ISO-2022-JP?B?GyRCQTA0Y0s8GyhCIg==?=) Content-Type: text/plain; charset=US-ASCII From: Tanaka Akira Date: 15 Sep 1999 21:47:44 +0900 Message-ID: User-Agent: Chao-gnus/6.12.5 AKEMI/1.13.2 (=?ISO-2022-JP?B?GyRCQTAbKEI=?= =?ISO-2022-JP?B?GyRCNGNLPBsoQg==?=) FLAM-DOODLE/1.12.6 (=?ISO-2022-JP?B?GyRCM3cbKEI=?= 10R4.0/5.0) Emacs/20.4 (sparc-sun-solaris2.6) MULE/4.0 (HANANOEN) I modified _tilde and _cd to use compadd -d. Index: Completion/Base/_tilde =================================================================== RCS file: /projects/zsh/zsh/Completion/Base/_tilde,v retrieving revision 1.1.1.6 diff -u -F^( -r1.1.1.6 _tilde --- _tilde 1999/08/23 10:07:20 1.1.1.6 +++ _tilde 1999/09/15 12:45:01 @@ -7,8 +7,10 @@ # `(( compstate[nmatches] )) || compgen -nu -qS/' # below that. -local d c s dirs list +setopt localoptions extendedglob +local d s dirs list + if [[ "$SUFFIX" = */* ]]; then ISUFFIX="/${SUFFIX#*/}$ISUFFIX" SUFFIX="${SUFFIX%%/*}" @@ -16,33 +18,32 @@ else s=(-qS/) fi - -if compset -P +; then - dirs="$(dirs -v)" - list=("${(f)dirs}") - [[ -o pushdminus ]] && dirs="$(awk '{ $1 = '$#list' - $1 - 1; - printf("%s\t%s\n", $1, $2); }' <<<$dirs)" - list=("${(@)list% *}") - c=(-y '$dirs' -k "($list)") - _description d 'directory stack' -elif compset -P -; then - dirs="$(dirs -v)" - list=("${(f)dirs}") - [[ ! -o pushdminus ]] && dirs="$(awk '{ $1 = '$#list' - $1 - 1; - printf("%s\t%s\n", $1, $2); }' <<<$dirs)" - list=("${(@)list% *}") - c=(-y '$dirs' -k "($list)") +if [[ -prefix [-+] ]]; then + lines=(${(f)"$(dirs -v)"}) + if [[ ( -prefix - && ! -o pushdminus ) || + ( -prefix + && -o pushdminus ) ]]; then + integer tot i + for (( i = 1, tot = $#lines-1; i <= $#lines; i++, tot-- )); do + lines[$i]="$tot -- ${lines[$i]##[0-9]#[ ]#}" + done + else + for (( i = 1, tot = 0; i <= $#lines; i++, tot++ )); do + lines[$i]="$tot -- ${lines[$i]##[0-9]#[ ]#}" + done + fi + list=(${lines%% *}) + compset -P '[-+]' _description d 'directory stack' + compadd "$d[@]" -d lines -Q - "$list[@]" else - c=(-nu) - if (( $# )); then d=( "$@" ) else _description d 'user or named directory' fi + + compgen "$d[@]" -nu "$s[@]" fi -compgen "$d[@]" "$c[@]" "$s[@]" Index: Completion/Builtins/_cd =================================================================== RCS file: /projects/zsh/zsh/Completion/Builtins/_cd,v retrieving revision 1.1.1.9 diff -u -F^( -r1.1.1.9 _cd --- _cd 1999/08/19 11:18:12 1.1.1.9 +++ _cd 1999/09/15 12:45:01 @@ -37,24 +37,25 @@ local list lines ret=1 # get the list of directories with their canonical number - lines="$(dirs -v)" - # turn the lines into an array, removing the current directory - list=(${${(f)lines}##0*}) + # and turn the lines into an array, removing the current directory + lines=( ${${(f)"$(dirs -v)"}##0*} ) if [[ ( $IPREFIX = - && ! -o pushdminus ) || ( $IPREFIX = + && -o pushdminus ) ]]; then # reverse the numbering: it counts the last one as -0, which # is a little strange. integer tot i - for (( i = 1, tot = $#list-1; tot >= 0; i++, tot-- )); do - list[$i]="$tot${list[$i]##[0-9]#}" + for (( i = 1, tot = $#lines-1; i <= $#lines; i++, tot-- )); do + lines[$i]="$tot -- ${lines[$i]##[0-9]#[ ]#}" done + else + for (( i = 1, tot = 1; i <= $#lines; i++, tot++ )); do + lines[$i]="$tot -- ${lines[$i]##[0-9]#[ ]#}" + done fi - # make sure -y treats this as a single string - lines="${(F)list}" # get the array of numbers only - list=(${list%%[ ]*}) + list=(${lines%% *}) _description expl 'directory stack index' - compgen "$expl[@]" -y '$lines' -Q -k list && ret=0 + compadd "$expl[@]" -d lines -Q - "$list[@]" && ret=0 [[ -z $compstate[list] ]] && compstate[list]=list && ret=0 [[ -n $compstate[insert] ]] && compstate[insert]=menu && ret=0 -- Tanaka Akira