Option to only save history on closing a view

This patch adds a setting, "history_on_close", that when set to "true" will only run the history check when a view is closed. This reduces the stored changes to major ones.

I was noticing that when working on long, frequently-saved-and-compiled LaTeX documents that my history was full of changes of a sentence or two rather than of major changes, and this seemed like a potentially useful way to rectify it.