On Tuesday 05 June 2007, you wrote:
 
> Hm. In the Vim 7.1 filetype.vim, filetype "conf" is set for any file, one
> of the first 5 lines of which starts with #, but only if everything else
> fails (and *.py is detected as type "python" before that...)
>
> I wonder what causes your first *.py, but not the others, to be detected as
> python.
   The first file, the one that got good syntax highlighting, did not have
    a she-bang line, others did not.
I'm having a similar problem:
I also program with a language called rebol.
filetype.vim does not properly "understand" how rebol works.
Here is the original code:
 " Rexx, Rebol or R
  au BufNewFile,BufRead *.r,*.R           call s:FTr()

  fun! s:FTr()
    if getline(1) =~ '^REBOL'
      setf rebol
    else
      let n = 1
      let max = line("$")
      if max > 50
        let max = 50
      endif
      while n < max
        " R has # comments
        if getline(n) =~ '^\s*#'
      setf r
      break
        endif
        " Rexx has /* comments */
        if getline(n) =~ '^\s*/\*'
      setf rexx
      break
        endif
        let n = n + 1
      endwhile
      if n >= max
        setf rexx
      endif
    endif
  endfun
# it is incomplete because a rebol file may
1)begin with the regex "REBOL" in either lower or upper or mixed case
2)begin with a shebang line containing "rebol"
3)furthermore, in some cases neither condition would be present.

Thus, I found that any rebol file *without* the shebang line highlighted 
properly, but with the shebang line, needed :setf rebol

Now here is what is weird:
I changed the code in filetype to the following simpler approach:
au BufNewFile,BufRead *.r,*.R,*.reb         setf rebol
removing function FTr entirely
but the same symptoms remain.

I would suspect that there is a side effect from some other file
that is sourced. When I get more time, I will remove files from
~/.vim/plugin , ... autoload etc and see what happens as I add
them back in. In the meantime, this highly annoying but not a
crisis, after all setf does the job.

thanks for looking into this,
I'd welcome other comments all the same.
regards
tim


Reply via email to