Using Emacs as the Clipboard Manager
Table of Contents
There is already a clipboard manager for Emacs, https://github.com/bburns/clipmon, but there is a serious bug with X-windows:
Warning (2015-12-24): in an X-windows system with clipmon-mode on, bringing up a graphical menu (e.g. Shift+Mouse-1) will cause Emacs to hang. See http://debbugs.gnu.org/cgi/bugreport.cgi?bug=22214. X-windows starts a timer when checking the contents of the clipboard, which interferes with the clipmon timer.
So I cooked up my own solution. In addition to the same functionality as clipmon, I also added a feature to paste anywhere from Emacs the clipboard manager.
1 kill-ring as clipboard manager
My solution is fairly simple: rewrite Glipper, adapt it for Emacs. Glipper is a Clipboard manager for GNOME, it's written in Python.
I updated its source code, so that when there is changes to the clipboard, it will run emacsclient to save the clipboard text in Emacs.
The source code is here glipper.cli.
2 Global Emacs Clipboard Manager
Here, the word “global” means I can use Emacs as clipboard manager in any window, for e.g., Terminal, Browser, and so on.
I have a global hotkey for this function “Super-h y”.
I'm using sawfish as my window manager, so the implementation is straight forward, when I press "Super-h y":
- sawfish will remember the current window
- sawfish will pop-up the Emacs window
Run an Emacs script with emacsclient, which will do the following
a. Remember b. Remember