Kate’s current indenters rely on highlighting information, which is actually elegant. But practice shows that changing syntax highlighting the indenter can be confused pretty fast.
Mainly the disadvantages are:
So the idea is to write an indenter initially for C++, which works highlighting independent. This can either be done by using some clever tricks (your ideas needed!) or by parsing the whole document from the beginning. Parsing would be far too slow every time you insert a character, so something like ”backup nodes” would have to be maintained - you see, it already begins to get quite complex :) Documentation about how to write Indenters can be found on the page Writing Indenters.