0

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 Jul 26 at 11:08
  • Thx. That did it. – Peter_LE_82 Jul 26 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 Jul 26 at 17:32
0

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))

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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