pinwheel: Update copy/paste in emacs to work in terminals

This commit is contained in:
Alexander Heldt
2023-11-06 17:01:29 +01:00
parent a501af2209
commit 9514c45210

View File

@@ -83,24 +83,22 @@
** Use wl-clipboard for interprocess copy/paste ** Use wl-clipboard for interprocess copy/paste
#+BEGIN_SRC emacs-lisp #+BEGIN_SRC emacs-lisp
(setq wl-copy-process nil) (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) (defun wl-paste ()
(setq wl-copy-process (make-process :name "wl-copy" (if (and wl-copy-process (process-live-p wl-copy-process))
:buffer nil nil ; should return nil if we're the current paste owner
:command '("wl-copy" "-f" "-n") (shell-command-to-string "wl-paste -n | tr -d \r")))
: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")))
(when (display-graphic-p)
(setq interprogram-cut-function 'wl-copy) (setq interprogram-cut-function 'wl-copy)
(setq interprogram-paste-function 'wl-paste) (setq interprogram-paste-function 'wl-paste))
)
#+END_SRC #+END_SRC
** Don't create backup files, don't create #autosave# files ** Don't create backup files, don't create #autosave# files
#+BEGIN_SRC emacs-lisp #+BEGIN_SRC emacs-lisp