From cd24a73429fcce6ae23ed1557d0f2562ce533f2d Mon Sep 17 00:00:00 2001 From: Hong Xu Date: Sun, 7 Jul 2019 10:29:31 -0700 Subject: [PATCH] Add cliphist to the xclipboard layer. --- CHANGELOG.develop | 4 ++++ layers/+tools/xclipboard/README.org | 25 +++++++++++++++++++++---- layers/+tools/xclipboard/config.el | 15 +++++++++++++++ layers/+tools/xclipboard/funcs.el | 14 ++++++++++++++ layers/+tools/xclipboard/packages.el | 13 ++++++++++++- 5 files changed, 66 insertions(+), 5 deletions(-) create mode 100644 layers/+tools/xclipboard/config.el create mode 100644 layers/+tools/xclipboard/funcs.el diff --git a/CHANGELOG.develop b/CHANGELOG.develop index e2733b960..c6b77a325 100644 --- a/CHANGELOG.develop +++ b/CHANGELOG.develop @@ -2598,6 +2598,10 @@ Other: (thanks to Voleking) **** Xclipboard - Added Requirements documentation (thanks to Chris Glass) +- Added =cliphist= with the following bindings: (thanks to Hong Xu) + - ~SPC x P~ paste item from history (cliphist must be enabled) + - ~SPC x R~ rectangly paste item from history (cliphist must be enabled) + - ~SPC x s~ select item from history (cliphist must be enabled) **** Ycmd - Search for =compile_commands.json= in build sub-directory (thanks to Amos Bird and Eivind Fonn) diff --git a/layers/+tools/xclipboard/README.org b/layers/+tools/xclipboard/README.org index 2406121df..b43e96e99 100644 --- a/layers/+tools/xclipboard/README.org +++ b/layers/+tools/xclipboard/README.org @@ -6,6 +6,8 @@ - [[#description][Description]] - [[#features][Features:]] - [[#requirements][Requirements]] +- [[#usage][Usage]] + - [[#clipboard-manager-integration][Clipboard Manager Integration]] - [[#key-bindings][Key bindings]] * Description @@ -14,6 +16,7 @@ ** Features: - adds copy support to the X-clipboard from the terminal. - adds paste support to the X-clipboard from the terminal. +- [[https://github.com/redguardtoo/cliphist][cliphist]] package: integration with clipboard managers on Linux and Mac. * Requirements This layer depends on a few platform-specific command-line tools: @@ -23,9 +26,23 @@ This layer depends on a few platform-specific command-line tools: Note that =xsel= might not be installed by default on e.g. Ubuntu systems. +Clipboard manager integration requires [[http://parcellite.sourceforge.net/][Parcellite]] or [[https://github.com/CristianHenzel/ClipIt][ClipIt]] installed on Linux +and [[https://github.com/TermiT/Flycut][Flycut]] installed on MacOS. + +* Usage +** Clipboard Manager Integration + Clipboard manager integration can be enabled by setting =xclipboard-enable-cliphist= to =t=. + #+BEGIN_SRC emacs-lisp + dotspacemacs-configuration-layers '( + (xclipboard :variables xclipboard-enable-cliphist t)) + #+END_SRC + * Key bindings -| Key binding | Description | -|-------------+---------------------------------------------| -| ~SPC x p~ | Paste clipboard contents at cursor position | -| ~SPC x y~ | Copy selection to clipboard | +| Key binding | Description | +|-------------+--------------------------------------------------------------| +| ~SPC x p~ | Paste clipboard contents at cursor position | +| ~SPC x y~ | Copy selection to clipboard | +| ~SPC x P~ | paste item from history (cliphist must be enabled) | +| ~SPC x R~ | rectangly paste item from history (cliphist must be enabled) | +| ~SPC x s~ | select item from history (cliphist must be enabled) | diff --git a/layers/+tools/xclipboard/config.el b/layers/+tools/xclipboard/config.el new file mode 100644 index 000000000..1a099f49b --- /dev/null +++ b/layers/+tools/xclipboard/config.el @@ -0,0 +1,15 @@ +;;; config.el --- xclipboard configuration File for Spacemacs +;; +;; Copyright (c) 2012-2019 Sylvain Benner & Contributors +;; +;; Author: Hong Xu +;; URL: https://github.com/syl20bnr/spacemacs +;; +;; This file is not part of GNU Emacs. +;; +;;; License: GPLv3 + +;; Variables + +(defvar xclipboard-enable-cliphist nil + "If non-nil, cliphist is enabled.") diff --git a/layers/+tools/xclipboard/funcs.el b/layers/+tools/xclipboard/funcs.el new file mode 100644 index 000000000..7c7a5c2f4 --- /dev/null +++ b/layers/+tools/xclipboard/funcs.el @@ -0,0 +1,14 @@ +;;; funcs.el --- xclipboard layer functions file for Spacemacs. +;; +;; Copyright (c) 2012-2019 Sylvain Benner & Contributors +;; +;; Author: Hong Xu +;; URL: https://github.com/syl20bnr/spacemacs +;; +;; This file is not part of GNU Emacs. +;; +;;; License: GPLv3 + +(defun spacemacs/xclipboard-cliphist-paste-item-rectangle () + (interactive) + (cliphist-paste-item 1)) diff --git a/layers/+tools/xclipboard/packages.el b/layers/+tools/xclipboard/packages.el index 46b1df864..e87872c5a 100644 --- a/layers/+tools/xclipboard/packages.el +++ b/layers/+tools/xclipboard/packages.el @@ -1,9 +1,10 @@ ;;; packages.el --- xclipboard layer packages file for Spacemacs. ;; -;; Copyright (c) 2012-2018 Sylvain Benner & Contributors +;; Copyright (c) 2012-2019 Sylvain Benner & Contributors ;; ;; Authors: Charles Weill ;; Google LLC. +;; Hong Xu ;; URL: https://github.com/syl20bnr/spacemacs ;; ;; This file is not part of GNU Emacs. @@ -13,8 +14,18 @@ (defconst xclipboard-packages '( (spacemacs-xclipboard :location local) + (cliphist :requires ivy + :toggle xclipboard-enable-cliphist) )) +(defun xclipboard/init-cliphist () + (use-package cliphist + :init (spacemacs/set-leader-keys + "xP" 'cliphist-paste-item + "xR" 'spacemacs/xclipboard-cliphist-paste-item-rectangle + "xs" 'cliphist-select-item) + :config (setq cliphist-cc-kill-ring t))) + (defun xclipboard/init-spacemacs-xclipboard () (use-package spacemacs-xclipboard :init (spacemacs/set-leader-keys