Karsten Hopp cf9f5a
" Vim support file to detect file types
Karsten Hopp cf9f5a
"
Karsten Hopp cf9f5a
" Maintainer:	Bram Moolenaar <Bram@vim.org>
Karsten Hopp cf9f5a
" Last Change:	2008 Nov 01
Karsten Hopp cf9f5a
Karsten Hopp cf9f5a
" Listen very carefully, I will say this only once
Karsten Hopp cf9f5a
if exists("did_load_filetypes")
Karsten Hopp cf9f5a
  finish
Karsten Hopp cf9f5a
endif
Karsten Hopp cf9f5a
let did_load_filetypes = 1
Karsten Hopp cf9f5a
Karsten Hopp cf9f5a
" Line continuation is used here, remove 'C' from 'cpoptions'
Karsten Hopp cf9f5a
let s:cpo_save = &cpo
Karsten Hopp cf9f5a
set cpo&vim
Karsten Hopp cf9f5a
Karsten Hopp cf9f5a
augroup filetypedetect
Karsten Hopp cf9f5a
Karsten Hopp cf9f5a
" Ignored extensions
Karsten Hopp cf9f5a
if exists("*fnameescape")
Karsten Hopp cf9f5a
au BufNewFile,BufRead ?\+.orig,?\+.bak,?\+.old,?\+.new,?\+.dpkg-dist,?\+.dpkg-old,?\+.rpmsave,?\+.rpmnew
Karsten Hopp cf9f5a
	\ exe "doau filetypedetect BufRead " . fnameescape(expand("<afile>:r"))
Karsten Hopp cf9f5a
au BufNewFile,BufRead *~
Karsten Hopp cf9f5a
	\ let s:name = expand("<afile>") |
Karsten Hopp cf9f5a
	\ let s:short = substitute(s:name, '\~$', '', '') |
Karsten Hopp cf9f5a
	\ if s:name != s:short && s:short != "" |
Karsten Hopp cf9f5a
	\   exe "doau filetypedetect BufRead " . fnameescape(s:short) |
Karsten Hopp cf9f5a
	\ endif |
Karsten Hopp cf9f5a
	\ unlet! s:name s:short
Karsten Hopp cf9f5a
au BufNewFile,BufRead ?\+.in
Karsten Hopp cf9f5a
	\ if expand("<afile>:t") != "configure.in" |
Karsten Hopp cf9f5a
	\   exe "doau filetypedetect BufRead " . fnameescape(expand("<afile>:r")) |
Karsten Hopp cf9f5a
	\ endif
Karsten Hopp cf9f5a
elseif &verbose > 0
Karsten Hopp cf9f5a
  echomsg "Warning: some filetypes will not be recognized because this version of Vim does not have fnameescape()"
Karsten Hopp cf9f5a
endif
Karsten Hopp cf9f5a
Karsten Hopp cf9f5a
" Pattern used to match file names which should not be inspected.
Karsten Hopp cf9f5a
" Currently finds compressed files.
Karsten Hopp cf9f5a
if !exists("g:ft_ignore_pat")
Karsten Hopp cf9f5a
  let g:ft_ignore_pat = '\.\(Z\|gz\|bz2\|zip\|tgz\)$'
Karsten Hopp cf9f5a
endif
Karsten Hopp cf9f5a
Karsten Hopp cf9f5a
" Function used for patterns that end in a star: don't set the filetype if the
Karsten Hopp cf9f5a
" file name matches ft_ignore_pat.
Karsten Hopp cf9f5a
func! s:StarSetf(ft)
Karsten Hopp cf9f5a
  if expand("<amatch>") !~ g:ft_ignore_pat
Karsten Hopp cf9f5a
    exe 'setf ' . a:ft
Karsten Hopp cf9f5a
  endif
Karsten Hopp cf9f5a
endfunc
Karsten Hopp cf9f5a
Karsten Hopp cf9f5a
" Abaqus or Trasys
Karsten Hopp cf9f5a
au BufNewFile,BufRead *.inp			call s:Check_inp()
Karsten Hopp cf9f5a
Karsten Hopp cf9f5a
func! s:Check_inp()
Karsten Hopp cf9f5a
  if getline(1) =~ '^\*'
Karsten Hopp cf9f5a
    setf abaqus
Karsten Hopp cf9f5a
  else
Karsten Hopp cf9f5a
    let n = 1
Karsten Hopp cf9f5a
    if line("$") > 500
Karsten Hopp cf9f5a
      let nmax = 500
Karsten Hopp cf9f5a
    else
Karsten Hopp cf9f5a
      let nmax = line("$")
Karsten Hopp cf9f5a
    endif
Karsten Hopp cf9f5a
    while n <= nmax
Karsten Hopp cf9f5a
      if getline(n) =~? "^header surface data"
Karsten Hopp cf9f5a
	setf trasys
Karsten Hopp cf9f5a
	break
Karsten Hopp cf9f5a
      endif
Karsten Hopp cf9f5a
      let n = n + 1
Karsten Hopp cf9f5a
    endwhile
Karsten Hopp cf9f5a
  endif
Karsten Hopp cf9f5a
endfunc
Karsten Hopp cf9f5a
Karsten Hopp cf9f5a
" A-A-P recipe
Karsten Hopp cf9f5a
au BufNewFile,BufRead *.aap			setf aap
Karsten Hopp cf9f5a
Karsten Hopp cf9f5a
" A2ps printing utility
Karsten Hopp cf9f5a
au BufNewFile,BufRead etc/a2ps.cfg,etc/a2ps/*.cfg,a2psrc,.a2psrc setf a2ps
Karsten Hopp cf9f5a
Karsten Hopp cf9f5a
" ABAB/4
Karsten Hopp cf9f5a
au BufNewFile,BufRead *.abap			setf abap
Karsten Hopp cf9f5a
Karsten Hopp cf9f5a
" ABC music notation
Karsten Hopp cf9f5a
au BufNewFile,BufRead *.abc			setf abc
Karsten Hopp cf9f5a
Karsten Hopp cf9f5a
" ABEL
Karsten Hopp cf9f5a
au BufNewFile,BufRead *.abl			setf abel
Karsten Hopp cf9f5a
Karsten Hopp cf9f5a
" AceDB
Karsten Hopp cf9f5a
au BufNewFile,BufRead *.wrm			setf acedb
Karsten Hopp cf9f5a
Karsten Hopp cf9f5a
" Ada (83, 9X, 95)
Karsten Hopp cf9f5a
au BufNewFile,BufRead *.adb,*.ads,*.ada		setf ada
Karsten Hopp cf9f5a
if has("vms")
Karsten Hopp cf9f5a
  au BufNewFile,BufRead *.gpr,*.ada_m,*.adc	setf ada
Karsten Hopp cf9f5a
else
Karsten Hopp cf9f5a
  au BufNewFile,BufRead *.gpr			setf ada
Karsten Hopp cf9f5a
endif
Karsten Hopp cf9f5a
Karsten Hopp cf9f5a
" AHDL
Karsten Hopp cf9f5a
au BufNewFile,BufRead *.tdf			setf ahdl
Karsten Hopp cf9f5a
Karsten Hopp cf9f5a
" AMPL
Karsten Hopp cf9f5a
au BufNewFile,BufRead *.run			setf ampl
Karsten Hopp cf9f5a
Karsten Hopp cf9f5a
" Ant
Karsten Hopp cf9f5a
au BufNewFile,BufRead build.xml			setf ant
Karsten Hopp cf9f5a
Karsten Hopp cf9f5a
" Apache style config file
Karsten Hopp cf9f5a
au BufNewFile,BufRead proftpd.conf*		call s:StarSetf('apachestyle')
Karsten Hopp cf9f5a
Karsten Hopp cf9f5a
" Apache config file
Karsten Hopp cf9f5a
au BufNewFile,BufRead .htaccess			 setf apache
Karsten Hopp cf9f5a
au BufNewFile,BufRead httpd.conf*,srm.conf*,access.conf*,apache.conf*,apache2.conf*,/etc/apache2/*.conf* call s:StarSetf('apache')
Karsten Hopp cf9f5a
Karsten Hopp cf9f5a
" XA65 MOS6510 cross assembler
Karsten Hopp cf9f5a
au BufNewFile,BufRead *.a65			setf a65
Karsten Hopp cf9f5a
Karsten Hopp cf9f5a
" Applescript
Karsten Hopp cf9f5a
au BufNewFile,BufRead *.scpt			setf applescript
Karsten Hopp cf9f5a
Karsten Hopp cf9f5a
" Applix ELF
Karsten Hopp cf9f5a
au BufNewFile,BufRead *.am
Karsten Hopp cf9f5a
	\ if expand("<afile>") !~? 'Makefile.am\>' | setf elf | endif
Karsten Hopp cf9f5a
Karsten Hopp cf9f5a
" ALSA configuration
Karsten Hopp cf9f5a
au BufNewFile,BufRead ~/.asoundrc,/usr/share/alsa/alsa.conf,/etc/asound.conf	setf alsaconf
Karsten Hopp cf9f5a
Karsten Hopp cf9f5a
" Arc Macro Language
Karsten Hopp cf9f5a
au BufNewFile,BufRead *.aml			setf aml
Karsten Hopp cf9f5a
Karsten Hopp cf9f5a
" Arch Inventory file
Karsten Hopp cf9f5a
au BufNewFile,BufRead .arch-inventory,=tagging-method	setf arch
Karsten Hopp cf9f5a
Karsten Hopp cf9f5a
" ART*Enterprise (formerly ART-IM)
Karsten Hopp cf9f5a
au BufNewFile,BufRead *.art			setf art
Karsten Hopp cf9f5a
Karsten Hopp cf9f5a
" ASN.1
Karsten Hopp cf9f5a
au BufNewFile,BufRead *.asn,*.asn1		setf asn
Karsten Hopp cf9f5a
Karsten Hopp cf9f5a
" Active Server Pages (with Visual Basic Script)
Karsten Hopp cf9f5a
au BufNewFile,BufRead *.asa
Karsten Hopp cf9f5a
	\ if exists("g:filetype_asa") |
Karsten Hopp cf9f5a
	\   exe "setf " . g:filetype_asa |
Karsten Hopp cf9f5a
	\ else |
Karsten Hopp cf9f5a
	\   setf aspvbs |
Karsten Hopp cf9f5a
	\ endif
Karsten Hopp cf9f5a
Karsten Hopp cf9f5a
" Active Server Pages (with Perl or Visual Basic Script)
Karsten Hopp cf9f5a
au BufNewFile,BufRead *.asp
Karsten Hopp cf9f5a
	\ if exists("g:filetype_asp") |
Karsten Hopp cf9f5a
	\   exe "setf " . g:filetype_asp |
Karsten Hopp cf9f5a
	\ elseif getline(1) . getline(2) . getline(3) =~? "perlscript" |
Karsten Hopp cf9f5a
	\   setf aspperl |
Karsten Hopp cf9f5a
	\ else |
Karsten Hopp cf9f5a
	\   setf aspvbs |
Karsten Hopp cf9f5a
	\ endif
Karsten Hopp cf9f5a
Karsten Hopp cf9f5a
" Grub (must be before catch *.lst)
Karsten Hopp cf9f5a
au BufNewFile,BufRead /boot/grub/menu.lst,/boot/grub/grub.conf,/etc/grub.conf	setf grub
Karsten Hopp cf9f5a
Karsten Hopp cf9f5a
" Assembly (all kinds)
Karsten Hopp cf9f5a
" *.lst is not pure assembly, it has two extra columns (address, byte codes)
Karsten Hopp cf9f5a
au BufNewFile,BufRead *.asm,*.[sS],*.[aA],*.mac,*.lst	call s:FTasm()
Karsten Hopp cf9f5a
Karsten Hopp cf9f5a
" This function checks for the kind of assembly that is wanted by the user, or
Karsten Hopp cf9f5a
" can be detected from the first five lines of the file.
Karsten Hopp cf9f5a
func! s:FTasm()
Karsten Hopp cf9f5a
  " make sure b:asmsyntax exists
Karsten Hopp cf9f5a
  if !exists("b:asmsyntax")
Karsten Hopp cf9f5a
    let b:asmsyntax = ""
Karsten Hopp cf9f5a
  endif
Karsten Hopp cf9f5a
Karsten Hopp cf9f5a
  if b:asmsyntax == ""
Karsten Hopp cf9f5a
    call s:FTasmsyntax()
Karsten Hopp cf9f5a
  endif
Karsten Hopp cf9f5a
Karsten Hopp cf9f5a
  " if b:asmsyntax still isn't set, default to asmsyntax or GNU
Karsten Hopp cf9f5a
  if b:asmsyntax == ""
Karsten Hopp cf9f5a
    if exists("g:asmsyntax")
Karsten Hopp cf9f5a
      let b:asmsyntax = g:asmsyntax
Karsten Hopp cf9f5a
    else
Karsten Hopp cf9f5a
      let b:asmsyntax = "asm"
Karsten Hopp cf9f5a
    endif
Karsten Hopp cf9f5a
  endif
Karsten Hopp cf9f5a
Karsten Hopp cf9f5a
  exe "setf " . fnameescape(b:asmsyntax)
Karsten Hopp cf9f5a
endfunc
Karsten Hopp cf9f5a
Karsten Hopp cf9f5a
func! s:FTasmsyntax()
Karsten Hopp cf9f5a
  " see if file contains any asmsyntax=foo overrides. If so, change
Karsten Hopp cf9f5a
  " b:asmsyntax appropriately
Karsten Hopp cf9f5a
  let head = " ".getline(1)." ".getline(2)." ".getline(3)." ".getline(4).
Karsten Hopp cf9f5a
	\" ".getline(5)." "
Karsten Hopp cf9f5a
  let match = matchstr(head, '\sasmsyntax=\zs[a-zA-Z0-9]\+\ze\s')
Karsten Hopp cf9f5a
  if match != ''
Karsten Hopp cf9f5a
    let b:asmsyntax = match
Karsten Hopp cf9f5a
  elseif ((head =~? '\.title') || (head =~? '\.ident') || (head =~? '\.macro') || (head =~? '\.subtitle') || (head =~? '\.library'))
Karsten Hopp cf9f5a
    let b:asmsyntax = "vmasm"
Karsten Hopp cf9f5a
  endif
Karsten Hopp cf9f5a
endfunc
Karsten Hopp cf9f5a
Karsten Hopp cf9f5a
" Macro (VAX)
Karsten Hopp cf9f5a
au BufNewFile,BufRead *.mar			setf vmasm
Karsten Hopp cf9f5a
Karsten Hopp cf9f5a
" Atlas
Karsten Hopp cf9f5a
au BufNewFile,BufRead *.atl,*.as		setf atlas
Karsten Hopp cf9f5a
Karsten Hopp cf9f5a
" Autoit v3
Karsten Hopp cf9f5a
au BufNewFile,BufRead *.au3			setf autoit
Karsten Hopp cf9f5a
Karsten Hopp cf9f5a
" Autohotkey
Karsten Hopp cf9f5a
au BufNewFile,BufRead *.ahk			setf autohotkey
Karsten Hopp cf9f5a
Karsten Hopp cf9f5a
" Automake
Karsten Hopp cf9f5a
au BufNewFile,BufRead [mM]akefile.am,GNUmakefile.am	setf automake
Karsten Hopp cf9f5a
Karsten Hopp cf9f5a
" Autotest .at files are actually m4
Karsten Hopp cf9f5a
au BufNewFile,BufRead *.at			setf m4
Karsten Hopp cf9f5a
Karsten Hopp cf9f5a
" Avenue
Karsten Hopp cf9f5a
au BufNewFile,BufRead *.ave			setf ave
Karsten Hopp cf9f5a
Karsten Hopp cf9f5a
" Awk
Karsten Hopp cf9f5a
au BufNewFile,BufRead *.awk			setf awk
Karsten Hopp cf9f5a
Karsten Hopp cf9f5a
" B
Karsten Hopp cf9f5a
au BufNewFile,BufRead *.mch,*.ref,*.imp		setf b
Karsten Hopp cf9f5a
Karsten Hopp cf9f5a
" BASIC or Visual Basic
Karsten Hopp cf9f5a
au BufNewFile,BufRead *.bas			call s:FTVB("basic")
Karsten Hopp cf9f5a
Karsten Hopp cf9f5a
" Check if one of the first five lines contains "VB_Name".  In that case it is
Karsten Hopp cf9f5a
" probably a Visual Basic file.  Otherwise it's assumed to be "alt" filetype.
Karsten Hopp cf9f5a
func! s:FTVB(alt)
Karsten Hopp cf9f5a
  if getline(1).getline(2).getline(3).getline(4).getline(5) =~? 'VB_Name\|Begin VB\.\(Form\|MDIForm\|UserControl\)'
Karsten Hopp cf9f5a
    setf vb
Karsten Hopp cf9f5a
  else
Karsten Hopp cf9f5a
    exe "setf " . a:alt
Karsten Hopp cf9f5a
  endif
Karsten Hopp cf9f5a
endfunc
Karsten Hopp cf9f5a
Karsten Hopp cf9f5a
" Visual Basic Script (close to Visual Basic)
Karsten Hopp cf9f5a
au BufNewFile,BufRead *.vbs,*.dsm,*.ctl		setf vb
Karsten Hopp cf9f5a
Karsten Hopp cf9f5a
" IBasic file (similar to QBasic)
Karsten Hopp cf9f5a
au BufNewFile,BufRead *.iba,*.ibi		setf ibasic
Karsten Hopp cf9f5a
Karsten Hopp cf9f5a
" FreeBasic file (similar to QBasic)
Karsten Hopp cf9f5a
au BufNewFile,BufRead *.fb,*.bi			setf freebasic
Karsten Hopp cf9f5a
Karsten Hopp cf9f5a
" Batch file for MSDOS.
Karsten Hopp cf9f5a
au BufNewFile,BufRead *.bat,*.sys		setf dosbatch
Karsten Hopp cf9f5a
" *.cmd is close to a Batch file, but on OS/2 Rexx files also use *.cmd.
Karsten Hopp cf9f5a
au BufNewFile,BufRead *.cmd
Karsten Hopp cf9f5a
	\ if getline(1) =~ '^/\*' | setf rexx | else | setf dosbatch | endif
Karsten Hopp cf9f5a
Karsten Hopp cf9f5a
" Batch file for 4DOS
Karsten Hopp cf9f5a
au BufNewFile,BufRead *.btm			call s:FTbtm()
Karsten Hopp cf9f5a
func! s:FTbtm()
Karsten Hopp cf9f5a
  if exists("g:dosbatch_syntax_for_btm") && g:dosbatch_syntax_for_btm
Karsten Hopp cf9f5a
    setf dosbatch
Karsten Hopp cf9f5a
  else
Karsten Hopp cf9f5a
    setf btm
Karsten Hopp cf9f5a
  endif
Karsten Hopp cf9f5a
endfunc
Karsten Hopp cf9f5a
Karsten Hopp cf9f5a
" BC calculator
Karsten Hopp cf9f5a
au BufNewFile,BufRead *.bc			setf bc
Karsten Hopp cf9f5a
Karsten Hopp cf9f5a
" BDF font
Karsten Hopp cf9f5a
au BufNewFile,BufRead *.bdf			setf bdf
Karsten Hopp cf9f5a
Karsten Hopp cf9f5a
" BibTeX bibliography database file
Karsten Hopp cf9f5a
au BufNewFile,BufRead *.bib			setf bib
Karsten Hopp cf9f5a
Karsten Hopp cf9f5a
" BibTeX Bibliography Style
Karsten Hopp cf9f5a
au BufNewFile,BufRead *.bst			setf bst
Karsten Hopp cf9f5a
Karsten Hopp cf9f5a
" BIND configuration
Karsten Hopp cf9f5a
au BufNewFile,BufRead named.conf,rndc.conf	setf named
Karsten Hopp cf9f5a
Karsten Hopp cf9f5a
" BIND zone
Karsten Hopp cf9f5a
au BufNewFile,BufRead named.root		setf bindzone
Karsten Hopp cf9f5a
au BufNewFile,BufRead *.db			call s:BindzoneCheck('')
Karsten Hopp cf9f5a
Karsten Hopp cf9f5a
func! s:BindzoneCheck(default)
Karsten Hopp cf9f5a
  if getline(1).getline(2).getline(3).getline(4) =~ '^; <<>> DiG [0-9.]\+ <<>>\|BIND.*named\|$ORIGIN\|$TTL\|IN\s\+SOA'
Karsten Hopp cf9f5a
    setf bindzone
Karsten Hopp cf9f5a
  elseif a:default != ''
Karsten Hopp cf9f5a
    exe 'setf ' . a:default
Karsten Hopp cf9f5a
  endif
Karsten Hopp cf9f5a
endfunc
Karsten Hopp cf9f5a
Karsten Hopp cf9f5a
" Blank
Karsten Hopp cf9f5a
au BufNewFile,BufRead *.bl			setf blank
Karsten Hopp cf9f5a
Karsten Hopp cf9f5a
" Blkid cache file
Karsten Hopp cf9f5a
au BufNewFile,BufRead /etc/blkid.tab,/etc/blkid.tab.old   setf xml
Karsten Hopp cf9f5a
Karsten Hopp cf9f5a
" C or lpc
Karsten Hopp cf9f5a
au BufNewFile,BufRead *.c			call s:FTlpc()
Karsten Hopp cf9f5a
Karsten Hopp cf9f5a
func! s:FTlpc()
Karsten Hopp cf9f5a
  if exists("g:lpc_syntax_for_c")
Karsten Hopp cf9f5a
    let lnum = 1
Karsten Hopp cf9f5a
    while lnum <= 12
Karsten Hopp cf9f5a
      if getline(lnum) =~# '^\(//\|inherit\|private\|protected\|nosave\|string\|object\|mapping\|mixed\)'
Karsten Hopp cf9f5a
	setf lpc
Karsten Hopp cf9f5a
	return
Karsten Hopp cf9f5a
      endif
Karsten Hopp cf9f5a
      let lnum = lnum + 1
Karsten Hopp cf9f5a
    endwhile
Karsten Hopp cf9f5a
  endif
Karsten Hopp cf9f5a
  setf c
Karsten Hopp cf9f5a
endfunc
Karsten Hopp cf9f5a
Karsten Hopp cf9f5a
" Calendar
Karsten Hopp cf9f5a
au BufNewFile,BufRead calendar			setf calendar
Karsten Hopp cf9f5a
au BufNewFile,BufRead */.calendar/*,
Karsten Hopp cf9f5a
	\*/share/calendar/*/calendar.*,*/share/calendar/calendar.*
