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

32309Re: bug in explicit :setf behavior?

Expand Messages
  • Dorai Sitaram
    May 1 7:25 AM
    • 0 Attachment
      Benji Fisher wrote
      > Dorai Sitaram wrote:
      > > Bram wrote:
      > >
      > >>You must be doing something wrong. Try typing ":setf c" in a help file,
      > >>the highlighting does change.
      > >
      > >
      > > Very strange. That works. My test case is editing an
      > > email message, where the filetype is initially 'mail'.
      > > I do 'setf scheme', which, among other things should 'setl
      > > lisp', and that doesn't happen. On the other hand,
      > > 'setf scheme' in a help file does work.
      > Try
      > :set verbose=20
      > :setf scheme
      > and then have a look at the messages you get. You should see the syntax,
      > ftplugin, and indent files loaded. If one of them bails out early, you should
      > be able to figure out why.

      Thanks, did that, and I think I know what's happening.
      The b:did_ftplugin is preventing loading of the
      ftplugin/newfiletype.vim file.

      The reason why some filetype-specific things do show up
      is because the 'mail' filetype (the original
      filetype) doesn't have b:did_indent set, so
      indent/newfiletype.vim, if it exists, does get loaded,
      and it happens to set some options (e.g., indent/c.vim
      sets cindent).

      Also, syntax highlighting gets changed correctly.

      In summary, :setf newfiletype does the following:

      1. it sets the &filetype variable to newfiletype.

      2. it changes highlighting correctly, if syntax is on.

      3. it sets stuff from indent/newfiletype.vim, _if_
      the original filetype didn't have an indent plugin.

      4. it doesn't do anything in filetype/newfiletype.vim,
      (except for the early 'finish').
    • Show all 17 messages in this topic