#!/usr/bin/env python # This program does its best to create a kate syntax file for the kate # editor. I'm using a program to do this (rather than just editing the xml file) # due to the long keyword lists ... and since mma can generate them ... let it # do the hard work. # And if you can improve this ... don't be shy!!! # bvdp May/2006 import sys, os, commands # First create a item list of keywords from mma l = commands.getoutput("mma -Dk") for a in l.split('\n'): if a.startswith("Base"): classnames = a.split(":")[1:][0].split() if a.startswith("Commands"): sfuncs = a.split(":")[1:][0].split() if a.startswith("Track"): tfuncs = a.split(":")[1:][0].split() # Combine the track and simple functions. for a in tfuncs: if sfuncs.count(a) == 0: sfuncs.append(a) sfuncs.sort() # Got our info. Create xml ... this is printed to stdout. print """ """ print """ """ for a in sfuncs: print ' %s ' % a.title() print " " print ' ' for a in classnames: print ' %s ' % a.title() print " " print ' ' for a in ('Begin', 'End'): print ' %s ' % a print " " print " " print ' ' # All the keywords get the same hilight. print ' ' # This creates a regexpr for each class so we can hilight words # like Bass-Sus ... is there an easier way by modifying the # basic Class attribute????? for a in classnames: print ' ' % a print ' ' # The Begin/End block get a separate hilight print ' ' # comments print ' ' # Macros - This does both $_xx and $xx. Note $__xx will not hilight (this illegal in MMA) print ' ' # linenumber, only if they start a line. print ' ' print ' ' print ' ' print ' ' # Set the hilight colors, etc. print ' ' print ' ' print ' ' print ' ' print ' ' print ' ' print ' ' print ' ' print ' ' print ' ' # finish off with the general stuff. print ' ' print ' ' print ' ' print ' ' print ' ' print ' ' print ''