emacs-bug-tracker
[Top][All Lists]
Advanced

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

[Emacs-bug-tracker] bug#9183: closed (js-mode highlights quotes inside r


From: GNU bug Tracking System
Subject: [Emacs-bug-tracker] bug#9183: closed (js-mode highlights quotes inside regexp character sets as string)
Date: Sat, 06 Aug 2011 03:13:02 +0000

Your message dated Fri, 05 Aug 2011 12:54:45 -0400
with message-id <address@hidden>
and subject line Re: bug#9183: js-mode highlights quotes inside regexp 
character sets as string
has caused the GNU bug report #9183,
regarding js-mode highlights quotes inside regexp character sets as string
to be marked as done.

(If you believe you have received this mail in error, please contact
address@hidden)


-- 
9183: http://debbugs.gnu.org/cgi/bugreport.cgi?bug=9183
GNU Bug Tracking System
Contact address@hidden with problems
--- Begin Message --- Subject: js-mode highlights quotes inside regexp character sets as string Date: Wed, 27 Jul 2011 21:27:34 +0200
The following is valid JavaScript:

/[']/.test(str)

js-mode erroneously highlights everything following `'' as a string.
Same problem with `"'.

-- 
Štěpán



--- End Message ---
--- Begin Message --- Subject: Re: bug#9183: js-mode highlights quotes inside regexp character sets as string Date: Fri, 05 Aug 2011 12:54:45 -0400 User-agent: Gnus/5.13 (Gnus v5.13) Emacs/24.0.50 (gnu/linux)
> 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.
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?  If so, is there a list of infix operators somewhere?

- I'm giving up on handling a /regexp/ that immediately follows an
  implicit semicolon.


        Stefan


=== modified file 'lisp/progmodes/js.el'
--- lisp/progmodes/js.el        2011-06-30 16:22:33 +0000
+++ lisp/progmodes/js.el        2011-08-05 16:52:20 +0000
@@ -1658,15 +1658,19 @@
 ;; below.
 (eval-and-compile
   (defconst js--regexp-literal
-    
"[=(,:]\\(?:\\s-\\|\n\\)*\\(/\\)\\(?:\\\\.\\|[^/*\\]\\)\\(?:\\\\.\\|[^/\\]\\)*\\(/\\)"
+    (concat
+     ;; We want to match regular expressions only at the beginning of
+     ;; expressions.
+     ;; FIXME: Should we also allow /regexp/ after infix operators such as +,
+     ;; /, -, *, >, ...?
+     "\\(?:\\`\\|[=([{,:;]\\)\\(?:\\s-\\|\n\\)*"
+     "\\(/\\)\\(?:\\\\.\\|[^/*\\]\\)\\(?:\\\\.\\|[^/\\]\\)*\\(/\\)")
   "Regexp matching a JavaScript regular expression literal.
 Match groups 1 and 2 are the characters forming the beginning and
 end of the literal."))
 
 (defconst js-syntax-propertize-function
   (syntax-propertize-rules
-   ;; We want to match regular expressions only at the beginning of
-   ;; expressions.
    (js--regexp-literal (1 "\"") (2 "\""))))
 
 ;;; Indentation



--- End Message ---

reply via email to

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