Monday, July 14, 2014

Re: RFE: honor 'eol' setting regardless of 'binary' flag.

Hi Ben,
haven't heard from in a while.
Am 2014-07-14 08:27, schrieb Benjamin R. Haskell:

> On Sun, Jul 13, 2014 at 5:04 PM, Linda W <vim@tlinx.org> wrote:
>> Tim Chase wrote:
>>
>>> Take Christian's advice: just put "set binary" in your vimrc and
>>> be
>>> done with it. Anything more is just trolling the list.
>> ---
>> set binary changes other settings that I don't want changed:
>> The following options will be ignored:
>> textwidth, wrapmargin, modeline, expandtab, fileformat, (and
>> fileformats)
>>
>> I only need this behavior:
>>
>> When writing a file the <EOL> for the last line is only written
>> if
>> there was one in the original file (normally Vim appends an
>> <EOL> to
>> the last line if there is none; this would make the file
>> longer). See
>> the 'endofline' option.
>>
>> --- and what I asked for initally (see subject)...
>> is for the eol setting to be honored regardless of it being in text
>> or binary
>> mode.
>
> I'd also like to +1 the initial request, but this is a request that
> has been made, and was subsequently denied, in the past:
> https://groups.google.com/d/msg/vim_use/clf_u55xrOA/UYLSNoIPELEJ [1] -
> wherein Bram replied:
>
> """
> Actually, you should normally not set binary to write back what was
> read.
> 'endoffile' is the exception, and that's because a decent text file
> must
> end with a LF. Vim fixes that for you (it always has). If other
> tools
> omit that LF you need to fix those tools, not Vim.
>
> """
>
> For the poster who suggested VCS's like git: that's the reason I want
> the 'eol' setting to be respected. If a file is checked into a git
> repo without the trailing newline, editing the file in Vim causes the
> newline to be added, which looks like a change, even if 'noeol' is
> set. I would like Vim to not add anything I'm not intentionally
> adding. The fact that 'eol' is conditioned on 'binary' simply doesn't
> make sense.

No this is a reasonable request.

I'll look into it but not sure, Bram will accept such a change. For the
time
being, I think a autocommand such as this should work (untested, but the
idea
should be clear):

fu! DetectNoEOL()
if !&eol
au BufWrite <buffer> :set binary noeol
au BufWritePost <buffer> :set nobinary
endif
endfu

augroup EOL
au!
au BufEnter * :call DetectNoEOL()
augroup


Best,
Christian

--
--
You received this message from the "vim_use" 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

---
You received this message because you are subscribed to the Google Groups "vim_use" group.
To unsubscribe from this group and stop receiving emails from it, send an email to vim_use+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

No comments: