I'm using some VBA scripts which copy Text in MS Outlook from an e-mail message and send it to the clipboard.

If I then paste the clipboard content with Ctrl-Y in Emacs 24.5.1 in Windows 7, the linebreaks are missing and I see a red ^M instead in my emacs buffer.

What can I do to directly insert linebreaks or convert the text in emacs to the "normal" encoding?

My current settings in my .emacs file are

;; file encoding utf-8 preferred
(prefer-coding-system 'utf-8)
(setq coding-system-for-read 'utf-8)
(setq coding-system-for-write 'utf-8)

However: If I copy a text from an e-Mail in MS Outlook to the Clipboard with Ctrl-C and paste it in an emacs-buffer with Ctrl-Y, the linebreaks are ok.


The linebreaks are missing because there is a conflict between your coding system on the desktop and your emacs setup. Emacs can be configured to have different coding systems for the terminal, keyboard and clipboard.

Try to set your clipboard coding system and selection coding system to utf-16-le, i.e.,:

(if (eq system-type 'windows-nt)
      (set-clipboard-coding-system 'utf-16-le)
      (set-selection-coding-system 'utf-16-le))
  (set-selection-coding-system 'utf-8))
(setq locale-coding-system 'utf-8)
(set-terminal-coding-system 'utf-8)
(set-keyboard-coding-system 'utf-8)
(prefer-coding-system 'utf-8)
  • 1
    unfortunately, this does not help but makes things even worse, as Umlauts are now also pasted as \xxx code (like \344 instead of ä). – p.m Jun 3 '16 at 11:11
  • 1
    Try setting (setq x-select-request-type '(UTF8_STRING COMPOUND_TEXT TEXT STRING)) – aagaard Jun 3 '16 at 11:27
  • unfortunately, this does not help either. :( Any other suggestion? – p.m Sep 30 '16 at 12:13

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Not the answer you're looking for? Browse other questions tagged or ask your own question.