emacs-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: "Raw" string literals for elisp


From: Lars Ingebrigtsen
Subject: Re: "Raw" string literals for elisp
Date: Wed, 08 Sep 2021 09:12:15 +0200
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/28.0.50 (gnu/linux)

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).

> 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.

-- 
(domestic pets only, the antidote for overdose, milk.)
   bloggy blog: http://lars.ingebrigtsen.no



reply via email to

[Prev in Thread] Current Thread [Next in Thread]