In the rounds of looking for a specific syntax highlighting mechanism for Text Wrangler ( a fairly nice but large text editor for OSX). I found what I was looking for there but realized there was a problem with Text Wrangler, it would only start the syntax highlighter based soley on the extension of the file. This is a problem because I was looking for a syntax highlighting for cmake, and the primary build files are usually denoted as CMakeLists.txt files. I really didn't want to start the syntax highlighter for all txt files as I end up processing a large variety of files. However I was reminded (yes I forgot completely) that nano the console editor is capable of performing syntax highlighting based on some regular expression (regex) rules and can match complete file names. Now nano has always been my favorite console editors, not saying the others are bad just personal preference primarily. So I figured that since I almost always have a console open at any given time (even on the mac) and I end up doing a good portion of things via the console that maybe it wouldn't be a bad idea to just use a console editor for my text editing requirements.
So to start things off OSX does come with nano on the system, I have no idea how it was configured when built though and it is a slightly older version than even the stable releases other *nix distros are using. So I downloaded the source tar.gz from Nano-editor of the latest version (at this writing it was 2.2.3). Now just need to bring up a console and navigate to the directory the source was extracted into. Then run the configure with these options:
--enable-color --enable-multibuffer --enable-nanorc &&
make
Now I understand that on a regular unix system dropping a program like this straight into /usr really isn't that big of a deal. I was a little hesitant about it on a mac but everything seems ok (it could have been left in /usr/local but the path would have to be edited to have /usr/local be searched first before /usr). The options layout like this, the sysconfdir is where the global config file is going to end up at. The option enable-color allows nano to be able to show colors, multibuffer allows for better editing and the enable-nanorc lets nano use the nanorc config files. Now nano comes with some sample config files and sample code highlighting mechanisms but running the sudo make install will not install the samples. However not a big deal with the next few areas so go ahead and run:
Which will install the man files and the program itself. Now we need to setup the global nanorc file to be somewhat useful. The options that can be set in the nanorc file are fully documented under man nanorc. So create the file and put some default values into it like this:
Now the values that I went with:
nanorc
set const
set fill 72
set historylog
set multibuffer
set regexp
set smooth
set suspend
set mouse
Ok, not quite finished yet I know. Now I created a folder called .nano under my home directory, and copied all the code.nanorc files into the directory.
So if we are still in the nano source dir we need to run these commands to copy everything.
cp * ~/.nano
Now just need to create our own ~/.nanorc this is pretty simple we are just going to list all the code.nanorc files in the ~/.nano folder. so this one is pretty straight forward.
~/.nanorc
include "~/.nano/awk.nanorc"
include "~/.nano/c.nanorc"
include "~/.nano/css.nanorc"
include "~/.nano/fortran.nanorc"
include "~/.nano/groff.nanorc"
include "~/.nano/html.nanorc"
include "~/.nano/java.nanorc"
include "~/.nano/makefile.nanorc"
include "~/.nano/man.nanorc"
include "~/.nano/mutt.nanorc"
include "~/.nano/nanorc.nanorc"
include "~/.nano/objc.nanorc"
include "~/.nano/ocaml.nanorc"
include "~/.nano/patch.nanorc"
include "~/.nano/perl.nanorc"
include "~/.nano/php.nanorc"
include "~/.nano/pov.nanorc"
include "~/.nano/python.nanorc"
include "~/.nano/ruby.nanorc"
include "~/.nano/sh.nanorc"
include "~/.nano/tcl.nanorc"
include "~/.nano/tex.nanorc"
include "~/.nano/xml.nanorc"
And that pretty well wraps it up. It is pretty easy to add custom ones, and the syntax and usage can be seen in any of the included files. I am working on one that will work with cmake and will post it later when it is working a bit better.
Ok cmake.nanorc is available on my project pages. Hope it helps out someone.






