-
-
Notifications
You must be signed in to change notification settings - Fork 183
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Indent JSX in Emacs 27 outside js2-minor-mode #529
Comments
If I recall correctly, that text property is set to avoid issues with
unmatched quotes in JSX strings. In general I think it's the "correct"
thing to do there, but possibly duplicative with what js-more is now doing.
…-Felipe
On Mon, Jun 3, 2019, 10:31 PM Jackson Ray Hamilton ***@***.***> wrote:
JSX indentation is currently only available if
- the user is using Emacs <26 and enables js2-jsx-mode (and this
indentation is rather poor), or
- the user is using Emacs >=27 and uses js-mode with js2-minor-mode
enabled (this indentation is better), or
- the user installs rjsx-mode
<https://github.com/felipeochoa/rjsx-mode>.
It would be nice if in Emacs 27, JSX indentation would be available in
plain old js2-mode as well.
Also, currently in Emacs 27, js2-jsx-mode no longer provides any
indentation support (since indentation in Emacs 27 relies on js-mode’s
syntax-propertize-function, which JS2 does not use; we temporarily decided
against that in #523 <#523>). This
is a regression.
If js2-mode were made to use js-mode’s syntax-propertize-function instead
of setting text properties while parsing the AST, then JSX indentation
should work again. This issue proposes making that change.
Before we go forward with that, we’d like to ensure that this change will
be compatible with derivative modes (like @felipeochoa
<https://github.com/felipeochoa>’s rjsx-mode) which set syntax-table
properties using the AST. Of particular interest is this line
<https://github.com/felipeochoa/rjsx-mode/blob/03dd8d1683501e81b58674d64c3032b7b718402c/rjsx-mode.el#L781-L782>
from rjsx-mode.
I’ll note that an alternative course of action would be to first implement
#527 <#527> and then set text
properties for indentation during the parse of the AST, like we currently
do while parsing regexps. But using syntax-propertize would probably be
better for performance and simplicity.
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#529?email_source=notifications&email_token=AAU4Y4G7FDDVE7KETKU3SP3PYXOYRA5CNFSM4HSYDJO2YY3PNVWWK3TUL52HS4DFUVEXG43VMWVGG33NNVSW45C7NFSM4GXNUK5Q>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AAU4Y4CQVNCJR6WLYBJ23KDPYXOYRANCNFSM4HSYDJOQ>
.
|
I think, if The ones that make |
Yeah, that’s the alternative course of action I referred to. If we do that, there’s the potential for the properties to be applied more accurately and in better alignment with the AST, at the expense of needing a full parse to figure out where to put the properties. syntax-propertize could be faster, being chunk-based. (Then again, it could also slow things down by adding more processing overhead overall on every keystroke.) Also, it could be easier to just delegate to js-mode rather than write more code. Decisions, decisions. |
The full parse will happen anyway, because we want the AST to be available.
Could be, in certain respects. However, it's only available in Emacs 27. Even just for backward compatibility reasons, I think we should wait in adopting this approach until 27 is released and widely available. |
Yeah, this is a good argument for using the AST. I’ll update the OP to reflect this. |
JSX indentation is currently only available if
It would be nice if in Emacs 27, JSX indentation would be available in plain old js2-mode as well.
Also, currently in Emacs 27, js2-jsx-mode no longer provides any indentation support (since indentation in Emacs 27 relies on certain text properties set by js-mode’s syntax-propertize-function, which JS2 does not use; we temporarily decided against that in #523). This is a regression.
If #527 is ever implemented, then during the parse, we can set the text properties needed by Emacs 27’s JSX indentation code. Then JSX indentation should work again. This issue proposes making that change. (Eventually, we may move over to using syntax-propertize for setting indentation-related text properties.)
Before we go forward with that, we’d like to ensure that this change will be compatible with derivative modes (like @felipeochoa’s rjsx-mode) which set syntax-table properties using the AST. Of particular interest is this line from rjsx-mode.
The text was updated successfully, but these errors were encountered: