diff options
author | Jackson Ray Hamilton <jackson@jacksonrayhamilton.com> | 2019-04-08 20:01:13 -0700 |
---|---|---|
committer | Jackson Ray Hamilton <jackson@jacksonrayhamilton.com> | 2019-04-08 22:48:25 -0700 |
commit | 9545519572d47b4712f27e53e7b64bf88d473877 (patch) | |
tree | a4e5bc0d1f15db2d22b699994c6440d97160f9e8 | |
parent | 18bbfc4c754ea653ee0a7e2e47d1d61304f5c42a (diff) | |
download | emacs-9545519572d47b4712f27e53e7b64bf88d473877.tar.gz |
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.
-rw-r--r-- | lisp/progmodes/js.el | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/lisp/progmodes/js.el b/lisp/progmodes/js.el index 9185371b523..1cec41d9270 100644 --- a/lisp/progmodes/js.el +++ b/lisp/progmodes/js.el @@ -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 JSXBoundaryElement’s name’s 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. |