unofficial mirror of help-gnu-emacs@gnu.org
 help / color / mirror / Atom feed
* Gnus nnmail-split-fancy regexps can’t support backrefs inside themselves?
@ 2018-03-16 19:15 Garreau, Alexandre
  2018-03-17  8:25 ` tomas
  2018-03-20 20:20 ` Stefan Monnier
  0 siblings, 2 replies; 7+ messages in thread
From: Garreau, Alexandre @ 2018-03-16 19:15 UTC (permalink / raw)
  To: help-gnu-emacs

If I use a rule with a match regexp including a backreference inside the
variable nnmail-split-fancy, it doesn’t match anything anymore:
("list-id" ".*<\\(gcc\\)-\\(help\\).\\1.\\(gnu\\)\\.org>.*" "lists.\\3.\\1.\\2")

Yet backrefs are supported on the other side of the rule… is this
normal? why is that? I at least would like a confirmation ^^



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

* Re: Gnus nnmail-split-fancy regexps can’t support backrefs inside themselves?
  2018-03-16 19:15 Gnus nnmail-split-fancy regexps can’t support backrefs inside themselves? Garreau, Alexandre
@ 2018-03-17  8:25 ` tomas
  2018-03-19 12:57   ` Garreau, Alexandre
  2018-03-20 20:20 ` Stefan Monnier
  1 sibling, 1 reply; 7+ messages in thread
From: tomas @ 2018-03-17  8:25 UTC (permalink / raw)
  To: Garreau, Alexandre; +Cc: help-gnu-emacs

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

On Fri, Mar 16, 2018 at 08:15:59PM +0100, Garreau, Alexandre wrote:
> If I use a rule with a match regexp including a backreference inside the
> variable nnmail-split-fancy, it doesn’t match anything anymore:
> ("list-id" ".*<\\(gcc\\)-\\(help\\).\\1.\\(gnu\\)\\.org>.*" "lists.\\3.\\1.\\2")

What are you trying to match? The above will match "gcc-help#gcc#gnu.org
(where '#' stands here for any character). This looks strange to me (what
is the use of \\(...\\) for a constant match? \1 will always (in the case
of a match, that is) be "gcc", \2 always "help" and \3 always "gnu".

Is that really your intention? What are you trying to match?

> Yet backrefs are supported on the other side of the rule… is this
> normal? why is that? I at least would like a confirmation ^^

Yes, backreferences should work OK.

Cheers
- -- t
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.12 (GNU/Linux)

iEYEARECAAYFAlqs0OIACgkQBcgs9XrR2kb/7gCfQtrYNuclg8m8NkKflY4le5SO
4ZIAniW1cb6Xc6W6B07N8QEgxC1roR2E
=8z9X
-----END PGP SIGNATURE-----



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

* Re: Gnus nnmail-split-fancy regexps can’t support backrefs inside themselves?
  2018-03-17  8:25 ` tomas
@ 2018-03-19 12:57   ` Garreau, Alexandre
  2018-03-19 15:10     ` tomas
  0 siblings, 1 reply; 7+ messages in thread
From: Garreau, Alexandre @ 2018-03-19 12:57 UTC (permalink / raw)
  To: tomas; +Cc: help-gnu-emacs

