I run emacs with a common configuration on osx and linux. I have some custom functions that need to get access to the GUI clipboard. I find interacting with the clipboard a bit of pain - so I've resorted to things like
(shell-command-to-string "pbpaste || xclip -o")
before.
Is there a correct way of doing this (i.e. a single function that intends to work across all GUIs which someone else maintains?).
This came up again in the context of working on a script that might in theory become a library that is shared with other people - so I would prefer not to use hacks in it (though I am currently putting a hack into it).
(car (kill-ring))
does not contain the gui clipboard until you paste. I guess you should use a temporary buffer and paste into it.(current-kill 0)
will return the gui clipboard and updatekill-ring
- so I guess current-kill is the function I want.