Add open/close parenthesis syntax to “<” and “>” in JSX

* lisp/progmodes/js.el (js-jsx--syntax-propertize-tag): Like in
sgml-mode, treat “<” and “>” like open/close parenthesis, making the
text more navigable via forward-sexp, etc.
This commit is contained in:
Jackson Ray Hamilton 2019-04-08 20:01:13 -07:00
parent 18bbfc4c75
commit 9545519572
No known key found for this signature in database
GPG key ID: B4771664B476B290

View file

@ -2099,6 +2099,8 @@ testing for syntax only valid as JSX."
(< (point) end)))
(cond
((= (char-after) ?>)
;; Make the closing “>” a close parenthesis.
(put-text-property (point) (1+ (point)) 'syntax-table '(5))
(forward-char)
(setq unambiguous t)
(throw 'stop nil))
@ -2183,6 +2185,8 @@ testing for syntax only valid as JSX."
(when unambiguous
;; Save JSXBoundaryElements names match data for font-locking.
(if name-beg (put-text-property name-beg (1+ name-beg) 'js-jsx-tag-name name-match-data))
;; Make the opening “<” an open parenthesis.
(put-text-property tag-beg (1+ tag-beg) 'syntax-table '(4))
;; Prevent “out of range” errors when typing at the end of a buffer.
(setq tag-end (if (eobp) (1- (point)) (point)))
;; Mark beginning and end of tag for font-locking.