unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
* bug#7882: 24.0.50; Bad regexp for javascript regexps
@ 2011-01-21 17:50 Harald Hanche-Olsen
  2011-01-21 20:50 ` Stefan Monnier
       [not found] ` <handler.7882.D7882.129564255010562.notifdone@debbugs.gnu.org>
  0 siblings, 2 replies; 3+ messages in thread
From: Harald Hanche-Olsen @ 2011-01-21 17:50 UTC (permalink / raw)
  To: 7882

Put the following four line code snippet in a new buffer:

replace(/\\/g,something);
// Now we're in trouble:
// Still in trouble.
// And all's well again.

and activate js-mode and font-lock-mode.

The syntax colouring is now off: The code starting with the first
slash on the first line and ending with the first slash on the second
line is coloured as a regexp; now the syntax highlighter is unaware
that we are in a comment, and reads the single quote as the start of a
string. After the second single quote things return to normal.

The problem seems to lie with the constant js--regexp-literal declared
in js.el, as this regexp does not treat backslashes with sufficient care.

In GNU Emacs 24.0.50.1 (x86_64-apple-darwin10.5.0, NS apple-appkit-1038.35)
 of 2010-12-27 on mack
Windowing system distributor `Apple', version 10.3.1038
configured using `configure  '--with-ns''

- Harald





^ permalink raw reply	[flat|nested] 3+ messages in thread

* bug#7882: 24.0.50; Bad regexp for javascript regexps
  2011-01-21 17:50 bug#7882: 24.0.50; Bad regexp for javascript regexps Harald Hanche-Olsen
@ 2011-01-21 20:50 ` Stefan Monnier
       [not found] ` <handler.7882.D7882.129564255010562.notifdone@debbugs.gnu.org>
  1 sibling, 0 replies; 3+ messages in thread
From: Stefan Monnier @ 2011-01-21 20:50 UTC (permalink / raw)
  To: Harald Hanche-Olsen; +Cc: 7882-done

> replace(/\\/g,something);

Thanks, I've installed the patch below into the emacs-23 branch which
should fix this problem.  The highlighting is not reliable when the
regexp spans multiple lines, tho, so I wonder: are multi-line regexps
valid? common? important?


        Stefan





^ permalink raw reply	[flat|nested] 3+ messages in thread

* bug#7882: closed
       [not found] ` <handler.7882.D7882.129564255010562.notifdone@debbugs.gnu.org>
@ 2011-01-21 21:16   ` Harald Hanche-Olsen
  0 siblings, 0 replies; 3+ messages in thread
From: Harald Hanche-Olsen @ 2011-01-21 21:16 UTC (permalink / raw)
  To: 7882, help-debbugs

I have no idea how common or important multiline regexps are in
javascript. As far as I am concerned, if it's difficult to match them
reliably, maybe one shouldn't even try. Though that has its own
dangers: Namely, stuff inside an unmatched regexp triggering
inappropriate syntax highlighting. So perhaps we should stick with
doing the best we can, anyhow.

- Harald





^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2011-01-21 21:16 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-01-21 17:50 bug#7882: 24.0.50; Bad regexp for javascript regexps Harald Hanche-Olsen
2011-01-21 20:50 ` Stefan Monnier
     [not found] ` <handler.7882.D7882.129564255010562.notifdone@debbugs.gnu.org>
2011-01-21 21:16   ` bug#7882: closed Harald Hanche-Olsen

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