From a2c77d6f92137fc087a074642da5f09f48936946 Mon Sep 17 00:00:00 2001 From: Jackson Ray Hamilton Date: Sun, 7 Apr 2019 18:49:18 -0700 Subject: [PATCH 01/12] Fix casing of mode name --- js2-mode.el | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/js2-mode.el b/js2-mode.el index d9cea032..21cccc9d 100644 --- a/js2-mode.el +++ b/js2-mode.el @@ -11704,7 +11704,7 @@ Selecting an error will jump it to the corresponding source-buffer error. (message msg)))))) ;;;###autoload -(define-derived-mode js2-mode js-mode "Javascript-IDE" +(define-derived-mode js2-mode js-mode "JavaScript-IDE" "Major mode for editing JavaScript code." (set (make-local-variable 'max-lisp-eval-depth) (max max-lisp-eval-depth 3000)) From aa8a8d66fc242f25c57a8a21925d4f0a6735cd7b Mon Sep 17 00:00:00 2001 From: Jackson Ray Hamilton Date: Sun, 7 Apr 2019 19:56:20 -0700 Subject: [PATCH 02/12] Properly initialize mode name and JSX in Emacs >=27 --- js2-mode.el | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/js2-mode.el b/js2-mode.el index 21cccc9d..2939a4e3 100644 --- a/js2-mode.el +++ b/js2-mode.el @@ -11750,6 +11750,11 @@ Selecting an error will jump it to the corresponding source-buffer error. (when js2-include-jslint-declaration-externs (add-hook 'js2-post-parse-callbacks 'js2-apply-jslint-declaration-externs nil t)) + ;; In Emacs >=27, in order to see enabled syntaxes (like “[JSX]”) in the + ;; modeline, we need to first call this function. + (when (fboundp 'js-use-syntactic-mode-name) + (js-use-syntactic-mode-name)) + (run-hooks 'js2-init-hook) (let ((js2-idle-timer-delay 0)) @@ -11768,7 +11773,12 @@ variables (`sgml-basic-offset' et al) locally, like so: (defun set-jsx-indentation () (setq-local sgml-basic-offset js2-basic-offset)) (add-hook \\='js2-jsx-mode-hook #\\='set-jsx-indentation)" - (set (make-local-variable 'indent-line-function) #'js2-jsx-indent-line)) + (if (version< emacs-version "27.0") + (set (make-local-variable 'indent-line-function) #'js2-jsx-indent-line) + (js-jsx-enable) + ;; Use the standard name because a syntactic part will be appended. + (setq mode-name "JavaScript-IDE") + (js-use-syntactic-mode-name))) (defun js2-mode-exit () "Exit `js2-mode' and clean up." From 596efa7b07232a3cdef26c8082e3687d8cfe3d55 Mon Sep 17 00:00:00 2001 From: Jackson Ray Hamilton Date: Sun, 7 Apr 2019 19:58:15 -0700 Subject: [PATCH 03/12] Update JSX documentation --- js2-mode.el | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/js2-mode.el b/js2-mode.el index 2939a4e3..8efba5c3 100644 --- a/js2-mode.el +++ b/js2-mode.el @@ -49,7 +49,7 @@ ;; ;; To install it as your major mode for JavaScript editing: -;; (add-to-list 'auto-mode-alist '("\\.js\\'" . js2-mode)) +;; (add-to-list 'auto-mode-alist '("\\.jsx?\\'" . js2-mode)) ;; Alternatively, to install it as a minor mode just for JavaScript linting, ;; you must add it to the appropriate major-mode hook. Normally this would be: @@ -60,8 +60,10 @@ ;; (add-to-list 'interpreter-mode-alist '("node" . js2-mode)) -;; Support for JSX is available via the derived mode `js2-jsx-mode'. If you -;; also want JSX support, use that mode instead: +;; Support for JSX is also available. In Emacs 27, support for the syntax will +;; be automatically enabled in buffers using it and in ".jsx" files. For Emacs +;; versions prior to 27, support is only available via the derived mode +;; `js2-jsx-mode'; if you want JSX support in Emacs <27, use that mode instead: ;; (add-to-list 'auto-mode-alist '("\\.jsx?\\'" . js2-jsx-mode)) ;; (add-to-list 'interpreter-mode-alist '("node" . js2-jsx-mode)) @@ -11761,14 +11763,14 @@ Selecting an error will jump it to the corresponding source-buffer error. ;; Schedule parsing for after when the mode hooks run. (js2-mode-reset-timer))) -;; We may eventually want js2-jsx-mode to derive from js-jsx-mode, but that'd be -;; a bit more complicated and it doesn't net us much yet. ;;;###autoload (define-derived-mode js2-jsx-mode js2-mode "JSX-IDE" - "Major mode for editing JSX code. + "Major mode for editing JavaScript+JSX code. -To customize the indentation for this mode, set the SGML offset -variables (`sgml-basic-offset' et al) locally, like so: +This is like `js-jsx-mode', which see. + +In Emacs versions prior to 27, customize indentation by setting +`sgml-basic-offset' locally, like so: (defun set-jsx-indentation () (setq-local sgml-basic-offset js2-basic-offset)) From 477284bd43676ce4ad0cb7119145af32b7f4ffaf Mon Sep 17 00:00:00 2001 From: Jackson Ray Hamilton Date: Sun, 7 Apr 2019 21:26:10 -0700 Subject: [PATCH 04/12] Use JSX syntax propertization and font-locking in Emacs 27 --- js2-mode.el | 31 +++++++++++++++++++++++++++++-- 1 file changed, 29 insertions(+), 2 deletions(-) diff --git a/js2-mode.el b/js2-mode.el index 8efba5c3..c1d0fb09 100644 --- a/js2-mode.el +++ b/js2-mode.el @@ -11705,6 +11705,31 @@ Selecting an error will jump it to the corresponding source-buffer error. (goto-char pos) (message msg)))))) +(eval-and-compile + (when (version< emacs-version "27.0") + ;; Prevent compilation errors: + (defvar js-jsx-syntax nil) + (defconst js-jsx--font-lock-keywords nil) + (defvar js-jsx--text-properties nil) + (defun js-jsx-enable ()) + (defun js-jsx--syntax-propertize-tag (_end)) + (defun js-use-syntactic-mode-name ()))) + +;; In Emacs >=27, this is needed for JSX indentation. +(defun js2-syntax-propertize (start end) + "Apply syntax properties from START to END." + (goto-char start) + (if js-jsx-syntax (remove-text-properties start end js-jsx--text-properties)) + (funcall + (syntax-propertize-rules + ("<" (0 (ignore (if js-jsx-syntax (js-jsx--syntax-propertize-tag end)))))) + (point) end)) + +;; In Emacs >=27, this is needed for JSX font-locking. +(defconst js2--font-lock-keywords + `(,@js-jsx--font-lock-keywords) + "Font lock keywords for `js2-mode'; see `font-lock-keywords'.") + ;;;###autoload (define-derived-mode js2-mode js-mode "JavaScript-IDE" "Major mode for editing JavaScript code." @@ -11712,7 +11737,8 @@ Selecting an error will jump it to the corresponding source-buffer error. (max max-lisp-eval-depth 3000)) (set (make-local-variable 'indent-line-function) #'js2-indent-line) (set (make-local-variable 'indent-region-function) #'js2-indent-region) - (set (make-local-variable 'syntax-propertize-function) nil) + (set (make-local-variable 'syntax-propertize-function) + (if (version< emacs-version "27.0") nil #'js2-syntax-propertize)) (set (make-local-variable 'comment-line-break-function) #'js2-line-break) (set (make-local-variable 'beginning-of-defun-function) #'js2-beginning-of-defun) (set (make-local-variable 'end-of-defun-function) #'js2-end-of-defun) @@ -11724,7 +11750,8 @@ Selecting an error will jump it to the corresponding source-buffer error. ;; needed for M-x rgrep, among other things (put 'js2-mode 'find-tag-default-function #'js2-mode-find-tag) - (setq font-lock-defaults '(nil t)) + (setq font-lock-defaults + (list (if (version< emacs-version "27.0") nil js2--font-lock-keywords) t)) ;; Experiment: make reparse-delay longer for longer files. (when (cl-plusp js2-dynamic-idle-timer-adjust) From a59c7b1c078f9814bbb52aa0fd37484f08973d68 Mon Sep 17 00:00:00 2001 From: Jackson Ray Hamilton Date: Mon, 8 Apr 2019 08:10:55 -0700 Subject: [PATCH 05/12] Syntactically fontify JSX --- js2-mode.el | 23 +++++++++++++++++++++-- 1 file changed, 21 insertions(+), 2 deletions(-) diff --git a/js2-mode.el b/js2-mode.el index c1d0fb09..c501eedf 100644 --- a/js2-mode.el +++ b/js2-mode.el @@ -11730,6 +11730,15 @@ Selecting an error will jump it to the corresponding source-buffer error. `(,@js-jsx--font-lock-keywords) "Font lock keywords for `js2-mode'; see `font-lock-keywords'.") +(defun js2-font-lock-syntactic-face-function (state) + "Return syntactic face given STATE." + ;; This mode parses and colors JS strings using its AST, but it does neither + ;; of those things for JSX strings. Until it does, fontify such strings in + ;; the typical `font-lock-syntactic-face-function' manner. + (when (and (nth 3 state) + (get-text-property (nth 8 state) 'js-jsx-string)) + font-lock-string-face)) + ;;;###autoload (define-derived-mode js2-mode js-mode "JavaScript-IDE" "Major mode for editing JavaScript code." @@ -11750,8 +11759,18 @@ Selecting an error will jump it to the corresponding source-buffer error. ;; needed for M-x rgrep, among other things (put 'js2-mode 'find-tag-default-function #'js2-mode-find-tag) - (setq font-lock-defaults - (list (if (version< emacs-version "27.0") nil js2--font-lock-keywords) t)) + (if (version< emacs-version "27.0") + ;; In the past, we didn’t want to fontify syntactically at all; strings + ;; and comments were only ever fontified using the AST. + (setq font-lock-defaults (list nil t)) + ;; JSX fontification in Emacs 27 is provided by syntactic font-locking, so + ;; we want to turn that on. We still only want to fontify JS strings and + ;; comments using the AST, but since JSX strings aren’t fontified by the AST + ;; yet, we fontify (only) those in `js2-font-lock-syntactic-face-function'. + (setq font-lock-defaults + (list js2--font-lock-keywords nil nil nil nil + '(font-lock-syntactic-face-function + . js2-font-lock-syntactic-face-function)))) ;; Experiment: make reparse-delay longer for longer files. (when (cl-plusp js2-dynamic-idle-timer-adjust) From 1f7e466a8509c16c87a4968ea8659d9136d4e082 Mon Sep 17 00:00:00 2001 From: Jackson Ray Hamilton Date: Tue, 9 Apr 2019 08:31:36 -0700 Subject: [PATCH 06/12] Clarify intents of functions --- js2-mode.el | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/js2-mode.el b/js2-mode.el index c501eedf..b8b8b735 100644 --- a/js2-mode.el +++ b/js2-mode.el @@ -11715,7 +11715,7 @@ Selecting an error will jump it to the corresponding source-buffer error. (defun js-jsx--syntax-propertize-tag (_end)) (defun js-use-syntactic-mode-name ()))) -;; In Emacs >=27, this is needed for JSX indentation. +;; In Emacs >=27, this is needed for JSX indentation and highlighting. (defun js2-syntax-propertize (start end) "Apply syntax properties from START to END." (goto-char start) @@ -11725,7 +11725,7 @@ Selecting an error will jump it to the corresponding source-buffer error. ("<" (0 (ignore (if js-jsx-syntax (js-jsx--syntax-propertize-tag end)))))) (point) end)) -;; In Emacs >=27, this is needed for JSX font-locking. +;; In Emacs >=27, this is needed for JSX highlighting. (defconst js2--font-lock-keywords `(,@js-jsx--font-lock-keywords) "Font lock keywords for `js2-mode'; see `font-lock-keywords'.") From ce701f55d9a0fadefdef9ff128431eb3642c43bb Mon Sep 17 00:00:00 2001 From: Jackson Ray Hamilton Date: Tue, 9 Apr 2019 08:38:37 -0700 Subject: [PATCH 07/12] =?UTF-8?q?Don=E2=80=99t=20forcefully=20define=20var?= =?UTF-8?q?s=20and=20functions=20with=20dummy=20values?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This should be a much safer way of silencing compiler warnings (I was encountering warnings, not errors). --- js2-mode.el | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/js2-mode.el b/js2-mode.el index b8b8b735..94eb5403 100644 --- a/js2-mode.el +++ b/js2-mode.el @@ -11705,15 +11705,14 @@ Selecting an error will jump it to the corresponding source-buffer error. (goto-char pos) (message msg)))))) -(eval-and-compile - (when (version< emacs-version "27.0") - ;; Prevent compilation errors: - (defvar js-jsx-syntax nil) - (defconst js-jsx--font-lock-keywords nil) - (defvar js-jsx--text-properties nil) - (defun js-jsx-enable ()) - (defun js-jsx--syntax-propertize-tag (_end)) - (defun js-use-syntactic-mode-name ()))) +;; These are not yet defined in Emacs versions prior to 27; +;; prevent compiler warnings when using them: +(defvar js-jsx-syntax) +(defvar js-jsx--font-lock-keywords) +(defvar js-jsx--text-properties) +(declare-function js-jsx-enable "js" ()) +(declare-function js-jsx--syntax-propertize-tag "js" (end)) +(declare-function js-use-syntactic-mode-name "js" ()) ;; In Emacs >=27, this is needed for JSX indentation and highlighting. (defun js2-syntax-propertize (start end) From d2e22f32e679371a3e8c3bc088fb5f74eda464e3 Mon Sep 17 00:00:00 2001 From: Jackson Ray Hamilton Date: Tue, 9 Apr 2019 08:42:44 -0700 Subject: [PATCH 08/12] Detect the presence of new JSX features rather than version-sniffing This should be safer. --- js2-mode.el | 56 ++++++++++++++++++++++++++++++++--------------------- 1 file changed, 34 insertions(+), 22 deletions(-) diff --git a/js2-mode.el b/js2-mode.el index 94eb5403..fd888e7a 100644 --- a/js2-mode.el +++ b/js2-mode.el @@ -11718,15 +11718,21 @@ Selecting an error will jump it to the corresponding source-buffer error. (defun js2-syntax-propertize (start end) "Apply syntax properties from START to END." (goto-char start) - (if js-jsx-syntax (remove-text-properties start end js-jsx--text-properties)) + (when (and + (boundp 'js-jsx--text-properties) + (bound-and-true-p js-jsx-syntax)) + (remove-text-properties start end js-jsx--text-properties)) (funcall (syntax-propertize-rules - ("<" (0 (ignore (if js-jsx-syntax (js-jsx--syntax-propertize-tag end)))))) + ("<" (0 (ignore (when (and + (fboundp 'js-jsx--syntax-propertize-tag) + (bound-and-true-p js-jsx-syntax)) + (js-jsx--syntax-propertize-tag end)))))) (point) end)) ;; In Emacs >=27, this is needed for JSX highlighting. (defconst js2--font-lock-keywords - `(,@js-jsx--font-lock-keywords) + `(,@(bound-and-true-p js-jsx--font-lock-keywords)) "Font lock keywords for `js2-mode'; see `font-lock-keywords'.") (defun js2-font-lock-syntactic-face-function (state) @@ -11746,7 +11752,7 @@ Selecting an error will jump it to the corresponding source-buffer error. (set (make-local-variable 'indent-line-function) #'js2-indent-line) (set (make-local-variable 'indent-region-function) #'js2-indent-region) (set (make-local-variable 'syntax-propertize-function) - (if (version< emacs-version "27.0") nil #'js2-syntax-propertize)) + (if (boundp 'js-jsx-syntax) #'js2-syntax-propertize nil)) (set (make-local-variable 'comment-line-break-function) #'js2-line-break) (set (make-local-variable 'beginning-of-defun-function) #'js2-beginning-of-defun) (set (make-local-variable 'end-of-defun-function) #'js2-end-of-defun) @@ -11758,18 +11764,20 @@ Selecting an error will jump it to the corresponding source-buffer error. ;; needed for M-x rgrep, among other things (put 'js2-mode 'find-tag-default-function #'js2-mode-find-tag) - (if (version< emacs-version "27.0") - ;; In the past, we didn’t want to fontify syntactically at all; strings - ;; and comments were only ever fontified using the AST. - (setq font-lock-defaults (list nil t)) - ;; JSX fontification in Emacs 27 is provided by syntactic font-locking, so - ;; we want to turn that on. We still only want to fontify JS strings and - ;; comments using the AST, but since JSX strings aren’t fontified by the AST - ;; yet, we fontify (only) those in `js2-font-lock-syntactic-face-function'. - (setq font-lock-defaults - (list js2--font-lock-keywords nil nil nil nil - '(font-lock-syntactic-face-function - . js2-font-lock-syntactic-face-function)))) + (setq font-lock-defaults + (if (boundp 'js-jsx-syntax) + ;; JSX fontification in Emacs 27 is provided by syntactic + ;; font-locking, so we want to turn that on. We still only want to + ;; fontify JS strings and comments using the AST, but since JSX + ;; strings aren’t fontified by the AST yet, we fontify (only) those + ;; in `js2-font-lock-syntactic-face-function'. + (list js2--font-lock-keywords nil nil nil nil + '(font-lock-syntactic-face-function + . js2-font-lock-syntactic-face-function)) + ;; Unless new Emacs >=27 JSX support is available, we don’t want to + ;; fontify syntactically at all; strings and comments are only ever + ;; fontified using the AST. + (list nil t))) ;; Experiment: make reparse-delay longer for longer files. (when (cl-plusp js2-dynamic-idle-timer-adjust) @@ -11820,12 +11828,16 @@ In Emacs versions prior to 27, customize indentation by setting (defun set-jsx-indentation () (setq-local sgml-basic-offset js2-basic-offset)) (add-hook \\='js2-jsx-mode-hook #\\='set-jsx-indentation)" - (if (version< emacs-version "27.0") - (set (make-local-variable 'indent-line-function) #'js2-jsx-indent-line) - (js-jsx-enable) - ;; Use the standard name because a syntactic part will be appended. - (setq mode-name "JavaScript-IDE") - (js-use-syntactic-mode-name))) + (if (and (fboundp 'js-jsx-enable) + (fboundp 'js-use-syntactic-mode-name)) + (progn + (js-jsx-enable) + ;; Use the standard name because a syntactic part will be appended. + (setq mode-name "JavaScript-IDE") + (js-use-syntactic-mode-name)) + ;; Unless new Emacs >=27 JSX support is available, the old way to provide + ;; JSX support (indentation only) is thus: + (set (make-local-variable 'indent-line-function) #'js2-jsx-indent-line))) (defun js2-mode-exit () "Exit `js2-mode' and clean up." From 63b7a72915263a423f71ff8e22f69915c2e88b21 Mon Sep 17 00:00:00 2001 From: Jackson Ray Hamilton Date: Tue, 9 Apr 2019 08:46:02 -0700 Subject: [PATCH 09/12] Remove now-unnecessary declarations MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Since all uses of these vars and functions are now guarded by “bound” checks, these are no longer necessary; the compiler seems to determine that proper “bound” guards will make guarded code safe. --- js2-mode.el | 9 --------- 1 file changed, 9 deletions(-) diff --git a/js2-mode.el b/js2-mode.el index fd888e7a..cfb4a4be 100644 --- a/js2-mode.el +++ b/js2-mode.el @@ -11705,15 +11705,6 @@ Selecting an error will jump it to the corresponding source-buffer error. (goto-char pos) (message msg)))))) -;; These are not yet defined in Emacs versions prior to 27; -;; prevent compiler warnings when using them: -(defvar js-jsx-syntax) -(defvar js-jsx--font-lock-keywords) -(defvar js-jsx--text-properties) -(declare-function js-jsx-enable "js" ()) -(declare-function js-jsx--syntax-propertize-tag "js" (end)) -(declare-function js-use-syntactic-mode-name "js" ()) - ;; In Emacs >=27, this is needed for JSX indentation and highlighting. (defun js2-syntax-propertize (start end) "Apply syntax properties from START to END." From 1d73b0f86f1aadc558ce50fce53a46e43a46c25b Mon Sep 17 00:00:00 2001 From: Jackson Ray Hamilton Date: Wed, 10 Apr 2019 23:28:27 -0700 Subject: [PATCH 10/12] Recover JSX syntax-table text properties (fixes #409) --- js2-mode.el | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/js2-mode.el b/js2-mode.el index cfb4a4be..ea55f380 100644 --- a/js2-mode.el +++ b/js2-mode.el @@ -11889,6 +11889,23 @@ Buffer edit spans from BEG to END and is of length LEN." (js2-mode-hide-overlay) (js2-mode-reset-timer)) +(defun js2--restore-jsx-syntax-table () + "Restore important JSX syntax-table text properties. +Should syntax-table text properties be removed from the buffer en +masse, ensure that some disambiguations are restored, like the +non-string nature of quote characters in JSXText." + (save-excursion + (goto-char (point-min)) + (let (val) + (while + (progn + (if (setq val (get-text-property (point) 'js-jsx-syntax-table)) + (put-text-property (point) (1+ (point)) 'syntax-table val) + (goto-char (next-single-property-change (point) 'js-jsx-syntax-table nil (point-max))) + (when (setq val (get-text-property (point) 'js-jsx-syntax-table)) + (put-text-property (point) (1+ (point)) 'syntax-table val))) + (if (eobp) nil (forward-char) t)))))) + (defun js2-reparse (&optional force) "Re-parse current buffer after user finishes some data entry. If we get any user input while parsing, including cursor motion, @@ -11917,6 +11934,7 @@ buffer will only rebuild its `js2-mode-ast' if the buffer is dirty." ;; literals stay ignored by `parse-partial-sexp' (remove-text-properties (point-min) (point-max) '(syntax-table)) + (js2--restore-jsx-syntax-table) (js2-mode-apply-deferred-properties) (js2-mode-remove-suppressed-warnings) (js2-mode-show-warnings) From 63b357a83b1eb074721c8fb628383294c06a538f Mon Sep 17 00:00:00 2001 From: Jackson Ray Hamilton Date: Thu, 11 Apr 2019 07:11:05 -0700 Subject: [PATCH 11/12] Use char-property-alias-alist rather than restoring syntax-table --- js2-mode.el | 24 ++++++------------------ 1 file changed, 6 insertions(+), 18 deletions(-) diff --git a/js2-mode.el b/js2-mode.el index ea55f380..e8a17f7d 100644 --- a/js2-mode.el +++ b/js2-mode.el @@ -11801,6 +11801,12 @@ Selecting an error will jump it to the corresponding source-buffer error. (when (fboundp 'js-use-syntactic-mode-name) (js-use-syntactic-mode-name)) + ;; We remove syntax-table text properties in js2-reparse, but since we + ;; actually still do care about the JSX ones, refer to an alternative text + ;; property for syntax-table provided by js-mode (which it provides for + ;; precisely this purpose). + (push '(syntax-table js-jsx-syntax-table) char-property-alias-alist) + (run-hooks 'js2-init-hook) (let ((js2-idle-timer-delay 0)) @@ -11889,23 +11895,6 @@ Buffer edit spans from BEG to END and is of length LEN." (js2-mode-hide-overlay) (js2-mode-reset-timer)) -(defun js2--restore-jsx-syntax-table () - "Restore important JSX syntax-table text properties. -Should syntax-table text properties be removed from the buffer en -masse, ensure that some disambiguations are restored, like the -non-string nature of quote characters in JSXText." - (save-excursion - (goto-char (point-min)) - (let (val) - (while - (progn - (if (setq val (get-text-property (point) 'js-jsx-syntax-table)) - (put-text-property (point) (1+ (point)) 'syntax-table val) - (goto-char (next-single-property-change (point) 'js-jsx-syntax-table nil (point-max))) - (when (setq val (get-text-property (point) 'js-jsx-syntax-table)) - (put-text-property (point) (1+ (point)) 'syntax-table val))) - (if (eobp) nil (forward-char) t)))))) - (defun js2-reparse (&optional force) "Re-parse current buffer after user finishes some data entry. If we get any user input while parsing, including cursor motion, @@ -11934,7 +11923,6 @@ buffer will only rebuild its `js2-mode-ast' if the buffer is dirty." ;; literals stay ignored by `parse-partial-sexp' (remove-text-properties (point-min) (point-max) '(syntax-table)) - (js2--restore-jsx-syntax-table) (js2-mode-apply-deferred-properties) (js2-mode-remove-suppressed-warnings) (js2-mode-show-warnings) From 1bddd20a64a767fd445e82f0d7c860e8ea24eb57 Mon Sep 17 00:00:00 2001 From: Jackson Ray Hamilton Date: Sat, 27 Apr 2019 16:52:52 -0700 Subject: [PATCH 12/12] Document/advertise JSX support in Emacs 27 --- README.md | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/README.md b/README.md index 755a8180..5274f1b0 100644 --- a/README.md +++ b/README.md @@ -14,6 +14,26 @@ The stable versions are hosted at [GNU ELPA](http://elpa.gnu.org/) You can also install the latest development version from [MELPA](https://melpa.org/#/getting-started). +JSX +=== + +Full support for highlighting and indenting of JSX is available in Emacs 27. +Eventually it can be downloaded [here](https://www.gnu.org/software/emacs/); +until it’s available there, you can install a snapshot of the Emacs master +branch: + +``` +git clone https://git.savannah.gnu.org/git/emacs.git +cd emacs +./autogen.sh +./configure +make +make install +``` + +Otherwise, in Emacs 26 and earlier, you can use `js2-jsx-mode` for rudimentary +JSX indentation support (only). + Emacs 22 and 23 ===============