Categories & Tags

Emacs mode for Unity Javascript

January 15, 2010 in Community by

As you  may have heard before every friday we spend our time working on personal projects.

I have been working on a Unity Javascript mode for Emacs for a few weeks ago and now is in a state that is usable enough to share with the community :).

emacs UnityJS

As you can see it colors comments (multiline and single line), has support for basic data types, and also supports string coloring.

It also colors function declarations, if – else decisions, while and for/foreach loops and most importantly, it colors all the Unity functions supported by the engine!

Feel free to modify it. Also if you do anything interesting that can be added to the mode just let me know!

If I have time I’ll add a function to open the browser and search the docs for the word where the cursor is positioned. If for some reason you make it before I can, then just contact me and I’ll add it to the mode :).

Anyway, if you, like me, are an emacs addict, you can grab this mode from here: unityjs-mode.el

To make it work, just add this to your .emacs:

;; UnityJS mode for emacs
(autoload ‘unityjs-mode “unityjs-mode” “Major mode for editing Unity script code.” t)
(require ‘unityjs-mode)

;; UnityJS mode for emacs
(autoload 'unityjs-mode "unityjs-mode" "Major mode for editing Unity Javascript code." t)
(require 'unityjs-mode)

And make sure to load the path where you are going to store the mode ;).

Share this post

Comments (7)

Comments are closed.

Cam Jackson
17 Jan 2010, 6:22 am

Does this have intellisense?

17 Jan 2010, 3:51 pm

Well… no…
you can add it tho with some ELisp programming : )

17 Jan 2010, 4:47 pm

visual web developer express 2010 has a great java script IDE and it’s free. everyone that needs javascript IDE and has windows should take a look at VS2010. i encourage you to use C# however.

21 Jan 2010, 6:17 pm

Awesome! I was wondering how difficult it would be to merge with ? It has some nifty features, I’d love to have it’s features and the unity-function stuff from yours!

21 Jan 2010, 10:38 pm

Just tried it with Aquamacs. Nice!

22 Jan 2010, 11:30 am

@timmcd: Shouldnt be difficult if you know some elisp.
Actually, you can create a minor mode for Unity Javascript and use as Major mode js2-mode : ).
check this page:

This is where I got the info for creating the mode, you can create a minor mode with the words and it should work : )

@technicat: I’m using Aquamacs as well : ), and now I only write unity js on emacs : P

23 Mar 2011, 8:31 pm

One of autoload or require are useless. The require loads the library immediately, the autoload defers it until unityjs-mode is invoked. Autoloading makes start up faster, and is usually preferable. This is what I would use:

(autoload ‘unityjs-mode “unityjs-mode” “Major mode for editing Unity Javascript code.” t)
(add-to-list ‘auto-mode-alist ‘(“\\.js\\’” . unityjs-mode))

Leave a Reply

Comments are closed.