From: Philippe Vaucher <philippe.vaucher@gmail.com>
To: "Clément Pit-Claudel" <cpitclaudel@gmail.com>
Cc: Emacs developers <emacs-devel@gnu.org>
Subject: Re: modern regexes in emacs
Date: Fri, 15 Feb 2019 16:03:03 +0100 [thread overview]
Message-ID: <CAGK7Mr5szEF6oB3h8RcjudW=4zNTqNhZDpnw1Q7GKMWkkzdMjw@mail.gmail.com> (raw)
In-Reply-To: <387b4e87-2255-0467-c23e-e60c6b090fb3@gmail.com>
[-- Attachment #1: Type: text/plain, Size: 1957 bytes --]
>
> > Would this even be possible? I can imagine a whole lot of packages
> breaking if the regexp syntax changed, and changing it just for the user
> input in interactive functions looks a bit sketchy.
>
> We could just add a special tag at the beginning of a regexp to indicate
> that it's a pcre regexp; something like this maybe? (re-search-forward
> "\\(?pcre:\\)…[pcre regexp goes here]…"). This form is currently a syntax
> error, so there would be no ambiguity, and we could define a (pcre …) macro
> so that you could write (re-search-forward (pcre "…[pcre regexp goes
> here]…")) instead. Alternatively, we could use an explicit tag, something
> like (re-search-forward (cons 'pcre "…[pcre regexp goes here]…")).
>
> For interactive functions, I imagine you'd have a defcustom with a
> preferred regexp dialect.
>
I like where this is going, that and Eli's suggestion of a special text
property we have plenty of ways to implement it where it'd play nice with
the existing code.
So far 3 proposals:
- Regexps are always strings, with "\\(?pcre:\\)" as part of the regexp
- when the string is displayed you need to scan the beginning to see
it is a PCRE regex
- no separation between the regexp and it's kind
- Regexps are strings (emacs regexps) or conses with their kind as
symbol with the first argument
- when the argument is displayed you see immediatly wether it's an
emacs regexp or one using another engine
- the regexp is clearly separated from it's kind, probably faciliting
convertions
- seems more "open", in the sense we can easily imagine new types
('emacs, 'pcre', 'rx, 'sed, 'vim-verymagic, etc)
- Special text property on the string
- Not immediatly visible that it is a PCRE regexp
- Harder to manipulate?
Given this I'm in favor of the 2nd option, but maybe I missed some points.
Philippe
[-- Attachment #2: Type: text/html, Size: 2320 bytes --]
next prev parent reply other threads:[~2019-02-15 15:03 UTC|newest]
Thread overview: 57+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-06-16 16:37 modern regexes in emacs Perry E. Metzger
2018-06-16 17:45 ` Radon Rosborough
2018-06-16 18:25 ` Perry E. Metzger
2018-06-16 21:01 ` Daniel Colascione
2018-06-16 22:31 ` Jay Kamat
2019-02-09 17:20 ` Philippe Vaucher
2019-02-10 9:39 ` Elias Mårtenson
2019-02-11 22:12 ` Mattias Engdegård
2019-02-15 13:42 ` Philippe Vaucher
2019-02-15 14:10 ` Clément Pit-Claudel
2019-02-15 15:03 ` Philippe Vaucher [this message]
2019-02-15 15:13 ` Clément Pit-Claudel
2019-02-15 14:18 ` Eli Zaretskii
2019-02-15 15:28 ` Perry E. Metzger
2019-02-15 16:06 ` Stefan Monnier
2019-02-15 16:24 ` Mattias Engdegård
2019-02-15 16:47 ` Perry E. Metzger
2019-02-15 17:54 ` Alan Mackenzie
2019-02-15 18:27 ` Drew Adams
2019-02-15 23:33 ` Perry E. Metzger
2019-02-16 0:34 ` Jay Kamat
2019-02-16 1:46 ` Perry E. Metzger
2019-02-16 2:44 ` Jay Kamat
2019-02-15 18:36 ` Eli Zaretskii
2019-02-15 18:43 ` Mattias Engdegård
2019-02-15 19:48 ` Eli Zaretskii
2019-02-17 3:17 ` Richard Stallman
2019-02-25 14:47 ` Lars Ingebrigtsen
2019-02-25 15:46 ` Clément Pit-Claudel
2019-02-26 2:57 ` Richard Stallman
2019-02-26 12:39 ` Lars Ingebrigtsen
2019-02-26 13:24 ` Troy Hinckley
2019-02-26 13:32 ` Lars Ingebrigtsen
2019-02-26 14:33 ` Andreas Schwab
2019-02-27 12:09 ` Mattias Engdegård
2019-02-27 18:18 ` Daniel Pittman
2019-02-26 15:29 ` Eli Zaretskii
2019-02-27 4:08 ` Richard Stallman
2019-02-26 3:47 ` Elias Mårtenson
2019-02-26 12:00 ` Mattias Engdegård
2019-02-15 23:35 ` Perry E. Metzger
2019-02-17 20:01 ` Juri Linkov
2019-02-18 0:38 ` Stefan Monnier
2019-02-15 18:46 ` Clément Pit-Claudel
2019-02-15 19:52 ` Eli Zaretskii
2019-02-15 20:08 ` Clément Pit-Claudel
2019-02-15 19:14 ` Alan Mackenzie
2019-02-15 20:00 ` Eli Zaretskii
2019-02-15 20:40 ` Alan Mackenzie
2019-02-15 23:33 ` Perry E. Metzger
2019-02-15 18:44 ` Clément Pit-Claudel
2019-02-15 19:37 ` Stefan Monnier
2019-02-19 12:29 ` Van L
2019-02-17 20:47 ` Stefan Monnier
2019-02-18 8:40 ` Philippe Vaucher
2019-02-18 8:55 ` Mattias Engdegård
-- strict thread matches above, loose matches on Subject: below --
2018-06-16 21:33 Jimmy Yuen Ho Wong
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://www.gnu.org/software/emacs/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to='CAGK7Mr5szEF6oB3h8RcjudW=4zNTqNhZDpnw1Q7GKMWkkzdMjw@mail.gmail.com' \
--to=philippe.vaucher@gmail.com \
--cc=cpitclaudel@gmail.com \
--cc=emacs-devel@gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://git.savannah.gnu.org/cgit/emacs.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).