[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
bug#25529: diagnosis and one approach to a fix
From: |
Tom Tromey |
Subject: |
bug#25529: diagnosis and one approach to a fix |
Date: |
Sun, 05 Feb 2017 11:05:45 -0700 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/25.1.91 (gnu/linux) |
Tom> I've appended a patch implementing this idea.
Another way is to use a regexp, see appended.
I'll try to write a test for this soon.
Tom
diff --git a/lisp/progmodes/js.el b/lisp/progmodes/js.el
index e42e014..2b4ae8e 100644
--- a/lisp/progmodes/js.el
+++ b/lisp/progmodes/js.el
@@ -1694,22 +1694,32 @@ js--syntax-propertize-regexp-syntax-table
(modify-syntax-entry ?\\ "\\" st)
st))
+(defconst js--syntax-propertize-regexp-regexp
+ (rx
+ ;; Start of regexp.
+ "/"
+ (0+ (or
+ ;; Match characters outside of a character class.
+ (not (any ?\[ ?/ ?\\))
+ ;; Match backslash quoted characters.
+ (and "\\" not-newline)
+ ;; Match character class.
+ (and
+ "["
+ (0+ (or
+ (not (any ?\] ?\\))
+ (and "\\" not-newline)))
+ "]")))
+ (group "/")))
+
(defun js-syntax-propertize-regexp (end)
(let ((ppss (syntax-ppss)))
(when (eq (nth 3 ppss) ?/)
;; A /.../ regexp.
- (while
- (when (re-search-forward "\\(?:\\=\\|[^\\]\\)\\(?:\\\\\\\\\\)*/"
- end 'move)
- (if (nth 1 (with-syntax-table
- js--syntax-propertize-regexp-syntax-table
- (let ((parse-sexp-lookup-properties nil))
- (parse-partial-sexp (nth 8 ppss) (point)))))
- ;; A / within a character class is not the end of a regexp.
- t
- (put-text-property (1- (point)) (point)
- 'syntax-table (string-to-syntax "\"/"))
- nil))))))
+ (goto-char (nth 8 ppss))
+ (when (looking-at js--syntax-propertize-regexp-regexp)
+ (put-text-property (match-beginning 1) (match-end 1)
+ 'syntax-table (string-to-syntax "\"/"))))))
(defun js-syntax-propertize (start end)
;; JavaScript allows immediate regular expression objects, written /.../.
- bug#25529: diagnosis and one approach to a fix, Tom Tromey, 2017/02/05
- bug#25529: diagnosis and one approach to a fix, Tom Tromey, 2017/02/05
- bug#25529: diagnosis and one approach to a fix,
Tom Tromey <=
- bug#25529: diagnosis and one approach to a fix, Tom Tromey, 2017/02/05
- bug#25529: diagnosis and one approach to a fix, Dmitry Gutov, 2017/02/05
- bug#25529: diagnosis and one approach to a fix, Tom Tromey, 2017/02/06
- bug#25529: diagnosis and one approach to a fix, Dmitry Gutov, 2017/02/06
- bug#25529: diagnosis and one approach to a fix, Tom Tromey, 2017/02/07
- bug#25529: diagnosis and one approach to a fix, Dmitry Gutov, 2017/02/07
- bug#25529: diagnosis and one approach to a fix, Stefan Monnier, 2017/02/07
- bug#25529: diagnosis and one approach to a fix, Tom Tromey, 2017/02/10
- bug#25529: diagnosis and one approach to a fix, Stefan Monnier, 2017/02/10
- bug#25529: diagnosis and one approach to a fix, Tom Tromey, 2017/02/10