Re: regexp-opt GNU "sync"?

Ville Skyttä <[email protected]>
Newsgroups gmane.emacs.xemacs.design
Organization The XEmacs Development Team
Message-ID <[email protected]>
On Fri, 2003-10-10 at 05:20, Stephen J. Turnbull wrote:
> >>>>> "Ville" == Ville Skytt <Ville> writes:
> 
>     Ville> Every now and the people run into the differing semantics
>     Ville> of regexp-opt between XEmacs and GNU Emacs.  PITA, will be
>     Ville> noticed at runtime only. It seems that an easy fix would be
>     Ville> to reverse the 4th, optional NON-SHY argument in the XEmacs
>     Ville> version, into SHY instead.
> 
> +1.  This looks like a good idea to me, as long as packages are fixed
> as you prpose.  I'll look into emitting a byte-compiler warning.  This
> will take time though, I know nothing about it.

Ok, I started some work on this, and now I'm convinced that the only
sane thing to do is to scratch the SHY/NON-SHY (3rd arg in fact, not
4th) argument altogether, and just Do The Right Thing like IMO the GNU
version does.  Everything else seems to again lead to subtle
incompatibilities.  The current documentation is already confusing and
I'm afraid that the result of the above change would make it even worse.

Both the GNU and the XEmacs docs are confusing, "grouping constructs"
seems to actually mean only "capturing group constructs" in GNU and in
XEmacs, well, in theory controlled by the NON-SHY flag but in practice
the flag doesn't affect only the "inner" groupings as documented but all
of them.

Ditto, for regexp-group-depth, why would anyone want to get a count of
non-capturing groups?

So, instead of the original GNU "sync", I'm now proposing a GNU sync :)

> Think about keeping the old API available, perhaps through a bindable
> dynamic variable.

Uh, I can't really think straight now, confused enough by the above for
the moment :@

Attached is some results with the current XEmacs one, the original
proposal above, and the GNU one.
regexp-opt.txt (text/plain, 1.2 KB)
Current XEmacs:

  (regexp-opt (list "bar" "baz" "bazaar"))
  "ba\\(?:zaar\\|[rz]\\)"
  (regexp-opt (list "bar" "baz" "bazaar") t)
  "\\(?:ba\\(?:zaar\\|[rz]\\)\\)"
  (regexp-opt (list "bar" "baz" "bazaar") 'words)
  "\\<\\(?:ba\\(?:zaar\\|[rz]\\)\\)\\>"
  (regexp-opt (list "bar" "baz" "bazaar") nil t)
  "ba\\(zaar\\|[rz]\\)"
  (regexp-opt (list "bar" "baz" "bazaar") t t)
  "\\(ba\\(zaar\\|[rz]\\)\\)"
  (regexp-opt (list "bar" "baz" "bazaar") 'words t)
  "\\<\\(ba\\(zaar\\|[rz]\\)\\)\\>"

Original proposal:

  (regexp-opt (list "bar" "baz" "bazaar"))
  "ba\\(zaar\\|[rz]\\)"
  (regexp-opt (list "bar" "baz" "bazaar") t)
  "\\(ba\\(zaar\\|[rz]\\)\\)"
  (regexp-opt (list "bar" "baz" "bazaar") 'words)
  "\\<\\(ba\\(zaar\\|[rz]\\)\\)\\>"
  (regexp-opt (list "bar" "baz" "bazaar") nil t)
  "ba\\(?:zaar\\|[rz]\\)"
  (regexp-opt (list "bar" "baz" "bazaar") t t)
  "\\(?:ba\\(?:zaar\\|[rz]\\)\\)"
  (regexp-opt (list "bar" "baz" "bazaar") 'words t)
  "\\<\\(?:ba\\(?:zaar\\|[rz]\\)\\)\\>"

GNU Emacs:

  (regexp-opt (list "bar" "baz" "bazaar"))
  "ba\\(?:zaar\\|[rz]\\)"
  (regexp-opt (list "bar" "baz" "bazaar") t)
  "\\(ba\\(?:zaar\\|[rz]\\)\\)"
  (regexp-opt (list "bar" "baz" "bazaar") 'words)
  "\\<\\(ba\\(?:zaar\\|[rz]\\)\\)\\>"
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.