> This construct allows you to force a particular
> group number. There is no particular restriction on the numbering,
> but when I try this:
> (looking-at "\\(a\\(?1:b\\)\\)")
> then it throws an error.
> I know it's possibly a collision with the containing group's number
> and I can overcome it by using a larger number,
Rather than a larger number, you can just stop the outer group from
getting a number: (looking-at "\\(?:a\\(?1:b\\)\\)") which happens to be
the same as (looking-at "\\(?:a\\(b\\)\\)").
> but the doc says I can use it to force a group number, so why does it
> throw an error then?
Because having the same group nested in "itself" leads to tricky
questions about the expected semantics: when matching
"\\(a\\(?1:b\\)c\\)", should a successful match's group1 match "abc" or
"b" or "ab" or "bc"? You'd probably want either "abc" or "b" but the
most likely behavior, given the current implementation, would be "bc".
> Is it a bug? I tried it with GNU Emacs 23.2.1
I (as implementor of the feature, and maintainer of Emacs) don't
consider it as a bug, no.
But I'd like to hear more context explaining why it's a problem for you,
Stefan