unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
* bug#6985: rx patterns don't compose
@ 2010-09-04 23:37 Daniel Colascione
  2010-09-05  7:22 ` Stefan Monnier
  2010-09-05  7:39 ` Andreas Schwab
  0 siblings, 2 replies; 5+ messages in thread
From: Daniel Colascione @ 2010-09-04 23:37 UTC (permalink / raw)
  To: 6985

It's not possible to do this currently:

(defconst foo-re (rx "abc"))
(defconst bar-re (rx (* (what-goes-here? foo-re)))

in any sensible way. This won't work

  (defconst bar-re (rx (* (regexp foo-re))))

because regexp always expects a string.

This won't work, because eval always quotes its argument:

  (defconst bar-re (rx (* (eval foo-re))))

I propose allowing regexp to accept a symbol as well as a string, and
using that symbol's value literally. Alternatively, rx could provide an
eval-unquoted facility. Or both.





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

* bug#6985: rx patterns don't compose
  2010-09-04 23:37 bug#6985: rx patterns don't compose Daniel Colascione
@ 2010-09-05  7:22 ` Stefan Monnier
  2010-09-05  7:39 ` Andreas Schwab
  1 sibling, 0 replies; 5+ messages in thread
From: Stefan Monnier @ 2010-09-05  7:22 UTC (permalink / raw)
  To: Daniel Colascione; +Cc: 6985

> It's not possible to do this currently:
> (defconst foo-re (rx "abc"))
> (defconst bar-re (rx (* (what-goes-here? foo-re)))

(defconst foo-re (rx "abc"))
(defconst bar-re `(rx (* (regexp ,foo-re)))


> in any sensible way. This won't work

>   (defconst bar-re (rx (* (regexp foo-re))))

> because regexp always expects a string.

> This won't work, because eval always quotes its argument:

>   (defconst bar-re (rx (* (eval foo-re))))

> I propose allowing regexp to accept a symbol as well as a string, and
> using that symbol's value literally. Alternatively, rx could provide an
> eval-unquoted facility. Or both.

eval-unquoted sounds OK


        Stefan





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

* bug#6985: rx patterns don't compose
  2010-09-04 23:37 bug#6985: rx patterns don't compose Daniel Colascione
  2010-09-05  7:22 ` Stefan Monnier
@ 2010-09-05  7:39 ` Andreas Schwab
  2010-09-05  7:42   ` Daniel Colascione
  1 sibling, 1 reply; 5+ messages in thread
From: Andreas Schwab @ 2010-09-05  7:39 UTC (permalink / raw)
  To: Daniel Colascione; +Cc: 6985

Daniel Colascione <dan.colascione@gmail.com> writes:

> It's not possible to do this currently:
>
> (defconst foo-re (rx "abc"))
> (defconst bar-re (rx (* (what-goes-here? foo-re)))

(defconst bar-re (eval `(rx (* (regexp ,foo-re))))

Andreas.

-- 
Andreas Schwab, schwab@linux-m68k.org
GPG Key fingerprint = 58CA 54C7 6D53 942B 1756  01D3 44D5 214B 8276 4ED5
"And now for something completely different."





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

* bug#6985: rx patterns don't compose
  2010-09-05  7:39 ` Andreas Schwab
@ 2010-09-05  7:42   ` Daniel Colascione
  2010-09-05 10:45     ` Andreas Schwab
  0 siblings, 1 reply; 5+ messages in thread
From: Daniel Colascione @ 2010-09-05  7:42 UTC (permalink / raw)
  To: Andreas Schwab; +Cc: 6985

On 9/5/10 12:39 AM, Andreas Schwab wrote:
> Daniel Colascione <dan.colascione@gmail.com> writes:
>
>> It's not possible to do this currently:
>>
>> (defconst foo-re (rx "abc"))
>> (defconst bar-re (rx (* (what-goes-here? foo-re)))
>
> (defconst bar-re (eval `(rx (* (regexp ,foo-re))))

Or better yet,

(defconst bar-re (rx-to-string `(* (regexp ,foo-re))))

But it's still cumbersome.





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

* bug#6985: rx patterns don't compose
  2010-09-05  7:42   ` Daniel Colascione
@ 2010-09-05 10:45     ` Andreas Schwab
  0 siblings, 0 replies; 5+ messages in thread
From: Andreas Schwab @ 2010-09-05 10:45 UTC (permalink / raw)
  To: Daniel Colascione; +Cc: 6985

Daniel Colascione <dan.colascione@gmail.com> writes:

> (defconst bar-re (rx-to-string `(* (regexp ,foo-re))))

To avoid the extra group:

(defconst bar-re (rx-to-string `(* (regexp ,foo-re)) t))

Andreas.

-- 
Andreas Schwab, schwab@linux-m68k.org
GPG Key fingerprint = 58CA 54C7 6D53 942B 1756  01D3 44D5 214B 8276 4ED5
"And now for something completely different."





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

end of thread, other threads:[~2010-09-05 10:45 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-09-04 23:37 bug#6985: rx patterns don't compose Daniel Colascione
2010-09-05  7:22 ` Stefan Monnier
2010-09-05  7:39 ` Andreas Schwab
2010-09-05  7:42   ` Daniel Colascione
2010-09-05 10:45     ` Andreas Schwab

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

	https://git.savannah.gnu.org/cgit/emacs.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).