From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: =?utf-8?Q?K=C3=A9vin_Le_Gouguec?= Newsgroups: gmane.emacs.help Subject: Re: rx and rx-to-string handle (regexp VAR) differently Date: Fri, 09 Jun 2023 08:20:11 +0200 Message-ID: <87mt19gns4.fsf@gmail.com> References: <87ttvhvdco.fsf@gmail.com> <257320f0-697c-cbc3-fcfc-584d6ac7051c@gmail.com> <87mt191knj.fsf@web.de> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="35508"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Gnus/5.13 (Gnus v5.13) Cc: help-gnu-emacs@gnu.org To: Michael Heerdegen Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane-mx.org@gnu.org Fri Jun 09 08:21:04 2023 Return-path: Envelope-to: geh-help-gnu-emacs@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1q7VUe-00097z-Bz for geh-help-gnu-emacs@m.gmane-mx.org; Fri, 09 Jun 2023 08:21:04 +0200 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1q7VU0-0002gp-3B; Fri, 09 Jun 2023 02:20:24 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1q7VTu-0002g5-3b for help-gnu-emacs@gnu.org; Fri, 09 Jun 2023 02:20:18 -0400 Original-Received: from mail-wm1-x32e.google.com ([2a00:1450:4864:20::32e]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1q7VTr-0004PK-Fn for help-gnu-emacs@gnu.org; Fri, 09 Jun 2023 02:20:17 -0400 Original-Received: by mail-wm1-x32e.google.com with SMTP id 5b1f17b1804b1-3f6d38a140bso10561105e9.1 for ; Thu, 08 Jun 2023 23:20:15 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1686291613; x=1688883613; h=content-transfer-encoding:mime-version:user-agent:message-id:date :references:in-reply-to:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=UlAGfoN8bXgGGrO0sAegQTMabHZxz9BIKyvrzkuAIgI=; b=OmTUXNVbmGCltwmV6VyvPpBAFC1DOoEds0nVN3FQmc+BmU1Tq7u058UyMWtaJTU1FO raGhVZiU7/zzGEs3/o6/vLQ8xrtLrabU2a1DLoe9/ESOygPdB++3ewgdanP5Cf7lu1XB 4wwZ/Q6YIYLbE1nZjOni+WVbOzIH5rUJ8GubsJ7ao0inOursUCbXrjzzJ6Yjtq27s81M k4Kyts2+kxFGZ9uKfxWXToIPJT2NRHjZuVq1GXU+qat5e0StZYWUFy5guxTu4pomFrvZ tA5uuh2+fBqokGkZpoOzo3bLi6BPMLX/ctzQmiL4iPMRA0bbjbaMuPWG07Y7RcAFkk4k 8ZhQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1686291613; x=1688883613; h=content-transfer-encoding:mime-version:user-agent:message-id:date :references:in-reply-to:subject:cc:to:from:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=UlAGfoN8bXgGGrO0sAegQTMabHZxz9BIKyvrzkuAIgI=; b=JR1umkJ7ro8iwiakidCmAfTmah3F288Oxe5Gzg9WhmWFP0TqlwAQt6AWXjXnmidG4O vsvCnO6DVdNA2l6OaHQ/p5uojPOkL25AD/J/09SuxqpbTZeyTMvqpwWj1JSR8JUP24CH Gc1PJHIcAFV2NiQVQ8B5i/aWp2NIqpDf8YJeWHwb9YMLnyvkBrsXf3YvmddfXlgpN9nt vdi8HgxG/yzgPORu9H2J2wN3ntcy3XDhrwaEn472vvgjNoaA0SwEGHpSfikGpVtltmCp AUobZ6UfegfLgMdP/Z/v99gDScrTvX47qOygEVintupxEAdqEJxrMB2y4EHBMv6QFDJN 4KPw== X-Gm-Message-State: AC+VfDwpMkNpdGY2cfVfLnvAL2XhZsWHaka4zKxWv0QVEilz4ghXibme bQN25Zji1QM+PQzq1rHP4OEGNCZjzw4= X-Google-Smtp-Source: ACHHUZ4Rlt98pa/AQ8/otR3MsmrZyT9CYA/Qms4UkxOe7BKNp5f/YevYm6h/W7bGXfAUaNXe9q/8qg== X-Received: by 2002:a1c:f70e:0:b0:3f4:1ce0:a606 with SMTP id v14-20020a1cf70e000000b003f41ce0a606mr612875wmh.1.1686291613071; Thu, 08 Jun 2023 23:20:13 -0700 (PDT) Original-Received: from amdahl30 ([2a01:e0a:253:fe0:2ef0:5dff:fed2:7b49]) by smtp.gmail.com with ESMTPSA id 2-20020a05600c020200b003f739a8bcc8sm1574355wmi.19.2023.06.08.23.20.12 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 08 Jun 2023 23:20:12 -0700 (PDT) In-Reply-To: <87mt191knj.fsf@web.de> (Michael Heerdegen's message of "Fri, 09 Jun 2023 03:36:48 +0200") Received-SPF: pass client-ip=2a00:1450:4864:20::32e; envelope-from=kevin.legouguec@gmail.com; helo=mail-wm1-x32e.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Users list for the GNU Emacs text editor List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane-mx.org@gnu.org Original-Sender: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane-mx.org@gnu.org Xref: news.gmane.io gmane.emacs.help:143897 Archived-At: Michael Heerdegen writes: > Platon Pronko writes: > >> rx-to-string docs explicitly say: "The arguments to =E2=80=98literal=E2= =80=99 and >> =E2=80=98regexp=E2=80=99 forms inside FORM must be constant strings." > > Is this a correct way to get what K=C3=A9vin 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!