Gnus development mailing list
 help / color / mirror / Atom feed
* how to make gnus print various group lists to stdout
@ 2017-06-19 23:18 Harry Putnam
  2017-06-20  1:39 ` Tim Landscheidt
  0 siblings, 1 reply; 5+ messages in thread
From: Harry Putnam @ 2017-06-19 23:18 UTC (permalink / raw)
  To: ding

I know gnus has a multitude of ways to list, and equally many to sort
groups so combining them constitute nearly any sort of informative
display one can think of.

I'd like to be able to push some of that to STDOUT to be captured in
files or whatever.  Examples so you understand what I mean:

List of of all level (N) groups.  A list of all subscribed nntp
groups.  Lists of groups belonging to each backend. List of agentized
groups.

Etc.  Gnus knows about all those I believe...And is willing and able
to display them.

But only the elisp adepts among us are able to get that infomation in
a form amenable to scripting with other tools (Perl I have in mind but
there are. of course, many others.)

For some of what I'm fiddling with it would be very handy to have some
of that information available on STDOUT.

Can anyone offer some ways to get at that kind of information other
than viewing it inside emacs, and creating a file from the buffer?




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

* Re: how to make gnus print various group lists to stdout
  2017-06-19 23:18 how to make gnus print various group lists to stdout Harry Putnam
@ 2017-06-20  1:39 ` Tim Landscheidt
  2017-06-20  3:37   ` Harry Putnam
  0 siblings, 1 reply; 5+ messages in thread
From: Tim Landscheidt @ 2017-06-20  1:39 UTC (permalink / raw)
  To: ding

Harry Putnam <reader@newsguy.com> wrote:

> […]

> But only the elisp adepts among us are able to get that infomation in
> a form amenable to scripting with other tools (Perl I have in mind but
> there are. of course, many others.)

> For some of what I'm fiddling with it would be very handy to have some
> of that information available on STDOUT.

> Can anyone offer some ways to get at that kind of information other
> than viewing it inside emacs, and creating a file from the buffer?

You can parse ~/.newsrc.eld with Perl, and apparently there
is even a CPAN module for reading Lisp (Data::SExpression),
but I would rather bite the bullet and learn some (basic)
Emacs Lisp.  For example, after starting Gnus, if you switch
to an empty buffer and evaluate:

| (dolist (group gnus-newsrc-alist)
|   (insert (format "%s\n" (car group))))

you get a list of all groups.  If you use:

| (dolist (group gnus-newsrc-alist)
|   (if (equal (nth 4 group) '(nntp "news.gmane.org"))
|       (insert (format "%s\n" (car group)))))

you get a list of all groups for Gmane.

The lack of documentation can be a bit daunting (and of
course you should make sure you have backups in case you ac-
cidentally set one of those Gnus variables with setq & Co.),
but for throw-away lists I think generating them from within
Gnus is much preferable.

Tim




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

* Re: how to make gnus print various group lists to stdout
  2017-06-20  1:39 ` Tim Landscheidt
@ 2017-06-20  3:37   ` Harry Putnam
  2017-11-18 18:08     ` Tim Landscheidt
  0 siblings, 1 reply; 5+ messages in thread
From: Harry Putnam @ 2017-06-20  3:37 UTC (permalink / raw)
  To: ding

Tim Landscheidt <tim@tim-landscheidt.de> writes:

>> Can anyone offer some ways to get at that kind of information other
>> than viewing it inside emacs, and creating a file from the buffer?
>
> You can parse ~/.newsrc.eld with Perl, and apparently there
> is even a CPAN module for reading Lisp (Data::SExpression),
> but I would rather bite the bullet and learn some (basic)
> Emacs Lisp.  For example, after starting Gnus, if you switch
> to an empty buffer and evaluate:

First, thanks for the great input.

That was exactly the point of my post.. to do it with gnus.. the
But make gnus write the info to files or stdout.

`other' tools come in after getting the basic group info from gnus.

I've been parsing .newsrc.eld or trying to, but I found a file that
shows all the agentized groups in a simpler setting:

News/agent/lib/categories.  Since the only category I use is `true'
and make it the default, then that is all that is in there so fairly
easy to pull the group names out of there with perl.

Still need access to other of gnus group lists though, which is in
.newsrc.eld.


> | (dolist (group gnus-newsrc-alist)
> |   (insert (format "%s\n" (car group))))

Yup... I see, and is exactly what I was asking about.

