all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: "Štěpán Němec" <stepnem@gmail.com>
To: 9183@debbugs.gnu.org
Subject: bug#9183: js-mode highlights quotes inside regexp character sets as string
Date: Sat, 06 Aug 2011 13:34:17 +0200	[thread overview]
Message-ID: <87vcua3hae.fsf@gmail.com> (raw)
In-Reply-To: <jwvaabnst43.fsf-monnier+emacs@gnu.org> (Stefan Monnier's message of "Fri, 05 Aug 2011 12:54:45 -0400")

reopen 9183
thanks

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:

    /[']/.test(str);
    /ahoj/.test(str);
    /[']/.test(str);
    /[']/.test(str);

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

(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
instance:
https://developer.mozilla.org/en/JavaScript/Reference/Operators

-- 
Štěpán





  reply	other threads:[~2011-08-06 11:34 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-07-27 19:27 bug#9183: js-mode highlights quotes inside regexp character sets as string Štěpán Němec
2011-08-05 16:54 ` Stefan Monnier
2011-08-06 11:34   ` Štěpán Němec [this message]
2011-08-12 15:48     ` Stefan Monnier
2011-08-12 16:47       ` Daniel Colascione
2011-08-12 17:25       ` Štěpán Němec

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=87vcua3hae.fsf@gmail.com \
    --to=stepnem@gmail.com \
    --cc=9183@debbugs.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.