Gnus development mailing list
 help / color / mirror / Atom feed
From: Chris Marusich <cmmarusich@gmail.com>
To: Andreas Schwab <schwab@linux-m68k.org>
Cc: ding@lists.math.uh.edu
Subject: Re: nnimap-split-fancy: regexp ".*" matches less than expected
Date: Sun, 08 Apr 2018 11:55:24 -0700	[thread overview]
Message-ID: <87vad1le8z.fsf@gmail.com> (raw)
In-Reply-To: <87h8on9ydh.fsf@linux-m68k.org> (Andreas Schwab's message of "Sat, 07 Apr 2018 11:09:14 +0200")

[-- Attachment #1: Type: text/plain, Size: 3364 bytes --]

Hello again!

Andreas Schwab <schwab@linux-m68k.org> writes:

> On Apr 06 2018, Chris Marusich <cmmarusich@gmail.com> wrote:
>
>> This is the same as before, but I've replaced "gnucash-user" with ".*".
>> I expected the same result as before, but Gnus surprised me.  Instead,
>> gnus-summary-respool-query says:
>>
>>   This message would go to list.user
>>
>> and gnus-summary-respool-trace says:
>>
>>   ("cc" "\\(.*\\)@gnucash.org" "list.\\1")
>>   "list.\\1"
>>
>> In this case, why does the ".*" match "user" instead of "gnucash-user"?
>
> I think that happens because the actual regexp used for searching is
> "\\(\\(FIELD\\):.*\\)\\<\\(VALUE\\)\\>", note the embedded ".*".

I've tried to figure out a good way to accomplish what I want, but I'm
stuck.  I was hoping to come up with a "fancy" splitting method that
would split the email into groups like this:

  foo@example-lists.com -> list.foo
  foo-bar@example-lists.com -> list.foo-bar
  foo-bar_baz@example-lists.com -> list.foo-bar_baz

I currently am in a situation where I need to filter a LOT of groups
like this, and I do not know a priori what their exact names will be.  I
could just observe the list names on emails I receive over time and add
individual rules explicitly for those list names as I discover them, but
if possible, I'd rather just craft a simple regexp to capture all of
them up front and be done with it.

How can I accomplish that?  Basically, whatever comes before the @, I
want to put it in the group the name.  Because the greedy ".*" is
foisted upon me, it eats up pretty much all of the characters in the
list name.  If instead of ".*" the embedded regexp used ".*?"
(non-greedy), I think it would be easy to accomplish what I want with a
regexp like this:

  "\\([[:graph:]]+\\)@example-lists.com"

However, that doesn't work when the greedy ".*" precedes my regexp,
since it eats up most of what I want to capture.  What to do?

As long as it isn't possible for me to change the regexp that precedes
my own, I think the only solution is for me to embed a sentinel regexp
at the start of my own regexp, to stop the greedy ".*" from going any
farther.  Thankfully, many of the lists I need to filter begin with a
specific string that does not repeat itself later in the list name, call
it "myprefix".  They all look kind of like this:

  myprefix-foo@example-lists.com
  myprefix-foo-bar@example-lists.com
  myprefix-foo-bar_baz@example-lists.com

Thanks to this happy coincidence, I suppose I can get by for now by
defining a single regexp like this in my "fancy" splitting method:

  "\\(myprefix-[[:graph:]]+\\)@example-lists.com"

But I'm curious: would there be a way to accomplish the same thing, even
when the list names are not entirely predictable?

Stepping back a moment, I also wonder: am I going about this the wrong
way?  Maybe my goal SHOULDN'T be to filter the list traffic like this.
Maybe the right thing to do in this situation is actually to learn to
use Gnus' "scoring" feature.  Maybe I should just dump all my mail into
a single group, and use the scoring feature to automatically hide the
messages that I don't care about.

The opinions of Gnus gurus would be very welcome.  As a famous Martian
once said, "I am but an egg."  Thank you again for the help!

-- 
Chris

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 832 bytes --]

  parent reply	other threads:[~2018-04-08 18:55 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-04-07  6:08 Chris Marusich
2018-04-07  9:09 ` Andreas Schwab
2018-04-07 17:03   ` Chris Marusich
2018-04-07 18:31     ` Andreas Schwab
2018-04-08 18:55   ` Chris Marusich [this message]
2018-04-08 19:49     ` Andreas Schwab
2018-04-10  0:14     ` Dan Christensen

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87vad1le8z.fsf@gmail.com \
    --to=cmmarusich@gmail.com \
    --cc=ding@lists.math.uh.edu \
    --cc=schwab@linux-m68k.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).