aboutsummaryrefslogtreecommitdiffstats
path: root/lisp/progmodes
diff options
context:
space:
mode:
authorTom Tromey2017-03-13 21:53:59 +0100
committerTom Tromey2017-04-01 15:03:46 -0600
commitf4ecb65f335e450dfa8f0ee8a496ac78cbbfdc51 (patch)
treef5cdc92819df4b3e7994f369dc81657ee0bb0692 /lisp/progmodes
parentac2ca82eb19bbf7f1cac7ec3f6c020ebf2b15882 (diff)
downloademacs-f4ecb65f335e450dfa8f0ee8a496ac78cbbfdc51.tar.gz
emacs-f4ecb65f335e450dfa8f0ee8a496ac78cbbfdc51.zip
fix two js-mode syntax propertization bugs
Bug#26070: * lisp/progmodes/js.el (js--syntax-propertize-regexp-regexp): Add zero-or-one to regular expression. (js-syntax-propertize-regexp): Update. Propertize body of regexp literal up to END. * test/lisp/progmodes/js-tests.el (js-mode-propertize-bug-1) (js-mode-propertize-bug-2): New tests.
Diffstat (limited to 'lisp/progmodes')
-rw-r--r--lisp/progmodes/js.el13
1 files changed, 7 insertions, 6 deletions
diff --git a/lisp/progmodes/js.el b/lisp/progmodes/js.el
index aed42a85076..3c720c05610 100644
--- a/lisp/progmodes/js.el
+++ b/lisp/progmodes/js.el
@@ -1713,7 +1713,7 @@ This performs fontification according to `js--class-styles'."
1713 (not (any ?\] ?\\)) 1713 (not (any ?\] ?\\))
1714 (and "\\" not-newline))) 1714 (and "\\" not-newline)))
1715 "]"))) 1715 "]")))
1716 (group "/")) 1716 (group (zero-or-one "/")))
1717 "Regular expression matching a JavaScript regexp literal.") 1717 "Regular expression matching a JavaScript regexp literal.")
1718 1718
1719(defun js-syntax-propertize-regexp (end) 1719(defun js-syntax-propertize-regexp (end)
@@ -1721,12 +1721,13 @@ This performs fontification according to `js--class-styles'."
1721 (when (eq (nth 3 ppss) ?/) 1721 (when (eq (nth 3 ppss) ?/)
1722 ;; A /.../ regexp. 1722 ;; A /.../ regexp.
1723 (goto-char (nth 8 ppss)) 1723 (goto-char (nth 8 ppss))
1724 (when (and (looking-at js--syntax-propertize-regexp-regexp) 1724 (when (looking-at js--syntax-propertize-regexp-regexp)
1725 ;; Don't touch text after END. 1725 ;; Don't touch text after END.
1726 (<= (match-end 1) end)) 1726 (when (> end (match-end 1))
1727 (put-text-property (match-beginning 1) (match-end 1) 1727 (setq end (match-end 1)))
1728 (put-text-property (match-beginning 1) end
1728 'syntax-table (string-to-syntax "\"/")) 1729 'syntax-table (string-to-syntax "\"/"))
1729 (goto-char (match-end 0)))))) 1730 (goto-char end)))))
1730 1731
1731(defun js-syntax-propertize (start end) 1732(defun js-syntax-propertize (start end)
1732 ;; JavaScript allows immediate regular expression objects, written /.../. 1733 ;; JavaScript allows immediate regular expression objects, written /.../.