zsh-workers
 help / color / mirror / code / Atom feed
* Re: PATCH: newsgroup completion
@ 2001-02-09 14:00 Sven Wischnowsky
  0 siblings, 0 replies; 2+ messages in thread
From: Sven Wischnowsky @ 2001-02-09 14:00 UTC (permalink / raw)
  To: zsh-workers


Oliver Kiddle wrote:

> ...
> 
> 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.

Hmhm. Re-use `path'.

> 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?

I always use ${array:#}.

> 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.

Handling of -S is non-trivial in _multiparts because there are so many 
placees where it has to use it itself. I've found one more place where 
the caller-supplied -S could be used, I think.

> I'm also getting a problem after the first part of a newsgroup is
> typed in full. e.g:
>   tin comp<tab>
> gives me:
>   tin comp..comp.
> I can reproduce this starting from zsh -f so it isn't my setup.

And I think I fixed this, too.

Bye
 Sven

Index: Completion/Core/_multi_parts
===================================================================
RCS file: /cvsroot/zsh/zsh/Completion/Core/_multi_parts,v
retrieving revision 1.4
diff -u -r1.4 _multi_parts
--- Completion/Core/_multi_parts	2000/07/24 12:52:42	1.4
+++ Completion/Core/_multi_parts	2001/02/09 13:55:48
@@ -113,7 +113,7 @@
 
 	if [[ $#imm -ne 0 && $#matches -eq 1 ]] ||
            zstyle -t ":completion:${curcontext}:" expand suffix; then
-	  compadd "$group[@]" "$expl[@]" "$opts[@]" \
+	  compadd "$group[@]" "$expl[@]" "$sopts[@]" \
                   -M "r:|${sep}=* r:|=* $matcher" - "$pref$matches[1]"
         else
 	  if (( $matches[(I)${tmp1[1]}${sep}*] )); then
@@ -235,7 +235,7 @@
     SUFFIX=""
 
     if [[ -n "$pref" && "$orig" != "$pref" ]]; then
-      if [[ "$pref" = *${sep} ]]; then
+      if [[ "$pref" = *${sep}*${sep} ]]; then
         compadd "$group[@]" "$expl[@]" "$opts[@]" \
                 -p "${pref%${sep}*${sep}}${sep}" -S "$sep" \
                 -M "r:|${sep}=* r:|=* $matcher" - "${${pref%${sep}}##*${sep}}"

--
Sven Wischnowsky                         wischnow@informatik.hu-berlin.de


^ permalink raw reply	[flat|nested] 2+ messages in thread

* PATCH: newsgroup completion
@ 2001-02-08 17:41 Oliver Kiddle
  0 siblings, 0 replies; 2+ messages in thread
From: Oliver Kiddle @ 2001-02-08 17:41 UTC (permalink / raw)
  To: zsh-workers

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.<newshostname> 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<tab>
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


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2001-02-09 14:00 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2001-02-09 14:00 PATCH: newsgroup completion Sven Wischnowsky
  -- strict thread matches above, loose matches on Subject: below --
2001-02-08 17:41 Oliver Kiddle

Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/zsh/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).