It sounds like transactions in discarded blocks are propagated back to the network to be included in the next block to be generated, is that the case? If so, is that triggered in the client when it discards a fork and accepts the longer chain?
I see some info and discussion on this in the protocol and forums, but it's not entirely clear, and sounds like the heuristic is somewhat complex and non-deterministic (eg, some transactions can just be lost).