Procmail regex group reuse
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
Procmail regex group reuse
Guyzmowrites: > 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]+ at 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
[PATCH v2 0/2] Customize how each tag is displayed
On Wed, Feb 6, 2013 at 3:53 PM, Damien Cassou wrote: > [PATCH 1/2] emacs: Add notmuch-combine-face-text-property-string > [PATCH 2/2] emacs: possibility to customize the rendering of tags still not a single comment after more than one month -- Damien Cassou http://damiencassou.seasidehosting.st "Success is the ability to go from one failure to another without losing enthusiasm." Winston Churchill
Re: [PATCH v2 0/2] Customize how each tag is displayed
On Wed, Feb 6, 2013 at 3:53 PM, Damien Cassou damien.cas...@gmail.com wrote: [PATCH 1/2] emacs: Add notmuch-combine-face-text-property-string [PATCH 2/2] emacs: possibility to customize the rendering of tags still not a single comment after more than one month -- Damien Cassou http://damiencassou.seasidehosting.st Success is the ability to go from one failure to another without losing enthusiasm. Winston Churchill ___ notmuch mailing list notmuch@notmuchmail.org http://notmuchmail.org/mailman/listinfo/notmuch
Procmail regex group reuse
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: 888---8 :0:notmuch.lock * .*foo\+\(\w+\)@mydomain\.tld.* { TAGS=${TAGS} $1 } 888---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 ___ notmuch mailing list notmuch@notmuchmail.org http://notmuchmail.org/mailman/listinfo/notmuch
Re: Procmail regex group reuse
Guyzmo guyzmo+notm...@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 ___ notmuch mailing list notmuch@notmuchmail.org http://notmuchmail.org/mailman/listinfo/notmuch
Re: Procmail regex group reuse
Hello, On Wed, Mar 13, 2013 at 12:16:29PM -0700, Istvan Marko wrote: Guyzmo guyzmo+notm...@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 ___ notmuch mailing list notmuch@notmuchmail.org http://notmuchmail.org/mailman/listinfo/notmuch