Karsten Hopp cf9f5a
	\					call s:StarSetf('calendar')
Karsten Hopp cf9f5a
Karsten Hopp cf9f5a
" C#
Karsten Hopp cf9f5a
au BufNewFile,BufRead *.cs			setf cs
Karsten Hopp cf9f5a
Karsten Hopp cf9f5a
" Cdrdao TOC
Karsten Hopp cf9f5a
au BufNewFile,BufRead *.toc			setf cdrtoc
Karsten Hopp cf9f5a
Karsten Hopp cf9f5a
" Cdrdao config
Karsten Hopp cf9f5a
au BufNewFile,BufRead etc/cdrdao.conf,etc/defaults/cdrdao,etc/default/cdrdao,~/.cdrdao						setf cdrdaoconf
Karsten Hopp cf9f5a
Karsten Hopp cf9f5a
" Cfengine
Karsten Hopp cf9f5a
au BufNewFile,BufRead cfengine.conf		setf cfengine
Karsten Hopp cf9f5a
Karsten Hopp cf9f5a
" Comshare Dimension Definition Language
Karsten Hopp cf9f5a
au BufNewFile,BufRead *.cdl			setf cdl
Karsten Hopp cf9f5a
Karsten Hopp cf9f5a
" Conary Recipe
Karsten Hopp cf9f5a
au BufNewFile,BufRead *.recipe			setf conaryrecipe
Karsten Hopp cf9f5a
Karsten Hopp cf9f5a
" Controllable Regex Mutilator
Karsten Hopp cf9f5a
au BufNewFile,BufRead *.crm			setf crm
Karsten Hopp cf9f5a
Karsten Hopp cf9f5a
" Cyn++
Karsten Hopp cf9f5a
au BufNewFile,BufRead *.cyn			setf cynpp
Karsten Hopp cf9f5a
Karsten Hopp cf9f5a
" Cynlib
Karsten Hopp cf9f5a
" .cc and .cpp files can be C++ or Cynlib.
Karsten Hopp cf9f5a
au BufNewFile,BufRead *.cc
Karsten Hopp cf9f5a
	\ if exists("cynlib_syntax_for_cc")|setf cynlib|else|setf cpp|endif
Karsten Hopp cf9f5a
au BufNewFile,BufRead *.cpp
Karsten Hopp cf9f5a
	\ if exists("cynlib_syntax_for_cpp")|setf cynlib|else|setf cpp|endif
Karsten Hopp cf9f5a
Karsten Hopp cf9f5a
" C++
Karsten Hopp cf9f5a
au BufNewFile,BufRead *.cxx,*.c++,*.hh,*.hxx,*.hpp,*.ipp,*.moc,*.tcc,*.inl setf cpp
Karsten Hopp cf9f5a
if has("fname_case")
Karsten Hopp cf9f5a
  au BufNewFile,BufRead *.C,*.H setf cpp
Karsten Hopp cf9f5a
endif
Karsten Hopp cf9f5a
Karsten Hopp cf9f5a
" .h files can be C, Ch C++, ObjC or ObjC++.
Karsten Hopp cf9f5a
" Set c_syntax_for_h if you want C, ch_syntax_for_h if you want Ch. ObjC is
Karsten Hopp cf9f5a
" detected automatically.
Karsten Hopp cf9f5a
au BufNewFile,BufRead *.h			call s:FTheader()
Karsten Hopp cf9f5a
Karsten Hopp cf9f5a
func! s:FTheader()
Karsten Hopp cf9f5a
  if match(getline(1, min([line("$"), 200])), '^@\(interface\|end\|class\)') > -1
Karsten Hopp cf9f5a
    setf objc
Karsten Hopp cf9f5a
  elseif exists("g:c_syntax_for_h")
Karsten Hopp cf9f5a
    setf c
Karsten Hopp cf9f5a
  elseif exists("g:ch_syntax_for_h")
Karsten Hopp cf9f5a
    setf ch
Karsten Hopp cf9f5a
  else
Karsten Hopp cf9f5a
    setf cpp
Karsten Hopp cf9f5a
  endif
Karsten Hopp cf9f5a
endfunc
Karsten Hopp cf9f5a
Karsten Hopp cf9f5a
" Ch (CHscript)
Karsten Hopp cf9f5a
au BufNewFile,BufRead *.chf			setf ch
Karsten Hopp cf9f5a
Karsten Hopp cf9f5a
" TLH files are C++ headers generated by Visual C++'s #import from typelibs
Karsten Hopp cf9f5a
au BufNewFile,BufRead *.tlh			setf cpp
Karsten Hopp cf9f5a
Karsten Hopp cf9f5a
" Cascading Style Sheets
Karsten Hopp cf9f5a
au BufNewFile,BufRead *.css			setf css
Karsten Hopp cf9f5a
Karsten Hopp cf9f5a
" Century Term Command Scripts (*.cmd too)
Karsten Hopp cf9f5a
au BufNewFile,BufRead *.con			setf cterm
Karsten Hopp cf9f5a
Karsten Hopp cf9f5a
" Changelog
Karsten Hopp cf9f5a
au BufNewFile,BufRead changelog.Debian,changelog.dch,NEWS.Debian,NEWS.dch
Karsten Hopp cf9f5a
					\	setf debchangelog
Karsten Hopp cf9f5a
Karsten Hopp cf9f5a
au BufNewFile,BufRead [cC]hange[lL]og
Karsten Hopp cf9f5a
	\  if getline(1) =~ '; urgency='
Karsten Hopp cf9f5a
	\|   setf debchangelog
Karsten Hopp cf9f5a
	\| else
Karsten Hopp cf9f5a
	\|   setf changelog
Karsten Hopp cf9f5a
	\| endif
Karsten Hopp cf9f5a
Karsten Hopp cf9f5a
au BufNewFile,BufRead NEWS
Karsten Hopp cf9f5a
	\  if getline(1) =~ '; urgency='
Karsten Hopp cf9f5a
	\|   setf debchangelog
Karsten Hopp cf9f5a
	\| endif
Karsten Hopp cf9f5a
Karsten Hopp cf9f5a
" CHILL
Karsten Hopp cf9f5a
au BufNewFile,BufRead *..ch			setf chill
Karsten Hopp cf9f5a
Karsten Hopp cf9f5a
" Changes for WEB and CWEB or CHILL
Karsten Hopp cf9f5a
au BufNewFile,BufRead *.ch			call s:FTchange()
Karsten Hopp cf9f5a
Karsten Hopp cf9f5a
" This function checks if one of the first ten lines start with a '@'.  In
Karsten Hopp cf9f5a
" that case it is probably a change file.
Karsten Hopp cf9f5a
" If the first line starts with # or ! it's probably a ch file.
Karsten Hopp cf9f5a
" If a line has "main", "include", "//" ir "/*" it's probably ch.
Karsten Hopp cf9f5a
" Otherwise CHILL is assumed.
Karsten Hopp cf9f5a
func! s:FTchange()
Karsten Hopp cf9f5a
  let lnum = 1
Karsten Hopp cf9f5a
  while lnum <= 10
Karsten Hopp cf9f5a
    if getline(lnum)[0] == '@'
Karsten Hopp cf9f5a
      setf change
Karsten Hopp cf9f5a
      return
Karsten Hopp cf9f5a
    endif
Karsten Hopp cf9f5a
    if lnum == 1 && (getline(1)[0] == '#' || getline(1)[0] == '!')
Karsten Hopp cf9f5a
      setf ch
Karsten Hopp cf9f5a
      return
Karsten Hopp cf9f5a
    endif
Karsten Hopp cf9f5a
    if getline(lnum) =~ "MODULE"
Karsten Hopp cf9f5a
      setf chill
Karsten Hopp cf9f5a
      return
Karsten Hopp cf9f5a
    endif
Karsten Hopp cf9f5a
    if getline(lnum) =~ 'main\s*(\|#\s*include\|//'
Karsten Hopp cf9f5a
      setf ch
Karsten Hopp cf9f5a
      return
Karsten Hopp cf9f5a
    endif
Karsten Hopp cf9f5a
    let lnum = lnum + 1
Karsten Hopp cf9f5a
  endwhile
Karsten Hopp cf9f5a
  setf chill
Karsten Hopp cf9f5a
endfunc
Karsten Hopp cf9f5a
Karsten Hopp cf9f5a
" ChordPro
Karsten Hopp cf9f5a
au BufNewFile,BufRead *.chopro,*.crd,*.cho,*.crdpro,*.chordpro	setf chordpro
Karsten Hopp cf9f5a
Karsten Hopp cf9f5a
" Clean
Karsten Hopp cf9f5a
au BufNewFile,BufRead *.dcl,*.icl		setf clean
Karsten Hopp cf9f5a
Karsten Hopp cf9f5a
" Clever
Karsten Hopp cf9f5a
au BufNewFile,BufRead *.eni			setf cl
Karsten Hopp cf9f5a
Karsten Hopp cf9f5a
" Clever or dtd
Karsten Hopp cf9f5a
au BufNewFile,BufRead *.ent			call s:FTent()
Karsten Hopp cf9f5a
Karsten Hopp cf9f5a
func! s:FTent()
Karsten Hopp cf9f5a
  " This function checks for valid cl syntax in the first five lines.
Karsten Hopp cf9f5a
  " Look for either an opening comment, '#', or a block start, '{".
Karsten Hopp cf9f5a
  " If not found, assume SGML.
Karsten Hopp cf9f5a
  let lnum = 1
Karsten Hopp cf9f5a
  while lnum < 6
Karsten Hopp cf9f5a
    let line = getline(lnum)
Karsten Hopp cf9f5a
    if line =~ '^\s*[#{]'
Karsten Hopp cf9f5a
      setf cl
Karsten Hopp cf9f5a
      return
Karsten Hopp cf9f5a
    elseif line !~ '^\s*$'
Karsten Hopp cf9f5a
      " Not a blank line, not a comment, and not a block start,
Karsten Hopp cf9f5a
      " so doesn't look like valid cl code.
Karsten Hopp cf9f5a
      break
Karsten Hopp cf9f5a
    endif
Karsten Hopp cf9f5a
    let lnum = lnum + 1
Karsten Hopp cf9f5a
  endw
Karsten Hopp cf9f5a
  setf dtd
Karsten Hopp cf9f5a
endfunc
Karsten Hopp cf9f5a
Karsten Hopp cf9f5a
" Clipper (or FoxPro; could also be eviews)
Karsten Hopp cf9f5a
au BufNewFile,BufRead *.prg
Karsten Hopp cf9f5a
	\ if exists("g:filetype_prg") |
Karsten Hopp cf9f5a
	\   exe "setf " . g:filetype_prg |
Karsten Hopp cf9f5a
	\ else |
Karsten Hopp cf9f5a
	\   setf clipper |
Karsten Hopp cf9f5a
	\ endif
Karsten Hopp cf9f5a
Karsten Hopp cf9f5a
" Cmake
Karsten Hopp cf9f5a
au BufNewFile,BufRead CMakeLists.txt,*.cmake,*.cmake.in		setf cmake
Karsten Hopp cf9f5a
Karsten Hopp cf9f5a
" Cmusrc
Karsten Hopp cf9f5a
au BufNewFile,BufRead ~/.cmus/{autosave,rc,command-history,*.theme} setf cmusrc
Karsten Hopp cf9f5a
au BufNewFile,BufRead */cmus/{rc,*.theme}			setf cmusrc
Karsten Hopp cf9f5a
Karsten Hopp cf9f5a
" Cobol
Karsten Hopp cf9f5a
au BufNewFile,BufRead *.cbl,*.cob,*.lib	setf cobol
Karsten Hopp cf9f5a
"   cobol or zope form controller python script? (heuristic)
Karsten Hopp cf9f5a
au BufNewFile,BufRead *.cpy
Karsten Hopp cf9f5a
	\ if getline(1) =~ '^##' |
Karsten Hopp cf9f5a
	\   setf python |
Karsten Hopp cf9f5a
	\ else |
Karsten Hopp cf9f5a
	\   setf cobol |
Karsten Hopp cf9f5a
	\ endif
Karsten Hopp cf9f5a
Karsten Hopp cf9f5a
" Coco/R
Karsten Hopp cf9f5a
au BufNewFile,BufRead *.atg			setf coco
Karsten Hopp cf9f5a
Karsten Hopp cf9f5a
" Cold Fusion
Karsten Hopp cf9f5a
au BufNewFile,BufRead *.cfm,*.cfi,*.cfc		setf cf
Karsten Hopp cf9f5a
Karsten Hopp cf9f5a
" Configure scripts
Karsten Hopp cf9f5a
au BufNewFile,BufRead configure.in,configure.ac setf config
Karsten Hopp cf9f5a
Karsten Hopp cf9f5a
" CUDA  Cumpute Unified Device Architecture
Karsten Hopp cf9f5a
au BufNewFile,BufRead *.cu			setf cuda
Karsten Hopp cf9f5a
Karsten Hopp cf9f5a
" WildPackets EtherPeek Decoder
Karsten Hopp cf9f5a
au BufNewFile,BufRead *.dcd			setf dcd
Karsten Hopp cf9f5a
Karsten Hopp cf9f5a
" Enlightenment configuration files
Karsten Hopp cf9f5a
au BufNewFile,BufRead *enlightenment/*.cfg	setf c
Karsten Hopp cf9f5a
Karsten Hopp cf9f5a
" Eterm
Karsten Hopp cf9f5a
au BufNewFile,BufRead *Eterm/*.cfg		setf eterm
Karsten Hopp cf9f5a
Karsten Hopp cf9f5a
" Lynx config files
Karsten Hopp cf9f5a
au BufNewFile,BufRead lynx.cfg			setf lynx
Karsten Hopp cf9f5a
Karsten Hopp cf9f5a
" Quake
Karsten Hopp cf9f5a
au BufNewFile,BufRead *baseq[2-3]/*.cfg,*id1/*.cfg	setf quake
Karsten Hopp cf9f5a
au BufNewFile,BufRead *quake[1-3]/*.cfg			setf quake
Karsten Hopp cf9f5a
Karsten Hopp cf9f5a
" Quake C
Karsten Hopp cf9f5a
au BufNewFile,BufRead *.qc			setf c
Karsten Hopp cf9f5a
Karsten Hopp cf9f5a
" Configure files
Karsten Hopp cf9f5a
au BufNewFile,BufRead *.cfg			setf cfg
Karsten Hopp cf9f5a
Karsten Hopp cf9f5a
" Communicating Sequential Processes
Karsten Hopp cf9f5a
au BufNewFile,BufRead *.csp,*.fdr		setf csp
Karsten Hopp cf9f5a
Karsten Hopp cf9f5a
" CUPL logic description and simulation
Karsten Hopp cf9f5a
au BufNewFile,BufRead *.pld			setf cupl
Karsten Hopp cf9f5a
au BufNewFile,BufRead *.si			setf cuplsim
Karsten Hopp cf9f5a
Karsten Hopp cf9f5a
" Debian Control
Karsten Hopp cf9f5a
au BufNewFile,BufRead */debian/control		setf debcontrol
Karsten Hopp cf9f5a
au BufNewFile,BufRead control
Karsten Hopp cf9f5a
	\  if getline(1) =~ '^Source:'
Karsten Hopp cf9f5a
	\|   setf debcontrol
Karsten Hopp cf9f5a
	\| endif
Karsten Hopp cf9f5a
Karsten Hopp cf9f5a
" Debian Sources.list
Karsten Hopp cf9f5a
au BufNewFile,BufRead /etc/apt/sources.list	setf debsources
Karsten Hopp cf9f5a
Karsten Hopp cf9f5a
" Deny hosts
Karsten Hopp cf9f5a
au BufNewFile,BufRead denyhosts.conf		setf denyhosts
Karsten Hopp cf9f5a
Karsten Hopp cf9f5a
" ROCKLinux package description
Karsten Hopp cf9f5a
au BufNewFile,BufRead *.desc			setf desc
Karsten Hopp cf9f5a
Karsten Hopp cf9f5a
" the D language or dtrace
Karsten Hopp cf9f5a
au BufNewFile,BufRead *.d			call s:DtraceCheck()
Karsten Hopp cf9f5a
Karsten Hopp cf9f5a
func! s:DtraceCheck()
Karsten Hopp cf9f5a
  let lines = getline(1, min([line("$"), 100]))
Karsten Hopp cf9f5a
  if match(lines, '^#!\S\+dtrace\|#pragma\s\+D\s\+option\|:\S\{-}:\S\{-}:') > -1
Karsten Hopp cf9f5a
    setf dtrace
Karsten Hopp cf9f5a
  else
Karsten Hopp cf9f5a
    setf d
Karsten Hopp cf9f5a
  endif
Karsten Hopp cf9f5a
endfunc
Karsten Hopp cf9f5a
Karsten Hopp cf9f5a
" Desktop files
Karsten Hopp cf9f5a
au BufNewFile,BufRead *.desktop,.directory	setf desktop
Karsten Hopp cf9f5a
Karsten Hopp cf9f5a
" Dict config
Karsten Hopp cf9f5a
au BufNewFile,BufRead dict.conf,.dictrc		setf dictconf
Karsten Hopp cf9f5a
Karsten Hopp cf9f5a
" Dictd config
Karsten Hopp cf9f5a
au BufNewFile,BufRead dictd.conf		setf dictdconf
Karsten Hopp cf9f5a
Karsten Hopp cf9f5a
" Diff files
Karsten Hopp cf9f5a
au BufNewFile,BufRead *.diff,*.rej,*.patch	setf diff
Karsten Hopp cf9f5a
Karsten Hopp cf9f5a
" Dircolors
Karsten Hopp cf9f5a
au BufNewFile,BufRead .dir_colors,/etc/DIR_COLORS	setf dircolors
Karsten Hopp cf9f5a
Karsten Hopp cf9f5a
" Diva (with Skill) or InstallShield
Karsten Hopp cf9f5a
au BufNewFile,BufRead *.rul
Karsten Hopp cf9f5a
	\ if getline(1).getline(2).getline(3).getline(4).getline(5).getline(6) =~? 'InstallShield' |
Karsten Hopp cf9f5a
	\   setf ishd |
Karsten Hopp cf9f5a
	\ else |
Karsten Hopp cf9f5a
	\   setf diva |
Karsten Hopp cf9f5a
	\ endif
Karsten Hopp cf9f5a
Karsten Hopp cf9f5a
" DCL (Digital Command Language - vms) or DNS zone file
Karsten Hopp cf9f5a
au BufNewFile,BufRead *.com			call s:BindzoneCheck('dcl')
Karsten Hopp cf9f5a
Karsten Hopp cf9f5a
" DOT
Karsten Hopp cf9f5a
au BufNewFile,BufRead *.dot			setf dot
Karsten Hopp cf9f5a
Karsten Hopp cf9f5a
" Dylan - lid files
Karsten Hopp cf9f5a
au BufNewFile,BufRead *.lid			setf dylanlid
Karsten Hopp cf9f5a
Karsten Hopp cf9f5a
" Dylan - intr files (melange)
Karsten Hopp cf9f5a
au BufNewFile,BufRead *.intr			setf dylanintr
Karsten Hopp cf9f5a
Karsten Hopp cf9f5a
" Dylan
Karsten Hopp cf9f5a
au BufNewFile,BufRead *.dylan			setf dylan
Karsten Hopp cf9f5a
Karsten Hopp cf9f5a
" Microsoft Module Definition
Karsten Hopp cf9f5a
au BufNewFile,BufRead *.def			setf def
Karsten Hopp cf9f5a
Karsten Hopp cf9f5a
" Dracula
Karsten Hopp cf9f5a
au BufNewFile,BufRead *.drac,*.drc,*lvs,*lpe	setf dracula
Karsten Hopp cf9f5a
Karsten Hopp cf9f5a
" dsl
Karsten Hopp cf9f5a
au BufNewFile,BufRead *.dsl			setf dsl
Karsten Hopp cf9f5a
Karsten Hopp cf9f5a
" DTD (Document Type Definition for XML)
Karsten Hopp cf9f5a
au BufNewFile,BufRead *.dtd			setf dtd
Karsten Hopp cf9f5a
Karsten Hopp cf9f5a
" EDIF (*.edf,*.edif,*.edn,*.edo)
Karsten Hopp cf9f5a
au BufNewFile,BufRead *.ed\(f\|if\|n\|o\)	setf edif
Karsten Hopp cf9f5a
Karsten Hopp cf9f5a
" Embedix Component Description
Karsten Hopp cf9f5a
au BufNewFile,BufRead *.ecd			setf ecd
Karsten Hopp cf9f5a
Karsten Hopp cf9f5a
" Eiffel or Specman
Karsten Hopp cf9f5a
au BufNewFile,BufRead *.e,*.E			call s:FTe()
Karsten Hopp cf9f5a
Karsten Hopp cf9f5a
" Elinks configuration
Karsten Hopp cf9f5a
au BufNewFile,BufRead */etc/elinks.conf,*/.elinks/elinks.conf	setf elinks
Karsten Hopp cf9f5a
Karsten Hopp cf9f5a
func! s:FTe()
Karsten Hopp cf9f5a
  let n = 1
