On 23/07/10 23:00, Bram Moolenaar wrote:

Matt Wozniski wrote:
[...]
Doing it *properly* (eg, for all supported encodings) would definitely
be difficult, but I can envision a quick hack that works for
single-byte encodings:

0) Start handling a :e command
1) remember what 'fenc' was set to before any modelines were handled
2) handle modelines
3) if fenc has changed, implicitly do an :e ++enc=&fenc (and whatever
other flags) (goto 0)

I think that should work fine as long as the modeline is a valid
modeline in both encodings, which should be true for all single-byte
encodings and utf-8, but won't hold for utf-16, utf-32, etc...  Any
thoughts?  If I'm not missing anything, it should be possible to make
vim handle the simplest (and most useful, since they can't be
unambiguously detected automatically) case without breaking things any
worse than they are for more complicated cases.

I would think this is possible with an autocommand: save the value of
'fenc' with a BufReadPre and check the value in BufReadPost.
Perhaps someone can try out how well this works.


Wouldn't BufReadPre be too early, in the sense that the buffer hasn't been read yet, and the 'fileencodings' magic not yet done? A BufReadCmd might just barely be imaginable, but I'd guess fraught with difficulties.


Best regards,
Tony.
--
You can pick your friends, and you can pick your nose, but you can't
pick your friend's nose.

--
You received this message from the "vim_dev" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

Raspunde prin e-mail lui