From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Stefan Kangas Newsgroups: gmane.emacs.devel Subject: Re: Ugly regexps Date: Wed, 3 Mar 2021 12:46:47 -0600 Message-ID: References: <83pn0g6ajq.fsf@gnu.org> <83v9a8jj2x.fsf@gnu.org> Mime-Version: 1.0 Content-Type: text/plain; charset="UTF-8" Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="431"; mail-complaints-to="usenet@ciao.gmane.io" Cc: emacs-devel@gnu.org To: Stefan Monnier , Eli Zaretskii Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Wed Mar 03 19:50:34 2021 Return-path: Envelope-to: ged-emacs-devel@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 1lHWZt-000AaP-Ay for ged-emacs-devel@m.gmane-mx.org; Wed, 03 Mar 2021 19:50:33 +0100 Original-Received: from localhost ([::1]:54734 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lHWZs-0001rx-6j for ged-emacs-devel@m.gmane-mx.org; Wed, 03 Mar 2021 13:50:32 -0500 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:33344) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lHWWI-0004jO-Jd for emacs-devel@gnu.org; Wed, 03 Mar 2021 13:46:50 -0500 Original-Received: from mail-pl1-x636.google.com ([2607:f8b0:4864:20::636]:42484) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1lHWWH-0007sL-4b; Wed, 03 Mar 2021 13:46:50 -0500 Original-Received: by mail-pl1-x636.google.com with SMTP id s16so14537235plr.9; Wed, 03 Mar 2021 10:46:48 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:in-reply-to:references:mime-version:date:message-id:subject:to :cc; bh=m9qZnGXGwWISpJ5e4jDllbENzSBELxTezC4ZDjtrYE0=; b=CRI3dFMZbmyxy7IZG77B6d1LNuHNSbhQgum2ezCmCp93Pat8kc84ttXGH6emmP11SS avx6uGn/PE1YWgLUkQ/royRsfHG0bDnkJwz1tuBQtWtJCPrlHHZJ+pyp6+Tdcql0P0Tt WBb3IG6VojFq6iTmHoXkn76sjRXZuxSshEoXoS2hcZAcJtaUxgkk+UGZMLjY4NpW5AZi NHcgYNwoIe2XCkwpp0zK71utT3u7QShHhXhhz3hvsqRdbrEKDh4pQfq3Tn2nxjpsJ8cQ Gr/1aBup6I+3w1BlIsxRdYk29G3vildpKVEI6CFsdfgeCEunOuAny+Ss6YRPcuTjZDPr 0+2A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:in-reply-to:references:mime-version:date :message-id:subject:to:cc; bh=m9qZnGXGwWISpJ5e4jDllbENzSBELxTezC4ZDjtrYE0=; b=Jz1n9c9IGZUagAyGJMACXuCgyAhietQ4Oi6e3iChp7UebHAV1WV0IMEcHlHOV5xpoK bqJMRuA3vltppVwdXj1Ku+/znFhiLSB87pKmhmXEJQUVFaR/BVjpbwtmsIbtPr+vYhGX 1OW9VAu3YyuvVUy36LbD4SrvFk5FL7Sk2tQuWI/9K7AkeMNwlw+xARSKn3c9rSCFJTd2 vdWCo4LtfvXHb42gsB4okefj7OOgPYqnVFN42sWtLubu89Fu9SXX5w7S1bxJM2Z3Z9TG RiTVKSM2DD5zHYYOJ3ICottscC//vV/b+myVxMJr8SrZz06hLfgep+TWLZDM2+5gGprc iyKA== X-Gm-Message-State: AOAM531eHzas+8Iyszgd+hquJTt64XkU3zCKMJ2El1HZDwkp03NZzPjt vrVO4sL/dTXUC4UytPOvx/jYSI/hkcE+5IYTbTjzaeHo X-Google-Smtp-Source: ABdhPJzV4ShkSum0QhT1jnbtmNyJ2xi8jvQdRB3dFjp/TXbYlgk0GxEMl50MW8wu2nYlKtaib8l2K4vDEgHpElP6mCk= X-Received: by 2002:a17:90a:c249:: with SMTP id d9mr505740pjx.104.1614797207599; Wed, 03 Mar 2021 10:46:47 -0800 (PST) Original-Received: from 753933720722 named unknown by gmailapi.google.com with HTTPREST; Wed, 3 Mar 2021 12:46:47 -0600 In-Reply-To: Received-SPF: pass client-ip=2607:f8b0:4864:20::636; envelope-from=stefankangas@gmail.com; helo=mail-pl1-x636.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 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Original-Sender: "Emacs-devel" Xref: news.gmane.io gmane.emacs.devel:265900 Archived-At: Stefan Monnier writes: >> Why would someone find rx unpalatable? > > Maybe just because of habit, but I think the main downside of `rx` is > that it's very verbose, which ends up hiding the "text". For example in > > (rx "(def" (or "macro" "un" "subst"))) > > I find the `or` to get a bit in the way of my visual cortex recognizing > the "defmacro" pattern above. It is also just another thing to learn. If you're just doing some basic ELisp functions for your personal editing you might not want to spend time parsing the docstring of `rx' just to say "^(foo|bar)". This applies also if you're just writing some small package that just needs a regexp or two. Also, `rx' does not translate to most other languages. So if you are learning regexps for the first time or are still struggling with them, you will IMO probably be better off staying away from `rx' for a while. Note also that you can't use `rx' syntax in `query-replace-regexp'. I am not surprised that we don't see `rx' used more, even if I would certainly wish that wasn't the case. Especially in our own sources. (It's too bad that we don't use it in our preloaded code, for example.)