Karsten Hopp cf9f5a
  while n < 100 && n < line("$")
Karsten Hopp cf9f5a
    if getline(n) =~ "^\\s*\\(<'\\|'>\\)\\s*$"
Karsten Hopp cf9f5a
      setf specman
Karsten Hopp cf9f5a
      return
Karsten Hopp cf9f5a
    endif
Karsten Hopp cf9f5a
    let n = n + 1
Karsten Hopp cf9f5a
  endwhile
Karsten Hopp cf9f5a
  setf eiffel
Karsten Hopp cf9f5a
endfunc
Karsten Hopp cf9f5a
Karsten Hopp cf9f5a
" ERicsson LANGuage; Yaws is erlang too
Karsten Hopp cf9f5a
au BufNewFile,BufRead *.erl,*.hrl,*.yaws	setf erlang
Karsten Hopp cf9f5a
Karsten Hopp cf9f5a
" Elm Filter Rules file
Karsten Hopp cf9f5a
au BufNewFile,BufRead filter-rules		setf elmfilt
Karsten Hopp cf9f5a
Karsten Hopp cf9f5a
" ESMTP rc file
Karsten Hopp cf9f5a
au BufNewFile,BufRead *esmtprc			setf esmtprc
Karsten Hopp cf9f5a
Karsten Hopp cf9f5a
" ESQL-C
Karsten Hopp cf9f5a
au BufNewFile,BufRead *.ec,*.EC			setf esqlc
Karsten Hopp cf9f5a
Karsten Hopp cf9f5a
" Esterel
Karsten Hopp cf9f5a
au BufNewFile,BufRead *.strl			setf esterel
Karsten Hopp cf9f5a
Karsten Hopp cf9f5a
" Essbase script
Karsten Hopp cf9f5a
au BufNewFile,BufRead *.csc			setf csc
Karsten Hopp cf9f5a
Karsten Hopp cf9f5a
" Exim
Karsten Hopp cf9f5a
au BufNewFile,BufRead exim.conf			setf exim
Karsten Hopp cf9f5a
Karsten Hopp cf9f5a
" Expect
Karsten Hopp cf9f5a
au BufNewFile,BufRead *.exp			setf expect
Karsten Hopp cf9f5a
Karsten Hopp cf9f5a
" Exports
Karsten Hopp cf9f5a
au BufNewFile,BufRead exports			setf exports
Karsten Hopp cf9f5a
Karsten Hopp cf9f5a
" Factor
Karsten Hopp cf9f5a
au BufNewFile,BufRead *.factor			setf factor
Karsten Hopp cf9f5a
Karsten Hopp cf9f5a
" Fetchmail RC file
Karsten Hopp cf9f5a
au BufNewFile,BufRead .fetchmailrc		setf fetchmail
Karsten Hopp cf9f5a
Karsten Hopp cf9f5a
" FlexWiki
Karsten Hopp cf9f5a
au BufNewFile,BufRead *.wiki			setf flexwiki
Karsten Hopp cf9f5a
Karsten Hopp cf9f5a
" Focus Executable
Karsten Hopp cf9f5a
au BufNewFile,BufRead *.fex,*.focexec		setf focexec
Karsten Hopp cf9f5a
Karsten Hopp cf9f5a
" Focus Master file (but not for auto.master)
Karsten Hopp cf9f5a
au BufNewFile,BufRead auto.master		setf conf
Karsten Hopp cf9f5a
au BufNewFile,BufRead *.mas,*.master		setf master
Karsten Hopp cf9f5a
Karsten Hopp cf9f5a
" Forth
Karsten Hopp cf9f5a
au BufNewFile,BufRead *.fs,*.ft			setf forth
Karsten Hopp cf9f5a
Karsten Hopp cf9f5a
" Reva Forth
Karsten Hopp cf9f5a
au BufNewFile,BufRead *.frt			setf reva
Karsten Hopp cf9f5a
Karsten Hopp cf9f5a
" Fortran
Karsten Hopp cf9f5a
if has("fname_case")
Karsten Hopp cf9f5a
  au BufNewFile,BufRead *.F,*.FOR,*.FPP,*.FTN,*.F77,*.F90,*.F95	 setf fortran
Karsten Hopp cf9f5a
endif
Karsten Hopp cf9f5a
au BufNewFile,BufRead   *.f,*.for,*.fortran,*.fpp,*.ftn,*.f77,*.f90,*.f95  setf fortran
Karsten Hopp cf9f5a
Karsten Hopp cf9f5a
" Framescript
Karsten Hopp cf9f5a
au BufNewFile,BufRead *.fsl			setf framescript
Karsten Hopp cf9f5a
Karsten Hopp cf9f5a
" FStab
Karsten Hopp cf9f5a
au BufNewFile,BufRead fstab,mtab		setf fstab
Karsten Hopp cf9f5a
Karsten Hopp cf9f5a
" GDB command files
Karsten Hopp cf9f5a
au BufNewFile,BufRead .gdbinit			setf gdb
Karsten Hopp cf9f5a
Karsten Hopp cf9f5a
" GDMO
Karsten Hopp cf9f5a
au BufNewFile,BufRead *.mo,*.gdmo		setf gdmo
Karsten Hopp cf9f5a
Karsten Hopp cf9f5a
" Gedcom
Karsten Hopp cf9f5a
au BufNewFile,BufRead *.ged			setf gedcom
Karsten Hopp cf9f5a
Karsten Hopp cf9f5a
" Git
Karsten Hopp cf9f5a
autocmd BufNewFile,BufRead *.git/COMMIT_EDITMSG    setf gitcommit
Karsten Hopp cf9f5a
autocmd BufNewFile,BufRead *.git/config,.gitconfig setf gitconfig
Karsten Hopp cf9f5a
autocmd BufNewFile,BufRead git-rebase-todo         setf gitrebase
Karsten Hopp cf9f5a
autocmd BufNewFile,BufRead .msg.[0-9]*
Karsten Hopp cf9f5a
      \ if getline(1) =~ '^From.*# This line is ignored.$' |
Karsten Hopp cf9f5a
      \   setf gitsendemail |
Karsten Hopp cf9f5a
      \ endif
Karsten Hopp cf9f5a
autocmd BufNewFile,BufRead *.git/**
Karsten Hopp cf9f5a
      \ if getline(1) =~ '^\x\{40\}\>\|^ref: ' |
Karsten Hopp cf9f5a
      \   setf git |
Karsten Hopp cf9f5a
      \ endif
Karsten Hopp cf9f5a
Karsten Hopp cf9f5a
" Gkrellmrc
Karsten Hopp cf9f5a
au BufNewFile,BufRead gkrellmrc,gkrellmrc_?	setf gkrellmrc
Karsten Hopp cf9f5a
Karsten Hopp cf9f5a
" GP scripts (2.0 and onward)
Karsten Hopp cf9f5a
au BufNewFile,BufRead *.gp,.gprc		setf gp
Karsten Hopp cf9f5a
Karsten Hopp cf9f5a
" GPG
Karsten Hopp cf9f5a
au BufNewFile,BufRead */.gnupg/options		setf gpg
Karsten Hopp cf9f5a
au BufNewFile,BufRead */.gnupg/gpg.conf		setf gpg
Karsten Hopp cf9f5a
au BufNewFile,BufRead /usr/**/gnupg/options.skel setf gpg
Karsten Hopp cf9f5a
Karsten Hopp cf9f5a
" Gnuplot scripts
Karsten Hopp cf9f5a
au BufNewFile,BufRead *.gpi			setf gnuplot
Karsten Hopp cf9f5a
Karsten Hopp cf9f5a
" GrADS scripts
Karsten Hopp cf9f5a
au BufNewFile,BufRead *.gs			setf grads
Karsten Hopp cf9f5a
Karsten Hopp cf9f5a
" Gretl
Karsten Hopp cf9f5a
au BufNewFile,BufRead *.gretl			setf gretl
Karsten Hopp cf9f5a
Karsten Hopp cf9f5a
" Groovy
Karsten Hopp cf9f5a
au BufNewFile,BufRead *.groovy			setf groovy
Karsten Hopp cf9f5a
Karsten Hopp cf9f5a
" GNU Server Pages
Karsten Hopp cf9f5a
au BufNewFile,BufRead *.gsp			setf gsp
Karsten Hopp cf9f5a
Karsten Hopp cf9f5a
" Group file
Karsten Hopp cf9f5a
au BufNewFile,BufRead /etc/group,/etc/group-,/etc/group.edit,/etc/gshadow,/etc/gshadow-,/etc/gshadow.edit,/var/backups/group.bak,/var/backups/gshadow.bak  setf group
Karsten Hopp cf9f5a
Karsten Hopp cf9f5a
" GTK RC
Karsten Hopp cf9f5a
au BufNewFile,BufRead .gtkrc,gtkrc		setf gtkrc
Karsten Hopp cf9f5a
Karsten Hopp cf9f5a
" Haml
Karsten Hopp cf9f5a
au BufNewFile,BufRead *.haml			setf haml
Karsten Hopp cf9f5a
Karsten Hopp cf9f5a
" Hamster Classic | Playground files
Karsten Hopp cf9f5a
au BufNewFile,BufRead *.hsc,*.hsm		setf hamster
Karsten Hopp cf9f5a
Karsten Hopp cf9f5a
" Haskell
Karsten Hopp cf9f5a
au BufNewFile,BufRead *.hs			setf haskell
Karsten Hopp cf9f5a
au BufNewFile,BufRead *.lhs			setf lhaskell
Karsten Hopp cf9f5a
au BufNewFile,BufRead *.chs			setf chaskell
Karsten Hopp cf9f5a
Karsten Hopp cf9f5a
" Haste
Karsten Hopp cf9f5a
au BufNewFile,BufRead *.ht			setf haste
Karsten Hopp cf9f5a
au BufNewFile,BufRead *.htpp			setf hastepreproc
Karsten Hopp cf9f5a
Karsten Hopp cf9f5a
" Hercules
Karsten Hopp cf9f5a
au BufNewFile,BufRead *.vc,*.ev,*.rs,*.sum,*.errsum	setf hercules
Karsten Hopp cf9f5a
Karsten Hopp cf9f5a
" HEX (Intel)
Karsten Hopp cf9f5a
au BufNewFile,BufRead *.hex,*.h32		setf hex
Karsten Hopp cf9f5a
Karsten Hopp cf9f5a
" Tilde (must be before HTML)
Karsten Hopp cf9f5a
au BufNewFile,BufRead *.t.html			setf tilde
Karsten Hopp cf9f5a
Karsten Hopp cf9f5a
" HTML (.shtml and .stm for server side)
Karsten Hopp cf9f5a
au BufNewFile,BufRead *.html,*.htm,*.shtml,*.stm  call s:FThtml()
Karsten Hopp cf9f5a
Karsten Hopp cf9f5a
" Distinguish between HTML, XHTML and Django
Karsten Hopp cf9f5a
func! s:FThtml()
Karsten Hopp cf9f5a
  let n = 1
Karsten Hopp cf9f5a
  while n < 10 && n < line("$")
Karsten Hopp cf9f5a
    if getline(n) =~ '\
Karsten Hopp cf9f5a
      setf xhtml
Karsten Hopp cf9f5a
      return
Karsten Hopp cf9f5a
    endif
Karsten Hopp cf9f5a
    if getline(n) =~ '{%\s*\(extends\|block\)\>'
Karsten Hopp cf9f5a
      setf htmldjango
Karsten Hopp cf9f5a
      return
Karsten Hopp cf9f5a
    endif
Karsten Hopp cf9f5a
    let n = n + 1
Karsten Hopp cf9f5a
  endwhile
Karsten Hopp cf9f5a
  setf html
Karsten Hopp cf9f5a
endfunc
Karsten Hopp cf9f5a
Karsten Hopp cf9f5a
" HTML with Ruby - eRuby
Karsten Hopp cf9f5a
au BufNewFile,BufRead *.erb,*.rhtml		setf eruby
Karsten Hopp cf9f5a
Karsten Hopp cf9f5a
" HTML with M4
Karsten Hopp cf9f5a
au BufNewFile,BufRead *.html.m4			setf htmlm4
Karsten Hopp cf9f5a
Karsten Hopp cf9f5a
" HTML Cheetah template
Karsten Hopp cf9f5a
au BufNewFile,BufRead *.tmpl			setf htmlcheetah
Karsten Hopp cf9f5a
Karsten Hopp cf9f5a
" Host config
Karsten Hopp cf9f5a
au BufNewFile,BufRead /etc/host.conf		setf hostconf
Karsten Hopp cf9f5a
Karsten Hopp cf9f5a
" Hosts access
Karsten Hopp cf9f5a
au BufNewFile,BufRead /etc/hosts.allow,/etc/hosts.deny  setf hostsaccess
Karsten Hopp cf9f5a
Karsten Hopp cf9f5a
" Hyper Builder
Karsten Hopp cf9f5a
au BufNewFile,BufRead *.hb			setf hb
Karsten Hopp cf9f5a
Karsten Hopp cf9f5a
" Icon
Karsten Hopp cf9f5a
au BufNewFile,BufRead *.icn			setf icon
Karsten Hopp cf9f5a
Karsten Hopp cf9f5a
" IDL (Interface Description Language)
Karsten Hopp cf9f5a
au BufNewFile,BufRead *.idl			call s:FTidl()
Karsten Hopp cf9f5a
Karsten Hopp cf9f5a
" Distinguish between standard IDL and MS-IDL
Karsten Hopp cf9f5a
func! s:FTidl()
Karsten Hopp cf9f5a
  let n = 1
Karsten Hopp cf9f5a
  while n < 50 && n < line("$")
Karsten Hopp cf9f5a
    if getline(n) =~ '^\s*import\s\+"\(unknwn\|objidl\)\.idl"'
Karsten Hopp cf9f5a
      setf msidl
Karsten Hopp cf9f5a
      return
Karsten Hopp cf9f5a
    endif
Karsten Hopp cf9f5a
    let n = n + 1
Karsten Hopp cf9f5a
  endwhile
Karsten Hopp cf9f5a
  setf idl
Karsten Hopp cf9f5a
endfunc
Karsten Hopp cf9f5a
Karsten Hopp cf9f5a
" Microsoft IDL (Interface Description Language)  Also *.idl
Karsten Hopp cf9f5a
" MOF = WMI (Windows Management Instrumentation) Managed Object Format
Karsten Hopp cf9f5a
au BufNewFile,BufRead *.odl,*.mof		setf msidl
Karsten Hopp cf9f5a
Karsten Hopp cf9f5a
" Icewm menu
Karsten Hopp cf9f5a
au BufNewFile,BufRead */.icewm/menu		setf icemenu
Karsten Hopp cf9f5a
Karsten Hopp cf9f5a
" Indent profile (must come before IDL *.pro!)
Karsten Hopp cf9f5a
au BufNewFile,BufRead .indent.pro		setf indent
Karsten Hopp cf9f5a
au BufNewFile,BufRead indent.pro		call s:ProtoCheck('indent')
Karsten Hopp cf9f5a
Karsten Hopp cf9f5a
" IDL (Interactive Data Language)
Karsten Hopp cf9f5a
au BufNewFile,BufRead *.pro			call s:ProtoCheck('idlang')
Karsten Hopp cf9f5a
Karsten Hopp cf9f5a
" Distinguish between "default" and Cproto prototype file. */
Karsten Hopp cf9f5a
func! s:ProtoCheck(default)
Karsten Hopp cf9f5a
  " Cproto files have a comment in the first line and a function prototype in
Karsten Hopp cf9f5a
  " the second line, it always ends in ";".  Indent files may also have
Karsten Hopp cf9f5a
  " comments, thus we can't match comments to see the difference.
Karsten Hopp cf9f5a
  if getline(2) =~ ';$'
Karsten Hopp cf9f5a
    setf cpp
Karsten Hopp cf9f5a
  else
Karsten Hopp cf9f5a
    exe 'setf ' . a:default
Karsten Hopp cf9f5a
  endif
Karsten Hopp cf9f5a
endfunc
Karsten Hopp cf9f5a
Karsten Hopp cf9f5a
Karsten Hopp cf9f5a
" Indent RC
Karsten Hopp cf9f5a
au BufNewFile,BufRead indentrc			setf indent
Karsten Hopp cf9f5a
Karsten Hopp cf9f5a
" Inform
Karsten Hopp cf9f5a
au BufNewFile,BufRead *.inf,*.INF		setf inform
Karsten Hopp cf9f5a
Karsten Hopp cf9f5a
" Initng
Karsten Hopp cf9f5a
au BufNewFile,BufRead /etc/initng/**/*.i,*.ii	setf initng
Karsten Hopp cf9f5a
Karsten Hopp cf9f5a
" Ipfilter
Karsten Hopp cf9f5a
au BufNewFile,BufRead ipf.conf,ipf6.conf,ipf.rules	setf ipfilter
Karsten Hopp cf9f5a
Karsten Hopp cf9f5a
" Informix 4GL (source - canonical, include file, I4GL+M4 preproc.)
Karsten Hopp cf9f5a
au BufNewFile,BufRead *.4gl,*.4gh,*.m4gl	setf fgl
Karsten Hopp cf9f5a
Karsten Hopp cf9f5a
" .INI file for MSDOS
Karsten Hopp cf9f5a
au BufNewFile,BufRead *.ini			setf dosini
Karsten Hopp cf9f5a
Karsten Hopp cf9f5a
" SysV Inittab
Karsten Hopp cf9f5a
au BufNewFile,BufRead inittab			setf inittab
Karsten Hopp cf9f5a
Karsten Hopp cf9f5a
" Inno Setup
Karsten Hopp cf9f5a
au BufNewFile,BufRead *.iss			setf iss
Karsten Hopp cf9f5a
Karsten Hopp cf9f5a
" JAL
Karsten Hopp cf9f5a
au BufNewFile,BufRead *.jal,*.JAL		setf jal
Karsten Hopp cf9f5a
Karsten Hopp cf9f5a
" Jam
Karsten Hopp cf9f5a
au BufNewFile,BufRead *.jpl,*.jpr		setf jam
Karsten Hopp cf9f5a
Karsten Hopp cf9f5a
" Java
Karsten Hopp cf9f5a
au BufNewFile,BufRead *.java,*.jav		setf java
Karsten Hopp cf9f5a
Karsten Hopp cf9f5a
" JavaCC
Karsten Hopp cf9f5a
au BufNewFile,BufRead *.jj,*.jjt		setf javacc
Karsten Hopp cf9f5a
Karsten Hopp cf9f5a
" JavaScript, ECMAScript
Karsten Hopp cf9f5a
au BufNewFile,BufRead *.js,*.javascript,*.es	setf javascript
Karsten Hopp cf9f5a
Karsten Hopp cf9f5a
" Java Server Pages
Karsten Hopp cf9f5a
au BufNewFile,BufRead *.jsp			setf jsp
Karsten Hopp cf9f5a
Karsten Hopp cf9f5a
" Java Properties resource file (note: doesn't catch font.properties.pl)
Karsten Hopp cf9f5a
au BufNewFile,BufRead *.properties,*.properties_??,*.properties_??_??	setf jproperties
Karsten Hopp cf9f5a
au BufNewFile,BufRead *.properties_??_??_*	call s:StarSetf('jproperties')
Karsten Hopp cf9f5a
Karsten Hopp cf9f5a
" Jess
Karsten Hopp cf9f5a
au BufNewFile,BufRead *.clp			setf jess
Karsten Hopp cf9f5a
Karsten Hopp cf9f5a
" Jgraph
Karsten Hopp cf9f5a
au BufNewFile,BufRead *.jgr			setf jgraph
Karsten Hopp cf9f5a
Karsten Hopp cf9f5a
" Kixtart
Karsten Hopp cf9f5a
au BufNewFile,BufRead *.kix			setf kix
Karsten Hopp cf9f5a
Karsten Hopp cf9f5a
" Kimwitu[++]
Karsten Hopp cf9f5a
au BufNewFile,BufRead *.k			setf kwt
Karsten Hopp cf9f5a
Karsten Hopp cf9f5a
" KDE script
Karsten Hopp cf9f5a
au BufNewFile,BufRead *.ks			setf kscript
Karsten Hopp cf9f5a
Karsten Hopp cf9f5a
" Kconfig
Karsten Hopp cf9f5a
au BufNewFile,BufRead Kconfig,Kconfig.debug	setf kconfig
Karsten Hopp cf9f5a
Karsten Hopp cf9f5a
" Lace (ISE)
Karsten Hopp cf9f5a
au BufNewFile,BufRead *.ace,*.ACE		setf lace
Karsten Hopp cf9f5a
Karsten Hopp cf9f5a
" Latte
Karsten Hopp cf9f5a
au BufNewFile,BufRead *.latte,*.lte		setf latte
Karsten Hopp cf9f5a
Karsten Hopp cf9f5a
" Limits
Karsten Hopp cf9f5a
au BufNewFile,BufRead /etc/limits		setf limits
Karsten Hopp cf9f5a
Karsten Hopp cf9f5a
" LambdaProlog (*.mod too, see Modsim)
Karsten Hopp cf9f5a
au BufNewFile,BufRead *.sig			setf lprolog
Karsten Hopp cf9f5a
Karsten Hopp cf9f5a
" LDAP LDIF
Karsten Hopp cf9f5a
au BufNewFile,BufRead *.ldif			setf ldif
Karsten Hopp cf9f5a
Karsten Hopp cf9f5a
" Ld loader
Karsten Hopp cf9f5a
au BufNewFile,BufRead *.ld			setf ld
Karsten Hopp cf9f5a
Karsten Hopp cf9f5a
" Lex
Karsten Hopp cf9f5a
au BufNewFile,BufRead *.lex,*.l			setf lex
Karsten Hopp cf9f5a
Karsten Hopp cf9f5a
" Libao
Karsten Hopp cf9f5a
au BufNewFile,BufRead /etc/libao.conf,*/.libao	setf libao
Karsten Hopp cf9f5a
Karsten Hopp cf9f5a
" Libsensors
Karsten Hopp cf9f5a
au BufNewFile,BufRead /etc/sensors.conf		setf sensors
Karsten Hopp cf9f5a
Karsten Hopp cf9f5a
" LFTP
Karsten Hopp cf9f5a
au BufNewFile,BufRead lftp.conf,.lftprc,*lftp/rc	setf lftp
Karsten Hopp cf9f5a
Karsten Hopp cf9f5a
" Lifelines (or Lex for C++!)
Karsten Hopp cf9f5a
au BufNewFile,BufRead *.ll			setf lifelines
Karsten Hopp cf9f5a
Karsten Hopp cf9f5a
" Lilo: Linux loader
Karsten Hopp cf9f5a
au BufNewFile,BufRead lilo.conf*		call s:StarSetf('lilo')
Karsten Hopp cf9f5a
Karsten Hopp cf9f5a
" Lisp (*.el = ELisp, *.cl = Common Lisp, *.jl = librep Lisp)
Karsten Hopp cf9f5a
if has("fname_case")
Karsten Hopp cf9f5a
  au BufNewFile,BufRead *.lsp,*.lisp,*.el,*.cl,*.jl,*.L,.emacs,.sawfishrc setf lisp
