Did you find that by creating an editor while writing your book, you were able to stay more engaged that if you had simply used a text editor and pushed off formatting until the content was done?
Though what _was_ a distraction was having to stop writing to switch contents and fix bugs or add features to my editor. This was still happening when I was in the final stages of the book because any time I context-switched, I tried to spend as little time on it as possible so I could get back to work. In retrospect, maybe I should have just taken a day or two to focus on the editor and then never go back.
Fortunately, I'm still using NJEdit for other things now that the book is done, so it seems to have been worth the investment. I've also open-sourced it so others can use it or fork it for their own needs, so hopefully others can find a way to benefit from it.
My editor can export to either DocBook XML or HTML, so I used the former to publish my book and the latter to publish essays on my web site. I also added support for slurping in source code from my repository so that I could be sure that the code samples in my writing actually worked. This was a bit of a pain, but definitely paid off, as readers are often infuriated by code samples that don't work. So far, no errata for code samples have been reported: http://oreilly.com/catalog/errata.csp?isbn=0636920001416