KDE 4.9 has branched, and so the Pâté plugin “host” for Python plugins has moved from Kate’s playground to be a mainstream plugin. Since a plugin-for-plugins might be a bit confusing, here is a quick tour of how it is managed and works, and especially a few rough edges it still has.

NOTE If you’ve installed this from a package, hopefully your distro will have added kate.so under PyKDE4 as needed, but if you are building from source, see the notes at the end of this post.

Start by enabling the enabling the Pâté plugin:

That should cause the Pâté plugin’s configuration page to pop into existence, but you may need to press the Reload button to see the right hand pane filled in like this:

Enable specific Python plugins of interest, and press the Reload button. The comment will be set to “Loaded”, then close and reopen the dialog (rough edge #1) to see any new configuration pages that the plugin provides:

Go back to the Pâté plugin’s configuration page, and now look at the second tab:

Use the combo box to select one of the built-in support modules (kate and kate.gui) or any of the loaded plugins. The first tab shows HTML documentation for the Python code and you can see any actions it has added into the Kate UI on the second tab (this will be empty for the built-in modules, but not for console):

It looks as though the Python console has added one entry to the View menu, alog with a shortcut. And so it has:

Yaay! See if you can guess what to do next 🙂

IF YOU HAVE BUILT FROM SOURCE

And then installed the results in say /usr/local, attempting to enable the plugin may result in a crash with something this on the terminal:

> File "/home/.../kate/plugins/pate/kate/__init__.py", line 38, in <module> from PyKDE4.kate import Kate
> No module named kate
> Could not import kate"

This is because the Pate build should install kate.so as part of the PyKDE4 bindings, but typically, a developer build will install this locally, and not to where the remaining system-supplied PyKDE4 files are installed:

So there I am, a confirmed Kate user, and now I need to find my way around a codebase of over 100,000 files using GNU ID utils. The rather crude answer for Kate 3 was to write a wrapper around the lid(1) utility and the DCOP scripting interface of Kate, all driven from the built-in Konsole. The result was clunky but somewhat usable. But Kate 3? In 2010? Because the version of KDE on our primary development environment is the venerable KDE 3.3!

Eventually though, I decide the time had come for something a little nicer, and the answer seemed to lie in Kate 4 and scripting, except that the Javascript API didn’t seem to offer a way to get to the ID database. That had me stumped for a while until I came across Pâté, which allowed Kate 4 to be extended in Python. Sadly, it was unmaintained and there things stalled until, inexorably, I got to the point where the itch needed scratching.

That most basic driver of Open Source usually comes with strings attached, like the need to find a way to work in a new codebase, and with a new team of hackers. Plus, in the this case, the minor issue of being pretty much a Python newbie. Luckily it turns out that Kate has one of the most responsive teams I’ve encountered, the Pâté code seemed reasonably tractable, and the Python C API solidly documented. What could possibly go wrong? 🙂 Not that much, because we now have:

A Kate plugin based on Pâté

A Python debugger console Pâté plugin

And oh yes, an ID file integration Pâté plugin

The Kate plugin has a configuration page that allows individual Python plugins to be enabled or disabled, and if need be, system installed plugins to be overridden. Like the original Pâté, Python plugins can hook into Kate’s menus and shortcuts. Unlike the original, this version:

Like last summer I am mentoring a student working on Kate’s Vi mode this summer. This year’s student is Vegard Øye from Oslo, Norway. I’ll let him introduce himself:

My name is Vegard Øye. I am a computer science student at the University of Oslo, Norway. I also have a bachelor’s degree in electrical engineering from Sør-Trøndelag University College in Trondheim, where I programmed for integrated circuits. It was a lot of fun, so I decided to embark on a grade with an even larger emphasis on programming.

My goal is to make modal editing more widespread outside of Vim. There is a Zen-like benefit to using a tool that does just what you tell it to – slicing and dicing text with surgical precision. My focus is not on adding new features to Kate (although I have implemented a few), but on sharpening existing functionality. In particular, I want to improve the integration between Kate’s vi mode and its extension system, as well as sort out various bugs pertaining to the vi mode.