From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Philipp Stephani Newsgroups: gmane.emacs.devel Subject: Re: Make regexp handling more regular Date: Wed, 2 Dec 2020 12:21:50 +0100 Message-ID: References: <87lfeg60iy.fsf@gnus.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="25088"; mail-complaints-to="usenet@ciao.gmane.io" Cc: Lars Ingebrigtsen , Emacs developers To: Stefan Kangas Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Wed Dec 02 12:48:01 2020 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 1kkQc5-0006QG-Ab for ged-emacs-devel@m.gmane-mx.org; Wed, 02 Dec 2020 12:48:01 +0100 Original-Received: from localhost ([::1]:50588 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kkQc4-0008NN-Bw for ged-emacs-devel@m.gmane-mx.org; Wed, 02 Dec 2020 06:48:00 -0500 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:43428) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kkQD1-0005Ix-Ps for emacs-devel@gnu.org; Wed, 02 Dec 2020 06:22:09 -0500 Original-Received: from mail-ot1-x32f.google.com ([2607:f8b0:4864:20::32f]:38325) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1kkQCz-0001HI-Iy for emacs-devel@gnu.org; Wed, 02 Dec 2020 06:22:07 -0500 Original-Received: by mail-ot1-x32f.google.com with SMTP id b62so1297594otc.5 for ; Wed, 02 Dec 2020 03:22:02 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=QQgAZihhv900LrhI/0GfyHreSPNY4PA3VT5ssgUV/+M=; b=ekCan1reTE6wyA8Kv0qnKaEJBLjiKYHvS1UYtnT4rpk0lsp0v0HH5fmGlwetw18IUH iQ8nt2VfY4qSQTa5AKD2menDeEbC0KclXjNbn2zj7l0PJWzrgczLupuI7YWVHMqq49Gf Zij5i4MlnZNtQCrso0b2lnb9hpqk+y5T9sA1J7cNWW0QMuTtDK2lpc3AnvGZTautvCge SQnKJ8CM77gePIq5tGW88sg+Yx1dfGIgUS0RWBe5hTEVZ1ED2RJRfgBpKcnlyhUaKtJh wp3f+/TDO8DLsWrg+gwZoaC9ifVJXu9gZ0voUWAbypX4Qt8QYDwfzguRkAji313rXPK6 CR3w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=QQgAZihhv900LrhI/0GfyHreSPNY4PA3VT5ssgUV/+M=; b=Ozaw3kRsTj0KDu7SrUknp7GLqdazQeZJ+KxKFlrsUQ0J8l7eY39SkbTrYiE5H/7F0X U8WiIc2h4ZwWWY71chamWYFaBRCFe/FfKGhl9g90wqZsXZ9nbV+2vwlXkfg2DPvrPm99 Dyu6G6UkFX1+v3cjSnS24QTZeCBHzyPU164q53UmdikXipy07QMOFTelJRhDhBVbedf0 SFcu4ZZ0Oo/JN54xu0hT9QJlZ5ZWq2VDM702vGFY+O6XGFKN6HdQO6UWbXbDZzxerS/2 LmKWbEVl01UvSgOeWjZprwvIPLDaEr97JO1wixQRTx4ZNPleyLm2gLkjhiOOjEHUvvAA PlrQ== X-Gm-Message-State: AOAM532oiRjgI39CNU30XIcSEAkbxvme7AEgVd0P8UGAqWOo9m4nbEAY fE1/Ozg2PfRmqdOj48UUpADzkyaW0JlDgcsCRxk= X-Google-Smtp-Source: ABdhPJyfcccNw9VikJ81vP/sPLVOrTBE2tEW/p9hUAb/F4g8pywfNzNb/wzPhJ430okgtaTsZUlOaqmBdwXs6QpNRMo= X-Received: by 2002:a05:6830:150a:: with SMTP id k10mr702916otp.36.1606908121948; Wed, 02 Dec 2020 03:22:01 -0800 (PST) In-Reply-To: Received-SPF: pass client-ip=2607:f8b0:4864:20::32f; envelope-from=p.stephani2@gmail.com; helo=mail-ot1-x32f.google.com X-Spam_score_int: -17 X-Spam_score: -1.8 X-Spam_bar: - X-Spam_report: (-1.8 / 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_ENVFROM_END_DIGIT=0.25, 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:260178 Archived-At: Am Mi., 2. Dez. 2020 um 12:14 Uhr schrieb Stefan Kangas : > > Lars Ingebrigtsen writes: > > > So my idle shower thought for the day is: Is there any reasonable path > > forward that the Emacs Lisp language could take here? > > > > Well, we obviously can't alter functions like `string-match' and > > `re-search-forward' -- they have well-defined semantics, and we can't > > make them return a match object. But we could make a new set of > > functions that are more, er, functional. > > I like the idea of adding an entirely new built-in API based on the > current state of the art. I would begin such a project by looking into > what other Lisps are doing, such as CL, Clojure, Guile and Racket. Why > shouldn't Emacs Lisp be best-in-class? > > As for naming, how about just using a short prefix such as "re-"? > AFAICT, we currently have only five functions using that prefix. > > Tangentially, I have always been wondering if its feasible to add a new > regular expression type to `read' where you don't have to incessantly > double quote all special characters. (One could take inspiration from > Python, for example, which adds an "r" character to strings to turn them > into regexps: r"regexp".) > Yes, I think all of these make sense: 1. Support for stateless matching, with functions returning match objects (like s-match, but also for searching) 2. Support for PCRE/"extended" regexp. Add customization options for the interactive commands to read this dialect. 3. Support for raw strings, maybe using a syntax like #"...". If we want to take more cues from other programming languages, we should create a "compiled regex pattern" type. Multiple dialects (traditional Emacs regexp, rx, PCRE) would then compile down to a single such type.