On Fri, Dec 10, 2010 at 09:48:40AM EST, Alex Efros wrote:
> Hi!
> 
> On Wed, Dec 08, 2010 at 12:44:37PM -0500, Chris Jones wrote:

> > The problem with this is that in Vim, non-asciidoc text (especially
> > where indentation is used to structure the document) often end up
> > syntax-highlighted in all kinds of weird colors.

> [cut]

> > Has anybody come up with a convenient implementation?
> 
> File type auto-detection configured in
>     
> http://code.google.com/p/asciidoc/source/browse/vim/ftdetect/asciidoc_filetype.vim
> which is probably installed on your system in
>     /usr/share/vim/vimfiles/ftdetect/asciidoc_filetype.vim
> 
> As you can see, there both unconditional and conditional implementations
> available, but unconditional is default one.
> 
> So, as first option, you can switch from unconditional to conditional by
> commenting first and uncommenting second line.

I saw that.

> 
> For me, conditional implementation doesn't work good enough,

We have indeed reached the same conclusion... :-)

> and at a glance it can be replaced by much simpler implementation
>(keeping in mind main document header is required for all document
>types, if I remember correctly):

> 
>     autocmd BufRead    *.txt,README,TODO,CHANGELOG,NOTES if getline(1) =~ '^= 
> '   | setlocal filetype=asciidoc | endif
>     autocmd BufRead    *.txt,README,TODO,CHANGELOG,NOTES if getline(2) =~ 
> '^====' | setlocal filetype=asciidoc | endif
>     autocmd BufNewFile *.txt,README,TODO,CHANGELOG,NOTES setlocal 
> filetype=asciidoc

Ah, thanks Alex, this definitely would work with most of the articles
I have written so far. 

The problem at a glance will be with parts of articles that are
‘included’ in articles and will normally not start with either 

  =Title

or

  Title
  =====

Fortunately, I don't have many of those at this point, your solution is
definitely worth a try.

OTOH, tex/latex files are ascii text and yet they have their own
official .tex/.latex MIME types. Python as well, for that matter. That's
why I was looking for what might have transpired in prior discussions of
these aspects: or is the jury still out on this one?

Thanks,

cj

-- 
You received this message because you are subscribed to the Google Groups 
"asciidoc" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/asciidoc?hl=en.

Reply via email to