[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Emacs-diffs] master 3eadf1e 24/28: Identify JSX strings (for js2-mode)
From: |
Jackson Ray Hamilton |
Subject: |
[Emacs-diffs] master 3eadf1e 24/28: Identify JSX strings (for js2-mode) |
Date: |
Tue, 9 Apr 2019 02:00:16 -0400 (EDT) |
branch: master
commit 3eadf1eff43c84a1095094334549a1e0d1e75d80
Author: Jackson Ray Hamilton <address@hidden>
Commit: Jackson Ray Hamilton <address@hidden>
Identify JSX strings (for js2-mode)
* lisp/progmodes/js.el (js-jsx--syntax-propertize-tag): Derived modes
like js2-mode may use font-lock-syntactic-face-function to apply faces
to JSX strings (and only JSX strings). Apply the js-jsx-string text
property to such strings so they can be distinctly identified.
(js-jsx--text-properties): Ensure the js-jsx-string text property gets
cleaned up, too.
---
lisp/progmodes/js.el | 13 +++++++++----
1 file changed, 9 insertions(+), 4 deletions(-)
diff --git a/lisp/progmodes/js.el b/lisp/progmodes/js.el
index a1de3ef..b1068bf 100644
--- a/lisp/progmodes/js.el
+++ b/lisp/progmodes/js.el
@@ -2165,9 +2165,14 @@ testing for syntax only valid as JSX."
;; JSXExpressionContainer here will be parsed in the
;; next iteration of the loop.
(if (memq (char-after) '(?\" ?\' ?\`))
- (condition-case nil
- (forward-sexp)
- (scan-error (throw 'stop nil)))
+ (progn
+ ;; Record the string’s position so derived modes
+ ;; applying syntactic fontification atypically
+ ;; (e.g. js2-mode) can recognize it as part of JSX.
+ (put-text-property (point) (1+ (point)) 'js-jsx-string t)
+ (condition-case nil
+ (forward-sexp)
+ (scan-error (throw 'stop nil))))
;; Save JSXAttribute’s beginning in case we find a
;; JSXExpressionContainer as the JSXAttribute’s value which
;; we should associate with the JSXAttribute.
@@ -2195,7 +2200,7 @@ testing for syntax only valid as JSX."
(defconst js-jsx--text-properties
(list
'js-jsx-tag-beg nil 'js-jsx-tag-end nil 'js-jsx-close-tag-pos nil
- 'js-jsx-tag-name nil 'js-jsx-attribute-name nil
+ 'js-jsx-tag-name nil 'js-jsx-attribute-name nil 'js-jsx-string nil
'js-jsx-text nil 'js-jsx-expr nil 'js-jsx-expr-attribute nil)
"Plist of text properties added by `js-syntax-propertize'.")
- [Emacs-diffs] master updated (e1872f8 -> cf416d9), Jackson Ray Hamilton, 2019/04/09
- [Emacs-diffs] master 27e9bce 03/28: Add new (failing) unclosed JSX test and separate such tests, Jackson Ray Hamilton, 2019/04/09
- [Emacs-diffs] master 2bedd23 09/28: Update expectations for JSX indentation in JSXAttribute space, Jackson Ray Hamilton, 2019/04/09
- [Emacs-diffs] master 16669d7 16/28: Fix counting of nested self-closing JSXOpeningElements, Jackson Ray Hamilton, 2019/04/09
- [Emacs-diffs] master 52a3113 06/28: Add basic JSX font-locking, Jackson Ray Hamilton, 2019/04/09
- [Emacs-diffs] master 339be7c 11/28: Finish replacing SGML-based JSX detection with js-mode’s parsing, Jackson Ray Hamilton, 2019/04/09
- [Emacs-diffs] master 8dae742 08/28: Propertize and font-lock JSXText and JSXExpressionContainers, Jackson Ray Hamilton, 2019/04/09
- [Emacs-diffs] master 3eadf1e 24/28: Identify JSX strings (for js2-mode),
Jackson Ray Hamilton <=
- [Emacs-diffs] master 4b305bb 02/28: Refactor JSX indentation code to improve enclosing JSX discovery, Jackson Ray Hamilton, 2019/04/09
- [Emacs-diffs] master 58c77f1 01/28: Add failing tests for JSX indentation bugs, Jackson Ray Hamilton, 2019/04/09
- [Emacs-diffs] master 4d2b5bb 07/28: Font-lock JSX while editing it by extending regions, Jackson Ray Hamilton, 2019/04/09
- [Emacs-diffs] master 462baab 19/28: Add tests for miscellaneous JSX parsing feats, Jackson Ray Hamilton, 2019/04/09
- [Emacs-diffs] master be86ece 04/28: js-syntax-propertize: Disambiguate JS from JSX, fixing some indents, Jackson Ray Hamilton, 2019/04/09
- [Emacs-diffs] master d9d1bb2 14/28: Rename tests to use the “.jsx” file extension, Jackson Ray Hamilton, 2019/04/09
- [Emacs-diffs] master 84b1cfb 15/28: Indent broken arrow function bodies as an N+1th arg, Jackson Ray Hamilton, 2019/04/09
- [Emacs-diffs] master 6f53576 05/28: Use js-jsx- prefix for functions and variables, Jackson Ray Hamilton, 2019/04/09
- [Emacs-diffs] master bf37078 12/28: Automatically detect JSX in JavaScript files, Jackson Ray Hamilton, 2019/04/09
- [Emacs-diffs] master cf416d9 28/28: Explain reasonings for JSX syntax support design decisions, Jackson Ray Hamilton, 2019/04/09