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

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

bug#26070: 26.0.50; js-mode slash insertion bug


From: Dmitry Gutov
Subject: bug#26070: 26.0.50; js-mode slash insertion bug
Date: Tue, 14 Mar 2017 07:56:35 +0200
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.0

On 13.03.2017 15:50, Tom Tromey wrote:

I think once js-syntax-propertize is called, the regexp should always
succeed, so this patch makes the trailing "/" optional.

Does it solve the infloop in the case like:

/x[

as well?

If not, I think the following is a better patch (could use some tweaking, probably):

diff --git a/lisp/progmodes/js.el b/lisp/progmodes/js.el
index aed42a8..d9e6ef3 100644
--- a/lisp/progmodes/js.el
+++ b/lisp/progmodes/js.el
@@ -1721,12 +1721,14 @@ js-syntax-propertize-regexp
     (when (eq (nth 3 ppss) ?/)
       ;; A /.../ regexp.
       (goto-char (nth 8 ppss))
-      (when (and (looking-at js--syntax-propertize-regexp-regexp)
-                 ;; Don't touch text after END.
-                 (<= (match-end 1) end))
-        (put-text-property (match-beginning 1) (match-end 1)
-                           'syntax-table (string-to-syntax "\"/"))
-        (goto-char (match-end 0))))))
+      (if (and (looking-at js--syntax-propertize-regexp-regexp)
+               ;; Don't touch text after END.
+               (<= (match-end 1) end))
+          (progn
+            (put-text-property (match-beginning 1) (match-end 1)
+                               'syntax-table (string-to-syntax "\"/"))
+            (goto-char (match-end 0)))
+        (goto-char (1+ (match-beginning 0)))))))

 (defun js-syntax-propertize (start end)
;; JavaScript allows immediate regular expression objects, written /.../.





reply via email to

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