From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 9974 invoked from network); 27 Feb 2000 20:42:06 -0000 Received: from sunsite.auc.dk (130.225.51.30) by ns1.primenet.com.au with SMTP; 27 Feb 2000 20:42:06 -0000 Received: (qmail 23603 invoked by alias); 27 Feb 2000 20:41:58 -0000 Mailing-List: contact zsh-workers-help@sunsite.auc.dk; run by ezmlm Precedence: bulk X-No-Archive: yes X-Seq: 9886 Received: (qmail 23590 invoked from network); 27 Feb 2000 20:41:52 -0000 From: "Bart Schaefer" Message-Id: <1000227204146.ZM27900@candle.brasslantern.com> Date: Sun, 27 Feb 2000 20:41:46 +0000 X-Mailer: Z-Mail (5.0.0 30July97) To: zsh-workers@sunsite.auc.dk Subject: _path_files and the -M option MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii 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. Everything is fine up to through the point where _path_files calls compadd -D tmp1 -F _comp_ignore -M "L:|[nN][oO]= M:_= M:{A-Z}={a-z}" - ... (somewhere between lines 300 and 310 in my current copy of _path_files, the line numbers reported by xtrace appear to be somewhat off). This correctly leaves the right set of matches in tmp1, but doesn't actually add the matches yet. That happens down after line 440 or so, after "if (( tmp4 ))" is tested, and the actual compadd is: compadd -Qf -J -default- -F _comp_ignore -p '' -W '' -M "r:|/=* r:|=*" - ... where the "..." is still the intended set of matches. But none of those actually match what's on the line; the "L:|..." has been lost, so (AFAICT) the presence of "no" on the line causes them all to be discarded. The following patch causes it to work by preserving the passed-in match specs on *every* call to compadd, simply appending the one _path_files supplied itself, but I'm not sure what else this might break. Please don't apply this patch until Sven chimes in. Sven? Index: Completion/Core/_path_files =================================================================== @@ -458,26 +458,26 @@ if [[ "$tmp3" = */* ]]; then compadd -Qf "$mopts[@]" -p "$linepath$tmp2" -s "/${tmp3#*/}" \ -W "$prepath$realpath$testpath" \ - "$pfxsfx[@]" -M "r:|/=* r:|=*" \ + "$pfxsfx[@]" "$matcher[@]" "r:|/=* r:|=*" \ - "${(@)tmp1%%/*}" else compadd -Qf "$mopts[@]" -p "$linepath$tmp2" \ -W "$prepath$realpath$testpath" \ - "$pfxsfx[@]" -M "r:|/=* r:|=*" \ + "$pfxsfx[@]" "$matcher[@]" "r:|/=* r:|=*" \ - "$tmp1[@]" fi else if [[ "$tmp3" = */* ]]; then atmp=( -Qf "$mopts[@]" -p "$linepath$tmp2" -W "$prepath$realpath$testpath" - "$pfxsfx[@]" -M "r:|/=* r:|=*" ) + "$pfxsfx[@]" "$matcher[@]" "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[@]" -M "r:|/=* r:|=*" \ + "$pfxsfx[@]" "$matcher[@]" "r:|/=* r:|=*" \ - "$tmp1[@]" fi fi @@ -525,7 +525,7 @@ tmp4="$testpath" compquote tmp4 tmp1 compadd -Qf "$mopts[@]" -p "$linepath$tmp4" -W "$prepath$realpath$testpath" \ - "$pfxsfx[@]" -M "r:|/=* r:|=*" - "$tmp1[@]" + "$pfxsfx[@]" "$matcher[@]" "r:|/=* r:|=*" - "$tmp1[@]" fi done @@ -541,7 +541,7 @@ if (( $#exppaths )); then PREFIX="${opre}" SUFFIX="${osuf}" - compadd -Q "$mopts[@]" -S '' -M "r:|/=* r:|=*" -p "$linepath" - "$exppaths[@]" + compadd -Q "$mopts[@]" -S '' "$matcher[@]" "r:|/=* r:|=*" -p "$linepath" - "$exppaths[@]" fi fi -- Bart Schaefer Brass Lantern Enterprises http://www.well.com/user/barts http://www.brasslantern.com