Hi, On Mon, Aug 22, 2011 at 10:35 PM, Christian Brabandt <cbli...@256bit.org> wrote: > Hi Charles! > > On Mo, 22 Aug 2011, Charles Campbell wrote: > >> The following short C file illustrates this problem: >> >> /* abc.c: */ >> #include <stdio.h> >> >> #if 0 >> int main() >> { >> printf("testing\n"); >> return 0; >> } >> #endif >> >> /* Modelines: >> * vim: fdm=syntax >> */ >> >> The #if 0 ... #endif region does not fold (and the modeline has set >> fdm to syntax). I see this behavior with >> >> vim -u NONE -N --noplugins abc.c >> :syn on >> >> The modelines comment does fold, thereby indicating that the >> syntax-based folding is active. >> >> Version information: >> >> VIM - Vi IMproved 7.3 (2010 Aug 15, compiled Aug 22 2011 12:23:56) >> Included patches: 1-285 >> Compiled by cecam...@xorn.gsfc.nasa.gov >> Huge version with GTK2 GUI. Features included (+) or not (-): > > I see. Attached patch fixes it. > > regards, > Christian > --
Christian, thank you for the patch, it nearly worked out right, but there is a problem: If the #if 0 ... has an #else clause, this should not be folded. I think, someone was confused by a doubled negation in the c.vim file ( !exists("c_no_if0_fold") ). The attached patch should fix it. @Bram: I send this mail directly to you, because i don't think, that i am subscribed to the dev mailing list. -- You received this message from the "vim_use" maillist. Do not top-post! Type your reply below the text you are replying to. For more information, visit http://www.vim.org/maillist.php
--- c.vim.diff 2011-08-26 13:12:04.000000000 +0200 +++ c.vim 2011-08-26 13:11:42.000000000 +0200 @@ -279,9 +279,9 @@ syn region cCppOutWrapper start="^\s*\(%:\|#\)\s*if\s\+0\+\s*\($\|//\|/\*\|&\)" end=".\@=\|$" contains=cCppOutIf,cCppOutElse syn region cCppOutIf contained start="0\+" matchgroup=cCppOutWrapper end="^\s*\(%:\|#\)\s*endif\>" contains=cCppOutIf2,cCppOutElse if !exists("c_no_if0_fold") - syn region cCppOutIf2 contained matchgroup=cCppOutWrapper start="0\+" end="^\s*\(%:\|#\)\s*\(else\>\|elif\s\+\(0\+\s*\($\|//\|/\*\|&\)\)\@!\|endif\>\)"me=s-1 contains=cSpaceError,cCppOutSkip - else syn region cCppOutIf2 contained matchgroup=cCppOutWrapper start="0\+" end="^\s*\(%:\|#\)\s*\(else\>\|elif\s\+\(0\+\s*\($\|//\|/\*\|&\)\)\@!\|endif\>\)"me=s-1 contains=cSpaceError,cCppOutSkip fold + else + syn region cCppOutIf2 contained matchgroup=cCppOutWrapper start="0\+" end="^\s*\(%:\|#\)\s*\(else\>\|elif\s\+\(0\+\s*\($\|//\|/\*\|&\)\)\@!\|endif\>\)"me=s-1 contains=cSpaceError,cCppOutSkip endif syn region cCppOutElse contained matchgroup=cCppOutWrapper start="^\s*\(%:\|#\)\s*\(else\|elif\)" end="^\s*\(%:\|#\)\s*endif\>"me=s-1 contains=TOP,cPreCondit syn region cCppInWrapper start="^\s*\(%:\|#\)\s*if\s\+0*[1-9]\d*\s*\($\|//\|/\*\||\)" end=".\@=\|$" contains=cCppInIf,cCppInElse