Monday, May 31, 2010

Progress indicator for :TOhtml command

I love using the :TOhtml command, and I keep finding more ways to use
it. Recently, I had a large-ish log file (several thousand lines), in
which I wanted to call attention to a few groups of lines, but I
figured people may want the context as well. So, I set up some folds
and some quick syntax highlighting, and went to go create an html copy
of it using the "dynamic folding" feature of the command.

Unfortunately, I discovered that processing such a large file, even
with no syntax highlighting, takes a *very* long time. I probably
should have selected just a smaller area of interest but...

I waited quite a while, and finally hit CTRL-C to stop it. Luckily it
hadn't actually gotten that far (probably about 30%), but I was
worried that it may have been almost done, and all I needed to do was
wait a bit longer.

So anyway, for future use, I wanted to be able to see quickly whether
the conversion was worth waiting for. Therefore, I have written a
patch to add a progress indicator. When I opened the file, I noticed
that indentation is quite a mess (a mix of tabs and spaces, sometimes
in the same line), so I also fixed that up (by using gg=G with noet,
sw=2, sts=2, and ts=2). For clarity, I ran the diff on the file
*after* fixing the ident.

Since the indentation patch is actually *larger* than the file itself,
I have just attached the fully patched file instead of a patch. This
will also make it easier for Windows users to try :-)

Please comment...especially if you know of a better way to accomplish
something similar. I tried using :echon to draw the progress bar, but
the echo was being cleared each time through the main loop, so I
switched to using :echo with a string that is gradually built as the
script processes.

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

No comments:

Post a Comment