From: "St/n_P/rm/n" <Stan@SandPframing.com>
To: emacs-devel@gnu.org
Subject: regexp-quote missing escapes in grouping constructs - Bug?
Date: Thu, 12 Jun 2008 19:39:12 -0400 [thread overview]
Message-ID: <d2afcfda0806121639g2d7a9762kf84edc9372645dd1@mail.gmail.com> (raw)
(regexp-quote "[0-9]\{2,4\}\(-\|/\)[0-9]?+\(-\|/\)[0-9]\{2,4\}")
---> "\\[0-9]{2,4}(-|/)\\[0-9]\\?\\+(-|/)\\[0-9]{2,4}"
Am I misunderstanding something?
Shouldn't passing that string to regexp-quote give back something more
like this:
---> "[0-9]\\{2,4\\}\\(-\\|/\\)[0-9]?+(-\\|/)[0-9]\\{2,4\\}"
or *flinches at the thought*
---> "[0-9]\\\\{2,4\\\\}\\\\(-\\\\|/\\\\)[0-9]?+(-\\\\|/)[0-9]\\\\{2,4\\\\}"
-
Its possible that I am misunderstanding the function, and I'd rather
not file this as a bug report b/c I am using a Lennart's recent W32
patched...
GNU Emacs 23.0.60.1 (i386-mingw-nt5.1.2600)
of 2008-05-12 on LENNART-69DE564 (patched)
However, currently building a derived mode and the regexp-opt and
-quote are kinda required, esp. as there doesn't seem to be a clean
way to avoid passing everything around through multiple instances of
defconst defvar defcustom etc. just to "cache" keyword regexes for
font-lock
---
I find the following two most relevant to the matter at hand.
case a)
We get the requisite lisp reader 4x \\\\ for the group construct , but
the function not only misses the interior alternative escape but omits
it e.g.
(regexp-quote "\\(123\|567\\)")
---> "\\\\(123|567\\\\)"
case b)
In contrast, when we give him enough the double escape "\\" inside the
group he DOES catch the the escape and gives us 4x the \
(regexp-quote "\\(123\\|567\\)")
---> "\\\\(123\\\\|567\\\\)"
---
This doesn't seem like consistent behavior esp. as regexp-quote is
feeding regexp-opt elsewhere.
---
These others examples do not strike me as edge cases when
'manually-optimizing' a regex for font-locks:
(regexp-quote "\(123\|567\)")
---> "(123|567)"
(regexp-quote `(,"\(123\|567\)")
---> ("(123|567)")
(regexp-quote '("\(123|567\)")
---> ("(123|567)")
(regexp-quote "(123|567)")
---> "(123|567)"
(regexp-quote '"(123|567)")
---> "(123|567)"
---
again, maybe I am missing something but my head hurts... despite
having really come to appreciate emacs regexps :)
next reply other threads:[~2008-06-12 23:39 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-06-12 23:39 St/n_P/rm/n [this message]
2008-06-13 6:17 ` regexp-quote missing escapes in grouping constructs - Bug? Miles Bader
2008-06-13 17:36 ` MON KEY
2008-06-13 22:21 ` Stefan Monnier
2008-06-14 4:16 ` tomas
2008-06-13 6:20 ` Herbert Euler
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
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=d2afcfda0806121639g2d7a9762kf84edc9372645dd1@mail.gmail.com \
--to=stan@sandpframing.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 external index
https://git.savannah.gnu.org/cgit/emacs.git
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.