[Top][All Lists]

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

bug#9183: js-mode highlights quotes inside regexp character sets as stri

From: Štěpán Němec
Subject: bug#9183: js-mode highlights quotes inside regexp character sets as string
Date: Sat, 06 Aug 2011 13:34:17 +0200
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/24.0.50 (gnu/linux)

reopen 9183

On Fri, 05 Aug 2011 18:54:45 +0200
Stefan Monnier wrote:

>> The following is valid JavaScript:
>> /[']/.test(str)
>> js-mode erroneously highlights everything following `'' as a string.
>> Same problem with `"'.
> I installed the patch below which should fix this case and a few
> others.

Thanks, but it doesn't seem to fix anything, just mess things up in a
somewhat different way.

E.g., with the following in a JS buffer:


All of the first /[']/ is highlighted as a string, and everything from
the second single quote up to the third single quote is highlighted as a

(Just in case, I downloaded the fixed js.el and loaded that with my
oldish Emacs 24 (started as emacs -Q), but I don't think that should
matter, right?)

> But I don't know how to solve it completely because I don't know
> Javascript enough to be sure exactly how to distinguish a /-division
> from a /-regexp from a /-comment-starter in all cases:
> - is something like
>     x = 1 + /a/.test("foo");
>   valid?

Yes, it's valid, although I suspect it would be considered bad style.

(BTW, in Debian there is a spidermonkey-bin package, which has minimal
dependencies and provides a `js' command, giving you a REPL.)

> If so, is there a list of infix operators somewhere?

I'd have to search for it just as you might have... There's this, for


reply via email to

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