all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: "Kévin Le Gouguec" <kevin.legouguec@gmail.com>
To: Michael Heerdegen <michael_heerdegen@web.de>
Cc: help-gnu-emacs@gnu.org
Subject: Re: rx and rx-to-string handle (regexp VAR) differently
Date: Fri, 09 Jun 2023 08:20:11 +0200	[thread overview]
Message-ID: <87mt19gns4.fsf@gmail.com> (raw)
In-Reply-To: <87mt191knj.fsf@web.de> (Michael Heerdegen's message of "Fri, 09 Jun 2023 03:36:48 +0200")

Michael Heerdegen <michael_heerdegen@web.de> writes:

> Platon Pronko <platon7pronko@gmail.com> writes:
>
>> rx-to-string docs explicitly say: "The arguments to ‘literal’ and
>> ‘regexp’ forms inside FORM must be constant strings."
>
> Is this a correct way to get what Kévin wants?
>
> #+begin_src emacs-lisp
>   (setq foo-regexp "fo+")
>   (rx-define foo (eval `(regexp ,foo-regexp)))
> #+end_src

Ah, nice catch!  I had started messing around with rx's 'eval', but
figured I should sort out my understanding of 'regexp' before throwing
more indirection at the problem.  It does seem like it fits my original
use-case better:

  (eval-and-compile
    (put 'foo 'rx-definition
         '((eval
            `(regexp ,foo-regexp))))
    'foo)

AFAICT (from that expansion and some cursory testing) that does allow
for (rx-to-string '(seq foo)) to change whenever foo-regexp changes.

> This also works in both cases:
>
> #+begin_src emacs-lisp
>   (setq foo-regexp '(regexp "fo+"))
>   (rx-define foo (eval foo-regexp))
> #+end_src

Noted.  Thanks a bunch for these hints!



  reply	other threads:[~2023-06-09  6:20 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-06-08 21:44 rx and rx-to-string handle (regexp VAR) differently Kévin Le Gouguec
2023-06-09  0:57 ` Platon Pronko
2023-06-09  1:36   ` Michael Heerdegen
2023-06-09  6:20     ` Kévin Le Gouguec [this message]
2023-06-09  5:35   ` Kévin Le Gouguec
2023-06-09  6:05 ` Eli Zaretskii
2023-06-09  6:35   ` Kévin Le Gouguec

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87mt19gns4.fsf@gmail.com \
    --to=kevin.legouguec@gmail.com \
    --cc=help-gnu-emacs@gnu.org \
    --cc=michael_heerdegen@web.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.