Excluded malign characters in the document id.
Added button to keep the selected documents.

It hides and shows itself automatically. And does nothing else.
Added 'union filter' item to filter list.

Previous filters are cloned into the union filter list item to state what the
union consists of. Their click handlers are lost, so there's no way to restore
the filter list right now.
Selections are separated by || and it looks kind of whacky.
Formatted call to filter_documents().

This solution seems to be the least painful one: filter_documents is called
with an 'union' filter object and it's member 'union' is simply a list of
documents with which the union is composed. An empty list would leave the
documents as they where.
Bypassed union-ized documents from filtering.
Switched to upper-case variable name.

The filter form wasn't doing anything anymore, and I didn't even touch the
keep-selection button. For some reason the js engine gets confused with my
choice of variable names, so I worked around it thusly.
Implemented union of two document sets.

The 'cancel' button still does nothing, but I like how dynamic objects saved
the day ... AGAIN: If the document is an element of filters[0].union, it is
tagged as such. The tag is removed after it has been used.
Changed set separator to <b>&cup;</b>.

It looks awesome and it only appears between two sets or more.
Simplified tagged document filter bypass.

The inital approach was not bad but this looks much simpler and more intuitive.
Implemented remove-button from #keep-selection.

It probably needs more tests but it seems to do what it's supposed to.
Everything is explained in the comments abundantly and the script itself
doesn't look too bad. I've seen worse.