OS Debian GNU/Linux 7 emacs-24.3

I want to save the content of the clipboard or the last item of the kill-ring (depending whats newer) as a string so that I can do stuff with it in a eLisp function. At the moment I use this:

  (setq zwischenablage (car kill-ring))

I have 2 problems at the moment:

  1. When the text was copied in emacs and was highlighted something like "#("Wechseln" 0 8 (fontified t face font-lock-doc-face))" is saved in the string. For some reason yank-handled-properties seems not to be applied.
  2. When I copy text from outside emacs like the browser or so it is not used. I have to yank it and after this my function works fine.

Does anyone know any solution for these problems?

  • (setq zwischenablage (current-kill 0 t)). gnu.org/software/emacs/manual/html_node/elisp/…
    – muffinmad
    Commented Jul 26, 2019 at 11:08
  • Thx. That did it. Commented Jul 26, 2019 at 14:04
  • @muffinmad: Please post your comment as an answer. You might want to also explain why what OP tried doesn't work. OP: please consider accepting muffinmad's answer, if it solves your problem.
    – Drew
    Commented Jul 26, 2019 at 17:32

2 Answers 2


According to documentation of the kill-ring variable, interact with the kill ring directly is not recommended:

Since the kill ring is supposed to interact nicely with cut-and-paste facilities offered by window systems, use of this variable should interact nicely with interprogram-cut-function and interprogram-paste-function. The functions kill-new, kill-append, and current-kill are supposed to implement this interaction; you may want to use them instead of manipulating the kill ring directly.

In this case solution is (setq zwischenablage (current-kill 0 t))


I'm on Windows 10, and I'm not sure if this answer applies to other OSs; but it may help. I'm currently using Emacs 27.1, and I'm working on my init.el. I had a line at the bottom of the file which was preventing the startup screen showing. I wanted a way to move the line to somewhere at the top of my configuration file.

While there are some neat functions to do this (in another Stack Exchange answer), I wanted an out of the box solution. The command Ctrl + K kills a line from the cursor and it seems to also copy the contents of that line to the clipboard.

What I ended up doing was pressing Ctrl + A, Ctrl + K. And to paste, I did Ctrl + Y.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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