Unified focus state save/restore mechanism for both buffer switching and minibuffer
This simplifies the code and makes it more robust to buffer switches
while the minibuffer is open. This also reduces chance of bugs due to
code duplication (one in isearch.js was fixed).
This also incorporates a patch by Joren Van Onder <joren.vanonder@gmail.com>:
When opening a hyperlink with its target attribute set to "_blank" a
new buffer is opened. When there is no content handler for the
mimetype a content_handler_prompt is opened and the new (blank) buffer
is killed. saved_focused_frame then references a destroyed object.
A simple example of what used to trigger the bug (unless a content
handler for midi files is available):
<a href="a.mid" target="_blank">link</a>