filetype.vim

Bram Moolenaar Bram@moolenaar.net
Wed, 16 Mar 2005 17:36:02 +0100


Pierre -

> > OK, that problem I can see.  Strange, why would the rule work one
> > time and not the other time.  I'll look into it.  I don't want to add
> > ".gz", I want to fix the real problem.
> 
> Agreed.
> 
> So let me informed when you have a real solution ;)

The good solution is a bit complicated.

What happens is that the pattern [cC]hange[lL]og* matches
changelog.Debian.gz.  It then checks the first line for "urgency =", but
since the file is still compressed it doesn't match and sets the
filetype to "changelog".  After decompressing the file the filetype
is already set and won't be changed.

To avoid this I made all filetype checks with a pattern ending in a "*"
compare the filename against g:ft_ignore_pat.  I do this in a function,
called from many places.  This is too complicated to include in the
stable 6.3 version.  I have changed it for Vim 7.

If you want a temporary fix, use something like this (untested):

" Changelog
au BufNewFile,BufRead [cC]hange[lL]og*
  	\ if expand("<amatch>") !~ g:ft_ignore_pat
	\   if getline(1) =~ '; urgency='
	\|    call s:StarSetf('debchangelog')
	\|  else
	\|    call s:StarSetf('changelog')
	\|  endif
	\|endif

- Bram

-- 
It is illegal to rob a bank and then shoot at the bank teller with a water
pistol.
		[real standing law in Louisana, United States of America]

 /// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net   \\\
///        Sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
\\\              Project leader for A-A-P -- http://www.A-A-P.org        ///
 \\\     Buy LOTR 3 and help AIDS victims -- http://ICCF.nl/lotr.html   ///