Thread: [Vim-latex-devel] Nested manual folding
Brought to you by:
srinathava,
tmaas
From: Cristian R. <cr...@li...> - 2006-02-02 22:31:35
|
Hi, I'm trying to allow nesting for manual folds in latex-suite; to do so I tried modifying the function MakeTexFolds in folding.vim, adding the "start= skip" and "endskip" arguments to the call of AddSyntaxFoldItem, like that (line 3= 26): " Original code "call AddSyntaxFoldItem (=20 " \ '<<<', " \ '>>>', " \ 0, " \ 0 " \ ) =20 " My re-writing: call AddSyntaxFoldItem ( \ '<<<', \ '>>>', \ 0, \ -1, \ '<<<', \ '>>>' \ ) But unfortunately it doesn't seem to work; as I open a latex file in vim, it freezes eating up all my CPU; if I break it with Ctrl-C I got a couple of e= rrors and a badly highlighted file. Error detected while processing /home/cri/.vim/ftplugin/tex_latexSuite.vi= m: line 13: Interrupted Error detected while processing /usr/share/vim/vim64/ftplugin/tex.vim: line 1: Interrupted (I'm using latest tgz package on Debian GNU/Linux unstable and vim 6.4) This happens whatever value I set to g:Tex_FoldedMisc (except, of course, i= f I don't include '<<<'). Are my changes wrong or am I missing something? For the curious, the reason why I'm looking for nested manual folds lies in= the fact that I'd like to define "arbitrary" manual foldings in the preamble (possibly containing blocks of comments) but "comment" folds seem to intera= ct badly with "manual" folds; again, I tried various settings of g:Tex_FoldedM= isc (e.g. exchanging the order of "<<<" and "comments") but I didn't find the right one; so that's why I turned to nested manual folding: if I could make them work, I would use only manual folding, dropping "comment" and "preambl= e" (which don't seem to work the way I expect together with manual folds). (I can elaborate on that and provide some examples if you are interested) Well, thanks for reading (and of course, thanks for this great project)! Cri --=20 GPG/PGP Key-Id 0x943A5F0E - http://www.linux.it/~cri/cri.asc |
From: Srinath A. <sri...@gm...> - 2006-02-03 03:19:40
|
Hi, upon reading the latter part of your email, I think there might be better ways to accomplish what you wish... Unfortunately, what you need is not really supported by latex-suite OOTB, but the modification is not that hard... I am still not quire sure why what you did is making latex-suite hang... Thats a bug for another day. On 2/2/06, Cristian Rigamonti <cr...@li...> wrote: [snip] > > For the curious, the reason why I'm looking for nested manual folds lies = in the > fact that I'd like to define "arbitrary" manual foldings in the preamble > (possibly containing blocks of comments) but "comment" folds seem to inte= ract > badly with "manual" folds; again, I tried various settings of g:Tex_Folde= dMisc > (e.g. exchanging the order of "<<<" and "comments") but I didn't find the > right one; so that's why I turned to nested manual folding: if I could ma= ke > them work, I would use only manual folding, dropping "comment" and "pream= ble" > (which don't seem to work the way I expect together with manual folds). > > (I can elaborate on that and provide some examples if you are interested) > > Well, thanks for reading (and of course, thanks for this great project)! > Can you try opening the following file and then opening it after applying the patch (also attached) to folding.vim? Is something like this what you want? Srinath \documentclass[a4paper]{report} %{{{ Packages %{{{ Math Packages \usepackage[sumlimits]{amsmath} \usepackage[sumlimits]{float} %}}} %{{{ Some other Packages \usepackage[sumlimits]{amsmath} \usepackage[sumlimits]{float} %}}} %}}} %{{{ Commands %{{{ Math commands \renewcommand{trivial}{trivial} \renewcommand{trivial}{trivial} %}}} %{{{ Some other commands \renewcommand{trivial}{trivial} \renewcommand{trivial}{trivial} %}}} %}}} \begin{document} %<<< A region of text \section{A section} This is a block This is a block \section{Another section} This is a block This is a block %>>> %<<< Another region of stuff \section{A third section} This is a block This is a block %>>> \end{document} Index: folding.vim =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D RCS file: /cvsroot/vim-latex/vimfiles/ftplugin/latex-suite/folding.vim,v retrieving revision 1.26 diff -u -r1.26 folding.vim --- folding.vim=093 Jan 2006 08:40:39 -0000=091.26 +++ folding.vim=093 Feb 2006 02:48:29 -0000 @@ -219,11 +219,24 @@ =09" =09" }}} =09" =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D + +=09" Manually folded regions {{{ +=09if g:Tex_FoldedMisc =3D~ '\(^\|,\)<<<\(,\|$\)' +=09=09call AddSyntaxFoldItem ( +=09=09=09\ '%{{'.'{', +=09=09=09\ '%}}'.'}', +=09=09=09\ 0, +=09=09=09\ 0, +=09=09=09\ '%{{'.'{', +=09=09=09\ '%}}'.'}' +=09=09=09\ ) +=09endif +=09" }}} =09 =09" {{{ comment lines =09if g:Tex_FoldedMisc =3D~ '\<comments\>' =09=09call AddSyntaxFoldItem ( -=09=09=09\ '^%\([^%]\|[^f]\|[^a]\|[^k]\|[^e]\)', +=09=09=09\ '^% ', =09=09=09\ '^[^%]', =09=09=09\ 0, =09=09=09\ -1 @@ -326,8 +339,8 @@ =09" Manually folded regions {{{ =09if g:Tex_FoldedMisc =3D~ '\(^\|,\)<<<\(,\|$\)' =09=09call AddSyntaxFoldItem ( -=09=09=09\ '<<<', -=09=09=09\ '>>>', +=09=09=09\ '^%<<<', +=09=09=09\ '^%>>>', =09=09=09\ 0, =09=09=09\ 0 =09=09=09\ ) |
From: Cristian R. <cr...@li...> - 2006-02-03 15:33:13
Attachments:
folding.vim.cri.patch
|
On Thu, Feb 02, 2006 at 06:50:17PM -0800, Srinath Avadhanula wrote: > I am still not quire sure why what you did is > making latex-suite hang... Thats a bug for another day. Thank you very much for your quick and valuable answer. Well, I found out that substituting '<<<' patterns with '^%<<<' (see attached patch) makes the "hang" problem disappear, and I got the nested manual folds to work as I wanted, although with the following caveats: - A) To avoid that a comment fold "eats up" any subsequent manual folds separated by empty lines, like in the following situation... % Comment block % ... % End comment block %<<< Manual fold ... %>>> ...you must include the empty line (i.e. the '^$' pattern) in the comment folds endpattern (as I've done in my patch). Note that this problem affects also your proposed patch. - B) If you want things to work nicely in the preamble too, you have to switch off the 'preamble' value from g:Tex_FoldedMisc (e.g. setting it to 'item,<<<,comments'), otherwise folds inside the preamble won't work anymore (you can only choose between a completely folded preamble or a completely unfolded one). Although this is not a major limitation (since you can always enclose the whole preamble in a big manual fold and retain nested manual folds), I tried to fix it by adding startskip and endskip pattern for the "preamble" folds, but without success (it seems that whatever skip pattern I add, the preamble doesn't get folded anymore, but I admit that I didn't play too much with that). > Can you try opening the following file and then opening it after > applying the patch (also attached) to folding.vim? Is something like > this what you want? I tried your patch and it works nicely, it does not suffer from the "preamble" bug as mine, although it suffers from the "empty line" bug I mentioned above. I tried fiddling with it a bit in order to see if we can avoid to use two different kinds of manual folding markers ("{{{" and "<<<"), but I couldn't achieve any better results than those of my patch. So, for now I'm quite satisfied with my patch, but I admit it could be interesting to work on the B) problem, in order to restore "normal" preamble folding working... Thanks again for your reply! Cri -- GPG/PGP Key-Id 0x943A5F0E - http://www.linux.it/~cri/cri.asc |