Bug 179295 - syntax highliting for .spec files: implement the yellow vertical bar on the left - for %if directives
Summary: syntax highliting for .spec files: implement the yellow vertical bar on the l...
Alias: None
Product: kate
Classification: Unclassified
Component: syntax (show other bugs)
Version: unspecified
Platform: unspecified Linux
: NOR wishlist (vote)
Target Milestone: ---
Assignee: KWrite Developers
Depends on:
Reported: 2009-01-01 17:05 UTC by urwald
Modified: 2009-01-18 21:24 UTC (History)
0 users

See Also:
Latest Commit:
Version Fixed In:

Experimental support for %if... and section headers (3.72 KB, application/xml)
2009-01-02 19:22 UTC, Joseph Wenninger
rpmspec.xml (8.48 KB, application/xml)
2009-01-03 14:33 UTC, urwald
template.spec (5.40 KB, text/plain)
2009-01-03 14:34 UTC, urwald
kdevelop3.spec (21.56 KB, text/plain)
2009-01-03 14:35 UTC, urwald

Note You need to log in before you can comment on or make changes to this bug.
Description urwald 2009-01-01 17:05:57 UTC
Version:           4.1.3 (KDE 4.1.3) "release 4.9" (using 4.1.3 (KDE 4.1.3) "release 4.9", openSUSE 11.1)
Compiler:          gcc
OS:                Linux (x86_64) release

For .cpp and .h and for many other files types, kwrite displays a vertical bar on the left, with yellow parts where you can hide or show for example the lines of a comment or a function. (I don't know how this feature is called.)

It would be great to have this feature also for .spec files. It would be very practical to be able to hide and show a block of conditional compiling.

So it would be about blocks of lines who start with a line that starts with "%if" (including "%ifarch", %ifos"...) and who end with a line that starts with "%endif".

This would especially be very helpfull because in .spec files you can't do indeting.
Comment 1 urwald 2009-01-02 11:41:28 UTC
It would also be usefull to highlight the beginn of sections (%description, %prep, %build, %install, %clean, %files, %changelog) more.

Actually these words are just painted in red color, just like everything else that starts with %. But as they have a special function (=starting a new section in the spec file), they could be highlighted much more.
Comment 2 Anders Lund 2009-01-02 11:53:25 UTC
I don't think it would be very difficult to implemnt your ideas, and AFAICS they are good! Did you look insde the xml file: $(kde-config --path data)/katepart/syntax/rpmspec.xml ? It is not extremely difficult to understand!
Comment 3 urwald 2009-01-02 12:57:50 UTC
Yes, I've looked into this file. However I didn't understand it really good. Is there any documentation available for the file format?
Comment 4 Anders Lund 2009-01-02 13:09:25 UTC
There is documentation in the maual, and at http://www.kate-editor.org.


The relevant manual chapter is here: http://docs.kde.org/kde3/en/kdebase/kate/katehighlight-xml-format.html
Comment 5 Joseph Wenninger 2009-01-02 19:22:57 UTC
Created attachment 29836 [details]
Experimental support for %if... and section headers

I have no good test spec file and I don't know enough about the syntax, so please try this and give feedback. If it is okay, I'll commit it
Comment 6 urwald 2009-01-03 14:33:29 UTC
Created attachment 29862 [details]

Okay, I've tried it - it's working.

But finally, I've spend some hours and made a new XML description for .spec files from scratch. While not perfect, it's IMHO much better than the previous one - highlighting is much more exact and fits better the meaning in the .spec file. Folding blocks are not supported for sections, but implemented only for %if/%endif blocks (because %if blocks can span over several (parts of) sections - it would not work fine to support folding blocks for both.) I'll attach test files for trying out the XML description...
Comment 7 urwald 2009-01-03 14:34:20 UTC
Created attachment 29863 [details]

example .spec file, showing some features of the new XML description
Comment 8 urwald 2009-01-03 14:35:37 UTC
Created attachment 29864 [details]

A (quite big and complex) real word example from openSUSE build service
Comment 9 Joseph Wenninger 2009-01-04 22:46:08 UTC
SVN commit 905702 by jowenn:

New RPM Spec file highlighting and two testcases, created / uploaded by Tim Fechtner as attachments to bug 179295.
BUG: 179295

 M  +129 -60   syntax/data/rpmspec.xml  
 A             tests/highlight.spec  
 A             tests/highlight1.spec  

WebSVN link: http://websvn.kde.org/?view=rev&revision=905702
Comment 10 urwald 2009-01-18 21:24:31 UTC
Verified in 4.2 RC.