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

External apps to open files in existing KDevelop session.

Tags: None
(comma "," separated)
chatsubo
Registered Member
Posts
5
Karma
0
Howdy,

I usually have a single session of KDevelop (4.3.1 on Kubuntu 12.04.2) open for all editing tasks, which includes my project source, but I edit external files with it too. I like having things open in one place and using the same UI metaphor all the time, Kate is just lacking relatively.

For files in my project all the standard stuff works fine. But often when I'm in a file browser (Krusader 99% of the time) I want to be able to open a file by using the context-menu, or even better, just double clicking for source files associated with KDevelop.

Invariably this results in a "session already open" type error message.

I can drag files into my existing session just fine (The fact that I have to drop it "just there" bugs me slightly, but fine...), but it just takes a bit longer to do. Mostly I've come to just "not do that" and using the built-in file browser, but it's still annoying... having to "re-find" a file I've just found.

So I played with the command line and tried doing:

Code: Select all
$ kdevelop -s 'SESSION-HASH' blah.txt


Hoping that I'd usually have the same session open and setting my "associated" command accordingly would give me what I want.

But it just pops my existing session into focus without opening the file (in perceived contradiction to the help text).

Is this a bug fixed in later versions (I doubt it I've had this problem for years)?

Or is there another way to do this?
User avatar
scummos
Global Moderator
Posts
1175
Karma
7
OS
Hey,

you can do this:
Code: Select all
qdbus org.kdevelop.kdevelop-$(pidof kdevelop) /org/kdevelop/DocumentController openDocumentSimple /tmp/test.txt

Granted, not very elegant, but if you put it into a shellscript called kdevelop-open or so it should work just fine. ;)

Oh you'll need adjustments of course if you have more than one instance of kdevelop open, but you said you haven't so it should work.

Cheers,
Sven


I'm working on the KDevelop IDE.
chatsubo
Registered Member
Posts
5
Karma
0
Sven, my man, that works beautifully! Thank you!

For future souls, my script ended up like this:

Code: Select all
#!/bin/bash

qdbus org.kdevelop.kdevelop-`pgrep -o kdevelop` /org/kdevelop/DocumentController openDocumentSimple $1
kdevelop -l | grep -P '\{' | awk '{print $1}' | xargs kdevelop -s


That should always "just work", assuming kdevelop is open. ;D

Edit: Can't image why kdevelop wouldn't be open.
chatsubo
Registered Member
Posts
5
Karma
0
Edited the above script with a line for giving kdevelop focus after it opens the file.


Bookmarks



Who is online

Registered users: bancha, Bing [Bot], Evergrowing, Google [Bot], lockheed, mesutakcan, Sogou [Bot]