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 16:40:09 -0400 Message-ID: References: <4209edd83cfee7c84b2d75ebfcd38784fa21b23c.camel@crossproduct.net> Mime-Version: 1.0 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: 7bit Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="1453"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Evolution 3.40.0-1 To: emacs-devel@gnu.org Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Wed Sep 08 22:42:39 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 1mO4P0-0000CF-8F for ged-emacs-devel@m.gmane-mx.org; Wed, 08 Sep 2021 22:42:38 +0200 Original-Received: from localhost ([::1]:56132 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mO4Oy-0006bw-2K for ged-emacs-devel@m.gmane-mx.org; Wed, 08 Sep 2021 16:42:36 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:40302) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mO4Mi-0005jt-2V for emacs-devel@gnu.org; Wed, 08 Sep 2021 16:40:16 -0400 Original-Received: from singularity.crossproduct.net ([136.248.125.68]:57852) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mO4Md-0005I5-VF for emacs-devel@gnu.org; Wed, 08 Sep 2021 16:40:15 -0400 Original-Received: from [192.168.1.147] (c-71-192-162-242.hsd1.ma.comcast.net [71.192.162.242]) by singularity.crossproduct.net (Postfix) with ESMTPSA id 5A8EC1E00DE for ; Wed, 8 Sep 2021 16:40:10 -0400 (EDT) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=crossproduct.net; s=crossproduct; t=1631133610; bh=t+8ercpM0cX5YI76TqeV5PGJumKLLy4crT1VRpgpXiA=; h=Subject:From:To:Date:In-Reply-To:References:From; b=2ZH4CEUfNiq07j5kmWPNHqSoobxH7R1w1cpoYErDJELC31Z+dtB0H6Q7xXtvZTnG/ UTuJw4OYTRMozDeY/9wmKQ4bAZb2ISs+FGP17c42d1697m1S/UdKaqXk7mJh10iTRN Oa/6TTt8Cwfgy4FIK91Wr+moG/Yx7DMu9LUYLbvs= In-Reply-To: <4209edd83cfee7c84b2d75ebfcd38784fa21b23c.camel@crossproduct.net> 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-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:274391 Archived-At: On Tue, 2021-09-07 at 21:49 -0400, Anna Glasgall wrote: > [snip] > I've successfully taught the elisp reader (read1 in lread.c) how to > read r-strings. I thought I had managed to make lisp-mode/elisp-mode > happy by allowing "r" to be a prefix character (C-x C-e and the > underlying forward-sexp/backward-sexp seemed to work fine at first), > but realized that I ran into trouble with strings containing the > sequence of characters '\\"'. > > The reader correctly reads r"a\\"" as a string containing the > sequence > of characters 'a', '\', '"', and M-: works. 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. > I've taken the suggestion Lars Ingebrigtsen made further up-thread and implemented another draft of this using #r"" instead of r""; not only does this not break existing elisp syntax (as noted by Po Lu earlier), forward-sexp and backwards-sexp understand the new syntax without having to be taught about it, to my considerable surprise. Or at least they understand it to the same extent that they understand #s() or #^[], anyway. Alan (Dr. Mackenzie? Forgive me, not sure what standards are here), your point about strings ending in \ is very well taken and I'm frankly not sure what the easiest path forward here is. Having "raw literals cannot end in a \" is a weird and unpleasant restriction, although the fact that it is one that Python places on r-strings (to my considerable surprise; I've been using Python since the mid-00s and have never run across this particular syntax oddity before) may mean that it is perhaps not so bad. The C++ concept of allowing r-strings to specify their own delimiters is perhaps maximally flexible, but is definitely going to be a heavier lift to implement than any of the above. I'd love to hear people's opinions on the merits of the various possible approaches here. You've all given me a great deal of food for thought, which I will attempt to digest before spinning a new revision of this patch. thanks, Anna > I've attached a copy of my WIP patch; it's definitely not near final > code quality and doesn't have documentation yet, all of which I would > take care of before submitting for inclusion. I also haven't filled > out > the copyright assignment paperwork yet, but should this work reach a > point where it was likely to be accepted, I'd be happy to do that. > > > I'd very much appreciate some pointers on what to try next here, or > some explanation of how syntax.c/syntax.el works beyond what's in the > reference manual. If this is a fool's errand I'm tilting at here, I'd > also appreciate being told that before I sink more time into it :) > > thanks, > > Anna Glasgall > >