emacs-elpa-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[elpa] externals/xclip 9407231 12/18: * packages/xclip/xclip.el: Add ten


From: Stefan Monnier
Subject: [elpa] externals/xclip 9407231 12/18: * packages/xclip/xclip.el: Add tentative support for wl-clipboard
Date: Sat, 28 Nov 2020 14:27:56 -0500 (EST)

branch: externals/xclip
commit 9407231981f6762fd4707423d19962db3cd60d27
Author: Stefan Monnier <monnier@iro.umontreal.ca>
Commit: Stefan Monnier <monnier@iro.umontreal.ca>

    * packages/xclip/xclip.el: Add tentative support for wl-clipboard
    
    (xclip-method): New possible value.
    (xclip-set-selection, xclip-get-selection): Handle it.
---
 xclip.el | 16 ++++++++++++++++
 1 file changed, 16 insertions(+)

diff --git a/xclip.el b/xclip.el
index 6302ff9..2c7be8c 100644
--- a/xclip.el
+++ b/xclip.el
@@ -74,6 +74,7 @@ If non-nil `xclip-program' is ignored.")
    (and (eq system-type 'cygwin) (executable-find "getclip") 'getclip)
    (and (executable-find "xclip") 'xclip)
    (and (executable-find "xsel") 'xsel)
+   (and (executable-find "wl-copy") 'wl-copy) ;github.com/bugaevc/wl-clipboard
    (and (fboundp 'x-create-frame) (getenv "DISPLAY") 'emacs)
    'xclip)
   "Method to use to access the GUI's clipboard.
@@ -84,6 +85,7 @@ and `getclip' under Cygwin, or `emacs' to use Emacs's GUI 
code for that."
           (const :tag "Cygwin: getclip/putclip" getclip)
           (const :tag "X11: xclip" xclip)
           (const :tag "X11: xsel" xsel)
+          (const :tag "Wayland: wl-copy" wl-copy)
           (const :tag "X11: Emacs" emacs)))
 
 (defcustom xclip-program (symbol-name xclip-method)
@@ -128,6 +130,12 @@ See also `x-set-selection'."
                  (start-process
                   "xsel" nil xclip-program
                   "-i" (concat "--" (downcase (symbol-name type))))))
+              (`wl-copy
+               (when (and (getenv "WAYLAND_DISPLAY")
+                          (memq type '(clipboard CLIPBOARD primary PRIMARY)))
+                 (apply #'start-process
+                        "wl-copy" nil xclip-program
+                        (if (memq type '(primary PRIMARY)) '("-p")))))
               (method (error "Unknown `xclip-method': %S" method)))))
       (when proc
         (process-send-string proc data)
@@ -160,6 +168,14 @@ See also `x-set-selection'."
                                  secondary SECONDARY)))
            (call-process xclip-program nil standard-output nil
                          "-o" (concat "--" (downcase (symbol-name type))))))
+        (`wl-copy
+         (when (and (getenv "WAYLAND_DISPLAY")
+                    (memq type '(clipboard CLIPBOARD primary PRIMARY)))
+           (apply #'call-process
+                  (replace-regexp-in-string "\\(.*\\)copy" "\\1paste"
+                                            xclip-program 'fixedcase)
+                  nil standard-output nil
+                  (if (memq type '(primary PRIMARY)) '("-p")))))
         (method (error "Unknown `xclip-method': %S" method))))))
 
 ;;;###autoload



reply via email to

[Prev in Thread] Current Thread [Next in Thread]