clipmon icon indicating copy to clipboard operation
clipmon copied to clipboard

Clipmon on Windows Modifies Existing Clipboard Text

Open ErikKnowles opened this issue 8 years ago • 1 comments

clipmon--on-clipboard-change calls (kill-new s) , which, if interprogram-cut-function is not nil, winds up placing the new clipboard text right back to the clipboard. Unfortunately, on Windows (at least) this can result in the clipboard text being changed from what the user actually cut or copied.

The reason lies in the fact that by the time clipmon--on-clipboard-change gets the clipboard text it's been altered by emacs -- carriage returns, which are a part of the cr/lf Windows line break, get removed and the text encoding can be altered. This altered text is then used by kill-new to paste back to the Clipboard, replacing the originally copied/cut text.

(I don't know if it would result in any problems, but I think emacs also becomes the Clipboard owner for every newly-copied piece of text, regardless of the application the cut or copy originates from.)

I've made the following advice function to get around the problem:

(defadvice clipmon--on-clipboard-change (around stop-clipboard-parsing activate) (let ((interprogram-cut-function nil)) ad-do-it))

Basically, it prevents (kill-new s) from disturbing the Clipboard.

ErikKnowles avatar Jan 04 '17 04:01 ErikKnowles

@ErikKnowles Thank you for figuring this out! I'll include it in the next tagged version, once I can test it on all versions/platforms.

bburns avatar Jan 29 '18 11:01 bburns