> you get a list of all groups.  If you use:
>
> | (dolist (group gnus-newsrc-alist)
> |   (if (equal (nth 4 group) '(nntp "news.gmane.org"))
> |       (insert (format "%s\n" (car group)))))

> you get a list of all groups for Gmane.

This second one looks like it could be edited to make it produce a
list from any foreign groups too.

I'm curious what the `nth 4 group' is all about... is it a reference
to level 4?

Also I should say that the second example does nothing here.. well it
prints `nil' when evaluated with C-x C-e

I do have gmane in ~/.gnus like this:

  (setq gnus-select-method '(nntp "news.gmane.org"))

Oh, and how would I go about making emacs/gnus send any list information
to stdout or to file?






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

* Re: how to make gnus print various group lists to stdout
  2017-06-20  3:37   ` Harry Putnam
@ 2017-11-18 18:08     ` Tim Landscheidt
  2017-11-18 18:34       ` Eric Abrahamsen
  0 siblings, 1 reply; 5+ messages in thread
From: Tim Landscheidt @ 2017-11-18 18:08 UTC (permalink / raw)
  To: ding

Harry Putnam <reader@newsguy.com> wrote a long time ago:

> […]

>> you get a list of all groups.  If you use:

>> | (dolist (group gnus-newsrc-alist)
>> |   (if (equal (nth 4 group) '(nntp "news.gmane.org"))
>> |       (insert (format "%s\n" (car group)))))

>> you get a list of all groups for Gmane.

> This second one looks like it could be edited to make it produce a
> list from any foreign groups too.

> I'm curious what the `nth 4 group' is all about... is it a reference
> to level 4?

No, it returns the fifth element of the list referred to by
group (C-h f nth RET).

> Also I should say that the second example does nothing here.. well it
> prints `nil' when evaluated with C-x C-e

> I do have gmane in ~/.gnus like this:

>   (setq gnus-select-method '(nntp "news.gmane.org"))

To be clear, my approach to gnus-newsrc-alist and other Gnus
data structures is entirely example-based: I look at my data
and see that my Gmane groups have the fifth element set to
'(nntp "news.gmane.org"), so I search for that.

That works for me because I have gnus-select-method set to
'(nnml "private"), so Gmane groups are … foreign groups (?)
which have their fifth element set to '(nntp
"news.gmane.org").  With gnus-select-method set to Gmane,
you will need to adapt the filter expression (maybe the
fifth element is nil for native groups?).

> Oh, and how would I go about making emacs/gnus send any list information
> to stdout or to file?

I would open a buffer with a new (empty) file and run the
code above while in this buffer.  This inserts the list of
groups there and you can then save the buffer as usual.

If you want to use the information in a pipe, that is a lot
more complicated.  For example, the code above assumes that
Gnus is running, so you would have to call Emacs with --eval
to start Gnus, output the list to stdout and then quit Gnus
again which I would shy away from just because too much
could go wrong (accidentally starting multiple Gnus in-
stances at the same time can lead to data loss).

You could also execute a script with --eval to open
~/.newsrc.eld, parse that buffer with read into a variable
and then process that variable.  But all solutions have in
common that you will need to learn at least the basics of
Emacs Lisp :-).  So I would start with "An Introduction to
Programming in Emacs Lisp" (C-h i g (eintr) RET).

Tim




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

* Re: how to make gnus print various group lists to stdout
  2017-11-18 18:08     ` Tim Landscheidt
@ 2017-11-18 18:34       ` Eric Abrahamsen
  0 siblings, 0 replies; 5+ messages in thread
From: Eric Abrahamsen @ 2017-11-18 18:34 UTC (permalink / raw)
  To: ding

Tim Landscheidt <tim@tim-landscheidt.de> writes:

> Harry Putnam <reader@newsguy.com> wrote a long time ago:
>
>> […]
>
>>> you get a list of all groups.  If you use:
>
>>> | (dolist (group gnus-newsrc-alist)
>>> |   (if (equal (nth 4 group) '(nntp "news.gmane.org"))
>>> |       (insert (format "%s\n" (car group)))))
>
>>> you get a list of all groups for Gmane.
>
>> This second one looks like it could be edited to make it produce a
>> list from any foreign groups too.
>
>> I'm curious what the `nth 4 group' is all about... is it a reference
>> to level 4?
>
> No, it returns the fifth element of the list referred to by
> group (C-h f nth RET).
>
>> Also I should say that the second example does nothing here.. well it
>> prints `nil' when evaluated with C-x C-e
>
>> I do have gmane in ~/.gnus like this:
>
>>   (setq gnus-select-method '(nntp "news.gmane.org"))
>
> To be clear, my approach to gnus-newsrc-alist and other Gnus
> data structures is entirely example-based: I look at my data
> and see that my Gmane groups have the fifth element set to
> '(nntp "news.gmane.org"), so I search for that.
>
> That works for me because I have gnus-select-method set to
> '(nnml "private"), so Gmane groups are … foreign groups (?)
> which have their fifth element set to '(nntp
> "news.gmane.org").  With gnus-select-method set to Gmane,
> you will need to adapt the filter expression (maybe the
> fifth element is nil for native groups?).

Yes, that's right -- that element is only present for non-native groups.




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

end of thread, other threads:[~2017-11-18 18:34 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-06-19 23:18 how to make gnus print various group lists to stdout Harry Putnam
2017-06-20  1:39 ` Tim Landscheidt
2017-06-20  3:37   ` Harry Putnam
2017-11-18 18:08     ` Tim Landscheidt
2017-11-18 18:34       ` Eric Abrahamsen

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