Skip to content
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

MMM-mode support #124

Open
CyborgMaster opened this issue Nov 24, 2013 · 18 comments
Open

MMM-mode support #124

CyborgMaster opened this issue Nov 24, 2013 · 18 comments

Comments

@CyborgMaster
Copy link

I love js2-mode and use it a my main javascript editing mode. I would love to see support for mmm-mode so I could use it to edit script tags. How hard would this be to accomplish? I would do it myself, but I'm still a noob when it comes to elisp.

@dgutov
Copy link
Collaborator

dgutov commented Nov 26, 2013

What's your use case? Scripts tags usually contain small-ish amounts of code, so it's not like the highlighting of undeclared vars will be useful. Are you aiming to use skewer-mode and ac-js2?

It should be doable now, if we remove the explicit parser scheduling and register the parser function as syntax-propertize-function. But it will break some things. Off the top of my head, calling widen will be prohibited, so #114 won't be fixed anymore. js2-dynamic-idle-timer-adjust won't work, since there's no corresponding setting in font-lock. And js2-mode parser is inherently slower than than js-syntax-propertize, so, even if it works okay, it may lower the size of files you can comfortably work with using mmm-mode by an order of magnitude.

I would do it myself, but I'm still a noob when it comes to elisp.

That's a convenient turn of phrase. :)

@CyborgMaster
Copy link
Author

My main use case is that js2-mode does auto-indenting exactly the way I want it while javascript mode is quite a bit less intelligent. It doesn't make a difference when people only use small snippets of code in script tags and keep most javascript in an external file, but I just ran into a testbench for an open source project I am contributing to that has a non-trivial amount of javascript in the html file.

It may be that the correct solution in this case is simply getting my javascript mode setup to do auto indenting correctly. I was trying to avoid maintaining my setup for two javascript editing modes, but that may be the easiest solution in this case. @dgutov what do you suggest?

@dgutov
Copy link
Collaborator

dgutov commented Dec 2, 2013

Because js2-mode indentation code doesn't depend on the generated syntax tree (or on the parser, in general), it's been intended for move to js-mode for some time now.

If you don't mind using Emacs compiled from trunk, or waiting a few months until 24.4, or at least copying js.el from trunk to somewhere on your load path (that should work, but I'm not 100% sure), file a bug for js-mode on the Emacs tracker (M-x report-emacs-bug), preferably with examples where indentation looks broken to you.

Then I'll try to do the move. The feature-freeze for Emacs 24.4 is scheduled for the middle of December, so I'd have to finish before that.

@mk0x9
Copy link

mk0x9 commented Jan 30, 2015

@CyborgMaster You can actually narrow buffer down to region inside script tags and change major mode to js2-mode.

@jaseemabid
Copy link

jsx support of emacs at the moment is pretty bad. The best approach I could think of at the moment is to use html-mode and js2-mode for a jsx buffer using mmm. So an update on this would be great.

@dgutov
Copy link
Collaborator

dgutov commented Mar 7, 2015

@jaseemabid Multi-mode support with js2-mode being the primary mode is not even being discussed now. It can be done, but for JSX, it would probably be better if someone implemented some addition to the indentation code that delegates to html-mode.

@xcodebuild
Copy link

@dgutov vuejs need this. See https://github.com/CodeFalling/vue-mode.

@binary132
Copy link

VueJS bump.

@benjcal
Copy link

benjcal commented Feb 1, 2017

+1

@dgutov
Copy link
Collaborator

dgutov commented Feb 1, 2017

@codefalling Why do you think you really need this?

vue-mode uses js-mode, which seems like a decent choice.

@benjcal
Copy link

benjcal commented Feb 2, 2017

@dgutov: ES6 highlighting is super important and vuejs uses it extensively. Vue has this components that include a <template> where there's HTML, a <style> where CSS goes and a <script> where the JS is and all of that is in a single file, thus the need for MMM.

If you point me on the right direction I can looking into adding support for MMM and make a pull request :-)

@dgutov
Copy link
Collaborator

dgutov commented Feb 2, 2017

@benjcalderon If there are important ES6 constructs that are not highlighted well in js-mode in recent Emacs (25.1), please report that as bugs.

If you point me on the right direction I can looking into adding support for MMM

I don't know of a good way to provide that support, and so can't provide a good direction.

@dgutov
Copy link
Collaborator

dgutov commented Feb 2, 2017

For some suggestions, see my first comment in this thread. But having thought more about this, running the parser as often as font-lock works is likely to make Emacs too slow in larger files.

@ustun
Copy link

ustun commented Dec 30, 2018

My main use case is that js2-mode does auto-indenting exactly the way I want it while javascript mode is quite a bit less intelligent. It doesn't make a difference when people only use small snippets of code in script tags and keep most javascript in an external file, but I just ran into a testbench for an open source project I am contributing to that has a non-trivial amount of javascript in the html file.

It may be that the correct solution in this case is simply getting my javascript mode setup to do auto indenting correctly. I was trying to avoid maintaining my setup for two javascript editing modes, but that may be the easiest solution in this case. @dgutov what do you suggest?

It wasn't around when the issue was originally posted, but prettier can format such files with mixed content (js within html etc.)

@osman-mohamad
Copy link

any change about mmm-support with js2-mode ?

@srcrip
Copy link

srcrip commented Feb 8, 2020

I also would desperately love this for editing .Vue files in vue-mode. Can we get some direction on what would have to be done for this to happen?

@NANASHI0X74
Copy link

I'll add another nag: Is there an estimate if/when this feature will be added? (use case is vue-mode as well)
Also, @dgutov's early comments have confused me a bit, was there the intention to eventually integrate/move the functionality of js2-mode into the js-mode that emacs ships by default?

@dgutov
Copy link
Collaborator

dgutov commented Oct 5, 2020

Is there an estimate if/when this feature will be added?

Nobody is working on it (AFAIK), so no. Sorry.

was there the intention to eventually integrate/move the functionality of js2-mode into the js-mode that emacs ships by default?

A number of features (indentation, syntax highlighting) have been ported over. But not the parser, of course.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests