Charles Campbell wrote:
> David Fishburn wrote:
>> I am writing an indent script for Flex which has similar HTML and Javascript.
>>
>> So the indent script is pretty simple.
>>
>> If inside a <mx:Script> tag"
>>           return cindent(a:lnum)
>> else
>>           " indent like XML
>> endif
>>
>> In my other indent scripts I have never used cindent() before.
>>
>> In my sample app, I have:
>> cinoptions=
>>
>> <?xml version="1.0" encoding="utf-8"?>
>> <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml";>
>>      <mx:Script>
>>      <![CDATA[
>>      private function update():void
>> {
>>
>> So, cindent() returns 4 for "private function update():void".
>> cindent() returns 0 for "{".
>>
>> Not sure really where to go from here.
>> I read through cinoptions, but nothing jumps out at me.
>>
>> Any ideas why it wouldn't return 4, as in the previous line?
>>   
> I believe cindent() is treating that "{" as the opening curly for a 
> function declaration;
> and "One requirement is that toplevel functions have a '{' in the first 
> column."
> 
> (from  :help C-indenting)

Your particular situation is also going to be difficult because
cindent() will look at context beyond the C code you want it to look at.
It will essentially try to return the indent the line would have if the
whole file were cindented. That means that because, e.g. <![CDATA[
doesn't have a semicolon at the end of it, the first line of your C code
will be thought to be a continuation of a line so will be indented
accordingly. Solving this will be tough, and I'm not sure what approach
would be best. Two possible solutions I can see are both very nasty: (1)
writing the C indenting functionality in Vimscript yourself; or (2)
copying the chunks of C code into another buffer, outdenting according
to the current XML indent, running cindent on it, then returning the
appropriate indent plus the current XML indent.

Ben.




--~--~---------~--~----~------------~-------~--~----~
You received this message from the "vim_use" maillist.
For more information, visit http://www.vim.org/maillist.php
-~----------~----~----~----~------~----~------~--~---

Reply via email to