Modify ftdetect to use function so autocmd filetype is used