Loading ...
Sorry, an error occurred while loading the content.

Re: c_syntax_for_h ignored

Expand Messages
  • Bram Moolenaar
    ... It s a bug. The FTheader() function is checking for c_syntax_for_h, but since it s inside a function this checks the function-local variable. It should
    Message 1 of 3 , Sep 5 2:14 PM
    • 0 Attachment
      Benjamin Fritz wrote:

      > I'm not sure if I'm doing something wrong, or if this is a bug.
      >
      > In my vimrc, I have:
      >
      > let g:c_syntax_for_h = 1
      >
      > If I open a .h file and do :verbose set ft? I get:
      >
      > filetype=cpp
      > Last set from C:\Program Files\Vim\vim72\filetype.vim
      >
      > If I do :debug e and step through, I see that s:FTheader() gets called
      > as expected from a BufRead autocmd.
      >
      > But, at the point where filetype.vim checks exists("c_syntax_for_h"),
      > echo exists("c_syntax_for_h") returns 0. At the same point,
      > exists("g:c_syntax_for_h") returns 1.
      >
      > Outside of the autocmd, exists("c_syntax_for_h") returns 1 as expected.
      >
      > I'm using Vim 7.2.2 "Big" with GUI and OLE for MS-Windows 32-bit,
      > obtained from the "Cream" sourceforge page.

      It's a bug. The FTheader() function is checking for c_syntax_for_h, but
      since it's inside a function this checks the function-local variable.
      It should test g:c_syntax_for_h.


      *** ../vim-7.2.009/runtime/filetype.vim Wed Aug 6 18:56:36 2008
      --- runtime/filetype.vim Fri Sep 5 23:04:55 2008
      ***************
      *** 364,372 ****
      func! s:FTheader()
      if match(getline(1, min([line("$"), 200])), '^@\(interface\|end\|class\)') > -1
      setf objc
      ! elseif exists("c_syntax_for_h")
      setf c
      ! elseif exists("ch_syntax_for_h")
      setf ch
      else
      setf cpp
      --- 367,375 ----
      func! s:FTheader()
      if match(getline(1, min([line("$"), 200])), '^@\(interface\|end\|class\)') > -1
      setf objc
      ! elseif exists("g:c_syntax_for_h")
      setf c
      ! elseif exists("g:ch_syntax_for_h")
      setf ch
      else
      setf cpp


      --
      Due knot trussed yore spell chequer two fined awl miss steaks.

      /// Bram Moolenaar -- Bram@... -- http://www.Moolenaar.net \\\
      /// sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
      \\\ download, build and distribute -- http://www.A-A-P.org ///
      \\\ help me help AIDS victims -- http://ICCF-Holland.org ///

      --~--~---------~--~----~------------~-------~--~----~
      You received this message from the "vim_use" maillist.
      For more information, visit http://www.vim.org/maillist.php
      -~----------~----~----~----~------~----~------~--~---
    Your message has been successfully submitted and would be delivered to recipients shortly.