I’m using Aquamacs, a macOS variant of Emacs. I’m writing an ELisp function that needs to paste the OS clipboard’s content. I tried using both (yank)
and (cua-paste nil)
(I’m not sure about the argument cua-paste
expects, though).
The problem is that when I copy text from another application, the text pasted is not that one, but rather whatever content was last pasted in Aquamacs.
If I first paste the text manually in Aquamacs once, using ⌘V, then ulterior calls to my function do paste that, as desired.
What code can I use to paste the contents of the OS clipboard?
The yank
command is only for Emacs' own internal system for cutting and pasting, which is more powerful than your standard operating system's variant. If you want to paste contents from the latter (e.g. text you have cut or copied from another application), use the command clipboard-yank
.