From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 19741 invoked from network); 28 Feb 2000 09:02:28 -0000 Received: from sunsite.auc.dk (130.225.51.30) by ns1.primenet.com.au with SMTP; 28 Feb 2000 09:02:28 -0000 Received: (qmail 17437 invoked by alias); 28 Feb 2000 09:02:21 -0000 Mailing-List: contact zsh-workers-help@sunsite.auc.dk; run by ezmlm Precedence: bulk X-No-Archive: yes X-Seq: 9892 Received: (qmail 17430 invoked from network); 28 Feb 2000 09:02:20 -0000 Date: Mon, 28 Feb 2000 10:02:16 +0100 (MET) Message-Id: <200002280902.KAA02148@beta.informatik.hu-berlin.de> From: Sven Wischnowsky To: zsh-workers@sunsite.auc.dk In-reply-to: "Bart Schaefer"'s message of Sun, 27 Feb 2000 20:41:46 +0000 Subject: PATCH: Re: _path_files and the -M option Bart Schaefer wrote: > I was experimenting with using match specs as documented in PWS's guide > (section 6.7) and made up this little function: > > function _test { _files -M 'L:|[nN][oO]= M:_= M:{A-Z}={a-z}' } > > You may recognize that -M as the one from the example setopts completion. > So what I'm trying to accomplish -- for no reason other than to play with > it -- is to complete file names after an optional "no" prefix, with case > and underscores ignored. > > Unfortunately, it doesn't work. I found the same problem (but with a different example) at the weekend. The patch just stuffs the $matcher into the $mopts. (It is relative to your patch because the CVS contained it, but only to back it out -- it made the 'r:...' and the '-' be added as matches because we ended up with `-M '...' 'r:...' - ...'.) > ... > > (somewhere between lines 300 and 310 in my current copy of _path_files, > the line numbers reported by xtrace appear to be somewhat off). Hm. Can't reproduce any wrong line numbers... The patch also contains some other hunks: a fix for a typo in _main_complete, making compdump use the (q) flag, removing compstyle (which hopefully noone uses any more) and updating compconf a bit. Bye Sven diff -ru ../z.old/Completion/Core/_main_complete Completion/Core/_main_complete --- ../z.old/Completion/Core/_main_complete Mon Feb 28 09:09:20 2000 +++ Completion/Core/_main_complete Mon Feb 28 09:14:27 2000 @@ -106,7 +106,7 @@ if [[ -n "$tmp" || $compstate[old_list] = keep || $compstate[nmatches]+$compstate[alternate_nmatches] -gt 1 ]]; then [[ _last_nmatches -ge 0 && - _last_nmatches -ne $compstate[nmatches]+$compstate[alternate_nmatches ]] && + _last_nmatches -ne $compstate[nmatches]+$compstate[alternate_nmatches] ]] && _menu_style=( "$_last_menu_style[@]" "$_menu_style[@]" ) if [[ "$compstate[insert]" = "$_saved_insert" ]]; then diff -ru ../z.old/Completion/Core/_path_files Completion/Core/_path_files --- ../z.old/Completion/Core/_path_files Mon Feb 28 09:09:21 2000 +++ Completion/Core/_path_files Mon Feb 28 09:58:16 2000 @@ -163,6 +163,8 @@ (( $mopts[(I)-F] )) || mopts=( "$mopts[@]" -F _comp_ignore ) fi +(( $#matcher )) && mopts=( "$mopts[@]" "$matcher[@]" ) + # Now let's have a closer look at the string to complete. if [[ "$pre[1]" = \~ ]]; then @@ -458,26 +460,26 @@ if [[ "$tmp3" = */* ]]; then compadd -Qf "$mopts[@]" -p "$linepath$tmp2" -s "/${tmp3#*/}" \ -W "$prepath$realpath$testpath" \ - "$pfxsfx[@]" "$matcher[@]" "r:|/=* r:|=*" \ + "$pfxsfx[@]" -M "r:|/=* r:|=*" \ - "${(@)tmp1%%/*}" else compadd -Qf "$mopts[@]" -p "$linepath$tmp2" \ -W "$prepath$realpath$testpath" \ - "$pfxsfx[@]" "$matcher[@]" "r:|/=* r:|=*" \ + "$pfxsfx[@]" -M "r:|/=* r:|=*" \ - "$tmp1[@]" fi else if [[ "$tmp3" = */* ]]; then atmp=( -Qf "$mopts[@]" -p "$linepath$tmp2" -W "$prepath$realpath$testpath" - "$pfxsfx[@]" "$matcher[@]" "r:|/=* r:|=*" ) + "$pfxsfx[@]" -M "r:|/=* r:|=*" ) for i in "$tmp1[@]"; do compadd "$atmp[@]" -s "/${i#*/}" - "${i%%/*}" done else compadd -Qf "$mopts[@]" -p "$linepath$tmp2" \ -W "$prepath$realpath$testpath" \ - "$pfxsfx[@]" "$matcher[@]" "r:|/=* r:|=*" \ + "$pfxsfx[@]" -M "r:|/=* r:|=*" \ - "$tmp1[@]" fi fi @@ -525,7 +527,7 @@ tmp4="$testpath" compquote tmp4 tmp1 compadd -Qf "$mopts[@]" -p "$linepath$tmp4" -W "$prepath$realpath$testpath" \ - "$pfxsfx[@]" "$matcher[@]" "r:|/=* r:|=*" - "$tmp1[@]" + "$pfxsfx[@]" -M "r:|/=* r:|=*" - "$tmp1[@]" fi done @@ -541,7 +543,7 @@ if (( $#exppaths )); then PREFIX="${opre}" SUFFIX="${osuf}" - compadd -Q "$mopts[@]" -S '' "$matcher[@]" "r:|/=* r:|=*" -p "$linepath" - "$exppaths[@]" + compadd -Q "$mopts[@]" -S '' -M "r:|/=* r:|=*" -p "$linepath" - "$exppaths[@]" fi fi diff -ru ../z.old/Completion/Core/compdump Completion/Core/compdump --- ../z.old/Completion/Core/compdump Mon Feb 28 09:09:22 2000 +++ Completion/Core/compdump Mon Feb 28 09:14:27 2000 @@ -29,19 +29,19 @@ print "_comps=(" >> $_d_file for _d_f in ${(ok)_comps}; do - print -r - "'${_d_f//\'/'\\''}'" "'${_comps[$_d_f]//\'/'\\''}'" + print -r - "${(q)_d_f}" "${(q)_comps[$_d_f]}" done >> $_d_file print ")" >> $_d_file print "\n_patcomps=(" >> $_d_file for _d_f in "${(ok@)_patcomps}"; do - print -r - "'${_d_f//\'/'\\''}'" "'${_patcomps[$_d_f]//\'/'\\''}'" + print -r - "${(q)_d_f}" "${(q)_patcomps[$_d_f]}" done >> $_d_file print ")" >> $_d_file print "\n_postpatcomps=(" >> $_d_file for _d_f in "${(ok@)_postpatcomps}"; do - print -r - "'${_d_f//\'/'\\''}'" "'${_postpatcomps[$_d_f]//\'/'\\''}'" + print -r - "${(q)_d_f}" "${(q)_postpatcomps[$_d_f]}" done >> $_d_file print ")" >> $_d_file diff -ru ../z.old/Completion/Core/compinit Completion/Core/compinit --- ../z.old/Completion/Core/compinit Mon Feb 28 09:09:22 2000 +++ Completion/Core/compinit Mon Feb 28 10:00:57 2000 @@ -308,12 +308,16 @@ Hello -\`compconf' will be removed in the near future. The \`styles' form of -your setup should be available in the file: +\`compconf' will be removed in the near future, we now use a more +general (and powerful) mechanism using the \`zstyle' builtin. An +approximation to your old setup using \`zstyle' should be available +in the file: \`${HOME}/.zsh-styles' -Note that the values for the style may not be fully correct. +Note that the values for the styles may be partly incorrect. Please +read the manual to find out how to configure the completion system +with styles. Have fun @@ -358,7 +362,7 @@ tmp="'*:options' prefix-needed yes" [[ "$val" = hide* ]] && tmp="$tmp -zstyle ':completion*:options' prefix-hidden yes" +zstyle ':completion:*:options' prefix-hidden yes" ;; group_matches) tmp="'*' group-name ''" @@ -373,28 +377,28 @@ tmp="'*:paths' cursor ${(qq)val}" ;; (approximate|incremental|predict|list|oldlist|match)_*) - tmp="':${name%%_*}' ${${name#*_}//_/-} ${(qq)val}" + tmp="'*${name%%_*}:*' ${${name#*_}//_/-} ${(qq)val}" ;; correct_*) cmt="# This one is a bit ugly. You may want to use only \`*:correct' # if you also have the \`correctword_*' or \`approximate_*' keys. " - tmp="':(correct(|-word)|approximate)' ${name#*_} ${(qq)val}" + tmp="'*(correct(|-word)|approximate):*' ${name#*_} ${(qq)val}" ;; correctword_*) - tmp="':correct-word' ${name#correctword_} ${(qq)val}" + tmp="'*:correct-word' ${name#correctword_} ${(qq)val}" ;; expand_*) cmt="# This one is a bit ugly. You may want to use only \`*:expand' # if you also have the \`expandword_*' keys. " - tmp="':expand(|expand-word)' ${name#*_} ${(qq)val}" + tmp="'*expand(|expand-word):*' ${name#*_} ${(qq)val}" ;; expandword_*) - tmp="':expand-word' ${name#expandword_} ${(qq)val}" + tmp="'expand-word:*' ${name#expandword_} ${(qq)val}" ;; history_*) - tmp="'*:history-words' ${name#history_} ${(qq)val}" + tmp="'history-words:*' ${name#history_} ${(qq)val}" ;; completer) tmp="'*' completer ${${(qqs.:.)val}}" @@ -403,71 +407,13 @@ tmp="'*' last-prompt 'yes'" ;; esac - [[ -n "$tmp" ]] && style="${style}${cmt}zstyle :completion${tmp} + [[ -n "$tmp" ]] && style="${style}${cmt}zstyle :completion:${tmp} " done eval "${style}" print "$style" >>! ${HOME}/.zsh-styles -} - -# Very simple interface for setting styles: -# -# compstyle pattern style values... - -compstyle() { - local long - - if [[ "$1" = -L ]]; then - long=yes - shift - fi - - if (( ! $# )); then - local pats styles vals pat style pre eq - - zstyle -g pats - - for pat in "${(@M)pats:#:completion*}"; do - if [[ -n "$long" ]]; then - pre="compstyle ${(qq)pat#:completion} " - else - print "${pat#:completion}" - pre=' ' - eq=' =' - fi - zstyle -g styles "$pat" - for style in "$styles[@]"; do - zstyle -g vals "$pat" "$style" - print "${pre}${style}${eq}" "${(@qq)vals}" - done - done - - return 0 - fi - - if [[ "$1" = -d ]]; then - if [[ $# -gt 1 ]]; then - zstyle -d ":completion$2" "${(@)argv[3,-1]}" - else - local pats - - zstyle -g pats - - for pat in "${(@M)pats:#:completion}"; do - zstyle -d "$pat" - done - fi - - return 0 - fi - - [[ "$1" = -(|-) ]] && shift - - zstyle - ":completion$1" "${(@)argv[2,-1]}" - - return 0 } # Now we automatically make the definition files autoloaded. -- Sven Wischnowsky wischnow@informatik.hu-berlin.de