On 2014-02-17, Christian Brabandt wrote:
> On So, 16 Feb 2014, Gary Johnson wrote:
> 
> > I have a plugin that needs to track the line number of the cursor in
> > order to display some information in the status line.  The
> > CursorHold event works fine for this except when a buffer is first
> > opened, as when opening a quickfix error file with -q.  I thought
> > that I could use the BufWinEnter event to grab the initial line
> > number in this case, but it appears to be triggered before the
> > quickfix procedure moves the cursor.
> > 
> > This behavior can be demonstrated as follows.  The source file
> > main.c contains an error at line 5.
> > 
> >     #include <stdio.h>
> > 
> >     main(int argc, char *argv[])
> >     {
> >         exit(0);
> >     }
> > 
> > When an error file is generated and opened with Vim's -q option, the
> > line number at the time of the BufWinEnter event is 1.  I would
> > think it would be 5, the line number that the cursor is on when the
> > buffer is displayed.
> > 
> >     $ make main > make.out 2>&1
> >     $ vim -N -u NONE -i NONE --cmd 'au BufWinEnter * let a=line(".")' -c 
> > 'let b=line(".")' -q make.out
> >     :echo a b
> >     1 5
> > 
> > Is this a bug?  ":help BufWinEnter" says it is triggered "After a
> > buffer is displayed in a window."  It appears to be triggered before
> > the buffer is displayed.
> 
> I think, what you are seeing is the effect of --cmd which means its 
> arguments will be executed early. In your case when the first empty 
> buffer is entered and before the errorfile is read in.

Yes, --cmd does execute its arguments early, "before processing any
vimrc file", but I am using it to define an autocommand.  It's the
timing of the triggering of the autocommand that I think is wrong,
or at least that I don't understand.

Regards,
Gary

-- 
-- 
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/groups/opt_out.

Raspunde prin e-mail lui