zsh-workers
 help / color / mirror / code / Atom feed
* PATCH: new _tin
@ 2001-02-01 14:54 Oliver Kiddle
  0 siblings, 0 replies; 3+ messages in thread
From: Oliver Kiddle @ 2001-02-01 14:54 UTC (permalink / raw)
  To: zsh-workers

Firstly, hello everyone. I'm now back from my time away.

I've written a new completion function for the tin newsreader.
Hopefully, I've not forgotten too much since I was last writing these
functions. I'm not convinced that I've done the best job of it though.

Is it wise to be separating the hostnames and nicknames for the news
servers rather than completing them together under one title? Is it okay
to overload tag names for unrelated things - 'nicknames' is also used
for NIS stuff. I'm also not too happy with the way this deals with an
empty or non-existant newsrctable file.

Why when completing newsgroups (the final part of _arguments) does it
display just 'newsgroup' instead of 'Completing newsgroup' when I have
zstyle ':completion:*' format 'Completing %d'?

I thought about completing newsgroups properly using something like:

: ${(A)_cache_newsgroups:=${${(f)"$(fgrep -v \! ~/.newsrc)"}%:*}}
_multi_parts -i . _cache_newsgroups

but I'm not too sure how consistent the .newsrc file format is. Can
anyone confirm if this would work with slrn. Note that I've removed
unsubscribed newsgroups here because otherwise it is painfully slow. I
realise that fgrep isn't necessary for this but it is a lot quicker than
doing it directly with zsh. Is it worth including this as an _newsgroups?

Oliver

Index: Completion/User/_tin
===================================================================
RCS file: _tin
diff -N _tin
--- /dev/null	Mon Dec 11 17:26:27 2000
+++ Completion/User/_tin	Thu Feb  1 06:46:44 2001
@@ -0,0 +1,52 @@
+#compdef tin rtin
+
+local newshosts expl state line curcontext="$curcontext" ret=1
+
+_arguments -C -s \
+  '-a[toggle color flag]' \
+  '-A[force authentication on connect]' \
+  '-c[mark all news as read in subscribed groups]' \
+  "-d[don't show newsgroup descriptions]" \
+  '-f[specify newsrc file to use]:newsrc file:_files' \
+  '-G[specify limit to articles/group to get]:number of articles/group 
to get' \
+  '-g[specify NNTP server]:NNTP server:->newshosts' \
+  '-h[display help on tin usage]' \
+  '-H[display help information]' \
+  '-I[specify news index file directory]:news index file 
directory:_files -/' \
+  '-l[get number of articles per group from the active file]' \
+  '-m[specify mailbox directory]:mailbox directory:_files -/' \
+  '-M[mail new news to specified user]:user:_users' \
+  '-n[only read subscribed groups from server]' \
+  '-N[mail new news to yourself]' \
+  '-o[post all postponed articles and exit]' \
+  '-p[specify port to connect to NNTP server]:NNTP port:_ports' \
+  "-q[don't check for new newsgroups]" \
+  '-Q[quick start. Same as -nqd]' \
+  ${${service:#r*}:+-r\[read news remotely over NNTP\]} \
+  '-R[read news saved with -S]' \
+  '-s[specify saved news directory]:saved news directory:_files -/' \
+  '-S[save new news for later reading]' \
+  '-u[update index files]' \
+  '-U[update index files in the background while reading news]' \
+  '-v[verbose output in batch mode]' \
+  '-V[display version information]' \
+  '-w[post an article and exit]' \
+  "-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
+
+if [[ "$state" = newshosts ]]; then
+  newshosts=( ${${(f)"$(<~/.tin/newsrctable)"}%%\#*} ) 2>/dev/null
+  _tags hosts nicknames
+  while _tags; do
+    _requested hosts expl 'NNTP server hostname' \
+        compadd ${=newshosts#*[[:blank:]]##[^[:blank:]]*[[:blank:]]} && 
ret=0
+    _requested nicknames expl 'NNTP server nickname' \
+        compadd -M 'r:|.=* r:|=*' ${newshosts%%[[:blank:]]*} && ret=0
+    (( ret )) || return 0
+  done
+fi
+
+return 1
+



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

* Re: PATCH: new _tin
  2001-02-01 15:04 Sven Wischnowsky
@ 2001-02-01 16:36 ` Bart Schaefer
  0 siblings, 0 replies; 3+ messages in thread
From: Bart Schaefer @ 2001-02-01 16:36 UTC (permalink / raw)
  To: zsh-workers

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

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


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

* Re: PATCH: new _tin
@ 2001-02-01 15:04 Sven Wischnowsky
  2001-02-01 16:36 ` Bart Schaefer
  0 siblings, 1 reply; 3+ messages in thread
From: Sven Wischnowsky @ 2001-02-01 15:04 UTC (permalink / raw)
  To: zsh-workers


Oliver Kiddle wrote:

> Firstly, hello everyone. I'm now back from my time away.

Hi!

> ...
> 
> Is it wise to be separating the hostnames and nicknames for the news
> servers rather than completing them together under one title?

I'd say yes. This way users can always use the group-name style if
they want to have them together but they couldn't do it the other way
round.

> Is it okay
> to overload tag names for unrelated things - 'nicknames' is also used
> for NIS stuff.

It's ok as long as it's easy enough to come up with patterns to
disambiguate between the different uses, I think. So in this case,
where one only needs to have the command name(s) (or patterns for
them)...

> I'm also not too happy with the way this deals with an
> empty or non-existant newsrctable file.
> 
> Why when completing newsgroups (the final part of _arguments) does it
> display just 'newsgroup' instead of 'Completing newsgroup' when I have
> zstyle ':completion:*' format 'Completing %d'?

Hm, doesn't happen to me.

> I thought about completing newsgroups properly using something like:
> 
> : ${(A)_cache_newsgroups:=${${(f)"$(fgrep -v \! ~/.newsrc)"}%:*}}
> _multi_parts -i . _cache_newsgroups
> 
> but I'm not too sure how consistent the .newsrc file format is. Can
> anyone confirm if this would work with slrn. Note that I've removed
> unsubscribed newsgroups here because otherwise it is painfully slow. I
> realise that fgrep isn't necessary for this but it is a lot quicker than
> doing it directly with zsh. Is it worth including this as an _newsgroups?

I don't know and have no opinion, respectively.

Bye
 Sven


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


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

end of thread, other threads:[~2001-02-01 16:37 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2001-02-01 14:54 PATCH: new _tin Oliver Kiddle
2001-02-01 15:04 Sven Wischnowsky
2001-02-01 16:36 ` Bart Schaefer

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