defunkt / coffee-mode

Emacs Major Mode for CoffeeScript
http://ozmm.org/posts/coffee_mode.html
574 stars 147 forks source link

feature request: support React #314

Open coyotemarin opened 9 years ago

coyotemarin commented 9 years ago

I'm using CoffeeScript for my startup, SpendRight and really appreciate being able to use coffee-mode in Emacs. I'd love to use React as well (compiling it with @jsdf's coffee-react compiler), but I don't have a working coffee-react mode for Emacs.

For plain JSX (i.e. JavaScript with React), the React project recommends just using web-mode.el, though there is also a jsx-mode, created by @abicky.

I haven't worked on emacs modes before, so I really have no idea if combining one emacs mode with another is easy or difficult. If it is relatively easy, I would totally appreciate it. :)

(I'm also the maintainer of mrjob and get feature requests all the time, so if you don't have the time or have different priorities for your project, I totally understand where you're coming from.)

syohex commented 9 years ago

I don't understand React well. What feature should we implement for supporting React ? syntax highlight ? indentation ? others ?

coyotemarin commented 9 years ago

Just indentation would be awesome. Right now, if I try to have a block of JSX (basically an HTML template) in the middle of my coffeescript, it messes up the indentation of any coffeescript code below it.

jasonm23 commented 8 years ago

IIRC the CoffeeScript dialect of JSX is called CSX (could be wrong!)

Edit: wrong ... it's cjsx

jasonm23 commented 8 years ago

https://github.com/jsdf/coffee-react

ibrahima commented 8 years ago

I'm curious enough to take a stab at this when I get some time, maybe this weekend or next... it seems js2-mode apparently has support for inline JSX now. I think just fixing indentation would be awesome, and syntax highlighting would be sweet as well. I wonder if something like MuMaMo would work, but I feel like that's more heavyweight of an approach than we really need.

(Note that I haven't worked with major modes before, but I've done a smattering of elisp here and there, so no idea how long it would take me to figure out what even needs to be done).

coyotemarin commented 8 years ago

That would be cool. Not urgent for me anymore; CoffeeScript's syntax is clean enough that you can create very readable code just using short names for React functions and CoffeeScript's indentation-based syntax.

CoffeeScript can be a bit brittle though; sometimes surprising things happen when you leave out a comma. So CJSX would probably be a bit more maintainable with proper editor support.