Karsten Hopp cf9f5a
else
Karsten Hopp cf9f5a
  au BufNewFile,BufRead *.lsp,*.lisp,*.el,*.cl,*.jl,.emacs,.sawfishrc setf lisp
Karsten Hopp cf9f5a
endif
Karsten Hopp cf9f5a
Karsten Hopp cf9f5a
" SBCL implementation of Common Lisp
Karsten Hopp cf9f5a
au BufNewFile,BufRead sbclrc,.sbclrc		setf lisp
Karsten Hopp cf9f5a
Karsten Hopp cf9f5a
" Lite
Karsten Hopp cf9f5a
au BufNewFile,BufRead *.lite,*.lt		setf lite
Karsten Hopp cf9f5a
Karsten Hopp cf9f5a
" LiteStep RC files
Karsten Hopp cf9f5a
au BufNewFile,BufRead */LiteStep/*/*.rc		setf litestep
Karsten Hopp cf9f5a
Karsten Hopp cf9f5a
" Login access
Karsten Hopp cf9f5a
au BufNewFile,BufRead /etc/login.access		setf loginaccess
Karsten Hopp cf9f5a
Karsten Hopp cf9f5a
" Login defs
Karsten Hopp cf9f5a
au BufNewFile,BufRead /etc/login.defs		setf logindefs
Karsten Hopp cf9f5a
Karsten Hopp cf9f5a
" Logtalk
Karsten Hopp cf9f5a
au BufNewFile,BufRead *.lgt			setf logtalk
Karsten Hopp cf9f5a
Karsten Hopp cf9f5a
" LOTOS
Karsten Hopp cf9f5a
au BufNewFile,BufRead *.lot,*.lotos		setf lotos
Karsten Hopp cf9f5a
Karsten Hopp cf9f5a
" Lout (also: *.lt)
Karsten Hopp cf9f5a
au BufNewFile,BufRead *.lou,*.lout		setf lout
Karsten Hopp cf9f5a
Karsten Hopp cf9f5a
" Lua
Karsten Hopp cf9f5a
au BufNewFile,BufRead *.lua			setf lua
Karsten Hopp cf9f5a
Karsten Hopp cf9f5a
" Linden Scripting Language (Second Life)
Karsten Hopp cf9f5a
au BufNewFile,BufRead *.lsl			setf lsl
Karsten Hopp cf9f5a
Karsten Hopp cf9f5a
" Lynx style file (or LotusScript!)
Karsten Hopp cf9f5a
au BufNewFile,BufRead *.lss			setf lss
Karsten Hopp cf9f5a
Karsten Hopp cf9f5a
" M4
Karsten Hopp cf9f5a
au BufNewFile,BufRead *.m4
Karsten Hopp cf9f5a
	\ if expand("<afile>") !~? 'html.m4$\|fvwm2rc' | setf m4 | endif
Karsten Hopp cf9f5a
Karsten Hopp cf9f5a
" MaGic Point
Karsten Hopp cf9f5a
au BufNewFile,BufRead *.mgp			setf mgp
Karsten Hopp cf9f5a
Karsten Hopp cf9f5a
" Mail (for Elm, trn, mutt, muttng, rn, slrn)
Karsten Hopp cf9f5a
au BufNewFile,BufRead snd.\d\+,.letter,.letter.\d\+,.followup,.article,.article.\d\+,pico.\d\+,mutt{ng,}-*-\w\+,mutt[[:alnum:]_-]\{6\},ae\d\+.txt,/tmp/SLRN[0-9A-Z.]\+,*.eml setf mail
Karsten Hopp cf9f5a
Karsten Hopp cf9f5a
" Mail aliases
Karsten Hopp cf9f5a
au BufNewFile,BufRead /etc/mail/aliases,/etc/aliases	setf mailaliases
Karsten Hopp cf9f5a
Karsten Hopp cf9f5a
" Mailcap configuration file
Karsten Hopp cf9f5a
au BufNewFile,BufRead .mailcap,mailcap		setf mailcap
Karsten Hopp cf9f5a
Karsten Hopp cf9f5a
" Makefile
Karsten Hopp cf9f5a
au BufNewFile,BufRead *[mM]akefile,*.mk,*.mak,*.dsp setf make
Karsten Hopp cf9f5a
Karsten Hopp cf9f5a
" MakeIndex
Karsten Hopp cf9f5a
au BufNewFile,BufRead *.ist,*.mst		setf ist
Karsten Hopp cf9f5a
Karsten Hopp cf9f5a
" Manpage
Karsten Hopp cf9f5a
au BufNewFile,BufRead *.man			setf man
Karsten Hopp cf9f5a
Karsten Hopp cf9f5a
" Man config
Karsten Hopp cf9f5a
au BufNewFile,BufRead /etc/man.conf,man.config	setf manconf
Karsten Hopp cf9f5a
Karsten Hopp cf9f5a
" Maple V
Karsten Hopp cf9f5a
au BufNewFile,BufRead *.mv,*.mpl,*.mws		setf maple
Karsten Hopp cf9f5a
Karsten Hopp cf9f5a
" Map (UMN mapserver config file)
Karsten Hopp cf9f5a
au BufNewFile,BufRead *.map			setf map
Karsten Hopp cf9f5a
Karsten Hopp cf9f5a
" Mason
Karsten Hopp cf9f5a
au BufNewFile,BufRead *.mason,*.mhtml		setf mason
Karsten Hopp cf9f5a
Karsten Hopp cf9f5a
" Matlab or Objective C
Karsten Hopp cf9f5a
au BufNewFile,BufRead *.m			call s:FTm()
Karsten Hopp cf9f5a
Karsten Hopp cf9f5a
func! s:FTm()
Karsten Hopp cf9f5a
  let n = 1
Karsten Hopp cf9f5a
  while n < 10
Karsten Hopp cf9f5a
    let line = getline(n)
Karsten Hopp cf9f5a
    if line =~ '^\s*\(#\s*\(include\|import\)\>\|/\*\)'
Karsten Hopp cf9f5a
      setf objc
Karsten Hopp cf9f5a
      return
Karsten Hopp cf9f5a
    endif
Karsten Hopp cf9f5a
    if line =~ '^\s*%'
Karsten Hopp cf9f5a
      setf matlab
Karsten Hopp cf9f5a
      return
Karsten Hopp cf9f5a
    endif
Karsten Hopp cf9f5a
    if line =~ '^\s*(\*'
Karsten Hopp cf9f5a
      setf mma
Karsten Hopp cf9f5a
      return
Karsten Hopp cf9f5a
    endif
Karsten Hopp cf9f5a
    let n = n + 1
Karsten Hopp cf9f5a
  endwhile
Karsten Hopp cf9f5a
  if exists("g:filetype_m")
Karsten Hopp cf9f5a
    exe "setf " . g:filetype_m
Karsten Hopp cf9f5a
  else
Karsten Hopp cf9f5a
    setf matlab
Karsten Hopp cf9f5a
  endif
Karsten Hopp cf9f5a
endfunc
Karsten Hopp cf9f5a
Karsten Hopp cf9f5a
" Mathematica notebook
Karsten Hopp cf9f5a
au BufNewFile,BufRead *.nb			setf mma
Karsten Hopp cf9f5a
Karsten Hopp cf9f5a
" Maya Extension Language
Karsten Hopp cf9f5a
au BufNewFile,BufRead *.mel			setf mel
Karsten Hopp cf9f5a
Karsten Hopp cf9f5a
" Messages
Karsten Hopp cf9f5a
au BufNewFile,BufRead /var/log/messages,/var/log/messages.*[0-9]  setf messages
Karsten Hopp cf9f5a
Karsten Hopp cf9f5a
" Metafont
Karsten Hopp cf9f5a
au BufNewFile,BufRead *.mf			setf mf
Karsten Hopp cf9f5a
Karsten Hopp cf9f5a
" MetaPost
Karsten Hopp cf9f5a
au BufNewFile,BufRead *.mp			setf mp
Karsten Hopp cf9f5a
Karsten Hopp cf9f5a
" MGL
Karsten Hopp cf9f5a
au BufNewFile,BufRead *.mgl			setf mgl
Karsten Hopp cf9f5a
Karsten Hopp cf9f5a
" MMIX or VMS makefile
Karsten Hopp cf9f5a
au BufNewFile,BufRead *.mms			call s:FTmms()
Karsten Hopp cf9f5a
Karsten Hopp cf9f5a
" Symbian meta-makefile definition (MMP)
Karsten Hopp cf9f5a
au BufNewFile,BufRead *.mmp			setf mmp
Karsten Hopp cf9f5a
Karsten Hopp cf9f5a
func! s:FTmms()
Karsten Hopp cf9f5a
  let n = 1
Karsten Hopp cf9f5a
  while n < 10
Karsten Hopp cf9f5a
    let line = getline(n)
Karsten Hopp cf9f5a
    if line =~ '^\s*\(%\|//\)' || line =~ '^\*'
Karsten Hopp cf9f5a
      setf mmix
Karsten Hopp cf9f5a
      return
Karsten Hopp cf9f5a
    endif
Karsten Hopp cf9f5a
    if line =~ '^\s*#'
Karsten Hopp cf9f5a
      setf make
Karsten Hopp cf9f5a
      return
Karsten Hopp cf9f5a
    endif
Karsten Hopp cf9f5a
    let n = n + 1
Karsten Hopp cf9f5a
  endwhile
Karsten Hopp cf9f5a
  setf mmix
Karsten Hopp cf9f5a
endfunc
Karsten Hopp cf9f5a
Karsten Hopp cf9f5a
Karsten Hopp cf9f5a
" Modsim III (or LambdaProlog)
Karsten Hopp cf9f5a
au BufNewFile,BufRead *.mod
Karsten Hopp cf9f5a
	\ if getline(1) =~ '\<module\>' |
Karsten Hopp cf9f5a
	\   setf lprolog |
Karsten Hopp cf9f5a
	\ else |
Karsten Hopp cf9f5a
	\   setf modsim3 |
Karsten Hopp cf9f5a
	\ endif
Karsten Hopp cf9f5a
Karsten Hopp cf9f5a
" Modula 2
Karsten Hopp cf9f5a
au BufNewFile,BufRead *.m2,*.DEF,*.MOD,*.md,*.mi setf modula2
Karsten Hopp cf9f5a
Karsten Hopp cf9f5a
" Modula 3 (.m3, .i3, .mg, .ig)
Karsten Hopp cf9f5a
au BufNewFile,BufRead *.[mi][3g]		setf modula3
Karsten Hopp cf9f5a
Karsten Hopp cf9f5a
" Monk
Karsten Hopp cf9f5a
au BufNewFile,BufRead *.isc,*.monk,*.ssc,*.tsc	setf monk
Karsten Hopp cf9f5a
Karsten Hopp cf9f5a
" MOO
Karsten Hopp cf9f5a
au BufNewFile,BufRead *.moo			setf moo
Karsten Hopp cf9f5a
Karsten Hopp cf9f5a
" Modconf
Karsten Hopp cf9f5a
au BufNewFile,BufRead /etc/modules.conf,/etc/conf.modules	setf modconf
Karsten Hopp cf9f5a
au BufNewFile,BufRead /etc/modutils/*
Karsten Hopp cf9f5a
	\ if executable(expand("<afile>")) != 1
Karsten Hopp cf9f5a
	\|  call s:StarSetf('modconf')
Karsten Hopp cf9f5a
	\|endif
Karsten Hopp cf9f5a
Karsten Hopp cf9f5a
" Mplayer config
Karsten Hopp cf9f5a
au BufNewFile,BufRead mplayer.conf,*/.mplayer/config	setf mplayerconf
Karsten Hopp cf9f5a
Karsten Hopp cf9f5a
" Moterola S record
Karsten Hopp cf9f5a
au BufNewFile,BufRead *.s19,*.s28,*.s37		setf srec
Karsten Hopp cf9f5a
Karsten Hopp cf9f5a
" Mrxvtrc
Karsten Hopp cf9f5a
au BufNewFile,BufRead mrxvtrc,.mrxvtrc		setf mrxvtrc
Karsten Hopp cf9f5a
Karsten Hopp cf9f5a
" Msql
Karsten Hopp cf9f5a
au BufNewFile,BufRead *.msql			setf msql
Karsten Hopp cf9f5a
Karsten Hopp cf9f5a
" Mysql
Karsten Hopp cf9f5a
au BufNewFile,BufRead *.mysql			setf mysql
Karsten Hopp cf9f5a
Karsten Hopp cf9f5a
" M$ Resource files
Karsten Hopp cf9f5a
au BufNewFile,BufRead *.rc			setf rc
Karsten Hopp cf9f5a
Karsten Hopp cf9f5a
" MuPAD source
Karsten Hopp cf9f5a
au BufRead,BufNewFile *.mu			setf mupad
Karsten Hopp cf9f5a
Karsten Hopp cf9f5a
" Mush
Karsten Hopp cf9f5a
au BufNewFile,BufRead *.mush			setf mush
Karsten Hopp cf9f5a
Karsten Hopp cf9f5a
" Mutt setup file (also for Muttng)
Karsten Hopp cf9f5a
au BufNewFile,BufRead Mutt{ng,}rc		setf muttrc
Karsten Hopp cf9f5a
Karsten Hopp cf9f5a
" Nano
Karsten Hopp cf9f5a
au BufNewFile,BufRead /etc/nanorc,.nanorc	setf nanorc
Karsten Hopp cf9f5a
Karsten Hopp cf9f5a
" Nastran input/DMAP
Karsten Hopp cf9f5a
"au BufNewFile,BufRead *.dat			setf nastran
Karsten Hopp cf9f5a
Karsten Hopp cf9f5a
" Natural
Karsten Hopp cf9f5a
au BufNewFile,BufRead *.NS[ACGLMNPS]		setf natural
Karsten Hopp cf9f5a
Karsten Hopp cf9f5a
" Netrc
Karsten Hopp cf9f5a
au BufNewFile,BufRead .netrc			setf netrc
Karsten Hopp cf9f5a
Karsten Hopp cf9f5a
" Novell netware batch files
Karsten Hopp cf9f5a
au BufNewFile,BufRead *.ncf			setf ncf
Karsten Hopp cf9f5a
Karsten Hopp cf9f5a
" Nroff/Troff (*.ms and *.t are checked below)
Karsten Hopp cf9f5a
au BufNewFile,BufRead *.me
Karsten Hopp cf9f5a
	\ if expand("<afile>") != "read.me" && expand("<afile>") != "click.me" |
Karsten Hopp cf9f5a
	\   setf nroff |
Karsten Hopp cf9f5a
	\ endif
Karsten Hopp cf9f5a
au BufNewFile,BufRead *.tr,*.nr,*.roff,*.tmac,*.mom	setf nroff
Karsten Hopp cf9f5a
au BufNewFile,BufRead *.[1-9]			call s:FTnroff()
Karsten Hopp cf9f5a
Karsten Hopp cf9f5a
" This function checks if one of the first five lines start with a dot.  In
Karsten Hopp cf9f5a
" that case it is probably an nroff file: 'filetype' is set and 1 is returned.
Karsten Hopp cf9f5a
func! s:FTnroff()
Karsten Hopp cf9f5a
  if getline(1)[0] . getline(2)[0] . getline(3)[0] . getline(4)[0] . getline(5)[0] =~ '\.'
Karsten Hopp cf9f5a
    setf nroff
Karsten Hopp cf9f5a
    return 1
Karsten Hopp cf9f5a
  endif
Karsten Hopp cf9f5a
  return 0
Karsten Hopp cf9f5a
endfunc
Karsten Hopp cf9f5a
Karsten Hopp cf9f5a
" Nroff or Objective C++
Karsten Hopp cf9f5a
au BufNewFile,BufRead *.mm			call s:FTmm()
Karsten Hopp cf9f5a
Karsten Hopp cf9f5a
func! s:FTmm()
Karsten Hopp cf9f5a
  let n = 1
Karsten Hopp cf9f5a
  while n < 10
Karsten Hopp cf9f5a
    let line = getline(n)
Karsten Hopp cf9f5a
    if line =~ '^\s*\(#\s*\(include\|import\)\>\|/\*\)'
Karsten Hopp cf9f5a
      setf objcpp
Karsten Hopp cf9f5a
      return
Karsten Hopp cf9f5a
    endif
Karsten Hopp cf9f5a
    let n = n + 1
Karsten Hopp cf9f5a
  endwhile
Karsten Hopp cf9f5a
  setf nroff
