Hi,
On Mon, Jul 18, 2016 at 06:02:10AM +0200, Tony Mechelynck wrote:
> Right.
>
> >
> > The issue happens when I open Vim with the following configuration
> > (.vimrc):
> >
> > " 3 is tree listing
> > let g:netrw_liststyle=3
> > let g:netrw_chgwin=2
> > let g:netrw_winsize=22
> >
> > After opening Vim I perform:
> >
> > :Lexplore
> >
> > To open `netrw` and finally press `r` to reorder the tree listing. I
> > then use `:buffers!` to look at the hidden buffers created and see this:
> >
> > 1 #a "[No Name]" line 1
> > 2u h + "NetrwTreeListing 1" line 1
> > 4u%a- "NetrwTreeListing 2" line 8
> > 5u "NetrwTreeListing" line 1
> >
> > Buffer no. 2 is marked as modified which makes Vim write the file if I
> > perform `:wall`. The same happens with the `R` (rename) and `D`
> > (delete) commands.
> >
> > After a while I end with dozens of `NetrwTreeListing *` files in the
> > current directory (I use `:wall` often).
> >
> > This does not happen if I change `g:netrw_liststyle` to any other value,
> > i.e. the bug is specific to the tree listing.
> >
> > I have seen this behaviour using the `netrw.vim` script shipped with Vim:
> > https://github.com/vim/vim/blob/master/runtime/autoload/netrw.vim
> >
> > And also within the `netrw.vim` script available in the Vimball on
> > DrChip's page:
> > http://www.drchip.org/astronaut/vim/#NETRW
> >
> > The investigation into this bug sprouted from a question on the vim
> > stack exchange:
> > http://vi.stackexchange.com/questions/8839/how-i-configure-vim-for-use-with-netrw
> >
> > ------
> >
> > I believe I have tracked the bug and a patch is attached. Although I
> > believe that my solution is ugly and not the best one by far. I only
> > learned Vimscript some two month ago.
> >
> > In the routine `s:NetrwRefresh(islocal,dirname)` I found that commenting
> > the following lines stopped the modified buffer from being generated:
> >
> > sil! NetrwKeepj %d _
> > if a:islocal
> > NetrwKeepj call netrw#LocalBrowseCheck(a:dirname)
> > else
> > NetrwKeepj call s:NetrwBrowse(a:islocal,a:dirname)
> > endif
> >
> > Therefore I managed to come up with the following solution:
> >
> > sil! NetrwKeepj %d _
> > setl nomod
> > if a:islocal
> > NetrwKeepj call netrw#LocalBrowseCheck(a:dirname)
> > setl nomod
> > else
> > NetrwKeepj call s:NetrwBrowse(a:islocal,a:dirname)
> > setl nomod
> > endif
> >
> > I have tested it, and the buffer is now correctly generated but the
> > modified flag is not set anymore. In essence, now all `NetrwTreeLisitng
> > *` buffers remain in unmodified state and are not written when I call
> > `:wall`.
> >
> > (Adding a single `setl nomod` after the `endif` does not appear to
> > work.)
> >
> > The patch attached contains this exact solution. It works. Yet, I
> > repeat, I'm not confident in my skills at editing Vimscript, and the
> > existence of a better solution is very likely.
> >
> > Can I ask for your input on this change?
> >
>
> Which netrw version were you using to generate you patch? The one from
> Dr. Chip's Astronaut site maybe? In that case it is indeed the most
> recent one but you ought to have mentioned the version number found
> near the top of the file.
>
> In the current "stable" version (156, dated 20 Apr 2016, as
> distributed with Vim 7.4.2066) I find your "line 8499" at line 8465
> i.e. more than 30 lines higher.
>
>
> Best regards,
> Tony.
Ops, sorry for that. When I started programming SVN already existed so
i'm pretty bad with patches.
The previous patch was generated against the netrw.vim from DrChip's
website. But... after reading about patches I noticed that I generated
it in a completely wrong way. Please ignore that patch.
Allow me to start again:
The issue happens on this configuration:
vim --version
VIM - Vi IMproved 7.4 (2013 Aug 10, compiled Jun 9 2016 09:35:51)
Included patches: 1-1910
Compiled by Arch Linux
And yes, I am running Vim (and netrw) on Arch Linux.
I can replicate the issue with *two* versions of the netrw.vim script:
Version: 156
(which it the netrw version present in the Vim repository:
https://github.com/vim/vim/blob/master/runtime/autoload/netrw.vim
And also with:
Version: 157h ASTRO-ONLY
I have now properly generated a patch for both versions of the netrw.vim
script. Both patches are attached:
netrw-156.patch: which can be run against the Vim repository.
netrw-157h.patch: which can be run against the most recent version of
the netrw.vim script from DrChip's website.
Best,
--
Mike Grochmal
key ID 0xC840C4F6
--
--
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
---
You received this message because you are subscribed to the Google Groups
"vim_dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/d/optout.
--- a/runtime/autoload/netrw.vim 2016-07-17 20:54:45.000181791 +0100
+++ b/runtime/autoload/netrw.vim 2016-07-18 23:02:37.321276147 +0100
@@ -8465,10 +8465,13 @@
" call Decho("win#".winnr().": ".winheight(0)."x".winwidth(0)."
curfile<".expand("%").">",'~'.expand("<slnum>"))
" call Decho("clearing buffer prior to refresh",'~'.expand("<slnum>"))
sil! NetrwKeepj %d _
+ setl nomod
if a:islocal
NetrwKeepj call netrw#LocalBrowseCheck(a:dirname)
+ setl nomod
else
NetrwKeepj call s:NetrwBrowse(a:islocal,a:dirname)
+ setl nomod
endif
" restore position
--- a/runtime/autoload/netrw.vim 2016-07-18 23:14:25.330874851 +0100
+++ b/runtime/autoload/netrw.vim 2016-07-18 23:15:41.033452456 +0100
@@ -8500,10 +8500,13 @@
" call Decho("win#".winnr().": ".winheight(0)."x".winwidth(0)."
curfile<".expand("%").">",'~'.expand("<slnum>"))
" call Decho("clearing buffer prior to refresh",'~'.expand("<slnum>"))
sil! NetrwKeepj %d _
+ setl nomod
if a:islocal
NetrwKeepj call netrw#LocalBrowseCheck(a:dirname)
+ setl nomod
else
NetrwKeepj call s:NetrwBrowse(a:islocal,a:dirname)
+ setl nomod
endif
" restore position