From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Anna Glasgall Newsgroups: gmane.emacs.devel Subject: Re: "Raw" string literals for elisp Date: Wed, 08 Sep 2021 10:20:46 -0400 Message-ID: References: <4209edd83cfee7c84b2d75ebfcd38784fa21b23c.camel@crossproduct.net> <875yvb7d80.fsf@gnus.org> Mime-Version: 1.0 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: 8bit Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="19714"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Evolution 3.40.0-1 Cc: emacs-devel@gnu.org To: Lars Ingebrigtsen Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Wed Sep 08 17:12:45 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 1mNzFk-0004yQ-OY for ged-emacs-devel@m.gmane-mx.org; Wed, 08 Sep 2021 17:12:45 +0200 Original-Received: from localhost ([::1]:43940 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mNzFj-0004zl-CZ for ged-emacs-devel@m.gmane-mx.org; Wed, 08 Sep 2021 11:12:43 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:44656) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mNyRV-0006e5-FU for emacs-devel@gnu.org; Wed, 08 Sep 2021 10:20:49 -0400 Original-Received: from singularity.crossproduct.net ([136.248.125.68]:57724) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mNyRT-0007ai-UY for emacs-devel@gnu.org; Wed, 08 Sep 2021 10:20:49 -0400 Original-Received: from cryptic.home.crossproduct.net (c-71-192-162-242.hsd1.ma.comcast.net [71.192.162.242]) by singularity.crossproduct.net (Postfix) with ESMTPSA id DF0251E00DE; Wed, 8 Sep 2021 10:20:46 -0400 (EDT) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=crossproduct.net; s=crossproduct; t=1631110846; bh=m6vkVUdEalUa0iDIQ7rZ7jFm4VweIi+KI0+IHg0NVzY=; h=Subject:From:To:Cc:Date:In-Reply-To:References:From; b=uFsU6vc0+L9pxTKOalk3sptVY0s3X096s3XiMI8wcOqufzUCnY1azcnE27Ox+Nmf8 B/gHfxwJOCiVJKTSEI1v8cgNMo40TsQu5FvROEMnPwvo7J2PK9qdY+NiWX3t5PLYSW Opu367Qq6Dn8qt3Cbw2/SKGyLFftXjlQd6BjhmeM= In-Reply-To: <875yvb7d80.fsf@gnus.org> Received-SPF: pass client-ip=136.248.125.68; envelope-from=anna@crossproduct.net; helo=singularity.crossproduct.net 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, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-Mailman-Approved-At: Wed, 08 Sep 2021 11:04:30 -0400 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:274354 Archived-At: On Wed, 2021-09-08 at 09:12 +0200, Lars Ingebrigtsen wrote: > Anna Glasgall writes: > > > I've long been annoyed by the number of backslashes needed when > > using > > string literals in elisp for certain things (regexes, UNC paths, > > etc), > > so I started work on a patch (WIP attached) to implement support > > for > > "raw" string literals, a la Python r-strings. > > Great!  This would be very welcome, and has been proposed a number of > times before, but nobody has actually implemented it.  As you've > found > out, making the reader support the syntax is pretty easy, but the > problem is with getting the rest of the Emacs tooling to understand > the > new syntax.  (Which is, in general, the stumbling block when > introducing > any new syntax in Emacs Lisp.) > > > The reader correctly reads r"a\\"" as a string containing the > > sequence > > of characters 'a', '\', '"', and M-: works. > > I think we'd prefer #r"..." -- # is used in Lisps to introduce most > special syntaxes (and it's more backwards-compatible, since "r" by > itself is a valid read syntax, but #r isn't today). > That would be fine by me; I'll see about revising this to change the syntax that. > > Unfortunately, if I try sexp-based navigation or e.g. C-x C-e, it > > falls apart. The parser in syntax.c, which afaict is what lisp-mode > > is > > using to try and find sexps in buffer text, doesn't seem to know > > what > > to do with this expression.  I've spent some time staring at > > syntax.c, > > but I must confess that I'm entirely defeated in terms of what > > changes > > need to be made here to teach this other parser about prefixed > > strings > > in where the prefix has meaning that affects the interpretation of > > the > > characters between string fences. > > Hopefully somebody else can give some insights here, because I'm not > overly familiar with syntax.c, either. > thanks, Anna