Inform "Intelligence"

There are two goals: collect information about the program being written in order to provide a live index and possibly also autocompletion, and possibly also to provide some limited automatic code generation.

We want the 'intelligence' system to provide the following features:
	* auto-indentation
		In Natural Inform, this means just using the tab width of the last line.
	* auto-section numbering
	* collection of section data

This means there are essentially three types of intelligence:
	Immediate insert (you type 'Volume ' and the intelligence inserts 'two')
	Later insert (after inserting 'Volume two', the old 'Volume two' and 'Volume 
		three' are renamed to 'Volume three' and 'Volume four')
	Data recording (so we know that 'Volume two' follows 'Volume one' and
		is contained by 'Part four')

The intelligence should be associated with the syntax highlighter, and follow the same semantics. That is, it should work on a by-line basis, and the 'intelligence' gathered for a line should only change if the highlighting information has also changed. It will need to be fast: intel for a line will change with every key press, and the immediate insert routines will also need to run with every keypress.

It will need to deal with cut and paste. That is, a lot of stuff can disappear at once and not just one letter at a time.

Data collection

Data collection is on a per-line basis, and more structured information is gathered from this.

Data collection should use a 'delta' system, so what's recorded for a line is how the state of the overall structure has changed. The actual structure is calculated from this as required.

Symbol structure is a tree:

Part one
	Volume one
		Chapter one
		Chapter two
	Volume two
		Chapter one
		Chapter two

Each symbol has: a type (dictating which tree it is in), a level and a name.

A level can be empty. (NI allows a fairly freeform structure here)

Each line can contain one or more symbols, and instructions as to how they fit into the tree so far. Valid instructions are:

	Place at level (puts the item at a specific level)
	Place at same level (same level as the preceding item)
	Place at a level with delta (puts the item up or down a number of levels relative to the preceeding item)

The lowest level is 0.

Each line contains one or more symbols.