Karsten Hopp cf9f5a
endfunc
Karsten Hopp cf9f5a
Karsten Hopp cf9f5a
" Not Quite C
Karsten Hopp cf9f5a
au BufNewFile,BufRead *.nqc			setf nqc
Karsten Hopp cf9f5a
Karsten Hopp cf9f5a
" NSIS
Karsten Hopp cf9f5a
au BufNewFile,BufRead *.nsi			setf nsis
Karsten Hopp cf9f5a
Karsten Hopp cf9f5a
" OCAML
Karsten Hopp cf9f5a
au BufNewFile,BufRead *.ml,*.mli,*.mll,*.mly	setf ocaml
Karsten Hopp cf9f5a
Karsten Hopp cf9f5a
" Occam
Karsten Hopp cf9f5a
au BufNewFile,BufRead *.occ			setf occam
Karsten Hopp cf9f5a
Karsten Hopp cf9f5a
" Omnimark
Karsten Hopp cf9f5a
au BufNewFile,BufRead *.xom,*.xin		setf omnimark
Karsten Hopp cf9f5a
Karsten Hopp cf9f5a
" OpenROAD
Karsten Hopp cf9f5a
au BufNewFile,BufRead *.or			setf openroad
Karsten Hopp cf9f5a
Karsten Hopp cf9f5a
" OPL
Karsten Hopp cf9f5a
au BufNewFile,BufRead *.[Oo][Pp][Ll]		setf opl
Karsten Hopp cf9f5a
Karsten Hopp cf9f5a
" Oracle config file
Karsten Hopp cf9f5a
au BufNewFile,BufRead *.ora			setf ora
Karsten Hopp cf9f5a
Karsten Hopp cf9f5a
" Packet filter conf
Karsten Hopp cf9f5a
au BufNewFile,BufRead pf.conf			setf pf
Karsten Hopp cf9f5a
Karsten Hopp cf9f5a
" Pam conf
Karsten Hopp cf9f5a
au BufNewFile,BufRead /etc/pam.conf		setf pamconf
Karsten Hopp cf9f5a
Karsten Hopp cf9f5a
" PApp
Karsten Hopp cf9f5a
au BufNewFile,BufRead *.papp,*.pxml,*.pxsl	setf papp
Karsten Hopp cf9f5a
Karsten Hopp cf9f5a
" Password file
Karsten Hopp cf9f5a
au BufNewFile,BufRead /etc/passwd,/etc/passwd-,/etc/passwd.edit,/etc/shadow,/etc/shadow-,/var/backups/passwd.bak,/var/backups/shadow.bak setf passwd
Karsten Hopp cf9f5a
Karsten Hopp cf9f5a
" Pascal (also *.p)
Karsten Hopp cf9f5a
au BufNewFile,BufRead *.pas			setf pascal
Karsten Hopp cf9f5a
Karsten Hopp cf9f5a
" Delphi project file
Karsten Hopp cf9f5a
au BufNewFile,BufRead *.dpr			setf pascal
Karsten Hopp cf9f5a
Karsten Hopp cf9f5a
" PDF
Karsten Hopp cf9f5a
au BufNewFile,BufRead *.pdf			setf pdf
Karsten Hopp cf9f5a
Karsten Hopp cf9f5a
" Perl
Karsten Hopp cf9f5a
if has("fname_case")
Karsten Hopp cf9f5a
  au BufNewFile,BufRead *.pl,*.PL		call s:FTpl()
Karsten Hopp cf9f5a
else
Karsten Hopp cf9f5a
  au BufNewFile,BufRead *.pl			call s:FTpl()
Karsten Hopp cf9f5a
endif
Karsten Hopp cf9f5a
au BufNewFile,BufRead *.plx,*.al		setf perl
Karsten Hopp cf9f5a
Karsten Hopp cf9f5a
func! s:FTpl()
Karsten Hopp cf9f5a
  if exists("g:filetype_pl")
Karsten Hopp cf9f5a
    exe "setf " . g:filetype_pl
Karsten Hopp cf9f5a
  else
Karsten Hopp cf9f5a
    " recognize Prolog by specific text in the first non-empty line
Karsten Hopp cf9f5a
    " require a blank after the '%' because Perl uses "%list" and "%translate"
Karsten Hopp cf9f5a
    let l = getline(nextnonblank(1))
Karsten Hopp cf9f5a
    if l =~ '\<prolog\>' || l =~ '^\s*\(%\+\(\s\|$\)\|/\*\)' || l =~ ':-'
Karsten Hopp cf9f5a
      setf prolog
Karsten Hopp cf9f5a
    else
Karsten Hopp cf9f5a
      setf perl
Karsten Hopp cf9f5a
    endif
Karsten Hopp cf9f5a
  endif
Karsten Hopp cf9f5a
endfunc
Karsten Hopp cf9f5a
Karsten Hopp cf9f5a
" Perl, XPM or XPM2
Karsten Hopp cf9f5a
au BufNewFile,BufRead *.pm
Karsten Hopp cf9f5a
	\ if getline(1) =~ "XPM2" |
Karsten Hopp cf9f5a
	\   setf xpm2 |
Karsten Hopp cf9f5a
	\ elseif getline(1) =~ "XPM" |
Karsten Hopp cf9f5a
	\   setf xpm |
Karsten Hopp cf9f5a
	\ else |
Karsten Hopp cf9f5a
	\   setf perl |
Karsten Hopp cf9f5a
	\ endif
Karsten Hopp cf9f5a
Karsten Hopp cf9f5a
" Perl POD
Karsten Hopp cf9f5a
au BufNewFile,BufRead *.pod			setf pod
Karsten Hopp cf9f5a
Karsten Hopp cf9f5a
" Php, php3, php4, etc.
Karsten Hopp cf9f5a
" Also Phtml (was used for PHP 2 in the past)
Karsten Hopp cf9f5a
" Also .ctp for Cake template file
Karsten Hopp cf9f5a
au BufNewFile,BufRead *.php,*.php\d,*.phtml,*.ctp	setf php
Karsten Hopp cf9f5a
Karsten Hopp cf9f5a
" Pike
Karsten Hopp cf9f5a
au BufNewFile,BufRead *.pike,*.lpc,*.ulpc,*.pmod setf pike
Karsten Hopp cf9f5a
Karsten Hopp cf9f5a
" Pinfo config
Karsten Hopp cf9f5a
au BufNewFile,BufRead */etc/pinforc,*/.pinforc	setf pinfo
Karsten Hopp cf9f5a
Karsten Hopp cf9f5a
" Palm Resource compiler
Karsten Hopp cf9f5a
au BufNewFile,BufRead *.rcp			setf pilrc
Karsten Hopp cf9f5a
Karsten Hopp cf9f5a
" Pine config
Karsten Hopp cf9f5a
au BufNewFile,BufRead .pinerc,pinerc,.pinercex,pinercex		setf pine
Karsten Hopp cf9f5a
Karsten Hopp cf9f5a
" PL/M (also: *.inp)
Karsten Hopp cf9f5a
au BufNewFile,BufRead *.plm,*.p36,*.pac		setf plm
Karsten Hopp cf9f5a
Karsten Hopp cf9f5a
" PL/SQL
Karsten Hopp cf9f5a
au BufNewFile,BufRead *.pls,*.plsql		setf plsql
Karsten Hopp cf9f5a
Karsten Hopp cf9f5a
" PLP
Karsten Hopp cf9f5a
au BufNewFile,BufRead *.plp			setf plp
Karsten Hopp cf9f5a
Karsten Hopp cf9f5a
" PO and PO template (GNU gettext)
Karsten Hopp cf9f5a
au BufNewFile,BufRead *.po,*.pot		setf po
Karsten Hopp cf9f5a
Karsten Hopp cf9f5a
" Postfix main config
Karsten Hopp cf9f5a
au BufNewFile,BufRead main.cf			setf pfmain
Karsten Hopp cf9f5a
Karsten Hopp cf9f5a
" PostScript (+ font files, encapsulated PostScript, Adobe Illustrator)
Karsten Hopp cf9f5a
au BufNewFile,BufRead *.ps,*.pfa,*.afm,*.eps,*.epsf,*.epsi,*.ai	  setf postscr
Karsten Hopp cf9f5a
Karsten Hopp cf9f5a
" PostScript Printer Description
Karsten Hopp cf9f5a
au BufNewFile,BufRead *.ppd			setf ppd
Karsten Hopp cf9f5a
Karsten Hopp cf9f5a
" Povray
Karsten Hopp cf9f5a
au BufNewFile,BufRead *.pov			setf pov
Karsten Hopp cf9f5a
Karsten Hopp cf9f5a
" Povray configuration
Karsten Hopp cf9f5a
au BufNewFile,BufRead .povrayrc			setf povini
Karsten Hopp cf9f5a
Karsten Hopp cf9f5a
" Povray, PHP or assembly
Karsten Hopp cf9f5a
au BufNewFile,BufRead *.inc			call s:FTinc()
Karsten Hopp cf9f5a
Karsten Hopp cf9f5a
func! s:FTinc()
Karsten Hopp cf9f5a
  if exists("g:filetype_inc")
Karsten Hopp cf9f5a
    exe "setf " . g:filetype_inc
Karsten Hopp cf9f5a
  else
Karsten Hopp cf9f5a
    let lines = getline(1).getline(2).getline(3)
Karsten Hopp cf9f5a
    if lines =~? "perlscript"
Karsten Hopp cf9f5a
      setf aspperl
Karsten Hopp cf9f5a
    elseif lines =~ "<%"
Karsten Hopp cf9f5a
      setf aspvbs
Karsten Hopp cf9f5a
    elseif lines =~ "
Karsten Hopp cf9f5a
      setf php
Karsten Hopp cf9f5a
    else
Karsten Hopp cf9f5a
      call s:FTasmsyntax()
Karsten Hopp cf9f5a
      if exists("b:asmsyntax")
Karsten Hopp cf9f5a
	exe "setf " . fnameescape(b:asmsyntax)
Karsten Hopp cf9f5a
      else
Karsten Hopp cf9f5a
	setf pov
Karsten Hopp cf9f5a
      endif
Karsten Hopp cf9f5a
    endif
Karsten Hopp cf9f5a
  endif
Karsten Hopp cf9f5a
endfunc
Karsten Hopp cf9f5a
Karsten Hopp cf9f5a
" Printcap and Termcap
Karsten Hopp cf9f5a
au BufNewFile,BufRead *printcap
Karsten Hopp cf9f5a
	\ let b:ptcap_type = "print" | setf ptcap
Karsten Hopp cf9f5a
au BufNewFile,BufRead *termcap
Karsten Hopp cf9f5a
	\ let b:ptcap_type = "term" | setf ptcap
Karsten Hopp cf9f5a
Karsten Hopp cf9f5a
" PCCTS / ANTRL
Karsten Hopp cf9f5a
"au BufNewFile,BufRead *.g			setf antrl
Karsten Hopp cf9f5a
au BufNewFile,BufRead *.g			setf pccts
Karsten Hopp cf9f5a
Karsten Hopp cf9f5a
" PPWizard
Karsten Hopp cf9f5a
au BufNewFile,BufRead *.it,*.ih			setf ppwiz
Karsten Hopp cf9f5a
Karsten Hopp cf9f5a
" Oracle Pro*C/C++
Karsten Hopp cf9f5a
au BufNewFile,BufRead *.pc			setf proc
Karsten Hopp cf9f5a
Karsten Hopp cf9f5a
" Privoxy actions file
Karsten Hopp cf9f5a
au BufNewFile,BufRead *.action			setf privoxy
Karsten Hopp cf9f5a
Karsten Hopp cf9f5a
" Procmail
Karsten Hopp cf9f5a
au BufNewFile,BufRead .procmail,.procmailrc	setf procmail
Karsten Hopp cf9f5a
Karsten Hopp cf9f5a
" Progress or CWEB
Karsten Hopp cf9f5a
au BufNewFile,BufRead *.w			call s:FTprogress_cweb()
Karsten Hopp cf9f5a
Karsten Hopp cf9f5a
func! s:FTprogress_cweb()
Karsten Hopp cf9f5a
  if exists("g:filetype_w")
Karsten Hopp cf9f5a
    exe "setf " . g:filetype_w
Karsten Hopp cf9f5a
    return
Karsten Hopp cf9f5a
  endif
Karsten Hopp cf9f5a
  if getline(1) =~ '&ANALYZE' || getline(3) =~ '&GLOBAL-DEFINE'
Karsten Hopp cf9f5a
    setf progress
Karsten Hopp cf9f5a
  else
Karsten Hopp cf9f5a
    setf cweb
Karsten Hopp cf9f5a
  endif
Karsten Hopp cf9f5a
endfunc
Karsten Hopp cf9f5a
Karsten Hopp cf9f5a
" Progress or assembly
Karsten Hopp cf9f5a
au BufNewFile,BufRead *.i			call s:FTprogress_asm()
Karsten Hopp cf9f5a
Karsten Hopp cf9f5a
func! s:FTprogress_asm()
Karsten Hopp cf9f5a
  if exists("g:filetype_i")
Karsten Hopp cf9f5a
    exe "setf " . g:filetype_i
Karsten Hopp cf9f5a
    return
Karsten Hopp cf9f5a
  endif
Karsten Hopp cf9f5a
  " This function checks for an assembly comment the first ten lines.
Karsten Hopp cf9f5a
  " If not found, assume Progress.
Karsten Hopp cf9f5a
  let lnum = 1
Karsten Hopp cf9f5a
  while lnum <= 10 && lnum < line('$')
Karsten Hopp cf9f5a
    let line = getline(lnum)
Karsten Hopp cf9f5a
    if line =~ '^\s*;' || line =~ '^\*'
Karsten Hopp cf9f5a
      call s:FTasm()
Karsten Hopp cf9f5a
      return
Karsten Hopp cf9f5a
    elseif line !~ '^\s*$' || line =~ '^/\*'
Karsten Hopp cf9f5a
      " Not an empty line: Doesn't look like valid assembly code.
Karsten Hopp cf9f5a
      " Or it looks like a Progress /* comment
Karsten Hopp cf9f5a
      break
Karsten Hopp cf9f5a
    endif
Karsten Hopp cf9f5a
    let lnum = lnum + 1
Karsten Hopp cf9f5a
  endw
Karsten Hopp cf9f5a
  setf progress
Karsten Hopp cf9f5a
endfunc
Karsten Hopp cf9f5a
Karsten Hopp cf9f5a
" Progress or Pascal
Karsten Hopp cf9f5a
au BufNewFile,BufRead *.p			call s:FTprogress_pascal()
Karsten Hopp cf9f5a
Karsten Hopp cf9f5a
func! s:FTprogress_pascal()
Karsten Hopp cf9f5a
  if exists("g:filetype_p")
Karsten Hopp cf9f5a
    exe "setf " . g:filetype_p
Karsten Hopp cf9f5a
    return
Karsten Hopp cf9f5a
  endif
Karsten Hopp cf9f5a
  " This function checks for valid Pascal syntax in the first ten lines.
Karsten Hopp cf9f5a
  " Look for either an opening comment or a program start.
Karsten Hopp cf9f5a
  " If not found, assume Progress.
Karsten Hopp cf9f5a
  let lnum = 1
Karsten Hopp cf9f5a
  while lnum <= 10 && lnum < line('$')
Karsten Hopp cf9f5a
    let line = getline(lnum)
Karsten Hopp cf9f5a
    if line =~ '^\s*\(program\|unit\|procedure\|function\|const\|type\|var\)\>'
Karsten Hopp cf9f5a
	\ || line =~ '^\s*{' || line =~ '^\s*(\*'
Karsten Hopp cf9f5a
      setf pascal
Karsten Hopp cf9f5a
      return
Karsten Hopp cf9f5a
    elseif line !~ '^\s*$' || line =~ '^/\*'
Karsten Hopp cf9f5a
      " Not an empty line: Doesn't look like valid Pascal code.
Karsten Hopp cf9f5a
      " Or it looks like a Progress /* comment
Karsten Hopp cf9f5a
      break
Karsten Hopp cf9f5a
    endif
Karsten Hopp cf9f5a
    let lnum = lnum + 1
Karsten Hopp cf9f5a
  endw
Karsten Hopp cf9f5a
  setf progress
Karsten Hopp cf9f5a
endfunc
Karsten Hopp cf9f5a
Karsten Hopp cf9f5a
Karsten Hopp cf9f5a
" Software Distributor Product Specification File (POSIX 1387.2-1995)
Karsten Hopp cf9f5a
au BufNewFile,BufRead *.psf			setf psf
Karsten Hopp cf9f5a
au BufNewFile,BufRead INDEX,INFO
Karsten Hopp cf9f5a
	\ if getline(1) =~ '^\s*\(distribution\|installed_software\|root\|bundle\|product\)\s*$' |
Karsten Hopp cf9f5a
	\   setf psf |
Karsten Hopp cf9f5a
	\ endif
Karsten Hopp cf9f5a
Karsten Hopp cf9f5a
" Prolog
Karsten Hopp cf9f5a
au BufNewFile,BufRead *.pdb			setf prolog
Karsten Hopp cf9f5a
Karsten Hopp cf9f5a
" Promela
Karsten Hopp cf9f5a
au BufNewFile,BufRead *.pml			setf promela
Karsten Hopp cf9f5a
Karsten Hopp cf9f5a
" Protocols
Karsten Hopp cf9f5a
au BufNewFile,BufRead /etc/protocols		setf protocols
Karsten Hopp cf9f5a
Karsten Hopp cf9f5a
" Pyrex
Karsten Hopp cf9f5a
au BufNewFile,BufRead *.pyx,*.pxd		setf pyrex
Karsten Hopp cf9f5a
Karsten Hopp cf9f5a
" Python
Karsten Hopp cf9f5a
au BufNewFile,BufRead *.py,*.pyw		setf python
Karsten Hopp cf9f5a
Karsten Hopp cf9f5a
" Quixote (Python-based web framework)
Karsten Hopp cf9f5a
au BufNewFile,BufRead *.ptl			setf python
Karsten Hopp cf9f5a
Karsten Hopp cf9f5a
" Radiance
Karsten Hopp cf9f5a
au BufNewFile,BufRead *.rad,*.mat		setf radiance
Karsten Hopp cf9f5a
Karsten Hopp cf9f5a
" Ratpoison config/command files
Karsten Hopp cf9f5a
au BufNewFile,BufRead .ratpoisonrc,ratpoisonrc	setf ratpoison
Karsten Hopp cf9f5a
Karsten Hopp cf9f5a
" RCS file
Karsten Hopp cf9f5a
au BufNewFile,BufRead *\,v			setf rcs
Karsten Hopp cf9f5a
Karsten Hopp cf9f5a
" Readline
Karsten Hopp cf9f5a
au BufNewFile,BufRead .inputrc,inputrc		setf readline
Karsten Hopp cf9f5a
Karsten Hopp cf9f5a
" Registry for MS-Windows
Karsten Hopp cf9f5a
au BufNewFile,BufRead *.reg
Karsten Hopp cf9f5a
	\ if getline(1) =~? '^REGEDIT[0-9]*\s*$\|^Windows Registry Editor Version \d*\.\d*\s*$' | setf registry | endif
Karsten Hopp cf9f5a
Karsten Hopp cf9f5a
" Renderman Interface Bytestream
Karsten Hopp cf9f5a
au BufNewFile,BufRead *.rib			setf rib
Karsten Hopp cf9f5a
Karsten Hopp cf9f5a
" Rexx
Karsten Hopp cf9f5a
au BufNewFile,BufRead *.rexx,*.rex,*.jrexx,*.rxj,*.orx	setf rexx
Karsten Hopp cf9f5a
Karsten Hopp cf9f5a
" R (Splus)
Karsten Hopp cf9f5a
if has("fname_case")
Karsten Hopp cf9f5a
  au BufNewFile,BufRead *.s,*.S			setf r
Karsten Hopp cf9f5a
else
Karsten Hopp cf9f5a
  au BufNewFile,BufRead *.s			setf r
Karsten Hopp cf9f5a
endif
Karsten Hopp cf9f5a
Karsten Hopp cf9f5a
" R Help file
Karsten Hopp cf9f5a
if has("fname_case")
Karsten Hopp cf9f5a
  au BufNewFile,BufRead *.rd,*.Rd		setf rhelp
Karsten Hopp cf9f5a
else
Karsten Hopp cf9f5a
  au BufNewFile,BufRead *.rd			setf rhelp
Karsten Hopp cf9f5a
endif
Karsten Hopp cf9f5a
Karsten Hopp cf9f5a
" R noweb file
Karsten Hopp cf9f5a
if has("fname_case")
Karsten Hopp cf9f5a
  au BufNewFile,BufRead *.Rnw,*.rnw,*.Snw,*.snw		setf rnoweb
Karsten Hopp cf9f5a
else
Karsten Hopp cf9f5a
  au BufNewFile,BufRead *.rnw,*.snw			setf rnoweb
Karsten Hopp cf9f5a
endif
Karsten Hopp cf9f5a
Karsten Hopp cf9f5a
" Rexx, Rebol or R
Karsten Hopp cf9f5a
au BufNewFile,BufRead *.r,*.R			call s:FTr()
Karsten Hopp cf9f5a
Karsten Hopp cf9f5a
func! s:FTr()
Karsten Hopp cf9f5a
  let max = line("$") > 50 ? 50 : line("$")
Karsten Hopp cf9f5a
Karsten Hopp cf9f5a
  for n in range(1, max)
Karsten Hopp cf9f5a
    " Rebol is easy to recognize, check for that first
Karsten Hopp cf9f5a
    if getline(n) =~? '\<REBOL\>'
Karsten Hopp cf9f5a
      setf rebol
Karsten Hopp cf9f5a
      return
Karsten Hopp cf9f5a
    endif
Karsten Hopp cf9f5a
  endfor
Karsten Hopp cf9f5a
Karsten Hopp cf9f5a
  for n in range(1, max)
Karsten Hopp cf9f5a
    " R has # comments
Karsten Hopp cf9f5a
    if getline(n) =~ '^\s*#'
Karsten Hopp cf9f5a
      setf r
Karsten Hopp cf9f5a
      return
Karsten Hopp cf9f5a
    endif
Karsten Hopp cf9f5a
    " Rexx has /* comments */
Karsten Hopp cf9f5a
    if getline(n) =~ '^\s*/\*'
Karsten Hopp cf9f5a
      setf rexx
Karsten Hopp cf9f5a
      return
Karsten Hopp cf9f5a
    endif
