diff options
author | William Carroll <wpcarro@gmail.com> | 2019-10-09T11·13+0100 |
---|---|---|
committer | William Carroll <wpcarro@gmail.com> | 2019-12-24T15·21+0000 |
commit | 6b456c1b7a4f6899f063a6e65355af51901d9c7a (patch) | |
tree | cfc70d74818ae9fabdbbfb0cf16cce092e4c1a09 /configs/shared/.emacs.d/wpc/clipboard.el | |
parent | a7c72adb2ebec1e497fc040eaf3551d564d61a5b (diff) |
Massive configuration overhaul
Currently paying the price of months of non-diligent git usage. Here's what has changed. - Theming support in Gvcci and wpgtk - Dropping support for i3 - Supporting EXWM - Many Elisp modules - Collapsed redundant directories in ./configs
Diffstat (limited to 'configs/shared/.emacs.d/wpc/clipboard.el')
-rw-r--r-- | configs/shared/.emacs.d/wpc/clipboard.el | 74 |
1 files changed, 74 insertions, 0 deletions
diff --git a/configs/shared/.emacs.d/wpc/clipboard.el b/configs/shared/.emacs.d/wpc/clipboard.el new file mode 100644 index 000000000000..975e06c5064f --- /dev/null +++ b/configs/shared/.emacs.d/wpc/clipboard.el @@ -0,0 +1,74 @@ +;;; clipboard.el --- Working with X11's pasteboard -*- lexical-binding: t -*- +;; Author: William Carroll <wpcarro@gmail.com> + +;;; Commentary: +;; Simple functions for copying and pasting. +;; +;; Integrate with bburns/clipmon so that System Clipboard can integrate with +;; Emacs's kill-ring. +;; +;; Wish list: +;; - Create an Emacs integration with github.com/cdown/clipmenud. + +;;; Code: + +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +;; Dependencies +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; + +(require 'bytes) + +;; autoinsert feature feels unappealing at first attempt. +(use-package clipmon + :config + ;; If this is too large, it could be set machine-dependently, so use + ;; `clipboard/print-clipboard-size' to help troubleshoot this if it becomes + ;; problematic. + (setq kill-ring-max 500) + (add-to-list 'after-init-hook #'clipmon-mode-start) + (clipmon-mode 1)) + +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +;; Library +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; + +(defvar clipboard/install-kbds? t + "When t, install keybindings.") + +(defun clipboard/copy (x) + "Copy string, X, to X11's clipboard." + (kill-new x) + (message "Copied!")) + +(defun clipboard/paste () + "Paste contents of X11 clipboard." + (yank) + (message "Pasted!")) + +(defun clipboard/print-clipboard-size () + "Message the size (in Bytes) of `kill-ring'." + (interactive) + (->> (clipmon-kill-ring-total) + bytes/to-string + message)) + +(defun clipboard/ivy-select () + "Use counsel to copy the selected entry to the system clipboard. +NOTE: A function, `counsel-yank-pop', exists that does something similar. + However instead of copying the entry to the system clipboard, it inserts it + where the current point is." + (interactive) + (ivy-read "kill-ring: " (counsel--yank-pop-kills) + :require-match t + :action #'clipboard/copy)) + +;; TODO: Support ivy-actions to insert into an Emacs buffer when an Emacs buffer +;; was the last active buffer. However, if an X window is the last buffer, +;; maybe use xdotool to insert the selected entry. This would be a bit of a +;; DWIM command. +(when clipboard/install-kbds? + (exwm-input-set-key + (kbd "C-M-v") #'clipboard/ivy-select)) + +(provide 'clipboard) +;;; clipboard.el ends here |