[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: "Raw" string literals for elisp
From: |
Anna Glasgall |
Subject: |
Re: "Raw" string literals for elisp |
Date: |
Wed, 08 Sep 2021 10:20:46 -0400 |
User-agent: |
Evolution 3.40.0-1 |
On Wed, 2021-09-08 at 09:12 +0200, Lars Ingebrigtsen wrote:
> Anna Glasgall <anna@crossproduct.net> 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
- "Raw" string literals for elisp, Anna Glasgall, 2021/09/08
- Re: "Raw" string literals for elisp, Po Lu, 2021/09/08
- Re: "Raw" string literals for elisp, Lars Ingebrigtsen, 2021/09/08
- Re: "Raw" string literals for elisp,
Anna Glasgall <=
- Re: "Raw" string literals for elisp, Alan Mackenzie, 2021/09/08
- Re: "Raw" string literals for elisp, Adam Porter, 2021/09/08
- Re: "Raw" string literals for elisp, Stefan Monnier, 2021/09/08