clipmon
clipmon copied to clipboard
Clipmon on Windows Modifies Existing Clipboard Text
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 Thank you for figuring this out! I'll include it in the next tagged version, once I can test it on all versions/platforms.