unofficial mirror of notmuch@notmuchmail.org
 help / color / mirror / code / Atom feed
* Procmail regex group reuse
@ 2013-03-13 15:16 Guyzmo
  2013-03-13 19:16 ` Istvan Marko
  0 siblings, 1 reply; 3+ messages in thread
From: Guyzmo @ 2013-03-13 15:16 UTC (permalink / raw)
  To: Notmuch

Hello,

    I have looked over that usage pattern over the procmail doc and
mailing lists for some time now, and it seems no one ever asked the
question:

    Would it be possible to reuse a part of the match regexp in procmail
so it can be reused in the action part of the rule. Something like the
following:

--------8<----------------8<----------------8<---------------8<--------
:0:notmuch.lock
* .*foo\+\(\w+\)@mydomain\.tld.*
{ 
    TAGS="${TAGS} $1"
}
-------->8---------------->8---------------->8--------------->8--------

    where "$1" would be the group match (like `\1` in sed). I used 
to do it easily when I was using sup, and I really miss it now that I
have switched to notmuch.

    Maybe I shall use another mail matching program like formail, or 
shall I write a patch for it, but I'd like first to ask here if someone 
had the same issue, and found a solution.

-- 
Guyzmo

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

* Re: Procmail regex group reuse
  2013-03-13 15:16 Procmail regex group reuse Guyzmo
@ 2013-03-13 19:16 ` Istvan Marko
  2013-03-13 22:09   ` guyzmo+notmuch
  0 siblings, 1 reply; 3+ messages in thread
From: Istvan Marko @ 2013-03-13 19:16 UTC (permalink / raw)
  To: Guyzmo, Notmuch

Guyzmo <guyzmo+notmuch@m0g.net> writes:

>     Would it be possible to reuse a part of the match regexp in procmail
> so it can be reused in the action part of the rule. 

procmail has a limited way of extracting subexpressions:

       MATCH This variable is assigned to by procmail whenever it is
             told to extract text from a matching regular expression.
             It will contain all text matching the regular expression
             past the `\/' token.

So you get everything between \/ to the end of the whole regexp. In your
case this will get hairy because you need to match stuff after the part
you want to extract. The ?? construct might help to further trim it
down, maybe something like:

* ^TO\/foo\+[a-z]+@mydomain\.tld
* MATCH ?? ^foo\+\/[a-z]+
{
  TAG=$MATCH
}

Or if you are willing to switch to maildrop it has pcre and proper
submatches.

Are you tagging with notmuch-deliver?

-- 
	Istvan

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

* Re: Procmail regex group reuse
  2013-03-13 19:16 ` Istvan Marko
@ 2013-03-13 22:09   ` guyzmo+notmuch
  0 siblings, 0 replies; 3+ messages in thread
From: guyzmo+notmuch @ 2013-03-13 22:09 UTC (permalink / raw)
  To: Istvan Marko; +Cc: Notmuch

Hello,

On Wed, Mar 13, 2013 at 12:16:29PM -0700, Istvan Marko wrote:
> Guyzmo <guyzmo+notmuch@m0g.net> writes:
> > Would it be possible to reuse a part of the match regexp in procmail
> > so it can be reused in the action part of the rule. 
[...]
> So you get everything between \/ to the end of the whole regexp. In your
> case this will get hairy because you need to match stuff after the part
> you want to extract. The ?? construct might help to further trim it
> down, maybe something like:
> 
> * ^TO\/foo\+[a-z]+@mydomain\.tld
> * MATCH ?? ^foo\+\/[a-z]+
> {
>   TAG=$MATCH
> }

interesting, I'll try hacking around that…

> Or if you are willing to switch to maildrop it has pcre and proper
> submatches.

or I may switch to maildrop, I used it at one point with courier for my
imag installation, but always stuck to procmail before switching to sup,
and naturally got back to procmail when I installed notmuch.

> Are you tagging with notmuch-deliver?

Yes, I am, is there best ways to filter incoming mails, as I'm using
notmuch on the same host as my MTA?

Thanks,

-- 
Guyzmo

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

end of thread, other threads:[~2013-03-13 22:10 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-03-13 15:16 Procmail regex group reuse Guyzmo
2013-03-13 19:16 ` Istvan Marko
2013-03-13 22:09   ` guyzmo+notmuch

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

	https://yhetil.org/notmuch.git/

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 read-only IMAP folder(s) and NNTP newsgroup(s).