#79 autoflush option for verbosefile


Currently, writes to verbosefile are buffered by the OS, which in most cases is about a 4KiB buffer. This is fine in some cases, such as invoking vim in verbose mode, but in other cases I want to turn on verbose logging to a file while testing something in vim and want to see what's happening right away. For example, I could be tailing a verbosefile while performing actions in vim that are triggering autocmds that call various functions and trying to debug why something's happening. It would be great to be able to see the verbose output in realtime as I perform those actions. Currently, I have to set verbose back to 0 for an fclose() to implicitly flush the verbosefile buffer (verbose_stop() in message.c), then track back through the log to figure out what happened when I wanted to see it. It would be great if there were a vim setting to "autoflush" the verbosefile fd after each line.

There are OS-specific ways to set a descriptor to be line-buffered, but that's a whole big can of worms for a cross-platform behemoth like vim. I've found in the past that a simple fflush() after any newline is the most reliable way to deal with this. Of course, you need to take platform-specific line endings into account for this, but it's not that tricky. This could be done in verbose_write, and perhaps in redir_write if it's so desired. This could use a vim setting such as verbosefile_linebuf=0/1 to conditionally call the fflush().


Log in to post a comment.

Get latest updates about Open Source Projects, Conferences and News.

Sign up for the SourceForge newsletter:

JavaScript is required for this form.

No, thanks