• Scripting in Kate

    by  • 2012-01-21 • Developers, Users • 9 Comments

    Since several releases, Kate Part has scripting support through javascript. So far, it seems it is not much used by users. Still, I stumbled over two extensions:

    If you have more user defined scripts, it would be nice if you let us know! For KDE5, we plan to extend this, so applications like Kile or KDevelop can reuse Kate’s internal code.

    On another note, here is a nice blog about the upcoming KDE 4.8 release :-)

    About

    Dominik is a PhD student at the Control Theory and Robotics Lab, TU Darmstadt, as part of the Research Training Group GKMM (GRK1362). My research focuses on state estimation in distributed systems. As hobby, I contribute to the KDE project and work on the Kate application and editor component.

    http://www.kate-editor.org

    9 Responses to Scripting in Kate

    1. Arno Wald
      2012-01-21 at 18:34

      I could need the scripting functionality if it was possible to invoke an external script, push some text (e.g. the current selection) via STDIN into it and do something with the STDOUT output of the script, e.g. replace the current selection. AFAIK this is not possible with kate scripting. So I am using medit for such things.

    2. Emmanuel Lepage Vallee
      2012-01-21 at 22:11

      No just KDevelop and Kile, every text field / label / lineedit / textedit / textbrower / webkit. KDE need an equivalent to Android Linkify subsystem. This would be great. There was a GSOC for that a while ago, but (i) had to give up because of internal conflict between using QtQuick/JS or KROSS. Then once it was sorted out (the final decision was that we would need two complete, competing system!?!?, I was against Kross), I had no time left and had to give up and find a real job. But that was some years ago. Having regex based text trigger and other script to kaction goodies would still be awesome for mobile and powerusers.

    3. Pascal
      2012-02-21 at 14:30

      Why is the Kate manual not available online on the website?
      It would help google and me a lot :-)

    4. Tynach
      2012-04-20 at 06:23

      I’m very tempted to learn the API for this, but I’d like to first ask if this is possible/allowed:

      I want auto-brackets/quotes that, upon typing the second quote/bracket/parenthesis, will simply move the cursor outside of the set.

      Right now, if I try to type ‘(‘, it will make ‘(|)’ (where the | is the position of the cursor). I want this, but I sometimes, without realizing it, type both ‘()’. But it instead does ‘()|)’.

      I realize there’s an extension for this, but I also like the non-extension (builtin) features of selecting text and hitting the parenthesis, and it’ll wrap the selection in the parenthesis. So, I figured I wanted to script/extend/modify the built-in feature instead.

      • 2012-05-16 at 09:21

        Auto brackets will ignore the ‘)’ if it already exists, i.e. Kate in KDE 4.9 will have this behavior.

    5. Ivan Ivanov
      2012-04-25 at 19:00

      I have ported the latest zen-coding JScrpt plugin for Kate. I’ve been using it for a few weeks and it works well. I did this because the Insane (not ZEN) HTML coding (light edition) extension lacked some very useful features. If you’re interested in a copy, let me know. One awesome addition for the kate js api would be creating user dialogs to ask for input. I am currently doing this by asking for input on the command line, but this has its own problems.

    6. cgk
      2012-05-4 at 04:23

      So is there any chance it will be possible to invoke external programs in future versions of Kate scripting? I’ve looked into this multiple times, but always found that the APIs provided are simply not sufficient to do what I want. This would not be such a problem if it was possible to invoke external programs to do the actual work (e.g., python scripts).

      Additionally, I have some external programs which do non-trivial stuff (e.g., code reformatting). I seriously do not want to replicate them in javascript, especially not since I already *have* working programs and all I would need would be a way to get the text into them, and out of them using the scripts.

      • 2012-05-16 at 09:24

        For a lot of stuff you can use the text filter plugin and pipe selected text through external programs, and with that you can e.g. reformat the text.

        But right, a js function to invoke external programs does not exist, yet. How would it look like? system.exec(“app with parameters”) ?

    Leave a Reply

    Your email address will not be published. Required fields are marked *


    *