From 9514c45210069cd7264749a7253371ad85414c2a Mon Sep 17 00:00:00 2001 From: Alexander Heldt Date: Mon, 6 Nov 2023 17:01:29 +0100 Subject: [PATCH] pinwheel: Update copy/paste in `emacs` to work in terminals --- hosts/pinwheel/modules/emacs/config.org | 28 ++++++++++++------------- 1 file changed, 13 insertions(+), 15 deletions(-) diff --git a/hosts/pinwheel/modules/emacs/config.org b/hosts/pinwheel/modules/emacs/config.org index 1eb76ca..7bed5ed 100644 --- a/hosts/pinwheel/modules/emacs/config.org +++ b/hosts/pinwheel/modules/emacs/config.org @@ -83,24 +83,22 @@ ** Use wl-clipboard for interprocess copy/paste #+BEGIN_SRC emacs-lisp (setq wl-copy-process nil) + (when (string-prefix-p "wayland" (getenv "WAYLAND_DISPLAY")) + (defun wl-copy (text) + (setq wl-copy-process (make-process :name "wl-copy" + :buffer nil + :command '("wl-copy" "-f" "-n") + :connection-type 'pipe)) + (process-send-string wl-copy-process text) + (process-send-eof wl-copy-process)) - (defun wl-copy (text) - (setq wl-copy-process (make-process :name "wl-copy" - :buffer nil - :command '("wl-copy" "-f" "-n") - :connection-type 'pipe)) - (process-send-string wl-copy-process text) - (process-send-eof wl-copy-process)) + (defun wl-paste () + (if (and wl-copy-process (process-live-p wl-copy-process)) + nil ; should return nil if we're the current paste owner + (shell-command-to-string "wl-paste -n | tr -d \r"))) - (defun wl-paste () - (if (and wl-copy-process (process-live-p wl-copy-process)) - nil ; should return nil if we're the current paste owner - (shell-command-to-string "wl-paste -n | tr -d \r"))) - - (when (display-graphic-p) (setq interprogram-cut-function 'wl-copy) - (setq interprogram-paste-function 'wl-paste) - ) + (setq interprogram-paste-function 'wl-paste)) #+END_SRC ** Don't create backup files, don't create #autosave# files #+BEGIN_SRC emacs-lisp