[Top][All Lists]

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

Re: Raw strings (experimental patches inside)

From: Ivan Andrus
Subject: Re: Raw strings (experimental patches inside)
Date: Sat, 4 Aug 2012 16:38:02 +0200

On Aug 4, 2012, at 12:43 AM, Stefan Monnier wrote:

>> When I type a regex I'm always annoyed by the amount of escaping
>> I have to do.  I've always wished Emacs Lisp had raw strings
>> ie. a syntax to type litteral text without interpretation.
> AFAIK, the only real use-case is indeed regexp, and for them a better
> solution would be to not escape the parentheses at all.

That doesn't handle the horror that is searching for backslashes...

>> I've made 2 patch for the reader (src/lread.c). There are proofs of
>> concepts, they should work on correct input but don't expect much.
> Adapting the reader is only one part, since you also need to adapt the
> elisp-mode syntax-tables accordingly (and check that the edebug reader
> doesn't need matching changes).
> As mentioned above, I'm not too excited by the idea of raw strings and
> would prefer solving the underlying root cause of dissatisfaction.
> Actually, we already have such a thing with `rx', but admittedly,
> a strings representation of regexps tends to be more concise, so maybe
> we also need some other trick like maybe a (re-escape "(?:foo)") which
> would return "\\(?:foo\\)".

It would also be nice to have a function which takes a string representation 
and converts it to an `rx' representation, which I couldn't find in rx when I 
looked.  I would like to convert some old libraries to use rx, but I'd rather 
not have to retype them all with the possibility of making mistakes etc.  

I think pcre2el [1] has such a thing, though I haven't tried it yet.  Is that 
on your radar for things to potentially include in Emacs?


[1] https://github.com/joddie/pcre2el

reply via email to

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