filetype in modeline

Rainer Müller raimue at macports.org
Mon Jan 14 07:35:29 PST 2013


On 2013-01-14 16:07, Clemens Lang wrote:
> On Mon, Jan 14, 2013 at 09:33:34AM -0500, Jeremy Lavergne wrote:
>>> Another way to make sure Portfiles have filetype set to Portfile despite
>>> the modeline is adding the following line to your .vimrc:
>>>    au BufNewFile,BufRead,BufWinEnter Portfile setlocal ft=Portfile
>>>
>>> That way you can use mpvim with your Portfiles but still use the
>>> standard modeline.
>>
>> We could update the standard modeline to include that too :-)
> 
> No we can't, because
>  - I think the command wouldn't be effective in a modeline
>  - it would be no different from putting ft=Portfile in the modeline
>    directly
>  - it would break for all users without mpvim, which is just what we're
>    trying to avoid.
> 
> We could however put that line into mpvim.

It already is in ftdetect/macports.vim [1], except that it is only done
for the events BufNewFile,BufRead and not for BufWinEnter, while the
latter is the reason your line actually works. The filetype is
overridden each time again the buffer of a Portfile is displayed.
Although this works in most circumstances, it has side effects when
using hidden buffers.

Rainer

[1] https://trac.macports.org/browser/contrib/mpvim/ftdetect/macports.vim


More information about the macports-dev mailing list