This forum has been archived. All content is frozen. Please use KDE Discuss instead.

Kate scripting

Tags: None
(comma "," separated)
Tyrn
Registered Member
Posts
15
Karma
0

Kate scripting

Fri May 12, 2017 2:15 pm
Hi,

I'd like to execute a bash shell command on shortcut. The command is going to take three parameters: (pdf) file name, current line number (in editor window), (edited) file name. The exact command will be something like this:
okular --unique 'file.pdf#src:linenumber file.tex'

Let me explain (not quite on topic). Where are developers' guides or something like that on KDE apps? This is not the first time I get frustrated. I looked up Kate/KatePart docs, of course. You can learn from them that scripting language is JavaScript, and that's pretty much that. This Okular command line solution is not documented at all. Inventive googling reluctantly brings it up, word-of-mouth like. Is it really FOSS 'undocumented function'? Config file formats also go undocumented, you have to guess Esc or Ctrl keys syntax, for instance.

What is the right KDE way to go about such should-be-easy things?
User avatar
scummos
Global Moderator
Posts
1175
Karma
7
OS

Re: Kate scripting

Sat May 13, 2017 9:38 am
Tyrn wrote:What is the right KDE way to go about such should-be-easy things?

"I want to write a script which opens a pdf at a specific place depending on the current cursor position in my text editor when I press a shortcut" is a strange thing to classify as "should-be-easy" ;)

Part of it is in okular --help; not in much detail, that's true. I don't know how you would find out about the # stuff; I'm not even sure if that is a pdf thing or an okular thing. If you need such a specific feature, my approach would be to a) read the source, or b) ask on a mailing list or IRC whether it's possible.

The kate scripting API reference is e.g. here: https://docs.kde.org/trunk5/en/applicat ... pting.html

Greetings,
Sven


I'm working on the KDevelop IDE.
Tyrn
Registered Member
Posts
15
Karma
0

Re: Kate scripting

Sat May 13, 2017 4:32 pm
scummos wrote:
Tyrn wrote:What is the right KDE way to go about such should-be-easy things?

"I want to write a script which opens a pdf at a specific place depending on the current cursor position in my text editor when I press a shortcut" is a strange thing to classify as "should-be-easy" ;)

The resulting script will take well inside ten lines of JavaScript code, curly braces included. Should be easy, IMHO.
The kate scripting API reference is e.g. here: https://docs.kde.org/trunk5/en/applicat ... pting.html

This is a good example of what I am ranting about. Not your fault, sorry.
User avatar
scummos
Global Moderator
Posts
1175
Karma
7
OS

Re: Kate scripting

Sun May 14, 2017 3:37 pm
Tyrn wrote:The resulting script will take well inside ten lines of JavaScript code, curly braces included. Should be easy, IMHO.

I'm not sure if that is a good measure for complexity ;)

This is a good example of what I am ranting about. Not your fault, sorry.

Hm, but why? Is that such a bad place for it to be? Or, let's turn it around: where do we put it so you'd say it is easy to find?

Best,
Sven


I'm working on the KDevelop IDE.
Tyrn
Registered Member
Posts
15
Karma
0

Re: Kate scripting

Mon May 15, 2017 4:33 am
scummos wrote:Hm, but why? Is that such a bad place for it to be? Or, let's turn it around: where do we put it so you'd say it is easy to find?

True, the official docs are easy enough to find. Unfortunately, they are very sparse, to put it mildly. This is consistent throughout the KDE project. The okular --unique 'file.pdf#src:linenumber file.tex' thing is nowhere to be found, just certain private messages, hard to google. Where did they find it? Not in the docs.
User avatar
scummos
Global Moderator
Posts
1175
Karma
7
OS

Re: Kate scripting

Mon May 15, 2017 11:33 pm
I feel this is consistent across the world; the more in-depth you go, the less docs you find. I would guess for the #-trick that either a developer answered, or somebody read the source code. Frankly, I think expecting this kind of niche feature to be neatly documented in some beginner-friendly tutorial is just unrealistic; nobody has the time to write and especially maintain that resource.

Kate scripting is a bit different, what do you think the documentation lacks? Contributions are cerainly welcome. We also have the KDE userbase wiki, which is a wiki, and you are very welcome to document your own findings there if you think they would be useful for others.


I'm working on the KDevelop IDE.


Bookmarks



Who is online

Registered users: abc72656, Bing [Bot], daret, Google [Bot], lockheed, Sogou [Bot], Yahoo [Bot]