Snippets In KDevelop / Kate
Wednesday, 3 February 2010
| Milian Wolff
Hey all!
Just wanted to give you a little rundown on Snippets in Kate 4.4 (via the snippets_tng plugin) and KDevelop Beta 8 (soon to be released).
Note: The Kate plugin was written by Jowenn and introduced me to all these nice features. For KDevelop I wrote a somewhat simpler yet imo better implementation. We will try to get the best of both worlds into KDE 4.5. Stay tuned!
General Usage & Features create a snippet repository (or download via GHNS [see below]) create snippets in that repository insert snippets via the snippets view (i.e. double click), or (imo better/faster) insert them via code-completion (remember: CTRL + Space requests code completion at the current cursor position!). snippet gets inserted (properly indented) and potential placeholders/variables get expanded. A variable is something like %{date} or ${email}. Also take a look at the API documentation. variables that get inserted via “${…}” will be “selectable”, meaning you can jump from one var to the other by hitting TAB / Shift TAB the %{...} vars will only get expanded and inserted, without getting selectable. multiple occurrences of the same variable will be updated once one of them gets edited, something that is called “mirroring” in other editors. once one edits ESC the cursor is placed at the end of the snippet or to the first occurrence of ${cursor} or %{cursor} and the user types something, the snippet-handler quits and you are left with your normal editor until you insert the next snippet nested snippets (i.e. insert snippet than insert another one) should “just work”. Snippet Management group snippets by file type, i.e. PHP snippets will only be offered during code completion when one edits a PHP file.
Note: In KDevelop and KDE 4.4 nested documents are supported, e.g. create a CSS snippet and it will be shown inside the CSS parts of a HTML document or similar. This uses my HighlightInterface I wrote for KDE 4.4. I still have to rewrite some parts of the snippets_tng plugin for Kate so that it works there as well group snippets in repositories, set an Author and a License of your choice publish snippet repositories via GHNS: In Kate you can already download snippets from GHNS but we sadly don’t have any repos up on opendesktop… I’ll have to add some prior to KDE 4.4. Also we didn’t have enough time to implement uploading of Repos from inside Kate in time for KDE 4.4. So stay tuned for KDE 4.5. KDevelop currently has no support for GHNS, but I plan to fix this tomorrow or the next days - together with uploading from inside KDevelop, i.e. all the nice features of GHNS v3. in KDevelop (and someday in Kate as well) you can simply select a part of your currently opened document and select the “create snippet from selection” in the ContextMenu - easy & fast! TODO There’s much to do.
Read More
Snippets In KDevelop / Kate
Wednesday, 3 February 2010
| Milian Wolff
Hey all!
Just wanted to give you a little rundown on Snippets in Kate 4.4 (via the snippets_tng plugin) and KDevelop Beta 8 (soon to be released).
Note: The Kate plugin was written by Jowenn and introduced me to all these nice features. For KDevelop I wrote a somewhat simpler yet imo better implementation. We will try to get the best of both worlds into KDE 4.5. Stay tuned!
General Usage & Features create a snippet repository (or download via GHNS [see below]) create snippets in that repository insert snippets via the snippets view (i.e. double click), or (imo better/faster) insert them via code-completion (remember: CTRL + Space requests code completion at the current cursor position!). snippet gets inserted (properly indented) and potential placeholders/variables get expanded. A variable is something like %{date} or ${email}. Also take a look at the API documentation. variables that get inserted via “${…}” will be “selectable”, meaning you can jump from one var to the other by hitting TAB / Shift TAB the %{...} vars will only get expanded and inserted, without getting selectable. multiple occurrences of the same variable will be updated once one of them gets edited, something that is called “mirroring” in other editors. once one edits ESC the cursor is placed at the end of the snippet or to the first occurrence of ${cursor} or %{cursor} and the user types something, the snippet-handler quits and you are left with your normal editor until you insert the next snippet nested snippets (i.e. insert snippet than insert another one) should “just work”. Snippet Management group snippets by file type, i.e. PHP snippets will only be offered during code completion when one edits a PHP file.
Note: In KDevelop and KDE 4.4 nested documents are supported, e.g. create a CSS snippet and it will be shown inside the CSS parts of a HTML document or similar. This uses my HighlightInterface I wrote for KDE 4.4. I still have to rewrite some parts of the snippets_tng plugin for Kate so that it works there as well group snippets in repositories, set an Author and a License of your choice publish snippet repositories via GHNS: In Kate you can already download snippets from GHNS but we sadly don’t have any repos up on opendesktop… I’ll have to add some prior to KDE 4.4. Also we didn’t have enough time to implement uploading of Repos from inside Kate in time for KDE 4.4. So stay tuned for KDE 4.5. KDevelop currently has no support for GHNS, but I plan to fix this tomorrow or the next days - together with uploading from inside KDevelop, i.e. all the nice features of GHNS v3. in KDevelop (and someday in Kate as well) you can simply select a part of your currently opened document and select the “create snippet from selection” in the ContextMenu - easy & fast! TODO There’s much to do.
Read More
Kate polishing
Thursday, 21 January 2010
| Milian Wolff
Phew, I just finished some last-minute backports to the KDE 4.3.5 branch. Lets hope the bug fixes I and pletourn did are as good as they look. Expect a much more stable Kate for 4.3.5 & 4.4! We managed to fix two bugs which are potentially the cause for dozens of bug reports, all seemingly random. Lets see whether our fixes hold up to our hopes!
Other than that: You should look forward to Kate scripting (with JavaScript) in 4.4. It’s dead simple but actually useful. In the utils.js file we ship with Kate there are now the following tools (all operate on the selection or - if none exists - on the whole document):
Read More
Kate polishing
Thursday, 21 January 2010
| Milian Wolff
Phew, I just finished some last-minute backports to the KDE 4.3.5 branch. Lets hope the bug fixes I and pletourn did are as good as they look. Expect a much more stable Kate for 4.3.5 & 4.4! We managed to fix two bugs which are potentially the cause for dozens of bug reports, all seemingly random. Lets see whether our fixes hold up to our hopes!
Other than that: You should look forward to Kate scripting (with JavaScript) in 4.4. It’s dead simple but actually useful. In the utils.js file we ship with Kate there are now the following tools (all operate on the selection or - if none exists - on the whole document):
Read More
Kate XML Completion Plugin: Help Wanted
Sunday, 17 January 2010
| Dominik Haumann
In KDE3 Kate had a plugin called “XML Completion Plugin”. It was able to list XML elements, attributes and attribute values and entities in a completion popup menu depending on the currently active DTD. For instance, it was able to complete all your KDE/docbook tags and, thus, was one of the best tools for writing KDE documentation.
Unfortunately, this plugin has not been ported to KDE4, yet. So this is a request for developers: Please someone pick it up and make it available for Kate in KDE4.
Read More
Kate Love: HighlightInterface, Autobrace
Sunday, 22 November 2009
| Milian Wolff
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:
HighlightInterface 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.
Read More
Kate Love: HighlightInterface, Autobrace
Sunday, 22 November 2009
| Milian Wolff
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:
HighlightInterface 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.
Read More
KDevelop & KWrite/Kate hacksprint 2010 in Berlin
Monday, 16 November 2009
| Milian Wolff
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:
Read More
Scripting Kate
Sunday, 1 November 2009
| Dominik Haumann
In my last blog I explained Kate’s scripting features in KDE 4.4. To better understand how scripting can be used let’s look at some use cases.
join lines: This feature request wants the action “join lines” to not join different paragraphs, i.e. not remove empty lines. We have not implemented this wish, as there are probably users who prefer the current behaviour. This request can be fixed by writing a small script that joins the lines according to the user’s wishes. reformat paragraph: An intelligent reformatter for paragraphs. Should be rather straight forward to implement. XML tools: In KDE3, Kate once had a xmltools plugin. Unfortunately noone ported it to KDE4. The plugin provided lots of very useful features for xml editing. For example, you could select text and then wrap it with xml elements, e.g. “text” would become “text”. This is a perfect example for a command line script as well. Any volunteers? :) Scripting also brings us closer to fixing the following reports:
Read More
Extending Kate with Scripts
Thursday, 29 October 2009
| Dominik Haumann
As mentioned in one of my last blogs, there has been quite some work for JavaScript scripting support in trunk recently. So what will Kate 3.4 (KDE 4.4) will bring? This is explained in detail in the sections:
Indentation Scripting Command Line Scripting Some Remarks The scripting allows to extend Kate with lots of little helper functions. All users can add scripts as they wish. The documentation here is copied from the official Kate handbook. So instead of using this blog as reference, please use the handbook later for an up-to-date version. To script something useful, you’ll need to know the scripting API. All the available functions are documented in the section Scripting API in the handbook as well. Enough said, here we go:
Read More