> Not just comment: we should document that every implementation of > gui-get-selection should return either a valid timestamp (and say what > is a valid timestamp) or nil, meaning 'CLIPBOARD 'TIMESTAMP is > unsupported. You are right that it is a dangerous assumption, and it's also hard to test and probably unnecessary. So I have changed the code to check the window-system variable instead and only use timestamps for X and haiku (I don't actually know the list of systems that support it, I have included haiku because it is also in the list of systems that support reliably gui-backend-selection-owner-p, according to the code). I also have defined the functions gui--set-last-clipboard/primary-selection and gui--clipboard/primary-selection-unchanged-p to just change the lines (setq gui--last-selected-text-clipboard/primary text) and (equal text gui--last-selected-text-clipboard/primary) with them. They behave exactly the same for systems other than X and haiku, and are backwards compatible with setting or reading directly the original gui--last-selected-text-clipboard/primary variable in other places. I have assumed this last thing (being backwards compatible) was the reason why Po Lu suggested to use text properties instead of changing the gui--last-selected-text-clipboard/primary variable, so I have taken the liberty of moving away from that idea and using the new variables gui--last-selection-timestamp-clipboard and gui--last-selection-timestamp-primary instead, which simplify the code. So here is the final, hopefully definitive patch, attached to the email and commented below: