On 5/24/06, Zdenek Sekera <[EMAIL PROTECTED]> wrote:
> -----Original Message-----
> From: Eric Arnold [mailto:[EMAIL PROTECTED]
> Sent: 24 May 2006 12:38
> To: Zdenek Sekera
> Cc: vim-dev@vim.org
> Subject: Re: set readonly - strange?
>
> I think 'readonly' does not belong in the .vimrc since it is a
> buffer-local-only option.
>

Yes, but I have only one buffer...

> However, you can use an autocommand to set it.  What are you really
> trying to do from the .vimrc ?  Setting the readonly value for the
> default empty starting buffer seems odd, and you can manage the
> reaonly property several ways for files actually loaded into buffers.
>

Clearly, my example was a case simplyfied to the utmost,
but describing what I really want to do: display a buffer
for reading only. My real '.vimtest' has many more options,
of course, so I thought I can this one into it as well
(just as I wanted 'modifiable', 'modified', and more).
This was to make things simple, start 'vim -u this that'.
Since that doesn't work for some of those settings, I'll
have to settle for another way like 'vim -R ...'.
I wanted to avoid any additional parameter on the vim call
(for some reasons), but I have to now change my mind.

There are other ways to do this.
- wrap the vim -R in a shell script to hide the -R
- use an autocommand to always set everything readonly

au BufEnter * set readonly

- use a self-destroying autocommand to set it for the first file:

aug Tst
        au!
        au BufEnter * set readonly
        au BufEnter * aug Tst
        au BufEnter * au!
        au BufEnter * aug END
aug END


and you can get a little more creative on which pattern to use ("*")
or when to destroy it.




You maybe right it doesn't belong to '.vimrc', but that's
not explicitly stated anywhere (and for others), hence
my trying and discovering a hole, perhaps a bug.
Wouldn't you think that it should apply always to at least
the first buffer on the vim call? Or all if it's in .vimrc?

Then it would be a global option.

The thing is, at the time you use  :set ro   in the .vimrc, you aren't
specifying a file or buffer name.  So, the only thing it could
possibly do is apply it to the first buffer it creates, which is could
be temporary buffer (though I suspect it discards the   :set ro  since
it doesn't have a buffer created yet).

The implementation is not clear IMHO, perhaps the doc needs
some update.

Well, it's not a simple topic.  To really undestand it, you have to
understand the states and steps Vim goes through on start up.

It will be indeed interesting to see what will Bram decide
about it. Let's wait.

---Zdenek

>
> On 5/24/06, Zdenek Sekera <[EMAIL PROTECTED]> wrote:
> > > -----Original Message-----
> > > From: Eric Arnold [mailto:[EMAIL PROTECTED]
> > > Sent: 24 May 2006 11:21
> > > To: Zdenek Sekera
> > > Cc: Yakov Lerner; vim-dev@vim.org
> > > Subject: Re: set readonly - strange?
> > >
> > > On 5/24/06, Zdenek Sekera <[EMAIL PROTECTED]> wrote:
> > > > > -----Original Message-----
> > > > > From: Eric Arnold [mailto:[EMAIL PROTECTED]
> > > > > Sent: 23 May 2006 18:12
> > > > > To: Yakov Lerner
> > > > > Cc: Zdenek Sekera; vim-dev@vim.org
> > > > > Subject: Re: set readonly - strange?
> > > > >
> > > > > As far as I can tell, there are several instances
> where there are
> > > > > transitory buffers as vim is starting, opening a new
> tab, probably
> > > > > some in closing op.s.
> > > > >
> > > >
> > > > That may be true, but...
> > > >
> > > > > I don't know if I used the right word by saying the buffer is
> > > > > "undefined", but I don't think it it's guaranteed to be
> > > usable until a
> > > > > certain point, which is after -u, and at the "first file
> > > loaded", i.e.
> > > > > -c
> > > > >
> > > > > If you open a buffer explicitly from inside .vimtest ,
> > > then that's a
> > > > > different story.
> > > > >
> > > >
> > > > In my test case, buffer must exist, I am well passed
> the '-u ...'
> > > > phase because I can *see* the buffer when I do :set readable?'.
> > > > I think Yakov's test case is saying even more.
> > >
> > > It's not clear that the buffer exists when the   :set ro
> command is
> > > read according to the -u option, though it might exist in
> some form
> > > since no error occurs.  Even if a buffer does exist at
> that time, I'm
> > > fairly sure that is was transitory, and that it's not the
> same buffer
> > > that you actually see and type  :set ro?  at.
> > >
> > > Secondly, you need to be past the -c or similar stage,
> where it states
> > > that files have been loaded.  It doesn't say that for -u.
> > >
> > > You *are* past the loading state when you type  :set ro?
> , but that's
> > > not the same as when the -u file is processed.
> > >
> >
> > I don't know to that depth as you do, but then we should
> > agree that 'set readonly' in .vimrc is useless, because
> > it would never work, right?
> > This is hard to accept. So it looks more and more just as a bug.
> >
> > ---Zdenek
> >
> > > > > It's kinda bug-ish, but it's not a bug unless it's
> > > contrary to stated
> > > > > behavior.  It'll be interesting to see how Bram addresses it.
> > > > >
> > > >
> > > > I also think it is bug.
> > > >
> > > > ---Zdenek
> > > >
> > > > > On 5/23/06, Yakov Lerner <[EMAIL PROTECTED]> wrote:
> > > > > > > On 5/23/06, Zdenek Sekera <[EMAIL PROTECTED]> wrote:
> > > > > > > > create a file ~/.vimtest as follows:
> > > > > > > >
> > > > > > > > cat > .vimtest
> > > > > > > > set nocompatible
> > > > > > > > set readonly
> > > > > > > > <C-D>
> > > > > > > >
> > > > > > > > and execute (g)vim:
> > > > > > > >
> > > > > > > > vim .vimtest -u .vimtest
> > > > > > > >
> > > > > > > > try :set readonly? and you'll get 'noreadonly'.
> > > > > >
> > > > > > The buffer does exist when initfile is executed. The ':ls'
> > > > > in initfile shows it.
> > > > > > Adding more printouts to initfile shows interesting results:
> > > > > >
> > > > > > vim -u 1 1
> > > > > > ----------------- file called 1 ---------------
> > > > > > set nocompatible
> > > > > > ls
> > > > > > call input('before set readonly 111')
> > > > > > set readonly
> > > > > > set readonly?
> > > > > > ls
> > > > > > set readonly?
> > > > > > set readonly?
> > > > > > echo "&readonly=".&readonly
> > > > > > call input('after set readonly 222')
> > > > > > -----------------------------------------------------
> > > > > > In vim, ':verb set readonly?' shows that readonly is
> > > > > misteriously reset.
> > > > > > The output differs between vim6 and vim7.
> > > > > > --------------- vim7 output ------------------
> > > > > >   1 %    "1"                            line 1
> > > > > > before set readonly 111
> > > > > >   1 % =  "1"                            line 1
> > > > > >
> > > > > >
> > > > > > &readonly=1
> > > > > > after set readonly 222
> > > > > > ----------------------------------------
> > > > > > Note the missing output of ':set readonly?'!!! It
> prints neither
> > > > > > 'readonly' nor 'noreadonly'.
> > > > > > ----------------- vim6 output --------------------
> > > > > >
> > > > > >   1 %    "1"                            line 1
> > > > > > before set readonly 111
> > > > > >  before set readonly 111
> > > > > >   1 % =  "1"                            line 1
> > > > > >   readonly
> > > > > >   readonly
> > > > > > &readonly=1
> > > > > > after set readonly 222
> > > > > > -----------------------------------------------------
> > > > > >
> > > > > > Looks like a bug to me.
> > > > > >
> > > > > > Yakov
> > > > > >
> > > > >
> > > >
> > >
> >
>

Reply via email to