netrw local browse doesn't respect readonly-ness of files

classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

netrw local browse doesn't respect readonly-ness of files

Steven Mueller
Hi Chip,

I've been enjoying flying around a large source tree using netrw, but
have discovered that when opening read-only files from the local
browse mechanism, setlocal noro is done on the new buffer anyway.

The offending line is near the end of the NetrwBrowseChgDir function
in netrw.vim.  A minimal patch against netrw version 132 (as included
with Vim 7.2) that fixes the issue for me is below.  (Please forgive
the inlinining; I figured it was simple and small enough to just
include here directly.)

From a quick glance, it looks like this would still patch the latest
netrw okay, if at a distant offset.

Thanks,
Steve

--- netrw.vim.orig      2010-05-19 09:39:11.734082000 -0700
+++ netrw.vim   2010-05-20 19:19:48.905330000 -0700
@@ -2907,7 +2907,10 @@
   call s:NetrwOptionRestore("s:")
   if dolockout
 "   call Decho("doing modification lockout settings: ma nomod noro")
-   setlocal ma nomod noro
+   setlocal ma nomod
+   if filewritable(expand("%"))
+     setlocal noro
+   endif
 "   call Decho("setlocal ma nomod noro")
   endif

--
Steven Mueller

--
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
Reply | Threaded
Open this post in threaded view
|

Re: netrw local browse doesn't respect readonly-ness of files

Benjamin Fritz


On May 20, 9:36 pm, Steven Mueller <[hidden email]> wrote:
> Hi Chip,
>
> I've been enjoying flying around a large source tree using netrw, but
> have discovered that when opening read-only files from the local
> browse mechanism, setlocal noro is done on the new buffer anyway.
>

This problem was also encountered in this thread on vim_use:

http://groups.google.com/group/vim_use/browse_thread/thread/82946ab8ac7e1c62/f4f6021bca21127b

Responding there might be nice when the fix is incorporated.

--
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
Reply | Threaded
Open this post in threaded view
|

Re: netrw local browse doesn't respect readonly-ness of files

Charles Campbell
In reply to this post by Steven Mueller
Steven Mueller wrote:

> Hi Chip,
>
> I've been enjoying flying around a large source tree using netrw, but
> have discovered that when opening read-only files from the local
> browse mechanism, setlocal noro is done on the new buffer anyway.
>
> The offending line is near the end of the NetrwBrowseChgDir function
> in netrw.vim.  A minimal patch against netrw version 132 (as included
> with Vim 7.2) that fixes the issue for me is below.  (Please forgive
> the inlinining; I figured it was simple and small enough to just
> include here directly.)
>
> >From a quick glance, it looks like this would still patch the latest
> netrw okay, if at a distant offset.
>  
Hello, Steve,

I've made v139a with your patch.  It also has a few other things,
although I haven't gotten to some of Jean Johner's issues yet.  You can
find it at:

  http://mysite.verizon.net/astronaut/vim/index.html#NETRW


Thank you for the patch,
Chip Campbell

--
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
Reply | Threaded
Open this post in threaded view
|

Re: netrw local browse doesn't respect readonly-ness of files

Charles Campbell
In reply to this post by Benjamin Fritz
Ben Fritz wrote:

> On May 20, 9:36 pm, Steven Mueller <[hidden email]> wrote:
>  
>> Hi Chip,
>>
>> I've been enjoying flying around a large source tree using netrw, but
>> have discovered that when opening read-only files from the local
>> browse mechanism, setlocal noro is done on the new buffer anyway.
>>
>>    
>
> This problem was also encountered in this thread on vim_use:
>
> http://groups.google.com/group/vim_use/browse_thread/thread/82946ab8ac7e1c62/f4f6021bca21127b
>
> Responding there might be nice when the fix is incorporated.
>  

I don't see where netrw use is mentioned; no browsing, "I opened a
directory, and...", etc, in that thread.  The problem addressed by SM
essentially meant that no warning was issued by vim when one modified a
read-only file when it should be; its not marking the buffer as "nomod"
(which is what the autocmd mentioned in that thread does, but only when
the file is readonly, so the netrw problem would prevent that autocmd
from firing, too).

Regards,
Chip Campbell

--
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