Friday, September 24, 2010

jEdit as a Mel IDE

Everyone has opinions about what the best editor for MEL is, but for me it's jEdit. So I'm going to share my setup and how I use it.

Step 1: Syntax Highlighting
First off get jEdit ( You'll need syntax highlighter for Mel which you can get here.

Once you have them both extract the highlighter and put it in your installation directory here (C:\Program Files\jEdit\modes) but be sure not to overwrite the existing catalog file, simply open the mel on and copy the contents to the end of the existing one.

That should do it for highlighting, you can adjust the colors in your Utilities -> Global Options, under Syntax Highlighting. Mine is setup like this.

Step 2: Auto Completion
A great plugin is TextAutoComplete which you can download under Plugins -> Plugin Manager. This will auto complete commands that you previously have typed in your buffer, standard in most editors.

Step 3: Buffer Tabs
Get this plugin in the Plugin Manager as well, makes tabs similar to your web browser for open files.

Step 4: MEL Parsing
Now this is by far the most complex and in some cases most useful tool. It will parse the current buffer and find procedures, variables, whatever u want basically. What it finds can be modified using regular expressions. It uses two plugins and some 3rd party software that pipes into jEdit. So in the plugin manager download CtagsSideKick and SideKick. You will also need to download Exuberant Ctags ( Get the source and binary zip file.

Now extract those files into your .jedit folder under a new directory (C:\Documents and Settings\USERNAME\.jedit\ctags\) and copy that path to the ctags Path Field under the CtagsSideKick Plugin Options inside of jEdit, so it shoulder read: C:/Documents and Settings/jacob.schieck/.jedit/ctags/ctags.exe If you don't do this it wont work.

Next you want to navigate to your user profile directory (C:\Documents and Settings\USERNAME\) or just %USERPROFILE% will take you there and make a new text document with the following contents:


--regex-mel=/\[ \t]*([$]+[a-zA-Z0-9_$]+)/\1/var string/
--regex-mel=/\[ \t]*([$]+[a-zA-Z0-9_$]+)/\1/var integer/
--regex-mel=/\[ \t]*([$]+[a-zA-Z0-9_$]+)/\1/var float/
--regex-mel=/\[ \t]*([$]+[a-zA-Z0-9_$]+)/\1/var matrix/
--regex-mel=/\[ \t]*([$]+[a-zA-Z0-9_$]+)/\1/var vector/

--regex-mel=/^global proc([ \t]|string|int|float|matrix|vector|\[\])*([a-zA-Z0-9_]+)/\2/global procedure/
--regex-mel=/^proc([ \t]|string|int|float|matrix|vector|\[\])*([a-zA-Z0-9_]+)/\2/local procedure/

--regex-C++=/[ \t]+\b(M[A-Za-z]+)[ \t]+([a-zA-Z0-9_]+)/\1 \2/maya api/

Save it out as ctags.cnf. This will tell the ctags.exe how to parse apart you mel script into finding variables and procedures. Personally I don't use the variables and just use procedures so if you don't want them just delete those lines.

Next you need to set up an environment variable pointing to that file. Technically, it's supposed to work without this step but it was the only way I got it work with jEdit. Right click on My Computer and click Properties. Go to the Advanced tab and at the bottom open up Environment Variables. Create a new User Environment Variable with the variable name "Files" without quotes and set the value to the path of your configuration file (C:\Documents and Settings\jacob.schieck\ctags.cnf;)

Alright now that should be it! Open up jEdit, under your SideKick Plugin Options under the Parser sections find mel and set it to ctags. Now open a mel script, and under Plugins -> SideKick, click SideKick and a window should pop-up that lists all your procedures and variables. If it doesn't make sure the dropdown box at the top says ctags, if it doesn't change it and if it still doesn't work then something is wrong. Run through again and make sure you didn't miss any steps and if you still can't figure it out let me know and I'll try to help you out.

And that's basically it! Those are all the plugins I use. I no longer use SendToMaya or whatever it was called, I just save and source my scripts manually now.