Blog Syndicate content

  • » Kate Love: HighlightInterface, Autobrace

    Sun, 11/22/2009 - 20:15

    Well, I have to admit: I didn’t spent much time developing the PHP plugin for KDevelop these past weeks. Instead I hacked on Kate:


    I added another Kate interface, this time to access some of the highlighting information:

    • what’s the Attribute for a given default style right now? Default styles are those known from syntax files, e.g. dsKeyword, dsFunction,…
    • what are used Attributes in a given line and what range do they occupy?
    • what modes do we embed? E.g. PHP embeds HTML, JavaScript, CSS, …
    • what mode is used at a given Cursor position?

    This made it possible to port the “Export to HTML” action to a real plugin. If you come up with other output formats I might add them, I wondered about LaTeX support… might do this at some point.

    This should also make it possible to use KatePart in other applications and than export the highlighting to a different format, e.g. a Flake shape for Koffice. Afaik this is actually planned by The_User - lets see if it works out!

    The other stuff gives huge potential in various places, but I fear it won’t make it in KDE 4.4. But think of it:

    • simple code completion based on keyword databases, dependent on the mode at the position where completion was requested
    • same as above for snippets (actually this will make it to 4.4).
    • insert your ideas here :)
    Auto-Brace plugin

    Jakob Petsovits created this gem of a plugin some time ago, yet it lived in playground was probably only used by few. I imported it to kdelibs, hence it will be shipped with KDE 4.4. It supersedes the limited “auto-brackets” feature of Kate and only adds braces when a newline gets added. I find this fits my personal coding habits much better than blindly copying brackets when they get added.

    And I don’t just copied to kdelibs, I also added a few features:

    • automatically add a semicolon after the closing brace when we start a new struct/class in C++ mode
    • check for auto-brackets feature and disable it automatically

    Also did this:

    • don’t add brace when current line contains namespace and a following line starts with class or struct (C++ mode only)
    • don’t add brace when current line contains class, interface or struct and the following line contains private, public, protected. C++ code is also checked for signals, Q_SIGNALS", other modes are checked forfunction`.

    This should fix the bug for code like (note the indendation levels):

    1. namespace foo { // insert line here
    2. class bar;
    3. }
    4. class asdf { // insert line here
    5. private:
    6. ...
    7. };
  • » KDevelop & KWrite/Kate hacksprint 2010 in Berlin

    Mon, 11/16/2009 - 16:38

    Hey everybody!

    If you are a KDevelop and/or Kate/Kwrite developer and do not read the mailing lists: There’s a hack sprint coming up in Berlin in 2010. I think there’ve been enough sprints in Berlin already so that you know it’s a great city for such an event. Though this time it won’t be at KDAB or Nokia offices, but at the Physics Faculty of the FU-Berlin. Since I (currently) work there as an IT admin, it was my first choice and worked out. I hope it will be a good location for the meeting. If you want to attend, vote on doodle:

    But you probably also should register either on the KDevelop or KWrite mailing lists so I have some kind of way to contact you.

    PS: in unrelated news I’ll do an internship at KDAB next year! yay

  • » Improving KDevelop-PG-Qt

    Mon, 10/26/2009 - 19:13

    Good news everyone :)


    After years of pretty much no documentation (except looking at the sources…), The_User aka. Jonathan Schmidt-Dominé started documenting the parser generator that is used for most KDevelop language plugins (java, python, php, …). You can find it here:

    It has to be improved and more examples have to be put in there, but it’s already a huge improvement over the situation before…


    In related news I did some profiling on the parsing of the quite big file that includes all internal PHP declarations (i.e. all functions, classes, definitions,…). It drops in at a whopping 1.9M, with ~80k lines. Well, turns out that this showed a pretty easy to fix bottleneck in KDevelop-PG’s LocationTable, which used to use a linear lookup algorithm. Profiling showed that nearly 75% was spent in that function. But I used the past tense for a reason:

    I replaced it with an algorithm that combines a relative search (i.e. relative to the last lookup) with a binary search fallback. That’s comparatively blazingly fast. I added some benchmarks to KDevelop-PG-Qt that proofs that (benchmark below run with release mode build):

    1. ********* Start testing of KDevPG::Benchmarks *********
    2. Config: Using QTest library 4.5.2, Qt 4.5.2
    3. PASS : KDevPG::Benchmarks::initTestCase()
    4. RESULT : KDevPG::Benchmarks::positionAt():"initial, linear":
    5. 1,184.0 msec per iteration (total: 11840, iterations: 10)
    6. RESULT : KDevPG::Benchmarks::positionAt():"initial, random":
    7. 1,008.5 msec per iteration (total: 10085, iterations: 10)
    8. RESULT : KDevPG::Benchmarks::positionAt():"relative, linear":
    9. 1.3 msec per iteration (total: 14, iterations: 10)
    10. RESULT : KDevPG::Benchmarks::positionAt():"relative, random":
    11. 1,185.0 msec per iteration (total: 11850, iterations: 10)
    12. RESULT : KDevPG::Benchmarks::positionAt():"binary, linear":
    13. 31.1 msec per iteration (total: 312, iterations: 10)
    14. RESULT : KDevPG::Benchmarks::positionAt():"binary, random":
    15. 39.2 msec per iteration (total: 392, iterations: 10)
    16. RESULT : KDevPG::Benchmarks::positionAt():"binary & relative, linear":
    17. 0.8 msec per iteration (total: 8, iterations: 10)
    18. RESULT : KDevPG::Benchmarks::positionAt():"binary & relative, random":
    19. 40.2 msec per iteration (total: 402, iterations: 10)
    20. PASS : KDevPG::Benchmarks::positionAt()
    21. PASS : KDevPG::Benchmarks::cleanupTestCase()
    22. Totals: 3 passed, 0 failed, 0 skipped
    23. ********* Finished testing of KDevPG::Benchmarks *********

    In our “realworld” phpfunctions.php example the DUChain building process got twice as fast (in debug mode though, but still).

    We should probably get lost of the LocationTable altogether and use an existing container (QList, QVector, QLinkedList,… or any STL variant of them). But this would mean more profiling, and well, lets see when we get to it… But just got a reply on the KDevelop list showing interest on this, so maybe someone does that eventually!

    Profiling rocks, and KCacheGrind is such a great application. I love such visualization. Well done! And the QTestLib benchmark utilities are also very solid, nice!

    PS: KDevelop beta6 is in the pipelines and we’ll release a beta1 of the PHP plugin together with it. Packagers and users rejoice :)

  • » first experience with Archlinux

    Sun, 10/18/2009 - 02:24

    So, I kinda messed up my desktop right after the upgrade to karmic, because I was too greedy for performance and converted my root file system to ext4. Well, that worked like a charm on my laptop, but it broke my desktop. This is in no way karmic’s fault, it’s my own misbehavior. Thankfully I could rescue most of my data.

    Since I’d had to reinstall anyways, I decided to finally try out Archlinux. I find the rolling release mantra very intriguing. Together with a “simpler” packaging, namely no splitting between -dev and -dbg packages like debian/ubuntu does, this is destined to be a good environment for a developer. I always hated it to track down missing -dev packages when compiling software. And don’t get me started on outdated software in repos… I just compiled kdelibs and the only missing build dependency was hspell, that I don’t need anyways. Under Jaunty I had to compile stuff from kdesupport to fulfill updated dependencies. And the list of not-found optional dependencies was huge, since I did not spent time to install all those -dev packages by hand…

    My first impression of Archlinux is very good so far. I also finally migrated to 64bit wich works like a charm, no issues with flash or anything. Since I never used a 64bit Ubuntu/Debian I’m not sure, whether the perceived performance increase is due to the switch to 64bit or whether Archlinux optimized packages are responsible. Probably both. Nevertheless I can safely say that my system feels snappier than before.

    Of course, the installation and initial setup is not as straight forward / easy as with Debian/Ubuntu: Yet it’s no big deal for anyone with some Linux experience. And, once everything is setup, you are running KDE again, so no real difference. Thanks to the Chakra team for kdemod, it works like a charm!

    I might have spent a bit more time during the installation / initial configuration, but I think this would have happened also if I’d installed any other distro I’ve never used before, like OpenSuse or Fedora.

    Oh and since I can install sudo I can keep my old habits. Neat.

    The only thing I miss so far is aptitude with it’s straight forward command structure. Yaourt/Pacman is fast and nice, esp. with pacman-color, but the commands don’t feel as straight forward to me… Personal preference I’d say.

    To conclude: Archlinux is very nice, I can wholeheartedly recommend using it so far. Probably nothing for a novice Linux user, yet perfect for advanced users. Very good as a development environment. Fast. Up to date. I like it :)

    Now I can finally continue hacking on Kate/Kdelibs again :) I’m currently in the process of refactoring Kate’s implementation of the TemplateInterface. Even in it’s current state it already implements features like mirrored snippets and the like. But once I’ve finished with the cleanup I will try to implement some more of the features that are found in e.g. yasnippet for Emacs. I really wonder why nobody else did that already…

    Once this is finished, you can expect that I will deeply integrate that feature in various places in KDevelop, especially for code completion, snippet plugin etc. pp. Stay tuned!

  • » KDevelop PHP digest - August to Oktober 2009

    Fri, 10/02/2009 - 15:08

    Hi there again! I’ve been silent again on my blog, but didn’t rest on development. In the one and a half months since the last digest, I started writing a PHP application This finally made me eat my own dog food :). It resulted in lots of polishing and quite a few bug fixes for the PHP plugin in KDevelop. Here’s a list of what I think are the notably changes since the last digest:

    (Note: to view screenshots, go to the bottom of this article.)

    • refactoring of parts of the Code Completion code, should already result in faster code under certain situations
    • properly mark constants as “Kind: Constant” in the declaration tooltips
    • offer argument hints for ctors during code completion in class init statements
    • greatly improve the generate inline documentation of built-in PHP functions, classes, properties etc. pp.
      • add documentation of public properties
      • support aliased functions (thanks to Victor Grischenko for his patch)
      • show more/all documentation, and not only the first paragraph
      • fix type-lookup
      • don’t get confused when a documentation file documents both, a method and a function (greatly improves e.g. MySQLi documentation)
    • don’t offer “jump to declaration” for built-in PHP declarations
    • add support for list(...) statement
    • cleanup code-completion list, esp. show the return type of functions in the prefix field, and not something a la “function ReturnType ($arg1, $arg2, …)”
    • improve the code-completion for include/require statements
    • add language constructs to code completion (e.g. class, while, foreach, print, …)
    • show declaration tooltip for magic constants, showing their current value
    • make functions, methods and classes case-insensitive, just like PHP handles them
    • some performance improvements, especially in code completion and parsing of the generated file containing php-internal declarations
    • lots of bug fixes, don’t want to iterate them all ;-)

    I created a Flickr account and will push screenshots to it for every upcoming digest I do. To see some of the features I talk about above, visit:

    EDIT: A note to those that want to try this out , but cannot / don’t want to compile it: I heard that there is / will be an AUR package for Arch users available. And I’d really appreciate it if others could create packages for their favorite distribution as well. You’ll need bleeding-edge kdevplatform + kdevelop though!

  • » Spotlight: linux-minidisc

    Thu, 09/03/2009 - 18:36

    Hi there!

    Today I want to abuse the fact, that my blog is aggregated on some planets, to bring a project of a friend of mine into the spotlight:

    The Linux-Minidisc project

    It’s a project to bring Read/Write access on mini discs to Linux. It consists of a CLI and a Qt Gui. All code is licensed under the GPL and can be accessed via Git.

    To get a nice introduction about the project, read this excerpt from a recent Linux Journal edition:

    The project itself has a wiki under the following address:

    As every other FOSS project, Adrian and his fellow developers need more man power. Especially someone who can spruce up the Qt GUI is needed. Help them!

  • » Easily access quassellogs from the CLI

    Thu, 08/27/2009 - 16:56

    Quassel is really a cool program. I like how I can use it from everywhere and access the same set of data. Now using IMAP and Quassel I’d really look forward for similar shared access to other IMs, but that’s not the topic of this blog post.

    What I want to introduce is a new addition to my set of shell helpers, called quassellog:

    1. $ quassellog -u milian -b "#kdevelop" | tail -n 1
    2. [2009-08-27 13:09:11] milian > hi all
    3. $ quassellog -b "#kdevelop" | tail -n 1
    4. [2009-08-27 16:43:35] Fersis!n=Fersis@ > yeah i did
    5. $ quassellog
    6. quassellog [-u USER] [-b BUFFER] [PATTERN]
    8. -u USER show only messages from users, who have USER at
    9. the start of their sender name.
    11. -b BUFFER show only messages in this buffer
    12. valid buffers are:
    13. ##linux #khtml &IMP ...SNIP...
    15. PATTERN a simple pattern, use * for wildcard matching
    17. NOTE: order of options is not exchangable, i.e. first -u, then -b then pattern...

    You can get the code from github. To make it work from all your servers I recommend the following alias:

    1. alias quassellog='QUASSEL_HOST=theHostQuasselCoreRunsOn quassellog'
    2. # e.g. for me:
    3. alias quassellog='QUASSEL_HOST=jongleur quassellog'

    That way the script runs automatically on the right server (provided it’s also accessible there under the same path). Have fun!

  • » Improved PHP support in Kate

    Wed, 08/26/2009 - 16:20

    Not only KDevelop gets better and better PHP support — the Kate PHP syntax file also got a few new features and fixes over the last weeks. The good thing is of course that all users of KWrite, Kate, Quanta, KDevelop and other editors leveraging the Katepart benefit from these changes.

    Improved HereDocs

    screenshot of improved highlighting in PHP heredocs
    screenshot of improved highlighting in PHP heredocs

    I went over PHP related bugs on today and spotted one that was fairly easy to fix:

    vim-like syntax highlighting support for heredocs in php.xml

    With some magic (IncludeRules just rocks) I got it working fairly easy. You can see the results to the right.

    Additionally I added code folding to heredocs, since often these strings include lots of text and hiding it often makes sense.

    Better support for overlapping syntax regions

    code folding with overlapping syntax regions
    code folding with overlapping syntax regions

    Another long standing bug (accommodate overlapping syntax regions (especially for php)) got fixed by James Sleeman.

    Finally PHP templates with code such as

    1. <?php if ( true ) : ?>
    2. <!-- some html stuff -->
    3. <?php elseif ( false ) { ?>
    4. <!-- some other html stuff -->
    5. <?php } ?>

    can be folded properly. This kind of spaghetti code is used quite often in simple templates and having the posibility to fold it properly is a huge win in my opinion. Thanks to James Sleeman again!

  • » News for PHP in KDevelop

    Sun, 08/16/2009 - 01:24

    So, after a period of silence I present you an unsorted list of features and bug fixes I did to the PHP plugin for KDevelop in the last few weeks:

    • added support for path autocompletion after require / include statements: This shares code with the Cpp plugin and it’s completion after #include. I plan to use this autocompletion eventually also for functions accepting filenames or paths. Think of fopen, file_get_contents etc. pp. So far only URLs that are covered by an open project can be completed. We will need support for custom include paths so we can support e.g. global PEAR or framework installations.

    • worked around a bug where the “schedule all project files for parsing” had no affect. Apaku is currently working on making some internal changes so I can remove the workaround and fix this properly. With this fixed/worked around you should retry the PHP plugin along with frameworks or similar to see how well it works. Just make sure to have the framework inside your project so it gets parsed.

    • fixed code completion of static class members for classes that where not defined in the current file

    • by sharing code with the cpp plugin I made it possible to show information about includes on hover. You can open the file from that popup or just see what classes, functions, variables etc. are defined there and jump to them quickly.

    • report errors when the user tries to include a directory

    • totally rewrite a huge part of the code completion: It now utilizes the token stream and can hence work much more reliably. Also the code is much cleaner in my opinion and it should be easier to extend its functionality. If you spot places where you think no code completion should happen or vice versa, please report that to me!

    • don’t crash on empty includes (i.e. include ""; )

    • ignore xml declarations (i.e. <?xml ... ?>)

    • support implicit declarations of referenced arguments, esp. important for e.g. preg_match("#...#", $string, $matches);, before the $matches was said to be undefined. Additionally references should be marked and shown as such now in the popups of e.g. function arguments.

    • support implicit array declarations, e.g. $a[0] = 1; // now $a is an array

    • fix bug which made the class browser not aware of changes in PHP class structures. Now we can see new classes, methods and members directly after writing them in a PHP file.

    • support /// comment syntax for doc-comments, especially useful for type hints of variables.

    • report error when someone tries to declare a class constant with an invalid type (i.e. not bool, int, float or string)

    I’m very happy to say that we seem to get more and more (happy) users!

  • » Dear Lazy Web: Hackable Mobile Phone with good Music Player?

    Mon, 07/06/2009 - 10:31

    Hey all, I need your help:

    I lost my Ipod and now have to live without music on the road… Sucks pretty much, I can’t live without music…

    Since my current mobile phone is pretty shabby I thought about fixing both in one go: Buy a mobile phone which could replace my Ipod as well!

    Now lets first say what I need most:

    • should’nt be too expensive: A new Ipod with 120gb costs only ~200€. So even though I hate that device, I doubt I’ll pay like twice the sum just to get something different…
    • It needs a “Klinke” stereo output, i.e. something where I can put my normal headphones in.
    • I need space for my music: My last Ipod (80Gb) was completly full… Ok, I think I can make a few cuts, though 8gb only is not enough. Hence the phone should support hot-swapping of SDHC cards at least.
    • If I buy such an expensive device, I’d like to be able to write my own software for it, or put existing software on it.

    What I found is the Nokia 5800 express music. It costs like ~260€. 16Gb more space costs like ~45€… It has stereo output and SDHC support. But what I don’t know: Where will custom software be saved on? Also on the SDHC? That would make hot-swapping kind of pointless…

    Good thing: It’s S60 5th gen, so Qt will run it and I can write my own software - that’s pretty cool. Though one question: Do I need Windows for the SDKs or can I develop under Linux?

    So… Does anyone have a better suggestion? Or any experience with that mobile phone? I really hate that there is no alternative to Ipods with a lot of space… Monopoly sucks! And I can’t even put my own stuff on such an Ipod… Not even Rockbox any more :( I hate Apple for that!

    But since I’m a poor student I somehow really doubt that I’ll get myself a new phone, esp. since additional SDHC cards cost quite much…