Karsten Hopp cf9f5a
  endfor
Karsten Hopp cf9f5a
Karsten Hopp cf9f5a
  " Nothing recognized, assume Rexx
Karsten Hopp cf9f5a
  setf rexx
Karsten Hopp cf9f5a
endfunc
Karsten Hopp cf9f5a
Karsten Hopp cf9f5a
" Remind
Karsten Hopp cf9f5a
au BufNewFile,BufRead .reminders*		call s:StarSetf('remind')
Karsten Hopp cf9f5a
Karsten Hopp cf9f5a
" Resolv.conf
Karsten Hopp cf9f5a
au BufNewFile,BufRead resolv.conf		setf resolv
Karsten Hopp cf9f5a
Karsten Hopp cf9f5a
" Relax NG Compact
Karsten Hopp cf9f5a
au BufNewFile,BufRead *.rnc			setf rnc
Karsten Hopp cf9f5a
Karsten Hopp cf9f5a
" RPL/2
Karsten Hopp cf9f5a
au BufNewFile,BufRead *.rpl			setf rpl
Karsten Hopp cf9f5a
Karsten Hopp cf9f5a
" Robots.txt
Karsten Hopp cf9f5a
au BufNewFile,BufRead robots.txt		setf robots
Karsten Hopp cf9f5a
Karsten Hopp cf9f5a
" Rpcgen
Karsten Hopp cf9f5a
au BufNewFile,BufRead *.x			setf rpcgen
Karsten Hopp cf9f5a
Karsten Hopp cf9f5a
" reStructuredText Documentation Format
Karsten Hopp cf9f5a
au BufNewFile,BufRead *.rst			setf rst
Karsten Hopp cf9f5a
Karsten Hopp cf9f5a
" RTF
Karsten Hopp cf9f5a
au BufNewFile,BufRead *.rtf			setf rtf
Karsten Hopp cf9f5a
Karsten Hopp cf9f5a
" Interactive Ruby shell
Karsten Hopp cf9f5a
au BufNewFile,BufRead .irbrc,irbrc		setf ruby
Karsten Hopp cf9f5a
Karsten Hopp cf9f5a
" Ruby
Karsten Hopp cf9f5a
au BufNewFile,BufRead *.rb,*.rbw,*.gem,*.gemspec	setf ruby
Karsten Hopp cf9f5a
Karsten Hopp cf9f5a
" Ruby on Rails
Karsten Hopp cf9f5a
au BufNewFile,BufRead *.builder,*.rxml,*.rjs	setf ruby
Karsten Hopp cf9f5a
Karsten Hopp cf9f5a
" Rantfile and Rakefile is like Ruby
Karsten Hopp cf9f5a
au BufNewFile,BufRead [rR]antfile,*.rant,[rR]akefile,*.rake	setf ruby
Karsten Hopp cf9f5a
Karsten Hopp cf9f5a
" S-lang (or shader language!)
Karsten Hopp cf9f5a
au BufNewFile,BufRead *.sl			setf slang
Karsten Hopp cf9f5a
Karsten Hopp cf9f5a
" Samba config
Karsten Hopp cf9f5a
au BufNewFile,BufRead smb.conf			setf samba
Karsten Hopp cf9f5a
Karsten Hopp cf9f5a
" SAS script
Karsten Hopp cf9f5a
au BufNewFile,BufRead *.sas			setf sas
Karsten Hopp cf9f5a
Karsten Hopp cf9f5a
" Sass
Karsten Hopp cf9f5a
au BufNewFile,BufRead *.sass			setf sass
Karsten Hopp cf9f5a
Karsten Hopp cf9f5a
" Sather
Karsten Hopp cf9f5a
au BufNewFile,BufRead *.sa			setf sather
Karsten Hopp cf9f5a
Karsten Hopp cf9f5a
" Scilab
Karsten Hopp cf9f5a
au BufNewFile,BufRead *.sci,*.sce		setf scilab
Karsten Hopp cf9f5a
Karsten Hopp cf9f5a
" SD: Streaming Descriptors
Karsten Hopp cf9f5a
au BufNewFile,BufRead *.sd			setf sd
Karsten Hopp cf9f5a
Karsten Hopp cf9f5a
" SDL
Karsten Hopp cf9f5a
au BufNewFile,BufRead *.sdl,*.pr		setf sdl
Karsten Hopp cf9f5a
Karsten Hopp cf9f5a
" sed
Karsten Hopp cf9f5a
au BufNewFile,BufRead *.sed			setf sed
Karsten Hopp cf9f5a
Karsten Hopp cf9f5a
" Sieve (RFC 3028)
Karsten Hopp cf9f5a
au BufNewFile,BufRead *.siv			setf sieve
Karsten Hopp cf9f5a
Karsten Hopp cf9f5a
" Sendmail
Karsten Hopp cf9f5a
au BufNewFile,BufRead sendmail.cf		setf sm
Karsten Hopp cf9f5a
Karsten Hopp cf9f5a
" Sendmail .mc files are actually m4.  Could also be MS Message text file.
Karsten Hopp cf9f5a
au BufNewFile,BufRead *.mc			call s:McSetf()
Karsten Hopp cf9f5a
Karsten Hopp cf9f5a
func! s:McSetf()
Karsten Hopp cf9f5a
  " Rely on the file to start with a comment.
Karsten Hopp cf9f5a
  " MS message text files use ';', Sendmail files use '#' or 'dnl'
Karsten Hopp cf9f5a
  for lnum in range(1, min([line("$"), 20]))
Karsten Hopp cf9f5a
    let line = getline(lnum)
Karsten Hopp cf9f5a
    if line =~ '^\s*\(#\|dnl\)'
Karsten Hopp cf9f5a
      setf m4  " Sendmail .mc file
Karsten Hopp cf9f5a
      return
Karsten Hopp cf9f5a
    elseif line =~ '^\s*;'
Karsten Hopp cf9f5a
      setf msmessages  " MS Message text file
Karsten Hopp cf9f5a
      return
Karsten Hopp cf9f5a
    endif
Karsten Hopp cf9f5a
  endfor
Karsten Hopp cf9f5a
  setf m4  " Default: Sendmail .mc file
Karsten Hopp cf9f5a
endfunc
Karsten Hopp cf9f5a
Karsten Hopp cf9f5a
" Services
Karsten Hopp cf9f5a
au BufNewFile,BufRead /etc/services		setf services
Karsten Hopp cf9f5a
Karsten Hopp cf9f5a
" Service Location config
Karsten Hopp cf9f5a
au BufNewFile,BufRead /etc/slp.conf		setf slpconf
Karsten Hopp cf9f5a
Karsten Hopp cf9f5a
" Service Location registration
Karsten Hopp cf9f5a
au BufNewFile,BufRead /etc/slp.reg		setf slpreg
Karsten Hopp cf9f5a
Karsten Hopp cf9f5a
" Service Location SPI
Karsten Hopp cf9f5a
au BufNewFile,BufRead /etc/slp.spi		setf slpspi
Karsten Hopp cf9f5a
Karsten Hopp cf9f5a
" Setserial config
Karsten Hopp cf9f5a
au BufNewFile,BufRead /etc/serial.conf		setf setserial
Karsten Hopp cf9f5a
Karsten Hopp cf9f5a
" SGML
Karsten Hopp cf9f5a
au BufNewFile,BufRead *.sgm,*.sgml
Karsten Hopp cf9f5a
	\ if getline(1).getline(2).getline(3).getline(4).getline(5) =~? 'linuxdoc' |
Karsten Hopp cf9f5a
	\   setf sgmllnx |
Karsten Hopp cf9f5a
	\ elseif getline(1) =~ '
Karsten Hopp cf9f5a
	\   let b:docbk_type="sgml" |
Karsten Hopp cf9f5a
	\   setf docbk |
Karsten Hopp cf9f5a
	\ else |
Karsten Hopp cf9f5a
	\   setf sgml |
Karsten Hopp cf9f5a
	\ endif
Karsten Hopp cf9f5a
Karsten Hopp cf9f5a
" SGMLDECL
Karsten Hopp cf9f5a
au BufNewFile,BufRead *.decl,*.dcl,*.dec
Karsten Hopp cf9f5a
	\ if getline(1).getline(2).getline(3) =~? '^
Karsten Hopp cf9f5a
	\    setf sgmldecl |
Karsten Hopp cf9f5a
	\ endif
Karsten Hopp cf9f5a
Karsten Hopp cf9f5a
" SGML catalog file
Karsten Hopp cf9f5a
au BufNewFile,BufRead catalog			setf catalog
Karsten Hopp cf9f5a
au BufNewFile,BufRead sgml.catalog*		call s:StarSetf('catalog')
Karsten Hopp cf9f5a
Karsten Hopp cf9f5a
" Shell scripts (sh, ksh, bash, bash2, csh); Allow .profile_foo etc.
Karsten Hopp cf9f5a
" Gentoo ebuilds are actually bash scripts
Karsten Hopp cf9f5a
au BufNewFile,BufRead .bashrc*,bashrc,bash.bashrc,.bash_profile*,.bash_logout*,*.bash,*.ebuild call SetFileTypeSH("bash")
Karsten Hopp cf9f5a
au BufNewFile,BufRead .kshrc*,*.ksh call SetFileTypeSH("ksh")
Karsten Hopp cf9f5a
au BufNewFile,BufRead /etc/profile,.profile*,*.sh,*.env call SetFileTypeSH(getline(1))
Karsten Hopp cf9f5a
Karsten Hopp cf9f5a
" Also called from scripts.vim.
Karsten Hopp cf9f5a
func! SetFileTypeSH(name)
Karsten Hopp cf9f5a
  if expand("<amatch>") =~ g:ft_ignore_pat
Karsten Hopp cf9f5a
    return
Karsten Hopp cf9f5a
  endif
Karsten Hopp cf9f5a
  if a:name =~ '\<ksh\>'
Karsten Hopp cf9f5a
    let b:is_kornshell = 1
Karsten Hopp cf9f5a
    if exists("b:is_bash")
Karsten Hopp cf9f5a
      unlet b:is_bash
Karsten Hopp cf9f5a
    endif
Karsten Hopp cf9f5a
    if exists("b:is_sh")
Karsten Hopp cf9f5a
      unlet b:is_sh
Karsten Hopp cf9f5a
    endif
Karsten Hopp cf9f5a
  elseif exists("g:bash_is_sh") || a:name =~ '\<bash\>' || a:name =~ '\<bash2\>'
Karsten Hopp cf9f5a
    let b:is_bash = 1
Karsten Hopp cf9f5a
    if exists("b:is_kornshell")
Karsten Hopp cf9f5a
      unlet b:is_kornshell
Karsten Hopp cf9f5a
    endif
Karsten Hopp cf9f5a
    if exists("b:is_sh")
Karsten Hopp cf9f5a
      unlet b:is_sh
Karsten Hopp cf9f5a
    endif
Karsten Hopp cf9f5a
  elseif a:name =~ '\<sh\>'
Karsten Hopp cf9f5a
    let b:is_sh = 1
Karsten Hopp cf9f5a
    if exists("b:is_kornshell")
Karsten Hopp cf9f5a
      unlet b:is_kornshell
Karsten Hopp cf9f5a
    endif
Karsten Hopp cf9f5a
    if exists("b:is_bash")
Karsten Hopp cf9f5a
      unlet b:is_bash
Karsten Hopp cf9f5a
    endif
Karsten Hopp cf9f5a
  endif
Karsten Hopp cf9f5a
  call SetFileTypeShell("sh")
Karsten Hopp cf9f5a
endfunc
Karsten Hopp cf9f5a
Karsten Hopp cf9f5a
" For shell-like file types, check for an "exec" command hidden in a comment,
Karsten Hopp cf9f5a
" as used for Tcl.
Karsten Hopp cf9f5a
" Also called from scripts.vim, thus can't be local to this script.
Karsten Hopp cf9f5a
func! SetFileTypeShell(name)
Karsten Hopp cf9f5a
  if expand("<amatch>") =~ g:ft_ignore_pat
Karsten Hopp cf9f5a
    return
Karsten Hopp cf9f5a
  endif
Karsten Hopp cf9f5a
  let l = 2
Karsten Hopp cf9f5a
  while l < 20 && l < line("$") && getline(l) =~ '^\s*\(#\|$\)'
Karsten Hopp cf9f5a
    " Skip empty and comment lines.
Karsten Hopp cf9f5a
    let l = l + 1
Karsten Hopp cf9f5a
  endwhile
Karsten Hopp cf9f5a
  if l < line("$") && getline(l) =~ '\s*exec\s' && getline(l - 1) =~ '^\s*#.*\\$'
Karsten Hopp cf9f5a
    " Found an "exec" line after a comment with continuation
Karsten Hopp cf9f5a
    let n = substitute(getline(l),'\s*exec\s\+\([^ ]*/\)\=', '', '')
Karsten Hopp cf9f5a
    if n =~ '\
Karsten Hopp cf9f5a
      setf tcl
Karsten Hopp cf9f5a
      return
Karsten Hopp cf9f5a
    endif
Karsten Hopp cf9f5a
  endif
Karsten Hopp cf9f5a
  exe "setf " . a:name
Karsten Hopp cf9f5a
endfunc
Karsten Hopp cf9f5a
Karsten Hopp cf9f5a
" tcsh scripts
Karsten Hopp cf9f5a
au BufNewFile,BufRead .tcshrc*,*.tcsh,tcsh.tcshrc,tcsh.login	call SetFileTypeShell("tcsh")
Karsten Hopp cf9f5a
Karsten Hopp cf9f5a
" csh scripts, but might also be tcsh scripts (on some systems csh is tcsh)
Karsten Hopp cf9f5a
au BufNewFile,BufRead .login*,.cshrc*,csh.cshrc,csh.login,csh.logout,*.csh,.alias  call s:CSH()
Karsten Hopp cf9f5a
Karsten Hopp cf9f5a
func! s:CSH()
Karsten Hopp cf9f5a
  if exists("g:filetype_csh")
Karsten Hopp cf9f5a
    call SetFileTypeShell(g:filetype_csh)
Karsten Hopp cf9f5a
  elseif &shell =~ "tcsh"
Karsten Hopp cf9f5a
    call SetFileTypeShell("tcsh")
Karsten Hopp cf9f5a
  else
Karsten Hopp cf9f5a
    call SetFileTypeShell("csh")
Karsten Hopp cf9f5a
  endif
Karsten Hopp cf9f5a
endfunc
Karsten Hopp cf9f5a
Karsten Hopp cf9f5a
" Z-Shell script
Karsten Hopp cf9f5a
au BufNewFile,BufRead .zprofile,/etc/zprofile,.zfbfmarks  setf zsh
Karsten Hopp cf9f5a
au BufNewFile,BufRead .zsh*,.zlog*,.zcompdump*  call s:StarSetf('zsh')
Karsten Hopp cf9f5a
au BufNewFile,BufRead *.zsh 			setf zsh
Karsten Hopp cf9f5a
Karsten Hopp cf9f5a
" Scheme
Karsten Hopp cf9f5a
au BufNewFile,BufRead *.scm,*.ss		setf scheme
Karsten Hopp cf9f5a
Karsten Hopp cf9f5a
" Screen RC
Karsten Hopp cf9f5a
au BufNewFile,BufRead .screenrc,screenrc	setf screen
Karsten Hopp cf9f5a
Karsten Hopp cf9f5a
" Simula
Karsten Hopp cf9f5a
au BufNewFile,BufRead *.sim			setf simula
Karsten Hopp cf9f5a
Karsten Hopp cf9f5a
" SINDA
Karsten Hopp cf9f5a
au BufNewFile,BufRead *.sin,*.s85		setf sinda
Karsten Hopp cf9f5a
Karsten Hopp cf9f5a
" SiSU
Karsten Hopp cf9f5a
au BufNewFile,BufRead *.sst,*.ssm,*.ssi,*.-sst,*._sst setf sisu
Karsten Hopp cf9f5a
au BufNewFile,BufRead *.sst.meta,*.-sst.meta,*._sst.meta setf sisu
Karsten Hopp cf9f5a
Karsten Hopp cf9f5a
" SKILL
Karsten Hopp cf9f5a
au BufNewFile,BufRead *.il,*.ils,*.cdf		setf skill
Karsten Hopp cf9f5a
Karsten Hopp cf9f5a
" SLRN
Karsten Hopp cf9f5a
au BufNewFile,BufRead .slrnrc			setf slrnrc
Karsten Hopp cf9f5a
au BufNewFile,BufRead *.score			setf slrnsc
Karsten Hopp cf9f5a
Karsten Hopp cf9f5a
" Smalltalk (and TeX)
Karsten Hopp cf9f5a
au BufNewFile,BufRead *.st			setf st
Karsten Hopp cf9f5a
au BufNewFile,BufRead *.cls
Karsten Hopp cf9f5a
	\ if getline(1) =~ '^%' |
Karsten Hopp cf9f5a
	\  setf tex |
Karsten Hopp cf9f5a
	\ else |
Karsten Hopp cf9f5a
	\  setf st |
Karsten Hopp cf9f5a
	\ endif
Karsten Hopp cf9f5a
Karsten Hopp cf9f5a
" Smarty templates
Karsten Hopp cf9f5a
au BufNewFile,BufRead *.tpl			setf smarty
Karsten Hopp cf9f5a
Karsten Hopp cf9f5a
" SMIL or XML
Karsten Hopp cf9f5a
au BufNewFile,BufRead *.smil
Karsten Hopp cf9f5a
	\ if getline(1) =~ '' |
Karsten Hopp cf9f5a
	\   setf xml |
Karsten Hopp cf9f5a
	\ else |
Karsten Hopp cf9f5a
	\   setf smil |
Karsten Hopp cf9f5a
	\ endif
Karsten Hopp cf9f5a
Karsten Hopp cf9f5a
" SMIL or SNMP MIB file
Karsten Hopp cf9f5a
au BufNewFile,BufRead *.smi
Karsten Hopp cf9f5a
	\ if getline(1) =~ '\<smil\>' |
Karsten Hopp cf9f5a
	\   setf smil |
Karsten Hopp cf9f5a
	\ else |
Karsten Hopp cf9f5a
	\   setf mib |
Karsten Hopp cf9f5a
	\ endif
Karsten Hopp cf9f5a
Karsten Hopp cf9f5a
" SMITH
Karsten Hopp cf9f5a
au BufNewFile,BufRead *.smt,*.smith		setf smith
Karsten Hopp cf9f5a
Karsten Hopp cf9f5a
" Snobol4 and spitbol
Karsten Hopp cf9f5a
au BufNewFile,BufRead *.sno,*.spt		setf snobol4
Karsten Hopp cf9f5a
Karsten Hopp cf9f5a
" SNMP MIB files
Karsten Hopp cf9f5a
au BufNewFile,BufRead *.mib,*.my		setf mib
Karsten Hopp cf9f5a
Karsten Hopp cf9f5a
" Snort Configuration
Karsten Hopp cf9f5a
au BufNewFile,BufRead *.hog,snort.conf,vision.conf	setf hog
Karsten Hopp cf9f5a
au BufNewFile,BufRead *.rules			call s:FTRules()
Karsten Hopp cf9f5a
Karsten Hopp cf9f5a
let s:ft_rules_udev_rules_pattern = '^\s*\cudev_rules\s*=\s*"\([^"]\{-1,}\)/*".*'
Karsten Hopp cf9f5a
func! s:FTRules()
Karsten Hopp cf9f5a
  if expand('<amatch>:p') =~ '^/etc/udev/\%(rules\.d/\)\=.*\.rules$'
Karsten Hopp cf9f5a
    setf udevrules
Karsten Hopp cf9f5a
    return
Karsten Hopp cf9f5a
  endif
Karsten Hopp cf9f5a
  try
Karsten Hopp cf9f5a
    let config_lines = readfile('/etc/udev/udev.conf')
Karsten Hopp cf9f5a
  catch /^Vim\%((\a\+)\)\=:E484/
Karsten Hopp cf9f5a
    setf hog
Karsten Hopp cf9f5a
    return
Karsten Hopp cf9f5a
  endtry
Karsten Hopp cf9f5a
  let dir = expand('<amatch>:p:h')
Karsten Hopp cf9f5a
  for line in config_lines
Karsten Hopp cf9f5a
    if line =~ s:ft_rules_udev_rules_pattern
Karsten Hopp cf9f5a
      let udev_rules = substitute(line, s:ft_rules_udev_rules_pattern, '\1', "")
Karsten Hopp cf9f5a
      if dir == udev_rules
Karsten Hopp cf9f5a
        setf udevrules
Karsten Hopp cf9f5a
      endif
Karsten Hopp cf9f5a
      break
Karsten Hopp cf9f5a
    endif
Karsten Hopp cf9f5a
  endfor
Karsten Hopp cf9f5a
  setf hog
