Gnus development mailing list
 help / color / mirror / Atom feed
* Regexp pita, extract info from .newsrc.eld
@ 2001-11-13  1:30 Harry Putnam
  2001-11-13  6:44 ` Paul Jarc
  0 siblings, 1 reply; 2+ messages in thread
From: Harry Putnam @ 2001-11-13  1:30 UTC (permalink / raw)


The following message is a courtesy copy of an article
that has been posted to gnu.emacs.gnus as well.

[ALERT: Cross posted to gnu.emacs.gnus and ding]

Going round and round with this problem, and getting nowhere fast.

The Problem:
Regexp match sections below that begin with `("nnml' and end with `")))'
(Simulation of newsrc.eld) 
`nnml' and `nnfolder' represent various backends that may have data there.

I've wrapped the test lines for easy display but they are actually one line.
Notice too that `nnfolder' has slipped in there and should not be matched.
The idea is to match each individual section, one at a time.

Starting `{"nnml:"' and ending `")))'
  
  ("nnml:" all kinds of guff including double and single facing and apposing
  parens) (kkskls;; )) . l bla more guff and finally  ")))
  
  ("nnml:": all kinds of guff including double single facing and apposing
  parens) (kkskls;; )) . l a more guff and finally  "))) 
  
  ("nnfolder:" all kinds of guff including double single facing and apposing
  parens) (kkskls;; )) . l a more guff and finally ")))
  
  ("nnml:": all kinds of guff including double single facing and apposing
  parens) (kkskls;; )) . l a more guff and finally ")))

The C-u C-s style search provides plenty of opportunity to test regexp
quickly.  But even after extensive experimentation I am only able to
match to the fartherest `")))', when the intent is to match the
closest.

You'll have to put the lines together for this to work, and mailing
will destroy the long line so you 'll have to imagine or copy the line
somewhere and put it together in one line.

I'll cheat and use C-u C-s so as not to have to escape so much:
`("nnml:.*)))'               = grabs everthing to the end

`("nnml:.*[^)][^)][^)]+")))' = ditto
`("nnml:.*[^)]\{3\}+")))'    = treble ditto

I'm trying to extract stuff from `gnus' file `newsrc.eld' using shell
tools and awk.  Maybe this is easily done with lisp?

I'm only concerned with the section under:
(setq gnus-newsrc-alist 

Eventually I want to be able to extract group information and format
it like this:

nnml:ding
((to-address . "ding@gnus.org")
 (total-expire . t)
 (expiry-wait . 30)
 (visible . t))

nnml:dong
((to-address . "dong@geese.org")
 (total-expire . t)
 (expiry-wait . 1)
 (gnus-show-threads nil))

etc....
And onward.....

Leaving out the other info like ticked dormant etc.  Just listing all
Group parameters like above.  And of course I want to be able to do
this quickly .. he he.  I don't mind how long it takes to learn how to
do it, I just mean that a solution, no matter how hard to devise,
should be no harder than `M-x something' to operate, and a buffer with
that info jumps up.  Or at least command line tools to do this.

I actually have beginning in hand but have quite a ways to go.



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

* Re: Regexp pita, extract info from .newsrc.eld
  2001-11-13  1:30 Regexp pita, extract info from .newsrc.eld Harry Putnam
@ 2001-11-13  6:44 ` Paul Jarc
  0 siblings, 0 replies; 2+ messages in thread
From: Paul Jarc @ 2001-11-13  6:44 UTC (permalink / raw)


Harry Putnam <reader@newsguy.com> wrote:
> The Problem:
> Regexp match sections below that begin with `("nnml' and end with `")))'

("nnml\([^"]\|"[^)]\|")[^)]\|"))[^)]\)*")))

> I'm trying to extract stuff from `gnus' file `newsrc.eld' using shell
> tools and awk.  Maybe this is easily done with lisp?

Use the function read.  Then you can manipulate the data structures as
Lisp objects instead of text.  You won't have to worry about strings
containing the end token you're looking for.

> Leaving out the other info like ticked dormant etc.  Just listing all
> Group parameters like above.

The function gnus-info-params should be useful together with read.


paul



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

end of thread, other threads:[~2001-11-13  6:44 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2001-11-13  1:30 Regexp pita, extract info from .newsrc.eld Harry Putnam
2001-11-13  6:44 ` Paul Jarc

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