Bug 179295

Summary: syntax highliting for .spec files: implement the yellow vertical bar on the left - for %if directives
Product: [Applications] kate Reporter: urwald <urwald>
Component: syntaxAssignee: KWrite Developers <kwrite-bugs-null>
Status: CLOSED FIXED    
Severity: wishlist    
Priority: NOR    
Version: unspecified   
Target Milestone: ---   
Platform: unspecified   
OS: Linux   
Latest Commit: Version Fixed In:
Sentry Crash Report:
Attachments: Experimental support for %if... and section headers
rpmspec.xml
template.spec
kdevelop3.spec

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 2.6.27.7-9-default

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.

http://www.kate-editor.org/article/writing_a_kate_highlighting_xml_file

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]
rpmspec.xml

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]
template.spec

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]
kdevelop3.spec

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.