From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 28910 invoked from network); 4 May 2001 05:17:10 -0000 Received: from sunsite.dk (130.225.51.30) by ns1.primenet.com.au with SMTP; 4 May 2001 05:17:10 -0000 Received: (qmail 22268 invoked by alias); 4 May 2001 05:17:04 -0000 Mailing-List: contact zsh-workers-help@sunsite.dk; run by ezmlm Precedence: bulk X-No-Archive: yes X-Seq: 14218 Received: (qmail 22211 invoked from network); 4 May 2001 05:17:03 -0000 From: "Bart Schaefer" Message-Id: <1010504051600.ZM18512@candle.brasslantern.com> Date: Fri, 4 May 2001 05:16:00 +0000 In-Reply-To: Comments: In reply to Tanaka Akira "Re: cvs completion does not support partial path completion" (May 1, 6:39pm) References: <200104300817.KAA02260@beta.informatik.hu-berlin.de> <1010430165626.ZM4866@candle.brasslantern.com> X-Mailer: Z-Mail (5.0.0 30July97) To: Tanaka Akira , zsh-workers@sunsite.dk Subject: PATCH: Re: cvs completion does not support partial path completion MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii On May 1, 6:39pm, Tanaka Akira wrote: } } The functions which have troubles with partial path completion are } functions which use CVS/Entries: _cvs_files, _cvs_files_modified, } _cvs_files_removed and _cvs_files_unmaintained. So fallback call to } _files should be placed at end of them. However _cvs_files_removed is } more problematic since it completes non-existing (but listed in } CVS/Entries) files, though. The following seems to give the desired behavior for the most part. It does partial-path completion as far as possible, then stops leaving the trailing file name uncompleted. Press TAB again, and it completes the final part by examining the CVS/Entries file as usual. There are actually only two hunks below that implement the behavior (the last and the third-from-last). The rest of the hunks remove explanation strings from calls to _arguments or _alternative in cases where the called action-function will eventually supply a more accurate one. This prevents messages that say e.g. "No matches for `file' or `removed file'" when in fact only `removed file' was really attempted. Are there other side-effects of this that I've missed? Index: Completion/Unix/Command/_cvs =================================================================== --- Completion/Unix/Command/_cvs 2001/04/09 20:14:09 1.1.1.1 +++ Completion/Unix/Command/_cvs 2001/05/04 05:04:17 @@ -73,7 +73,7 @@ _arguments -s \ '-k+[keyword]:keyword substitution:_cvs_k' \ '-m+[message]:message:_cvs_m' \ - '*:file:_cvs_files_unmaintained' \ + '*::_cvs_files_unmaintained' \ } (( $+functions[_cvs_admin] )) || @@ -100,7 +100,7 @@ '-t-[replace descriptive text]:descriptive text:_cvs_admin_t' \ '-V+:version (obsolete):' \ '-k+[set keyword substitution]:keyword substitution:_cvs_k' \ - '*:file:_cvs_files' + '*::_cvs_files' } (( $+functions[_cvs_admin_t] )) || @@ -121,7 +121,7 @@ '(-l)-R[recursive]' \ '(-f -D)-r+[specify revision]:tag:_cvs_revisions' \ '(-f -r)-D+[specify date]:date:_cvs_D' \ - '*:file:_cvs_files' + '*::_cvs_files' } (( $+functions[_cvs_checkout] )) || @@ -157,7 +157,7 @@ '(-F)-m+[message]:message:_cvs_m' \ '(-m)-F+[message file]:log message file:_files' \ '-r+[specify revision]:tag:_cvs_revisions' \ - '*:file:_cvs_files_modified' + '*::_cvs_files_modified' } (( $+functions[_cvs_diff] )) || @@ -267,7 +267,7 @@ '(--minimal)-d[try to find a smaller set of changes]' \ '(-H)--speed-large-files[assume large files and many small changes]' \ '(--speed-large-files)-H[assume large files and many small changes]' \ - '*:file:_cvs_diff_arg' + '*::_cvs_diff_arg' } (( $+functions[_cvs_diff_arg] )) || @@ -282,7 +282,7 @@ '(-R)-l[don'\''t recursive]' \ '(-l)-R[recursive]' \ '-a+[specify action]:action:(edit unedit commit all none)' \ - '*:file:_cvs_files' + '*::_cvs_files' } (( $+functions[_cvs_editors] )) || @@ -291,7 +291,7 @@ _arguments -s \ '(-R)-l[don'\''t recursive]' \ '(-l)-R[recursive]' \ - '*:file:_cvs_files' + '*::_cvs_files' } (( $+functions[_cvs_export] )) || @@ -323,7 +323,7 @@ '-w[working directory]' \ '-D+[since date]:date:_cvs_D' \ '-b+[back to record]:string:' \ - '-f+[specify file]:file:_cvs_files' \ + '-f+[specify file]::_cvs_files' \ '-m+[specify module]:module:_cvs_modules' \ '*-n+[in module]:module:_cvs_modules' \ '*-p+[in repository]:repository:' \ @@ -333,7 +333,7 @@ '-x+[specify type]:type:_cvs_history_x' \ '-X+[debugging]:arg:' \ '-z+[specify timezone]:timezone:' \ - '*:file:_cvs_files' + '*::_cvs_files' } (( $+functions[_cvs_history_x] )) || @@ -386,7 +386,7 @@ '-r-[specify revisions]:revisions:' \ '-s+[specify states]:states:(Exp Stab Rel dead)' \ '-w-[specify logins]:logins:' \ - '*:file:_cvs_files' + '*::_cvs_files' } (( $+functions[_cvs_login] )) || @@ -434,7 +434,7 @@ '-f[force to remove]' \ '(-R)-l[don'\''t recursive]' \ '(-l)-R[recursive]' \ - '*:file:_cvs_remove_arg' + '*:removed file:_cvs_remove_arg' } (( $+functions[_cvs_remove_arg] )) || @@ -471,7 +471,7 @@ '-v[verbose]' \ '(-R)-l[don'\''t recursive]' \ '(-l)-R[recursive]' \ - '*:file:_cvs_files' + '*::_cvs_files' } (( $+functions[_cvs_tag] )) || @@ -488,7 +488,7 @@ '-r+[specify revision]:tag:_cvs_revisions' \ '-D+[specify date]:date:_cvs_D' \ ':tag:' \ - '*:file:_cvs_files' + '*::_cvs_files' } (( $+functions[_cvs_unedit] )) || @@ -497,7 +497,7 @@ _arguments -s \ '(-R)-l[don'\''t recursive]' \ '(-l)-R[recursive]' \ - '*:file:_cvs_files' + '*::_cvs_files' } (( $+functions[_cvs_update] )) || @@ -515,10 +515,10 @@ '-k+[keyword]:keyword substitution:_cvs_k' \ '(-D)-r+[specify revision]:tag:_cvs_revisions' \ '(-r)-D+[specify date]:date:_cvs_D' \ - '-j+[merge]:tag:_cvs_revisions' \ - '*-I+[ignore files]:name:_files' \ + '-j+[merge]::_cvs_revisions' \ + '*-I+[ignore files]::_files' \ '*-W+[wrapper specification]:spec:_files' \ - '*:file:_cvs_files' + '*::_cvs_files' } (( $+functions[_cvs_watch] )) || @@ -534,7 +534,7 @@ '(-R)-l[don'\''t recursive]' \ '(-l)-R[recursive]' \ ':watch command:' \ - '*:file:_cvs_files' + '*::_cvs_files' ;; add|remove) # "+lRa:" _arguments -s \ @@ -542,7 +542,7 @@ '(-l)-R[recursive]' \ '*-a+[specify action]:action:(edit unedit commit all none)' \ ':watch command:' \ - '*:file:_cvs_files' + '*::_cvs_files' ;; esac fi @@ -554,7 +554,7 @@ _arguments -s \ '(-R)-l[don'\''t recursive]' \ '(-l)-R[recursive]' \ - '*:file:_cvs_files' + '*::_cvs_files' } (( $+functions[_cvs_version] )) || @@ -826,24 +826,24 @@ (( $+functions[_cvs_files] )) || _cvs_files () { _alternative \ - 'directories:directory:_cvs_existing_directories' \ - 'existing-files:file:_cvs_existing_entries' \ - 'removed-files:removed file:_cvs_nonexisting_entries' + 'directories::_cvs_existing_directories' \ + 'existing-files::_cvs_existing_entries' \ + 'removed-files::_cvs_nonexisting_entries' } (( $+functions[_cvs_files_modified] )) || _cvs_files_modified () { _alternative \ - 'directories:directory:_cvs_existing_directories' \ - 'existing-files:file:_cvs_modified_entries' \ - 'removed-files:removed file:_cvs_nonexisting_entries' + 'directories::_cvs_existing_directories' \ + 'existing-files::_cvs_modified_entries' \ + 'removed-files::_cvs_nonexisting_entries' } (( $+functions[_cvs_files_removed] )) || _cvs_files_removed () { _alternative \ - 'directories:directory:_cvs_existing_directories' \ - 'removed-files:removed file:_cvs_nonexisting_entries' + 'directories::_cvs_existing_directories' \ + 'removed-files::_cvs_nonexisting_entries' } (( $+functions[_cvs_files_unmaintained] )) || @@ -856,7 +856,8 @@ (( $+functions[_cvs_existing_directories] )) || _cvs_existing_directories () { local expl - _wanted files expl file _path_files -g "*~(*/|)CVS(/)" + _wanted directories expl directory _path_files -g "*~(*/|)CVS(/)" || + _cvs_path_prefixes } (( $+functions[_cvs_existing_entries] )) || @@ -881,7 +882,7 @@ realdir=${(e)~linedir} [[ -f "$realdir"CVS/Entries ]] && [[ -n ${pat::="${(@j:|:)${(@)${(@)${(@)${(@)${(@)${(@M)${(@f)"$(<"$realdir"CVS/Entries)"}:#/*}#/}/\\/[^\\/]#\\///}%/[^/]#/[^/]#}:#${(j:|:)~${${${${(f)"$(LC_ALL=C builtin stat -gn +mtime -F '%a %b %e %T %Y' ${realdir}*(D) 2>/dev/null)"}##*/}/ //}//(#m)[][*?()<|^~#\\]/\\$MATCH}}}%%/*}//(#m)[][*?()<|^~#\\]/\\$MATCH}"} ]] && - _wanted files expl file _path_files -g "$pat" + _wanted files expl 'modified file' _path_files -g "$pat" else _cvs_existing_entries fi @@ -945,7 +946,21 @@ ${${${${(M)${(f)"$(<"$realdir"CVS/Entries)"}:#(D|)/*}#(D|)/}%%/*}:#${(j:|:)~${files//(#m)[][*?()<|^~#\\]/\\$MATCH}}} ) compquote files - _wanted files expl file compadd -Qp "$linedir" -a files + _wanted files expl 'nonexistent file' compadd -Qp "$linedir" -a files + } +} + +(( $+functions[_cvs_path_prefixes] )) || +_cvs_path_prefixes () { + local expl match + match=() + : ${PREFIX:#(#b)(*)(/[^/]#)} + [[ -n "$match[1]" ]] && { + PREFIX="$match[1]" + ISUFFIX="$match[2]$SUFFIX$ISUFFIX" + SUFFIX='' + _wanted directories expl directory \ + _path_files -g "*~($PREFIX|(*/|)CVS)(/)" -S '' } } -- Bart Schaefer Brass Lantern Enterprises http://www.well.com/user/barts http://www.brasslantern.com Zsh: http://www.zsh.org | PHPerl Project: http://phperl.sourceforge.net