Karsten Hopp cf9f5a
endfunc
Karsten Hopp cf9f5a
Karsten Hopp cf9f5a
Karsten Hopp cf9f5a
" Spec (Linux RPM)
Karsten Hopp cf9f5a
au BufNewFile,BufRead *.spec			setf spec
Karsten Hopp cf9f5a
Karsten Hopp cf9f5a
" Speedup (AspenTech plant simulator)
Karsten Hopp cf9f5a
au BufNewFile,BufRead *.speedup,*.spdata,*.spd	setf spup
Karsten Hopp cf9f5a
Karsten Hopp cf9f5a
" Slice
Karsten Hopp cf9f5a
au BufNewFile,BufRead *.ice			setf slice
Karsten Hopp cf9f5a
Karsten Hopp cf9f5a
" Spice
Karsten Hopp cf9f5a
au BufNewFile,BufRead *.sp,*.spice		setf spice
Karsten Hopp cf9f5a
Karsten Hopp cf9f5a
" Spyce
Karsten Hopp cf9f5a
au BufNewFile,BufRead *.spy,*.spi		setf spyce
Karsten Hopp cf9f5a
Karsten Hopp cf9f5a
" Squid
Karsten Hopp cf9f5a
au BufNewFile,BufRead squid.conf		setf squid
Karsten Hopp cf9f5a
Karsten Hopp cf9f5a
" SQL for Oracle Designer
Karsten Hopp cf9f5a
au BufNewFile,BufRead *.tyb,*.typ,*.tyc,*.pkb,*.pks	setf sql
Karsten Hopp cf9f5a
Karsten Hopp cf9f5a
" SQL
Karsten Hopp cf9f5a
au BufNewFile,BufRead *.sql			call s:SQL()
Karsten Hopp cf9f5a
Karsten Hopp cf9f5a
func! s:SQL()
Karsten Hopp cf9f5a
  if exists("g:filetype_sql")
Karsten Hopp cf9f5a
    exe "setf " . g:filetype_sql
Karsten Hopp cf9f5a
  else
Karsten Hopp cf9f5a
    setf sql
Karsten Hopp cf9f5a
  endif
Karsten Hopp cf9f5a
endfunc
Karsten Hopp cf9f5a
Karsten Hopp cf9f5a
" SQLJ
Karsten Hopp cf9f5a
au BufNewFile,BufRead *.sqlj			setf sqlj
Karsten Hopp cf9f5a
Karsten Hopp cf9f5a
" SQR
Karsten Hopp cf9f5a
au BufNewFile,BufRead *.sqr,*.sqi		setf sqr
Karsten Hopp cf9f5a
Karsten Hopp cf9f5a
" OpenSSH configuration
Karsten Hopp cf9f5a
au BufNewFile,BufRead ssh_config,*/.ssh/config	setf sshconfig
Karsten Hopp cf9f5a
Karsten Hopp cf9f5a
" OpenSSH server configuration
Karsten Hopp cf9f5a
au BufNewFile,BufRead sshd_config		setf sshdconfig
Karsten Hopp cf9f5a
Karsten Hopp cf9f5a
" Stata
Karsten Hopp cf9f5a
au BufNewFile,BufRead *.ado,*.class,*.do,*.imata,*.mata   setf stata
Karsten Hopp cf9f5a
Karsten Hopp cf9f5a
" SMCL
Karsten Hopp cf9f5a
au BufNewFile,BufRead *.hlp,*.ihlp,*.smcl	setf smcl
Karsten Hopp cf9f5a
Karsten Hopp cf9f5a
" Stored Procedures
Karsten Hopp cf9f5a
au BufNewFile,BufRead *.stp			setf stp
Karsten Hopp cf9f5a
Karsten Hopp cf9f5a
" Standard ML
Karsten Hopp cf9f5a
au BufNewFile,BufRead *.sml			setf sml
Karsten Hopp cf9f5a
Karsten Hopp cf9f5a
" Sratus VOS command macro
Karsten Hopp cf9f5a
au BufNewFile,BufRead *.cm			setf voscm
Karsten Hopp cf9f5a
Karsten Hopp cf9f5a
" Sysctl
Karsten Hopp cf9f5a
au BufNewFile,BufRead /etc/sysctl.conf		setf sysctl
Karsten Hopp cf9f5a
Karsten Hopp cf9f5a
" Sudoers
Karsten Hopp cf9f5a
au BufNewFile,BufRead /etc/sudoers,sudoers.tmp	setf sudoers
Karsten Hopp cf9f5a
Karsten Hopp cf9f5a
" If the file has an extension of 't' and is in a directory 't' then it is
Karsten Hopp cf9f5a
" almost certainly a Perl test file.
Karsten Hopp cf9f5a
" If the first line starts with '#' and contains 'perl' it's probably a Perl
Karsten Hopp cf9f5a
" file.
Karsten Hopp cf9f5a
" (Slow test) If a file contains a 'use' statement then it is almost certainly
Karsten Hopp cf9f5a
" a Perl file.
Karsten Hopp cf9f5a
func! s:FTperl()
Karsten Hopp cf9f5a
  if expand("%:e") == 't' && expand("%:p:h:t") == 't'
Karsten Hopp cf9f5a
    setf perl
Karsten Hopp cf9f5a
    return 1
Karsten Hopp cf9f5a
  endif
Karsten Hopp cf9f5a
  if getline(1)[0] == '#' && getline(1) =~ 'perl'
Karsten Hopp cf9f5a
    setf perl
Karsten Hopp cf9f5a
    return 1
Karsten Hopp cf9f5a
  endif
Karsten Hopp cf9f5a
  if search('^use\s\s*\k', 'nc', 30)
Karsten Hopp cf9f5a
    setf perl
Karsten Hopp cf9f5a
    return 1
Karsten Hopp cf9f5a
  endif
Karsten Hopp cf9f5a
  return 0
Karsten Hopp cf9f5a
endfunc
Karsten Hopp cf9f5a
Karsten Hopp cf9f5a
" Tads (or Nroff or Perl test file)
Karsten Hopp cf9f5a
au BufNewFile,BufRead *.t
Karsten Hopp cf9f5a
	\ if !s:FTnroff() && !s:FTperl() | setf tads | endif
Karsten Hopp cf9f5a
Karsten Hopp cf9f5a
" Tags
Karsten Hopp cf9f5a
au BufNewFile,BufRead tags			setf tags
Karsten Hopp cf9f5a
Karsten Hopp cf9f5a
" TAK
Karsten Hopp cf9f5a
au BufNewFile,BufRead *.tak			setf tak
Karsten Hopp cf9f5a
Karsten Hopp cf9f5a
" Tcl (JACL too)
Karsten Hopp cf9f5a
au BufNewFile,BufRead *.tcl,*.tk,*.itcl,*.itk,*.jacl	setf tcl
Karsten Hopp cf9f5a
Karsten Hopp cf9f5a
" TealInfo
Karsten Hopp cf9f5a
au BufNewFile,BufRead *.tli			setf tli
Karsten Hopp cf9f5a
Karsten Hopp cf9f5a
" Telix Salt
Karsten Hopp cf9f5a
au BufNewFile,BufRead *.slt			setf tsalt
Karsten Hopp cf9f5a
Karsten Hopp cf9f5a
" Terminfo
Karsten Hopp cf9f5a
au BufNewFile,BufRead *.ti			setf terminfo
Karsten Hopp cf9f5a
Karsten Hopp cf9f5a
" TeX
Karsten Hopp cf9f5a
au BufNewFile,BufRead *.latex,*.sty,*.dtx,*.ltx,*.bbl	setf tex
Karsten Hopp cf9f5a
au BufNewFile,BufRead *.tex			call s:FTtex()
Karsten Hopp cf9f5a
Karsten Hopp cf9f5a
" Choose context, plaintex, or tex (LaTeX) based on these rules:
Karsten Hopp cf9f5a
" 1. Check the first line of the file for "%&<format>".
Karsten Hopp cf9f5a
" 2. Check the first 1000 non-comment lines for LaTeX or ConTeXt keywords.
Karsten Hopp cf9f5a
" 3. Default to "latex" or to g:tex_flavor, can be set in user's vimrc.
Karsten Hopp cf9f5a
func! s:FTtex()
Karsten Hopp cf9f5a
  let firstline = getline(1)
Karsten Hopp cf9f5a
  if firstline =~ '^%&\s*\a\+'
Karsten Hopp cf9f5a
    let format = tolower(matchstr(firstline, '\a\+'))
Karsten Hopp cf9f5a
    let format = substitute(format, 'pdf', '', '')
Karsten Hopp cf9f5a
    if format == 'tex'
Karsten Hopp cf9f5a
      let format = 'plain'
Karsten Hopp cf9f5a
    endif
Karsten Hopp cf9f5a
  else
Karsten Hopp cf9f5a
    " Default value, may be changed later:
Karsten Hopp cf9f5a
    let format = exists("g:tex_flavor") ? g:tex_flavor : 'plain'
Karsten Hopp cf9f5a
    " Save position, go to the top of the file, find first non-comment line.
Karsten Hopp cf9f5a
    let save_cursor = getpos('.')
Karsten Hopp cf9f5a
    call cursor(1,1)
Karsten Hopp cf9f5a
    let firstNC = search('^\s*[^[:space:]%]', 'c', 1000)
Karsten Hopp cf9f5a
    if firstNC " Check the next thousand lines for a LaTeX or ConTeXt keyword.
Karsten Hopp cf9f5a
      let lpat = 'documentclass\>\|usepackage\>\|begin{\|newcommand\>\|renewcommand\>'
Karsten Hopp cf9f5a
      let cpat = 'start\a\+\|setup\a\+\|usemodule\|enablemode\|enableregime\|setvariables\|useencoding\|usesymbols\|stelle\a\+\|verwende\a\+\|stel\a\+\|gebruik\a\+\|usa\a\+\|imposta\a\+\|regle\a\+\|utilisemodule\>'
Karsten Hopp cf9f5a
      let kwline = search('^\s*\\\%(' . lpat . '\)\|^\s*\\\(' . cpat . '\)',
Karsten Hopp cf9f5a
			      \ 'cnp', firstNC + 1000)
Karsten Hopp cf9f5a
      if kwline == 1	" lpat matched
Karsten Hopp cf9f5a
	let format = 'latex'
Karsten Hopp cf9f5a
      elseif kwline == 2	" cpat matched
Karsten Hopp cf9f5a
	let format = 'context'
Karsten Hopp cf9f5a
      endif		" If neither matched, keep default set above.
Karsten Hopp cf9f5a
      " let lline = search('^\s*\\\%(' . lpat . '\)', 'cn', firstNC + 1000)
Karsten Hopp cf9f5a
      " let cline = search('^\s*\\\%(' . cpat . '\)', 'cn', firstNC + 1000)
Karsten Hopp cf9f5a
      " if cline > 0
Karsten Hopp cf9f5a
      "   let format = 'context'
Karsten Hopp cf9f5a
      " endif
Karsten Hopp cf9f5a
      " if lline > 0 && (cline == 0 || cline > lline)
Karsten Hopp cf9f5a
      "   let format = 'tex'
Karsten Hopp cf9f5a
      " endif
Karsten Hopp cf9f5a
    endif " firstNC
Karsten Hopp cf9f5a
    call setpos('.', save_cursor)
Karsten Hopp cf9f5a
  endif " firstline =~ '^%&\s*\a\+'
Karsten Hopp cf9f5a
Karsten Hopp cf9f5a
  " Translation from formats to file types.  TODO:  add AMSTeX, RevTex, others?
Karsten Hopp cf9f5a
  if format == 'plain'
Karsten Hopp cf9f5a
    setf plaintex
Karsten Hopp cf9f5a
  elseif format == 'context'
Karsten Hopp cf9f5a
    setf context
Karsten Hopp cf9f5a
  else " probably LaTeX
Karsten Hopp cf9f5a
    setf tex
Karsten Hopp cf9f5a
  endif
Karsten Hopp cf9f5a
  return
