chrisbra/NrrwRgn

NrrwRgn agnostic to changes by vim-over

Konfekt opened this issue · 7 comments

After a change in the scratch buffer by :%s using https://github.com/osyo-manga/vim-over , the changes are not reflected upon writing the scratch buffer by :write!.

Am 2015-02-25 12:11, schrieb Konfekt:

After a change in the scratch buffer by :%s using
https://github.com/osyo-manga/vim-over [1] , the changes are not
reflected upon writing the scratch buffer by :write!.

I do not understand. What is vim-over doing? And where are you doing
this?

Best,
Christian

https://github.com/osyo-manga/vim-over is a tool that shows the strings as they will appear after :substitute next to them while typing the regular expressions.

To reproduce, after installing https://github.com/osyo-manga/vim-over map S to

nnoremap <silent> S ms:OverCommandLine<CR>:%substitute:\v::cgI<Left><Left><Left><Left><Left>

and narrow a region, say the buffer containing

hello

by NrrwRgn. In the scratchbuffer, hit S and replace hello by bye. Then the changes of the scratchbuffer are not reflected in the original buffer, even on :write! in the scratchbuffer.

Granted that this could be an issue of https://github.com/osyo-manga/vim-over but perhaps you have a good idea why so at least?!

Am 2015-02-25 12:33, schrieb Konfekt:

Ok, after installing https://github.com/osyo-manga/vim-over [1] map S
to

nnoremap S
ms:OverCommandLine:%substitute:v::cgI

and narrow a region, say the buffer containing

hello

by NrrwRgn. In the scratchbuffer, hit S and replace hello by bye. Then
the changes of the scratchbuffer are not reflected in the original
buffer, even on :write! in the scratchbuffer.

Granted that this could be an issue of
https://github.com/osyo-manga/vim-over [1] but perhaps you have a good
idea why so at least?!

Thanks I'll check it out. Can you post the output of
:au BufWriteCmd

That should contain something like this:
...
NrrwRgn1 BufWriteCmd
<buffer=5>
:call s:WriteNrrwRgn(1)

And afterwards please also show the output of
:au NrrwRgn1

Ok, in a nrrwrgn buffer au BufWriteCmd gives

--- Auto-Commands ---
fugitive_files  BufWriteCmd
    fugitive://**//[0-3]/**
              exe s:BufWriteIndexFile()
Network  BufWriteCmd
    ftp://*   exe "sil doau BufWritePre ".fnameescape(expand("<amatch>"))|exe 'Nwrite '.fnameescape(expand("<amatch>"))|exe "sil doau BufWritePost ".fnameescape(expand("<amatch>"))
    rcp://*   exe "sil doau BufWritePre ".fnameescape(expand("<amatch>"))|exe 'Nwrite '.fnameescape(expand("<amatch>"))|exe "sil doau BufWritePost ".fnameescape(expand("<amatch>"))
    scp://*   exe "sil doau BufWritePre ".fnameescape(expand("<amatch>"))|exe 'Nwrite '.fnameescape(expand("<amatch>"))|exe "sil doau BufWritePost ".fnameescape(expand("<amatch>"))
    http://*  exe "sil doau BufWritePre ".fnameescape(expand("<amatch>"))|exe 'Nwrite '.fnameescape(expand("<amatch>"))|exe "sil doau BufWritePost ".fnameescape(expand("<amatch>"))
    dav://*   exe "sil doau BufWritePre ".fnameescape(expand("<amatch>"))|exe 'Nwrite '.fnameescape(expand("<amatch>"))|exe "sil doau BufWritePost ".fnameescape(expand("<amatch>"))
    davs://*  exe "sil doau BufWritePre ".fnameescape(expand("<amatch>"))|exe 'Nwrite '.fnameescape(expand("<amatch>"))|exe "sil doau BufWritePost ".fnameescape(expand("<amatch>"))
    rsync://* exe "sil doau BufWritePre ".fnameescape(expand("<amatch>"))|exe 'Nwrite '.fnameescape(expand("<amatch>"))|exe "sil doau BufWritePost ".fnameescape(expand("<amatch>"))
    sftp://*  exe "sil doau BufWritePre ".fnameescape(expand("<amatch>"))|exe 'Nwrite '.fnameescape(expand("<amatch>"))|exe "sil doau BufWritePost ".fnameescape(expand("<amatch>"))
tar  BufWriteCmd
    tarfile::*
              call tar#Write(expand("<amatch>"))
    tarfile::*/*
              call tar#Write(expand("<amatch>"))
zip  BufWriteCmd
    zipfile:* call zip#Write(expand("<amatch>"))
    zipfile:*/*
              call zip#Write(expand("<amatch>"))
NrrwRgn1  BufWriteCmd
    <buffer=3>
              :call s:WriteNrrwRgn(1)

and au NrrwRgn1 gives

--- Auto-Commands ---
NrrwRgn1  BufDelete
    <buffer=3>
              :call s:WriteNrrwRgn()
NrrwRgn1  BufWipeout
    <buffer=3>
              :call s:WriteNrrwRgn()
NrrwRgn1  BufWinLeave
    <buffer=3>
              :call s:WriteNrrwRgn()
    <buffer=2>
              if <sid>HasMatchID(1)|call <sid>DeleteMatches(1)|endif
NrrwRgn1  BufWriteCmd
    <buffer=3>
              :call s:WriteNrrwRgn(1)
NrrwRgn1  CursorMoved
    <buffer=3>
              :call s:UpdateOrigWin()

Besides, a problem sometimes occuring with vim-over without being able to make it reproducable, is that the changes are not recognized by Vim, so that :update does not save them, only :write.

Okay, I see the problem. The scratch window is not marked modified and therefore the content is not written back. That might be considered a bug in the vim-over plugin.
I have removed that check now, since it seems to be useless.

Thanks! Can you explain How to Mark the Window modified to remove the apparent bug in vim-over

Hi Konfekt!

On Mi, 25 Feb 2015, Konfekt wrote:

Thanks! Can you explain How to Mark the Window modified to remove the apparent bug in vim-over

In the scratch window, issue :set modified

But this shouldn't be necessary anymore. I removed that check.

Best,

Christian

Erfolg bei Frauen ist oft der Anlass übler Nachrede.
-- Walter Hasenclever