Le 17/03/2018 à 09h25, tomas@tuxteam.de a écrit :
> On Fri, Mar 16, 2018 at 08:15:59PM +0100, Garreau, Alexandre wrote:
>> If I use a rule with a match regexp including a backreference inside the
>> variable nnmail-split-fancy, it doesn’t match anything anymore:
>> ("list-id" ".*<\\(gcc\\)-\\(help\\).\\1.\\(gnu\\)\\.org>.*" "lists.\\3.\\1.\\2")
>
> What are you trying to match? The above will match "gcc-help#gcc#gnu.org
> (where '#' stands here for any character). This looks strange to me (what
> is the use of \\(...\\) for a constant match? \1 will always (in the case
> of a match, that is) be "gcc", \2 always "help" and \3 always "gnu".
>
> Is that really your intention? What are you trying to match?

Yes, and sorry (for the .), indeed I did correct this since, it is now
".*<\\(gcc\\)-\\(help\\)\\.gcc\\.\\(gnu\\)\\.org>.*". As the variable
I’m talking about and the car of the list I’m talking about show, I’m
trying to match the list-id mail header of the gcc-help mailing list,
which contains “<gcc-help.gcc.gnu.org>”, but I reuse the words “gnu”,
“gcc” and help in the group name I’m splitting this in
(“lists.gnu.gcc.help”), so I group these names, so that later I can
better factorise with other splitting rules. For maintainance and
factorisations reasons, I’d also like to write “gcc” only once here,
except it seems gnus/mail-split stops to match anything as soon as I
include backrefs in the searching regexp.

>> Yet backrefs are supported on the other side of the rule… is this
>> normal? why is that? I at least would like a confirmation ^^
>
> Yes, backreferences should work OK.

So why isn’t this regexp matching any line containing
“<gcc-help.gcc.gnu.org>”?



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

* Re: Gnus nnmail-split-fancy regexps can’t support backrefs inside themselves?
  2018-03-19 12:57   ` Garreau, Alexandre
@ 2018-03-19 15:10     ` tomas
  0 siblings, 0 replies; 7+ messages in thread
From: tomas @ 2018-03-19 15:10 UTC (permalink / raw)
  To: Garreau, Alexandre; +Cc: help-gnu-emacs

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

On Mon, Mar 19, 2018 at 01:57:07PM +0100, Garreau, Alexandre wrote:
> Le 17/03/2018 à 09h25, tomas@tuxteam.de a écrit :
> > On Fri, Mar 16, 2018 at 08:15:59PM +0100, Garreau, Alexandre wrote:
> >> If I use a rule with a match regexp including a backreference inside the
> >> variable nnmail-split-fancy, it doesn’t match anything anymore:
> >> ("list-id" ".*<\\(gcc\\)-\\(help\\).\\1.\\(gnu\\)\\.org>.*" "lists.\\3.\\1.\\2")
> >
> > What are you trying to match? The above will match "gcc-help#gcc#gnu.org
> > (where '#' stands here for any character). This looks strange to me (what
> > is the use of \\(...\\) for a constant match? \1 will always (in the case
> > of a match, that is) be "gcc", \2 always "help" and \3 always "gnu".
> >
> > Is that really your intention? What are you trying to match?
> 
> Yes, and sorry (for the .), indeed I did correct this since, it is now
> ".*<\\(gcc\\)-\\(help\\)\\.gcc\\.\\(gnu\\)\\.org>.*". As the variable
> I’m talking about and the car of the list I’m talking about show, I’m
> trying to match the list-id mail header of the gcc-help mailing list,
> which contains “<gcc-help.gcc.gnu.org>”, but I reuse the words “gnu”,
> “gcc” and help in the group name I’m splitting this in
> (“lists.gnu.gcc.help”), so I group these names, so that later I can
> better factorise with other splitting rules. For maintainance and
> factorisations reasons, I’d also like to write “gcc” only once here,
> except it seems gnus/mail-split stops to match anything as soon as I
> include backrefs in the searching regexp.
> 
> >> Yet backrefs are supported on the other side of the rule… is this
> >> normal? why is that? I at least would like a confirmation ^^
> >
> > Yes, backreferences should work OK.
> 
> So why isn’t this regexp matching any line containing
> “<gcc-help.gcc.gnu.org>”?

By this you mean the one from your original mail, the one above,
i.e. ".*<\\(gcc\\)-\\(help\\).\\1.\\(gnu\\)\\.org>.*"?

For me, it matches:

  (string-match
    ".*<\\(gcc\\)-\\(help\\).\\1.\\(gnu\\)\\.org>.*"
    "<gcc-help.gcc.gnu.org>")

(returns 0, which is the start index. All is well).

Escaping the dots matches too, btw.

Cheers
- -- t
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.12 (GNU/Linux)

iEYEARECAAYFAlqv0ugACgkQBcgs9XrR2kb0TwCff38mQighe65RPZcHEyMriqZP
vNsAn1YgLztlYBFTnV0dQkjrMRMB0/4U
=3clN
-----END PGP SIGNATURE-----



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

* Re: Gnus nnmail-split-fancy regexps can’t support backrefs inside themselves?
  2018-03-16 19:15 Gnus nnmail-split-fancy regexps can’t support backrefs inside themselves? Garreau, Alexandre
  2018-03-17  8:25 ` tomas
@ 2018-03-20 20:20 ` Stefan Monnier
  2018-03-20 21:09   ` tomas
  1 sibling, 1 reply; 7+ messages in thread
From: Stefan Monnier @ 2018-03-20 20:20 UTC (permalink / raw)
  To: help-gnu-emacs


Indeed, they don't support backrefs, because Gnus takes the regexp you
specify and embeds it into a larger regexp which also uses \(...\)
grouping, so you'd have to offset your backrefs by the proper number of
preceding \( in order for them to work right (and changes in Emacs/Gnus
can change this offset, of course, to make things more interesting).


        Stefan




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

* Re: Gnus nnmail-split-fancy regexps can’t support backrefs inside themselves?
  2018-03-20 20:20 ` Stefan Monnier
@ 2018-03-20 21:09   ` tomas
  2018-03-20 22:05     ` Stefan Monnier
  0 siblings, 1 reply; 7+ messages in thread
From: tomas @ 2018-03-20 21:09 UTC (permalink / raw)
  To: help-gnu-emacs

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

On Tue, Mar 20, 2018 at 04:20:41PM -0400, Stefan Monnier wrote:
> 
> Indeed, they don't support backrefs, because Gnus takes the regexp you
> specify and embeds it into a larger regexp which also uses \(...\)
> grouping, so you'd have to offset your backrefs by the proper number of
> preceding \( in order for them to work right (and changes in Emacs/Gnus
> can change this offset, of course, to make things more interesting).

Oh, good catch. Perhaps using explicitly numbered groups \(?NUM:...\)
might help here...

Cheers
- -- tomás
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.12 (GNU/Linux)

iEYEARECAAYFAlqxeJgACgkQBcgs9XrR2kY2wQCfblkYkeayFrliIxv1D9UVhS91
uHsAnRoh6QO6Li0/HlkV1on6WbTonCFH
=7wjF
-----END PGP SIGNATURE-----



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

* Re: Gnus nnmail-split-fancy regexps can’t support backrefs inside themselves?
  2018-03-20 21:09   ` tomas
@ 2018-03-20 22:05     ` Stefan Monnier
  0 siblings, 0 replies; 7+ messages in thread
From: Stefan Monnier @ 2018-03-20 22:05 UTC (permalink / raw)
  To: help-gnu-emacs

> Oh, good catch. Perhaps using explicitly numbered groups \(?NUM:...\)
> might help here...

Right, but use large enough numbers to avoid conflict,


        Stefan




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

end of thread, other threads:[~2018-03-20 22:05 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2018-03-16 19:15 Gnus nnmail-split-fancy regexps can’t support backrefs inside themselves? Garreau, Alexandre
2018-03-17  8:25 ` tomas
2018-03-19 12:57   ` Garreau, Alexandre
2018-03-19 15:10     ` tomas
2018-03-20 20:20 ` Stefan Monnier
2018-03-20 21:09   ` tomas
2018-03-20 22:05     ` Stefan Monnier

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