Karsten Hopp cf9f5a
endfunc
Karsten Hopp cf9f5a
Karsten Hopp cf9f5a
" ConTeXt
Karsten Hopp cf9f5a
au BufNewFile,BufRead tex/context/*/*.tex,*.mkii,*.mkiv   setf context
Karsten Hopp cf9f5a
Karsten Hopp cf9f5a
" Texinfo
Karsten Hopp cf9f5a
au BufNewFile,BufRead *.texinfo,*.texi,*.txi	setf texinfo
Karsten Hopp cf9f5a
Karsten Hopp cf9f5a
" TeX configuration
Karsten Hopp cf9f5a
au BufNewFile,BufRead texmf.cnf			setf texmf
Karsten Hopp cf9f5a
Karsten Hopp cf9f5a
" Tidy config
Karsten Hopp cf9f5a
au BufNewFile,BufRead .tidyrc,tidyrc		setf tidy
Karsten Hopp cf9f5a
Karsten Hopp cf9f5a
" TF mud client
Karsten Hopp cf9f5a
au BufNewFile,BufRead *.tf,.tfrc,tfrc		setf tf
Karsten Hopp cf9f5a
Karsten Hopp cf9f5a
" TPP - Text Presentation Program
Karsten Hopp cf9f5a
au BufNewFile,BufReadPost *.tpp			setf tpp
Karsten Hopp cf9f5a
Karsten Hopp cf9f5a
" Trustees
Karsten Hopp cf9f5a
au BufNewFile,BufRead trustees.conf		setf trustees
Karsten Hopp cf9f5a
Karsten Hopp cf9f5a
" TSS - Geometry
Karsten Hopp cf9f5a
au BufNewFile,BufReadPost *.tssgm		setf tssgm
Karsten Hopp cf9f5a
Karsten Hopp cf9f5a
" TSS - Optics
Karsten Hopp cf9f5a
au BufNewFile,BufReadPost *.tssop		setf tssop
Karsten Hopp cf9f5a
Karsten Hopp cf9f5a
" TSS - Command Line (temporary)
Karsten Hopp cf9f5a
au BufNewFile,BufReadPost *.tsscl		setf tsscl
Karsten Hopp cf9f5a
Karsten Hopp cf9f5a
" Motif UIT/UIL files
Karsten Hopp cf9f5a
au BufNewFile,BufRead *.uit,*.uil		setf uil
Karsten Hopp cf9f5a
Karsten Hopp cf9f5a
" Udev conf
Karsten Hopp cf9f5a
au BufNewFile,BufRead /etc/udev/udev.conf	setf udevconf
Karsten Hopp cf9f5a
Karsten Hopp cf9f5a
" Udev permissions
Karsten Hopp cf9f5a
au BufNewFile,BufRead /etc/udev/permissions.d/*.permissions setf udevperm
Karsten Hopp cf9f5a
"
Karsten Hopp cf9f5a
" Udev symlinks config
Karsten Hopp cf9f5a
au BufNewFile,BufRead /etc/udev/cdsymlinks.conf	setf sh
Karsten Hopp cf9f5a
Karsten Hopp cf9f5a
" UnrealScript
Karsten Hopp cf9f5a
au BufNewFile,BufRead *.uc			setf uc
Karsten Hopp cf9f5a
Karsten Hopp cf9f5a
" Updatedb
Karsten Hopp cf9f5a
au BufNewFile,BufRead /etc/updatedb.conf	setf updatedb
Karsten Hopp cf9f5a
Karsten Hopp cf9f5a
" Vera
Karsten Hopp cf9f5a
au BufNewFile,BufRead *.vr,*.vri,*.vrh		setf vera
Karsten Hopp cf9f5a
Karsten Hopp cf9f5a
" Verilog HDL
Karsten Hopp cf9f5a
au BufNewFile,BufRead *.v			setf verilog
Karsten Hopp cf9f5a
Karsten Hopp cf9f5a
" Verilog-AMS HDL
Karsten Hopp cf9f5a
au BufNewFile,BufRead *.va,*.vams		setf verilogams
Karsten Hopp cf9f5a
Karsten Hopp cf9f5a
" VHDL
Karsten Hopp cf9f5a
au BufNewFile,BufRead *.hdl,*.vhd,*.vhdl,*.vbe,*.vst  setf vhdl
Karsten Hopp cf9f5a
au BufNewFile,BufRead *.vhdl_[0-9]*		call s:StarSetf('vhdl')
Karsten Hopp cf9f5a
Karsten Hopp cf9f5a
" Vim script
Karsten Hopp cf9f5a
au BufNewFile,BufRead *.vim,*.vba,.exrc,_exrc	setf vim
Karsten Hopp cf9f5a
Karsten Hopp cf9f5a
" Viminfo file
Karsten Hopp cf9f5a
au BufNewFile,BufRead .viminfo,_viminfo		setf viminfo
Karsten Hopp cf9f5a
Karsten Hopp cf9f5a
" Virata Config Script File or Drupal module
Karsten Hopp cf9f5a
au BufRead,BufNewFile *.hw,*.module,*.pkg
Karsten Hopp cf9f5a
	\ if getline(1) =~ '
Karsten Hopp cf9f5a
	\   setf php |
Karsten Hopp cf9f5a
	\ else |
Karsten Hopp cf9f5a
	\   setf virata |
Karsten Hopp cf9f5a
	\ endif
Karsten Hopp cf9f5a
Karsten Hopp cf9f5a
" Visual Basic (also uses *.bas) or FORM
Karsten Hopp cf9f5a
au BufNewFile,BufRead *.frm			call s:FTVB("form")
Karsten Hopp cf9f5a
Karsten Hopp cf9f5a
" SaxBasic is close to Visual Basic
Karsten Hopp cf9f5a
au BufNewFile,BufRead *.sba			setf vb
Karsten Hopp cf9f5a
Karsten Hopp cf9f5a
" Vgrindefs file
Karsten Hopp cf9f5a
au BufNewFile,BufRead vgrindefs			setf vgrindefs
Karsten Hopp cf9f5a
Karsten Hopp cf9f5a
" VRML V1.0c
Karsten Hopp cf9f5a
au BufNewFile,BufRead *.wrl			setf vrml
Karsten Hopp cf9f5a
Karsten Hopp cf9f5a
" Webmacro
Karsten Hopp cf9f5a
au BufNewFile,BufRead *.wm			setf webmacro
Karsten Hopp cf9f5a
Karsten Hopp cf9f5a
" Wget config
Karsten Hopp cf9f5a
au BufNewFile,BufRead .wgetrc,wgetrc		setf wget
Karsten Hopp cf9f5a
Karsten Hopp cf9f5a
" Website MetaLanguage
Karsten Hopp cf9f5a
au BufNewFile,BufRead *.wml			setf wml
Karsten Hopp cf9f5a
Karsten Hopp cf9f5a
" Winbatch
Karsten Hopp cf9f5a
au BufNewFile,BufRead *.wbt			setf winbatch
Karsten Hopp cf9f5a
Karsten Hopp cf9f5a
" WSML
Karsten Hopp cf9f5a
au BufNewFile,BufRead *.wsml			setf wsml
Karsten Hopp cf9f5a
Karsten Hopp cf9f5a
" WvDial
Karsten Hopp cf9f5a
au BufNewFile,BufRead wvdial.conf,.wvdialrc	setf wvdial
Karsten Hopp cf9f5a
Karsten Hopp cf9f5a
" CVS RC file
Karsten Hopp cf9f5a
au BufNewFile,BufRead .cvsrc			setf cvsrc
Karsten Hopp cf9f5a
Karsten Hopp cf9f5a
" CVS commit file
Karsten Hopp cf9f5a
au BufNewFile,BufRead cvs\d\+			setf cvs
Karsten Hopp cf9f5a
Karsten Hopp cf9f5a
" WEB (*.web is also used for Winbatch: Guess, based on expecting "%" comment
Karsten Hopp cf9f5a
" lines in a WEB file).
Karsten Hopp cf9f5a
au BufNewFile,BufRead *.web
Karsten Hopp cf9f5a
	\ if getline(1)[0].getline(2)[0].getline(3)[0].getline(4)[0].getline(5)[0] =~ "%" |
Karsten Hopp cf9f5a
	\   setf web |
Karsten Hopp cf9f5a
	\ else |
Karsten Hopp cf9f5a
	\   setf winbatch |
Karsten Hopp cf9f5a
	\ endif
Karsten Hopp cf9f5a
Karsten Hopp cf9f5a
" Windows Scripting Host and Windows Script Component
Karsten Hopp cf9f5a
au BufNewFile,BufRead *.ws[fc]			setf wsh
Karsten Hopp cf9f5a
Karsten Hopp cf9f5a
" XHTML
Karsten Hopp cf9f5a
au BufNewFile,BufRead *.xhtml,*.xht		setf xhtml
Karsten Hopp cf9f5a
Karsten Hopp cf9f5a
" X Pixmap (dynamically sets colors, use BufEnter to make it work better)
Karsten Hopp cf9f5a
au BufEnter *.xpm
Karsten Hopp cf9f5a
	\ if getline(1) =~ "XPM2" |
Karsten Hopp cf9f5a
	\   setf xpm2 |
Karsten Hopp cf9f5a
	\ else |
Karsten Hopp cf9f5a
	\   setf xpm |
Karsten Hopp cf9f5a
	\ endif
Karsten Hopp cf9f5a
au BufEnter *.xpm2				setf xpm2
Karsten Hopp cf9f5a
Karsten Hopp cf9f5a
" XFree86 config
Karsten Hopp cf9f5a
au BufNewFile,BufRead XF86Config
Karsten Hopp cf9f5a
	\ if getline(1) =~ '\<XConfigurator\>' |
Karsten Hopp cf9f5a
	\   let b:xf86c_xfree86_version = 3 |
Karsten Hopp cf9f5a
	\ endif |
Karsten Hopp cf9f5a
	\ setf xf86conf
Karsten Hopp cf9f5a
Karsten Hopp cf9f5a
" Xorg config
Karsten Hopp cf9f5a
au BufNewFile,BufRead xorg.conf,xorg.conf-4	let b:xf86c_xfree86_version = 4 | setf xf86conf
Karsten Hopp cf9f5a
Karsten Hopp cf9f5a
" Xinetd conf
Karsten Hopp cf9f5a
au BufNewFile,BufRead /etc/xinetd.conf		setf xinetd
Karsten Hopp cf9f5a
Karsten Hopp cf9f5a
" XS Perl extension interface language
Karsten Hopp cf9f5a
au BufNewFile,BufRead *.xs			setf xs
Karsten Hopp cf9f5a
Karsten Hopp cf9f5a
" X resources file
Karsten Hopp cf9f5a
au BufNewFile,BufRead .Xdefaults,.Xpdefaults,.Xresources,xdm-config,*.ad setf xdefaults
Karsten Hopp cf9f5a
Karsten Hopp cf9f5a
" Xmath
Karsten Hopp cf9f5a
au BufNewFile,BufRead *.msc,*.msf		setf xmath
Karsten Hopp cf9f5a
au BufNewFile,BufRead *.ms
Karsten Hopp cf9f5a
	\ if !s:FTnroff() | setf xmath | endif
Karsten Hopp cf9f5a
Karsten Hopp cf9f5a
" XML  specific variants: docbk and xbl
Karsten Hopp cf9f5a
au BufNewFile,BufRead *.xml			call s:FTxml()
Karsten Hopp cf9f5a
Karsten Hopp cf9f5a
func! s:FTxml()
Karsten Hopp cf9f5a
  let n = 1
Karsten Hopp cf9f5a
  while n < 100 && n < line("$")
Karsten Hopp cf9f5a
    let line = getline(n)
Karsten Hopp cf9f5a
    if line =~ '
Karsten Hopp cf9f5a
      let b:docbk_type = "xml"
Karsten Hopp cf9f5a
      setf docbk
Karsten Hopp cf9f5a
      return
Karsten Hopp cf9f5a
    endif
Karsten Hopp cf9f5a
    if line =~ 'xmlns:xbl="http://www.mozilla.org/xbl"'
Karsten Hopp cf9f5a
      setf xbl
Karsten Hopp cf9f5a
      return
Karsten Hopp cf9f5a
    endif
Karsten Hopp cf9f5a
    let n += 1
Karsten Hopp cf9f5a
  endwhile
Karsten Hopp cf9f5a
  setf xml
Karsten Hopp cf9f5a
endfunc
Karsten Hopp cf9f5a
Karsten Hopp cf9f5a
" XMI (holding UML models) is also XML
Karsten Hopp cf9f5a
au BufNewFile,BufRead *.xmi			setf xml
Karsten Hopp cf9f5a
Karsten Hopp cf9f5a
" CSPROJ files are Visual Studio.NET's XML-based project config files
Karsten Hopp cf9f5a
au BufNewFile,BufRead *.csproj,*.csproj.user	setf xml
Karsten Hopp cf9f5a
Karsten Hopp cf9f5a
" Qt Linguist translation source and Qt User Interface Files are XML
Karsten Hopp cf9f5a
au BufNewFile,BufRead *.ts,*.ui			setf xml
Karsten Hopp cf9f5a
Karsten Hopp cf9f5a
" TPM's are RDF-based descriptions of TeX packages (Nikolai Weibull)
Karsten Hopp cf9f5a
au BufNewFile,BufRead *.tpm			setf xml
Karsten Hopp cf9f5a
Karsten Hopp cf9f5a
" Xdg menus
Karsten Hopp cf9f5a
au BufNewFile,BufRead /etc/xdg/menus/*.menu	setf xml
Karsten Hopp cf9f5a
Karsten Hopp cf9f5a
" ATI graphics driver configuration
Karsten Hopp cf9f5a
au BufNewFile,BufRead fglrxrc			setf xml
Karsten Hopp cf9f5a
Karsten Hopp cf9f5a
" XLIFF (XML Localisation Interchange File Format) is also XML
Karsten Hopp cf9f5a
au BufNewFile,BufRead *.xlf			setf xml
Karsten Hopp cf9f5a
au BufNewFile,BufRead *.xliff			setf xml
Karsten Hopp cf9f5a
Karsten Hopp cf9f5a
" X11 xmodmap (also see below)
Karsten Hopp cf9f5a
au BufNewFile,BufRead *Xmodmap			setf xmodmap
Karsten Hopp cf9f5a
Karsten Hopp cf9f5a
" Xquery
Karsten Hopp cf9f5a
au BufNewFile,BufRead *.xq,*.xql,*.xqm,*.xquery,*.xqy	setf xquery
Karsten Hopp cf9f5a
Karsten Hopp cf9f5a
" XSD
Karsten Hopp cf9f5a
au BufNewFile,BufRead *.xsd			setf xsd
Karsten Hopp cf9f5a
Karsten Hopp cf9f5a
" Xslt
Karsten Hopp cf9f5a
au BufNewFile,BufRead *.xsl,*.xslt		setf xslt
Karsten Hopp cf9f5a
Karsten Hopp cf9f5a
" Yacc
Karsten Hopp cf9f5a
au BufNewFile,BufRead *.yy			setf yacc
Karsten Hopp cf9f5a
Karsten Hopp cf9f5a
" Yacc or racc
Karsten Hopp cf9f5a
au BufNewFile,BufRead *.y			call s:FTy()
Karsten Hopp cf9f5a
Karsten Hopp cf9f5a
func! s:FTy()
Karsten Hopp cf9f5a
  let n = 1
Karsten Hopp cf9f5a
  while n < 100 && n < line("$")
Karsten Hopp cf9f5a
    let line = getline(n)
Karsten Hopp cf9f5a
    if line =~ '^\s*%'
Karsten Hopp cf9f5a
      setf yacc
Karsten Hopp cf9f5a
      return
Karsten Hopp cf9f5a
    endif
Karsten Hopp cf9f5a
    if getline(n) =~ '^\s*\(#\|class\>\)' && getline(n) !~ '^\s*#\s*include'
Karsten Hopp cf9f5a
      setf racc
Karsten Hopp cf9f5a
      return
Karsten Hopp cf9f5a
    endif
Karsten Hopp cf9f5a
    let n = n + 1
Karsten Hopp cf9f5a
  endwhile
Karsten Hopp cf9f5a
  setf yacc
Karsten Hopp cf9f5a
endfunc
Karsten Hopp cf9f5a
Karsten Hopp cf9f5a
Karsten Hopp cf9f5a
" Yaml
Karsten Hopp cf9f5a
au BufNewFile,BufRead *.yaml,*.yml		setf yaml
Karsten Hopp cf9f5a
Karsten Hopp cf9f5a
" Zope
Karsten Hopp cf9f5a
"   dtml (zope dynamic template markup language), pt (zope page template),
Karsten Hopp cf9f5a
"   cpt (zope form controller page template)
Karsten Hopp cf9f5a
au BufNewFile,BufRead *.dtml,*.pt,*.cpt		call s:FThtml()
Karsten Hopp cf9f5a
"   zsql (zope sql method)
Karsten Hopp cf9f5a
au BufNewFile,BufRead *.zsql			call s:SQL()
Karsten Hopp cf9f5a
Karsten Hopp cf9f5a
" Z80 assembler asz80
Karsten Hopp cf9f5a
au BufNewFile,BufRead *.z8a			setf z8a
Karsten Hopp cf9f5a
Karsten Hopp cf9f5a
augroup END
Karsten Hopp cf9f5a
Karsten Hopp cf9f5a
Karsten Hopp cf9f5a
" Source the user-specified filetype file, for backwards compatibility with
Karsten Hopp cf9f5a
" Vim 5.x.
Karsten Hopp cf9f5a
if exists("myfiletypefile") && filereadable(expand(myfiletypefile))
Karsten Hopp cf9f5a
  execute "source " . myfiletypefile
Karsten Hopp cf9f5a
endif
Karsten Hopp cf9f5a
Karsten Hopp cf9f5a
Karsten Hopp cf9f5a
" Check for "*" after loading myfiletypefile, so that scripts.vim is only used
Karsten Hopp cf9f5a
" when there are no matching file name extensions.
Karsten Hopp cf9f5a
" Don't do this for compressed files.
Karsten Hopp cf9f5a
augroup filetypedetect
Karsten Hopp cf9f5a
au BufNewFile,BufRead *
Karsten Hopp cf9f5a
	\ if !did_filetype() && expand("<amatch>") !~ g:ft_ignore_pat
Karsten Hopp cf9f5a
	\ | runtime! scripts.vim | endif
Karsten Hopp cf9f5a
au StdinReadPost * if !did_filetype() | runtime! scripts.vim | endif
Karsten Hopp cf9f5a
Karsten Hopp cf9f5a
Karsten Hopp cf9f5a
" Extra checks for when no filetype has been detected now.  Mostly used for
Karsten Hopp cf9f5a
" patterns that end in "*".  E.g., "zsh*" matches "zsh.vim", but that's a Vim
Karsten Hopp cf9f5a
" script file.
Karsten Hopp cf9f5a
" Most of these should call s:StarSetf() to avoid names ending in .gz and the
Karsten Hopp cf9f5a
" like are used.
Karsten Hopp cf9f5a
Karsten Hopp cf9f5a
" More Apache files.
Karsten Hopp cf9f5a
au BufNewFile,BufRead /etc/apache2/conf.*/*,/etc/apache2/sites-*/*,/etc/apache2/mods-*/*		call s:StarSetf('apache')
Karsten Hopp cf9f5a
Karsten Hopp cf9f5a
" Asterisk config file
Karsten Hopp cf9f5a
au BufNewFile,BufRead *asterisk/*.conf*		call s:StarSetf('asterisk')
Karsten Hopp cf9f5a
au BufNewFile,BufRead *asterisk*/*voicemail.conf* call s:StarSetf('asteriskvm')
Karsten Hopp cf9f5a
Karsten Hopp cf9f5a
" Bazaar version control
Karsten Hopp cf9f5a
au BufNewFile,BufRead bzr_log.*			setf bzr
Karsten Hopp cf9f5a
Karsten Hopp cf9f5a
" BIND zone
Karsten Hopp cf9f5a
au BufNewFile,BufRead */named/db.*,*/bind/db.*	call s:StarSetf('bindzone')
Karsten Hopp cf9f5a
Karsten Hopp cf9f5a
" Changelog
Karsten Hopp cf9f5a
au BufNewFile,BufRead [cC]hange[lL]og*
Karsten Hopp cf9f5a
	\ if getline(1) =~ '; urgency='
Karsten Hopp cf9f5a
	\|  call s:StarSetf('debchangelog')
Karsten Hopp cf9f5a
	\|else
Karsten Hopp cf9f5a
	\|  call s:StarSetf('changelog')
Karsten Hopp cf9f5a
	\|endif
Karsten Hopp cf9f5a
Karsten Hopp cf9f5a
" Crontab
Karsten Hopp cf9f5a
au BufNewFile,BufRead crontab,crontab.*,/etc/cron.d/*		call s:StarSetf('crontab')
Karsten Hopp cf9f5a
Karsten Hopp cf9f5a
" Debian Sources.list
Karsten Hopp cf9f5a
au BufNewFile,BufRead /etc/apt/sources.list.d/*	call s:StarSetf('debsources')
Karsten Hopp cf9f5a
Karsten Hopp cf9f5a
" Dracula
Karsten Hopp cf9f5a
au BufNewFile,BufRead drac.*			call s:StarSetf('dracula')
Karsten Hopp cf9f5a
Karsten Hopp cf9f5a
" Fvwm
Karsten Hopp cf9f5a
au BufNewFile,BufRead */.fvwm/*			call s:StarSetf('fvwm')
Karsten Hopp cf9f5a
au BufNewFile,BufRead *fvwmrc*,*fvwm95*.hook
Karsten Hopp cf9f5a
	\ let b:fvwm_version = 1 | call s:StarSetf('fvwm')
Karsten Hopp cf9f5a
au BufNewFile,BufRead *fvwm2rc*
Karsten Hopp cf9f5a
	\ if expand("<afile>:e") == "m4"
Karsten Hopp cf9f5a
	\|  call s:StarSetf('fvwm2m4')
Karsten Hopp cf9f5a
	\|else
Karsten Hopp cf9f5a
	\|  let b:fvwm_version = 2 | call s:StarSetf('fvwm')
Karsten Hopp cf9f5a
	\|endif
Karsten Hopp cf9f5a
Karsten Hopp cf9f5a
" GTK RC
Karsten Hopp cf9f5a
au BufNewFile,BufRead .gtkrc*,gtkrc*		call s:StarSetf('gtkrc')
Karsten Hopp cf9f5a
Karsten Hopp cf9f5a
" Jam
Karsten Hopp cf9f5a
au BufNewFile,BufRead Prl*.*,JAM*.*		call s:StarSetf('jam')
Karsten Hopp cf9f5a
Karsten Hopp cf9f5a
" Jargon
Karsten Hopp cf9f5a
au! BufNewFile,BufRead *jarg*
Karsten Hopp cf9f5a
	\ if getline(1).getline(2).getline(3).getline(4).getline(5) =~? 'THIS IS THE JARGON FILE'
Karsten Hopp cf9f5a
	\|  call s:StarSetf('jargon')
Karsten Hopp cf9f5a
	\|endif
Karsten Hopp cf9f5a
Karsten Hopp cf9f5a
" Kconfig
Karsten Hopp cf9f5a
au BufNewFile,BufRead Kconfig.*			call s:StarSetf('kconfig')
Karsten Hopp cf9f5a
Karsten Hopp cf9f5a
" Makefile
Karsten Hopp cf9f5a
au BufNewFile,BufRead [mM]akefile*		call s:StarSetf('make')
Karsten Hopp cf9f5a
Karsten Hopp cf9f5a
" Ruby Makefile
Karsten Hopp cf9f5a
au BufNewFile,BufRead [rR]akefile*		call s:StarSetf('ruby')
Karsten Hopp cf9f5a
Karsten Hopp cf9f5a
" Mail (also matches muttrc.vim, so this is below the other checks)
Karsten Hopp cf9f5a
au BufNewFile,BufRead mutt[[:alnum:]._-]\{6\}	setf mail
Karsten Hopp cf9f5a
Karsten Hopp cf9f5a
" Modconf
Karsten Hopp cf9f5a
au BufNewFile,BufRead /etc/modprobe.*		call s:StarSetf('modconf')
Karsten Hopp cf9f5a
Karsten Hopp cf9f5a
" Mutt setup file
Karsten Hopp cf9f5a
au BufNewFile,BufRead .mutt{ng,}rc*,*/.mutt{ng,}/mutt{ng,}rc*	call s:StarSetf('muttrc')
Karsten Hopp cf9f5a
au BufNewFile,BufRead mutt{ng,}rc*,Mutt{ng,}rc*		call s:StarSetf('muttrc')
Karsten Hopp cf9f5a
Karsten Hopp cf9f5a
" Nroff macros
Karsten Hopp cf9f5a
au BufNewFile,BufRead tmac.*			call s:StarSetf('nroff')
Karsten Hopp cf9f5a
Karsten Hopp cf9f5a
" Pam conf
Karsten Hopp cf9f5a
au BufNewFile,BufRead /etc/pam.d/*		call s:StarSetf('pamconf')
Karsten Hopp cf9f5a
Karsten Hopp cf9f5a
" Printcap and Termcap
Karsten Hopp cf9f5a
au BufNewFile,BufRead *printcap*
Karsten Hopp cf9f5a
	\ if !did_filetype()
Karsten Hopp cf9f5a
	\|  let b:ptcap_type = "print" | call s:StarSetf('ptcap')
Karsten Hopp cf9f5a
	\|endif
Karsten Hopp cf9f5a
au BufNewFile,BufRead *termcap*
Karsten Hopp cf9f5a
	\ if !did_filetype()
Karsten Hopp cf9f5a
	\|  let b:ptcap_type = "term" | call s:StarSetf('ptcap')
Karsten Hopp cf9f5a
	\|endif
Karsten Hopp cf9f5a
Karsten Hopp cf9f5a
" Vim script
Karsten Hopp cf9f5a
au BufNewFile,BufRead *vimrc*			call s:StarSetf('vim')
Karsten Hopp cf9f5a
Karsten Hopp cf9f5a
" Subversion commit file
Karsten Hopp cf9f5a
au BufNewFile,BufRead svn-commit*.tmp		setf svn
Karsten Hopp cf9f5a
Karsten Hopp cf9f5a
" X resources file
Karsten Hopp cf9f5a
au BufNewFile,BufRead Xresources*,*/app-defaults/*,*/Xresources/* call s:StarSetf('xdefaults')
Karsten Hopp cf9f5a
Karsten Hopp cf9f5a
" XFree86 config
Karsten Hopp cf9f5a
au BufNewFile,BufRead XF86Config-4*
Karsten Hopp cf9f5a
	\ let b:xf86c_xfree86_version = 4 | call s:StarSetf('xf86conf')
Karsten Hopp cf9f5a
au BufNewFile,BufRead XF86Config*
Karsten Hopp cf9f5a
	\ if getline(1) =~ '\<XConfigurator\>'
Karsten Hopp cf9f5a
	\|  let b:xf86c_xfree86_version = 3
Karsten Hopp cf9f5a
	\|endif
Karsten Hopp cf9f5a
	\|call s:StarSetf('xf86conf')
Karsten Hopp cf9f5a
Karsten Hopp cf9f5a
" X11 xmodmap
Karsten Hopp cf9f5a
au BufNewFile,BufRead *xmodmap*			call s:StarSetf('xmodmap')
Karsten Hopp cf9f5a
Karsten Hopp cf9f5a
" Xinetd conf
Karsten Hopp cf9f5a
au BufNewFile,BufRead /etc/xinetd.d/*		call s:StarSetf('xinetd')
Karsten Hopp cf9f5a
Karsten Hopp cf9f5a
" Z-Shell script
Karsten Hopp cf9f5a
au BufNewFile,BufRead zsh*,zlog*		call s:StarSetf('zsh')
Karsten Hopp cf9f5a
Karsten Hopp cf9f5a
Karsten Hopp cf9f5a
" Generic configuration file (check this last, it's just guessing!)
Karsten Hopp cf9f5a
au BufNewFile,BufRead,StdinReadPost *
Karsten Hopp cf9f5a
	\ if !did_filetype() && expand("<amatch>") !~ g:ft_ignore_pat
Karsten Hopp cf9f5a
	\    && (getline(1) =~ '^#' || getline(2) =~ '^#' || getline(3) =~ '^#'
Karsten Hopp cf9f5a
	\	|| getline(4) =~ '^#' || getline(5) =~ '^#') |
Karsten Hopp cf9f5a
	\   setf conf |
Karsten Hopp cf9f5a
	\ endif
Karsten Hopp cf9f5a
Karsten Hopp cf9f5a
" Use the plugin-filetype checks last, they may overrule any of the previously
Karsten Hopp cf9f5a
" detected filetypes.
Karsten Hopp cf9f5a
runtime! ftdetect/*.vim
Karsten Hopp cf9f5a
Karsten Hopp cf9f5a
augroup END
Karsten Hopp cf9f5a
Karsten Hopp cf9f5a
Karsten Hopp cf9f5a
" If the GUI is already running, may still need to install the Syntax menu.
Karsten Hopp cf9f5a
" Don't do it when the 'M' flag is included in 'guioptions'.
Karsten Hopp cf9f5a
if has("menu") && has("gui_running")
Karsten Hopp cf9f5a
      \ && !exists("did_install_syntax_menu") && &guioptions !~# "M"
Karsten Hopp cf9f5a
  source <sfile>:p:h/menu.vim
Karsten Hopp cf9f5a
endif
Karsten Hopp cf9f5a
Karsten Hopp cf9f5a
" Function called for testing all functions defined here.  These are
Karsten Hopp cf9f5a
" script-local, thus need to be executed here.
Karsten Hopp cf9f5a
" Returns a string with error messages (hopefully empty).
Karsten Hopp cf9f5a
func! TestFiletypeFuncs(testlist)
Karsten Hopp cf9f5a
  let output = ''
Karsten Hopp cf9f5a
  for f in a:testlist
Karsten Hopp cf9f5a
    try
Karsten Hopp cf9f5a
      exe f
Karsten Hopp cf9f5a
    catch
Karsten Hopp cf9f5a
      let output = output . "\n" . f . ": " . v:exception
Karsten Hopp cf9f5a
    endtry
Karsten Hopp cf9f5a
  endfor
Karsten Hopp cf9f5a
  return output
Karsten Hopp cf9f5a
endfunc
Karsten Hopp cf9f5a
Karsten Hopp cf9f5a
" Restore 'cpoptions'
Karsten Hopp cf9f5a
let &cpo = s:cpo_save
Karsten Hopp cf9f5a
unlet s:cpo_save