This post was originally titled “Prevent Emacs wiping the system clipboard”, which was a rubbish description of what this tip actually covers, so I renamed it! Apologies if you see it twice in your RSS reader.
I wrote previously about adding mouse selections in Emacs to the system clipboard, and here is another tip to integrate the system clipboard more nicely with Emacs. This comes from the fantastic Emacs operating system set of configuration files, which are full of gems like this (thanks to Irreal for pointing me to EOS).
By default, if you copy something to the system clipboard (e.g. some text in firefox) and then copy or kill some text in Emacs, then the text from firefox is lost. If you set the option below in your emacs config file then copying or killing text in Emacs will add the system clipboard text to the kill-ring so that you can find it when you cycle through your clipboard history in Emacs.
;; Save whatever’s in the current (system) clipboard before ;; replacing it with the Emacs’ text. ;; https://github.com/dakrone/eos/blob/master/eos.org (setq save-interprogram-paste-before-kill t)
Hm, apparently `(setq x-select-enable-clipboard t)` defaults to `t` since emacs 24.1. It is a good change, from the “just do what the user wants” point of view.
Maybe its sister variable `save-interprogram-paste-before-kill` could use a more sensible default as well…
LikeLike
It’s far from the only thing which could use more of a sensible default *looks at long `setq` paragraph* 😛
LikeLike