Saturday, March 27, 2010

Trying to suppress "--No files in buffer--" message within plugin

I'm trying to eliminate a little cosmetic glitch in the Command-T
plugin (http://www.vim.org/scripts/script.php?script_id=3025), wherein
the status line will show "--No files in buffer--" after a couple of
files have been opened, and will only go away when the user provokes a
redraw.

The plug-in creates a temporary buffer with:

:silent! botright

Displays some stuff, and once it's finished, blows away the temporary
buffer with :bwipeout. The plug-in code can be inspected at
http://git.wincent.com/command-t.git

The strange thing is that the "--No files in buffer--" message doesn't
appear the first time the plug-in displays, nor the second time, but
it does on the third, fourth and all other subsequent times.

The other confusing thing is that the plugin actually is
calling :redraw itself, but only a user-initated action will clear the
unwanted message (ie. a key press), from which I deduce that the
message is being printed _after_ the plugin has finished its initial
display logic and has returned control to VIM.

I've looked at the VIM source code to see what kind of situations the
"--No files in buffer--" message gets displayed, but I can only see
three places (ml_delete_int() in memline.c, cursor_pos_info() in
ops.c, fileinfo() in buffer.c). Of those, cursor_pos_info() looks to
be called only in response to user action (<C-g>), ml_delete_int() is
called via ml_delete() from a bunch of places, and fileinfo() likewise
has a few different callsites, so I am not really sure when/why the
message is being generated.

As I mentioned above, I suspect VIM is emitting the message after the
plug-in returns control, and that makes me suspect that fileinfo()
might be the ultimate source seeing as it seems to be tied in with a
global variable "need_fileinfo" which looks to be used as a flag to
request deferred display of the file information.

Can anyone shine a ray of light on what's happening here? And of most
interest to me, how I could modify the plug-in to suppress the
message?

Cheers,
Wincent

--
You received this message from the "vim_use" 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

To unsubscribe from this group, send email to vim_use+unsubscribegooglegroups.com or reply to this email with the words "REMOVE ME" as the subject.

No comments: