From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 841 invoked from network); 19 Apr 2004 20:56:35 -0000 Received: from sunsite.dk (130.225.247.90) by ns1.primenet.com.au with SMTP; 19 Apr 2004 20:56:35 -0000 Received: (qmail 12485 invoked by alias); 19 Apr 2004 20:56:30 -0000 Mailing-List: contact zsh-workers-help@sunsite.dk; run by ezmlm Precedence: bulk X-No-Archive: yes X-Seq: 19798 Received: (qmail 12464 invoked from network); 19 Apr 2004 20:56:29 -0000 Received: from localhost (HELO sunsite.dk) (127.0.0.1) by localhost with SMTP; 19 Apr 2004 20:56:29 -0000 X-MessageWall-Score: 0 (sunsite.dk) Received: from [130.225.247.86] by sunsite.dk (MessageWall 1.0.8) with SMTP; 19 Apr 2004 20:56:29 -0000 Received: (qmail 20871 invoked from network); 19 Apr 2004 20:56:29 -0000 Received: from acolyte.scowler.net (216.254.112.45) by a.mx.sunsite.dk with SMTP; 19 Apr 2004 20:56:26 -0000 Received: by acolyte.scowler.net (Postfix, from userid 1000) id 58F6D7004A; Mon, 19 Apr 2004 16:55:59 -0400 (EDT) Date: Mon, 19 Apr 2004 16:55:59 -0400 From: Clint Adams To: zsh-workers@sunsite.dk Subject: PATCH: _bogofilter (bogoutil completion) Message-ID: <20040419205559.GA27305@scowler.net> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.5.5.1+cvs20040105i X-Spam-Checker-Version: SpamAssassin 2.63 on a.mx.sunsite.dk X-Spam-Level: X-Spam-Status: No, hits=0.0 required=6.0 tests=none autolearn=no version=2.63 X-Spam-Hits: 0.0 This is poorly done, but it fits my needs. Index: Completion/Unix/Command/.distfiles =================================================================== RCS file: /cvsroot/zsh/zsh/Completion/Unix/Command/.distfiles,v retrieving revision 1.61 diff -u -r1.61 .distfiles --- Completion/Unix/Command/.distfiles 16 Apr 2004 15:50:02 -0000 1.61 +++ Completion/Unix/Command/.distfiles 19 Apr 2004 20:54:03 -0000 @@ -25,4 +25,5 @@ _perforce _printenv _python _raggle _rar _renice _sablotron _screen _sed _subversion _tla _php _uniq _vorbis _vux _wiggle _xmlsoft +_bogofilter ' Index: Completion/Unix/Command/_bogofilter =================================================================== RCS file: Completion/Unix/Command/_bogofilter diff -N Completion/Unix/Command/_bogofilter --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ Completion/Unix/Command/_bogofilter 19 Apr 2004 20:54:03 -0000 @@ -0,0 +1,57 @@ +#compdef bogoutil + +local ret bogotokens + +_bogoutil_caching_policy () { + + # rebuild if cache is more than a week old + oldp=( "$1"(mw+1) ) + (( $#oldp )) && return 0 + + return 1 +} + +_bogofilter() { + _arguments -C \ + '-v[verbose]' \ + '-n[replace non-ASCII characters]' \ + '-D[redirect debug output to stdout]' \ + '-a[acceptable token age]:date or day count' \ + '-c[acceptable count]:count threshold' \ + '-s[acceptable size range]:min-max range' \ + '-y[date for when unknown]:date' \ + '-I[input file]:input file:_files' \ + '-x[debug flags]:debug flags:' \ + '-d[print contents of db]:database:_files -g "*.db"' \ + '-l[load file into db]:textfile:_files' \ + '-m[perform maintenance functions]' \ + '-w[display token information]:database file or directory:_files' \ + '-w[display token probability information]:database file or directory:_files' \ + '-H[print histogram]' \ + '(-R)-r[recalculate ROBX]' \ + '(-r)-R[recalculate and save ROBX]' \ + '-h[help]' \ + '-V[version]' \ + '*:tokens:->tokens' && ret=0 + + zstyle -s ":completion:${curcontext}:" cache-policy update_policy + if [[ -z "$update_policy" ]]; then + zstyle ":completion:${curcontext}:" cache-policy _bogoutil_caching_policy + fi + + case $state in + (tokens) + if ( [[ -z "$bogotokens" ]] || _cache_invalid bogotokens ) && + ! _retrieve_cache bogotokens; then + bogotokens=(${${(f)"$(_call_program bogoutil bogoutil -d ~/.bogofilter/wordlist.db -c 50)"}%% *}) + _store_cache bogotokens bogotokens + else + : + fi + _wanted tokens expl "token" \ + compadd -a bogotokens + ;; + esac +} + +_bogofilter "$@"