From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 4135 invoked from network); 8 Feb 2001 17:42:07 -0000 Received: from sunsite.dk (130.225.51.30) by ns1.primenet.com.au with SMTP; 8 Feb 2001 17:42:07 -0000 Received: (qmail 1928 invoked by alias); 8 Feb 2001 17:41:57 -0000 Mailing-List: contact zsh-workers-help@sunsite.dk; run by ezmlm Precedence: bulk X-No-Archive: yes X-Seq: 13448 Received: (qmail 1917 invoked from network); 8 Feb 2001 17:41:56 -0000 Date: Thu, 8 Feb 2001 17:41:55 +0000 From: Oliver Kiddle To: zsh-workers@sunsite.dk Subject: PATCH: newsgroup completion Message-ID: <20010208174155.A890@rambo.logica.co.uk> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.2.5i Sender: Oliver Kiddle Bart wrote: > } > I'm not too sure how consistent the .newsrc file format is. Can > } > anyone confirm if this would work with slrn. > I can't confirm it for slrn, but it would work for Pine and Netscape > (though netscape uses .newsrc. in some cases). I think > the newsrc format is pretty well established, and it would be unlikely > for a newsreader to use that file name and not that format. Thanks. Something else I read also indicated that .newsrc should be fairly standard so I've added the _newsgroups. _netscape and _tin make now use of it. _slrn possibly also could but I don't have slrn to check. I look in .newsrc* for newsgroups as this covers netscape and setups like mine where I have configured tin's newsrctable for multiple news servers. Having a glob also simplified the situation where .newsrc* doesn't exit because zsh doesn't run the fgrep. I suppose we could also add a style to specify a different newsrc file. When no .newsrc file exists, I end up with _cache_newsgroups containing one empty value (''). I got around this by using the ${(w)#_cache_newsgroups} but it'd be nice if there was a parameter expansion flag or maybe a typeset option to remove empty entries from an array. Any opinions? This newsgroup completion shows up a few problems with _multi_parts. The suffix handling doesn't seem to work properly. If I use _newsgroups -S',' I still get a space and not a comma after a full newsgroup name. I'm also getting a problem after the first part of a newsgroup is typed in full. e.g: tin comp gives me: tin comp..comp. I can reproduce this starting from zsh -f so it isn't my setup. I wrote: > Why when completing newsgroups (the final part of _arguments) does it > display just 'newsgroup' instead of 'Completing newsgroup' when I have Sorry about this. I traced this problem to a rogue zstyle in my setup. Oliver Index: Completion/User/.distfiles =================================================================== RCS file: /cvsroot/zsh/zsh/Completion/User/.distfiles,v retrieving revision 1.14 diff -u -r1.14 .distfiles --- Completion/User/.distfiles 2000/12/16 16:30:38 1.14 +++ Completion/User/.distfiles 2001/02/08 17:07:03 @@ -7,12 +7,12 @@ _gs _gv _gzip _hosts _imagemagick _ispell _java _joe _killall _lp _look _lynx _lzop _mailboxes _make _man _mere _mh _mount _mutt _my_accounts _mysql_utils - _nedit _netscape _nslookup _other_accounts + _nedit _netscape _newsgroups _nslookup _other_accounts _pack _patch _pbm _pdf _perl _perl_basepods _perl_builtin_funcs _perl_modules _perldoc _ports _prcs _printers _prompt _ps _pspdf _psutils _rcs _rlogin _sh _slrn _socket _ssh _strip _stty _su _sudo - _tar _tar_archive _telnet _tex _texi _tiff _tilde_files + _tar _tar_archive _telnet _tex _texi _tiff _tilde_files _tin _urls _use_lo _user_at_host _users _users_on _webbrowser _wget _whereis _whois _xargs _yodl _yp _zcat _zdump Index: Completion/User/_netscape =================================================================== RCS file: /cvsroot/zsh/zsh/Completion/User/_netscape,v retrieving revision 1.8 diff -u -r1.8 _netscape --- Completion/User/_netscape 2000/05/31 09:38:26 1.8 +++ Completion/User/_netscape 2001/02/08 17:07:03 @@ -74,13 +74,15 @@ _wanted values expl 'about what' \ compadd "$@" authors blank cache document fonts global hype image-cache \ license logo memory-cache mozilla plugins && ret=0 + elif compset -P news: ; then + _newsgroups "$@" && ret=0 else _tags prefixes while _tags; do while _next_label prefixes expl 'URL prefix' "$@"; do _urls "$expl[@]" && ret=0 compset -S '[^:]*' - compadd -S '' "$expl[@]" about: mocha: javascript: && ret=0 + compadd -S '' "$expl[@]" about: news: mocha: javascript: && ret=0 done (( ret )) || return 0 done Index: Completion/User/_newsgroups =================================================================== RCS file: _newsgroups diff -N _newsgroups --- /dev/null Mon Dec 11 17:26:27 2000 +++ _newsgroups Thu Feb 8 09:07:03 2001 @@ -0,0 +1,9 @@ +#autoload + +local expl + +: ${(A)_cache_newsgroups:=${${(f)"$(fgrep -vh \! ~/.newsrc*)"}%:*}} + +(( ${(w)#_cache_newsgroups} )) && _wanted newsgroups expl 'newsgroup' \ + _multi_parts "$@" -i . _cache_newsgroups + Index: Completion/User/_tin =================================================================== RCS file: /cvsroot/zsh/zsh/Completion/User/_tin,v retrieving revision 1.1 diff -u -r1.1 _tin --- Completion/User/_tin 2001/02/01 15:00:43 1.1 +++ Completion/User/_tin 2001/02/08 17:07:03 @@ -34,7 +34,7 @@ "-X[don't save any files on quit]" \ '-z[start if any unread news]' \ '-Z[return status to indicate if any unread news]' \ - '::newsgroup' && return 0 + '::newsgroup:_newsgroups' && return 0 if [[ "$state" = newshosts ]]; then newshosts=( ${${(f)"$(<~/.tin/newsrctable)"}%%\#*} ) 2>/dev/null