jump to navigation

CLIPS Formatting Bundle for TextMate April 6, 2009

Posted by Robert Harder in Utility.

We used CLIPS, a forward chaining production system in some artificial intelligence and cognitive engineering classes as well as Pyps, a sort of Python “CLIPS Light” that the professor Dr. Chris Darken worked up. Since I love TextMate so much, I wanted a more TextMate-like experience, so I worked up a bundle for CLIPS (and Pyps).



Download the TextMate CLIPS bundle here.



After downloading the zip file above, expand it, and you’ll have a file/bundle called CLIPS (or possible CLIPS.tmbundle if the extension is showing). Move this bundle to your TextMate bundles folder:


You’ll need to create this folder (or folders) if they are not already there.

Quit and restart TextMate.


You’ll now have CLIPS-specific formatting and a few commands available to you. If your filename ends with .clp or .pyp, TextMate should automatically make the CLIPS bundle the active one. If it does not, you can select CLIPS manually at the bottom of the editor window:


The bundle makes three commands available as well as the nice formatting:

  • Batch (Cmd-B): Loads the file into the current CLIPS session like CLIPS’ (batch ..) command
  • Run (Cmd-R): Loads the file (as with Batch) and executes (run) in CLIPS.
  • Clear & Run (Cmd-Shift-R): Clears CLIPS working memory, loads the file, and runs it.


The following words have special formatting as special language keywords:

  • defrule
  • not
  • or
  • and
  • assert
  • retract
  • gensym

Rule names (follows defrule) are also formatted specially.


Making it Better

You can extend the CLIPS support yourself with TextMate’s Bundle Editor (that’s how I made this initially). Go to TextMate’s Bundles menu, select Bundle Editor and then Show Bundle Editor.


Learning the TextMate tricks and syntax can be a bit daunting, but just look at other languages for examples. Here’s the editor showing the CLIPS bundle’s language details:


I’ve only used a simple subset of CLIPS, so perhaps you want to add some more keywords to be highlighted. Look for where the string defrule|not|or|and|assert|retract|gensym is above, and you can add run, clear, batch, etc as you like.

The most sophisticated formatting instruction is for the rule names. Here is the instruction I finally figured out:

{ name = 'meta.function.clips';
  match = '(^.*(defrule)[ t]+)([a-zA-Z0-9_-]+)';
  captures = {
    2 = { name = 'keyword.control.clips'; };
    3 = { name = 'entity.name.function.clips'; };

You may want to use it as a template if you need to do further complex formatting instructions.

If you make good changes, I don’t mind putting them up here for others to use. Email me.


1. studying online - October 10, 2014

A number of financial aid programs are offered by the federal government in the form of grants, aids and work-study
programs. One of my favourite examples is “high tension”; in English it is high-voltage
powerlines or a taut rope, in Japanese it’s an excited
person. Another important aspect of studying this field
is that students choose this course to help disadvantaged individuals, groups,
and families through practical assistance, but after completing their study from an online
institute, most of the students fail to interact with disadvantaged people in real life.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: