Sunday, November 01, 2009

Scripting Kate

In my last blog I explained Kate's scripting features in KDE 4.4. To better understand how scripting can be used let's look at some use cases.

  • join lines: This feature request wants the action "join lines" to not join different paragraphs, i.e. not remove empty lines. We have not implemented this wish, as there are probably users who prefer the current behaviour. This request can be fixed by writing a small script that joins the lines according to the user's wishes.

  • reformat paragraph: An intelligent reformatter for paragraphs. Should be rather straight forward to implement.

  • XML tools: In KDE3, Kate once had a xmltools plugin. Unfortunately noone ported it to KDE4. The plugin provided lots of very useful features for xml editing. For example, you could select text and then wrap it with xml elements, e.g. "text" would become "<para>text</para>". This is a perfect example for a command line script as well. Any volunteers? :)


Scripting also brings us closer to fixing the following reports:

  • macro system: Kate still does not have a macro system. A macro can be interpreted as a group of scripts, executed in a sequence (more or less). The vi input mode already supports pretty complex commands, and the code for scripting is all there. It's just a matter of putting this together so it's usable for users.

  • word count: maybe the word count features can be implemented by a script (too slow?). Problem is, that a script cannot show dialogs etc.


To make scripting an even better experience, we still need to implement binding shortcuts to scripts. Again: any volunteers? :)