Fullquote, 'cause copying this message to vim_dev

Hi Andy!

On Di, 01 Dez 2009, Andy Wokula wrote:

> Christian Brabandt schrieb:
> > Hi Andy!
> > 
> > On Di, 01 Dez 2009, Andy Wokula wrote:
> > 
> >> Andy Wokula schrieb:
> >> setlocal formatexpr=FexLogBook()
> >>
> >> func! FexLogBook()
> >>     if mode() =~# '[iR]'
> >>    return 1
> >>     endif
> >>     exec v:lnum. "mark ["
> >>     exec (v:lnum + v:count - 1). "mark ]"
> >>     '[,']s/^\[.*]$/&\r/
> >>     setl fex=
> >>     normal! '[gq']
> >>     setl fex=FexLogBook()
> >>     '[,']s/^\[.*]\zs\n$//
> >>     return
> >> endfunc
> >>
> > Nice. But there seems to be a bug somewhere.
> > 
> > With this file
> 
> > [headline1]
> > Some Text here.
> > Some more text
> > Even more text
> > 
> > 
> > [headline2]
> > Some Text here.
> > Some more text
> > Even more text
> 
> > Now executing vim on Windows (this does not happen on Linux):
> > 
> > vim -u NONE file.txt
> > :so fex.vim
> > :norm! gqG
> > :norm! u
> > 
> > Now the file looks like this:
> 
> > [headline1]
> > Some Text here.
> > Some more (ext
> > Even more text
> > 
> > 
> > [headline2]
> > Some Text here.
> > Some more text
> > Even more text
> 
> > Notice the ( in the first paragraph. The position of the parenthesis 
> > changes, but the buffer stays modified and only :e! reloaded it  
> > correctly. This happened with vim 7.2.284 on Windows, same Version under 
> > Linux is not affected. Can any Windows user confirm this bahaviour?
> 
> Here on Win32, I checked with gVim 7.0 and gVim7.2.218, and I get almost
> the same:
> 
> 
> [headline1]
> Some Text (ere.
> Some more text
> Even more text
> 
> 
> [headline2]
> Some Text here.
> Some more text
> Even more text
> 
> 
> After undoing, the buffer is not left modified.
> And I typed the commands in (not using :normal).
> 
> Maybe the recursive gq is a problem?
> 

Sorry, I meant my buffer was not left modified either.

Here is an minimal example:
func! FexLogBook()
    set fex=
    exe 'normal! gqap'
endfunc
setlocal formatexpr=FexLogBook()
call feedkeys('gqapu', 't')

Open vim with the sample text file from above:
~$ vim -u NONE -N fex.txt
and source the file:
:so fex.vim

Note the change. BTW: this does not happen, when you call vim like this:
~$ vim -u NONE -N -S fex.vim fex.txt

Try sourcing it several times, the change does not always occur and 
looks differently sometimes. e.g. I get this result:
[headline1]()

However changing the function to this, does not result in the bug:
func! FexLogBook()
    let &l:fex=''
    exe 'normal! gqap'
endfunc
setlocal formatexpr=FexLogBook()
call feedkeys('gqapu', 't')


regards,
Christian
-- 
:wq

-- 
You received this message from the "vim_dev" maillist.
For more information, visit http://www.vim.org/maillist.php

Raspunde prin e-mail lui