Version: 2.1 (using KDE 3.1.0) Installed from: (sid) Compiler: gcc version 2.95.4 20011002 (Debian prerelease) OS: Linux (i686) release 2.4.20-grsec Mathematical latex documents are look so chaotic with all the equation environments. It would help immensly with code-folding to collapse all the \begin{equation}\label{momentumconservation) ... ... \end{equation} into just +\begin{equation}\label{momentumconservation} Maybe code-folding also would work well for the 'figure' environment, and maybe also for each chapter/section/subsection. Thanks for a great editor. Torquil
This would be _so_cool_. I had exactly the same thing in mind. Actually so cool that I am on the verge of volonteering to do it. How does code folding work ? Is there some general code and XML syntax definition files that the folding algo load before doing its work ? That would be a great way to do it. It would need to include many different ideas though: 1) the most common delimiters-couple based: ( ), { }, [ ], begin{*} end {*}, if fi, etc... nestability defined as an attribute 2) indentation based (think python) 3) "new-marker" based, with hierarchy (more complicated): -Used for html, latex, etc.. -Folding at a level of the hierarchy fold everything under (much like nested delimiters-couple) -It would require a AnyLevel definition that could include delimiter-couple and other kind of stuff that can apply at any hierarchy level. -One of the main advantage of using XML files is that with expandable language (such as latex, where I can define custom \chapter function and use them everywhere), I can, as a user, modify the folding behaviour the same way I hack the highlighting today. MyGroup1={"\paragraph","\paragraphcustom1"} KateLevel0={ "\chapter", "\chaptercustom", } KateLevel1={"\section"} KateLevel2:{ "\subsection", "\otherstuff", } KateLevel3={ MyGroup1, "paragraphcustom2", } KateAnylevel={ } (I don't know XML yet, this is just to give an idea)
Have a look at kate's other xml highlighting files, including c++. The folding stuff is the beginRegion / endRegion attribute. Check also the kate website for some preliminary documentation on the xml format: http://kate.kde.org/doc/hlhowto.html
OK I've started to implement latex code-folding and while it is indeed pretty trivial for any \begin{} and \end{} environment block, I rapidely run into roblems with anything else. The main reason is that latex regions to fold, like \part{}, \section{}, \paragraph{}, do not end with a trivial matching token but with the begining of any other such region at an equal or deeper level of the hierarchy, where part > section > paragraph. So starting with revision 1.29 from here: http://webcvs.kde.org/cgi-bin/cvsweb.cgi/kdelibs/kate/data/latex.xml I try to do something like this: <context attribute="Normal Text" lineEndContext="#stay" name="Normal"> <snip...> <StringDetect String="\section{" attribute="Begin End" context="Paren1" insensitive="FALSE" endRegion="Sect" endRegion="SubSect" /> <StringDetect String="\subsection{" attribute="Begin End" context="Paren2" insensitive="FALSE" endRegion="SubSect" /> <snip...> </context> <context attribute="Environment" lineEndContext="#stay" name="Paren1" > <DetectChar char="}" attribute="Begin End" context="#pop" beginRegion="Sect"/> </context> <context attribute="Environment" lineEndContext="#stay" name="Paren2" > <DetectChar char="}" attribute="Begin End" context="#pop" beginRegion="SubSect"/> </context> or even simpler like this: <context attribute="Normal Text" lineEndContext="#stay" name="Normal"> <snip...> <StringDetect String="\section{" attribute="Begin End" context="Paren1" insensitive="FALSE" endRegion="Sect" endRegion="SubSect" beginRegion="Sect"/> <StringDetect String="\subsection{" attribute="Begin End" context="Paren2" insensitive="FALSE" endRegion="SubSect" beginRegion="SubSect"/> <snip...> </context> The problem is that it seem the code-folding functions don't allow to start and end a region on the same line. Even in .cpp with something like this: if(i){ a; }else{ b; } folding at the "if" level will change both if and else, while folding at the "else" level will do nothing. Well the additional problem with latex is that a single token must be able to end _many_ regions and start a new one. I don't think this is supported right now. Note that the beginRegion and endRegion must be able to match from one context to an other and that some endRegion must be able to appear for non existing beginRegion without problems. Is it likely that this feature will be implemented in Kwrite / Kate ? Not only latex would benefit
I've had a look to the cpp code but this is certainly to big for me to swallow considering the time I have. If I can make a suggestion for anybody who's familiar with the code, the basic idea would be to provide a list of RegionIds for the multiple endRegion strings that could be defined in a context subelement. In a document to be code-folded, if one or many effective endRegion strings are found on the same line of a beginRegion string, the desired result would be for the precedent code to fold upto but not incloding this line so that with: - if(a){ i; - } else { j; } we could get + if(a){ - } else { j; } and in latex: - \part{a} - \section{b} - \subsection{c} - \section{d} - \part{a} + \section{b} - \section{d} + \part{a}
*** This bug has been confirmed by popular vote. ***
Maybe some ideas could be got from kile, the latex file editor?
Kile currently has no code folding. It just switched over to Katepart though I think... It used it's own editor before.
Hi guys, Just to let you know, kile has its own XML file for syntax highlighting (didn't like to current one that comes with Kate, it's buggy too). You can get it from: http://webcvs.kde.org/cgi-bin/cvsweb.cgi/kdeextragear-2/kile/kile/syntax/ It is likely that this file is going to be the highlighting for Kate too. It would be great if you could implement the folding on this XML file. thanks, Jeroen - Kile maintainer
CVS commit by dhaumann: Added code folding. This file is latex-kile.xml from http://webcvs.kde.org/cgi-bin/cvsweb.cgi/kdeextragear-2/kile/kile/syntax/ Code folding for \section and \subsection is not possible right now. But there is a workaroud: Use region markers instead (%BEGIN, %END). Example: % BEGIN some description <text> % END This file is for KDE 3.3 (kate 2.3) and not backward compatible (eg. no KDE 3.2.x). However, there will be a version of this file in KDE 3.2.3 which supports this, too :) Jeroen: In theory you can remove your extra latex-kile.xml file now. If you don't want to remove it, make sure to use the one that is in KDE_3_2_BRANCH. You are btw, the author of the new latex.xml file, I hope you agree :-) CCMAIL: 54199-done@bugs.kde.org, Jeroen.Wijnhout@kdemail.net M +142 -338 latex.xml 1.31
> Added code folding. This file is latex-kile.xml from > http://webcvs.kde.org/cgi-bin/cvsweb.cgi/kdeextragear-2/kile/kile/syntax/ > Code folding for \section and \subsection is not possible right now. But I thought this was possible (using beginRegion and endRegion in one tag), however the feature is broken in KDE 3.2.x (and fixed in HEAD)? > there is a workaroud: Use region markers instead (%BEGIN, %END). Example: > % BEGIN some description > <text> > % END > > This file is for KDE 3.3 (kate 2.3) and not backward compatible > (eg. no KDE 3.2.x). However, there will be a version of this file in > KDE 3.2.3 which supports this, too :) How come the latex.xml is not backward compatible? The latex-kile.xml is, so what did you do to change that (the diff didn't tell me much)? > Jeroen: In theory you can remove your extra latex-kile.xml file now. If you Ok, thanks. I will keep the file until Kile requires KDE 3.3 though. > don't want to remove it, make sure to use the one that is in KDE_3_2_BRANCH. > You are btw, the author of the new latex.xml file, I hope you agree :-) That's ok :-) It's a good thing there will only be one latex.xml file (less confusing to Kile users), since I maintained latex-kile.xml anyway, there is no extra work for me. best, Jeroen
Thanks for the workaround. I think the status of this bug shouldn't be listed as "resolved" though as the work around is not trivial for people knowing just "raw latex".
code folding support right now: \begin{...} ... \end{...} A (sub-)section does not have a corresponding endsection, which makes it (almost?) impossible to match an end of a section correctly.