[ldapvi] [PATCH] use fileencoding instead of encoding for vim
Devin J. Pohly
djpohly at gmail.com
Tue Jan 25 15:38:09 CET 2011
On 01/25/2011 09:20 AM, Ulrich Spörlein wrote:
> On Sun, 23.01.2011 at 13:36:50 -0500, Devin J. Pohly wrote:
>> When running ldapvi, vim complains about setting 'encoding' in a
>> modeline, since that defines vim's internal encoding. I think ldapvi
>> means to use the 'fileencoding' option.
>>
>> ---
>> ldapvi/ldapvi.c | 2 +-
>> 1 files changed, 1 insertions(+), 1 deletions(-)
>>
>> diff --git a/ldapvi/ldapvi.c b/ldapvi/ldapvi.c
>> index 7b312f8..f99efd7 100644
>> --- a/ldapvi/ldapvi.c
>> +++ b/ldapvi/ldapvi.c
>> @@ -1414,7 +1414,7 @@ write_file_header(FILE *s, cmdline *cmdline)
>> int nlines = 0;
>>
>> if (print_binary_mode == PRINT_UTF8&& !cmdline->ldif) {
>> - fputs("# -*- coding: utf-8 -*- vim:encoding=utf-8:\n", s);
>> + fputs("# -*- coding: utf-8 -*- vim:fileencoding=utf-8:\n", s);
>> nlines++;
>> }
>> if (cmdline->ldif) {
>> --
>
> This is slightly more correct, but still useless. When reading the
> modeline, vim(1) already made up its mind about which fileencoding the
> file is in.
>
> From the helpfile:
>
> When reading a file 'fileencoding' will be set from 'fileencodings'.
> To read a file in a certain encoding it won't work by setting
> 'fileencoding', use the |++enc| argument. One exception: when
> 'fileencodings' is empty the value of 'fileencoding' is used.
>
> So, I think the best thing would be to have a BOM at the start of the
> tempfile so that all sane editors can figure out the encoding by
> themselves. I, for one, never had problems with vim(1) not detecting the
> encoding ...
>
> Regards,
> Uli
Or just take out the 'encoding' option altogether, since a BOM is
"neither required nor recommended for UTF-8" (Unicode standard). I've
never had issues with autodetection either, but I haven't used any of
the more unusual encodings. The problem was just that vim would always
throw an annoying error about 'encoding' at every startup.
*dp
More information about the ldapvi
mailing list