[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] master a889e02: * packages/xclip/xclip.el: Add tentative WSL supp
From: |
Stefan Monnier |
Subject: |
[elpa] master a889e02: * packages/xclip/xclip.el: Add tentative WSL support |
Date: |
Mon, 13 Jul 2020 11:22:59 -0400 (EDT) |
branch: master
commit a889e024283e0d6d8748b9e95a458accb3105dd2
Author: Stefan Monnier <monnier@iro.umontreal.ca>
Commit: Stefan Monnier <monnier@iro.umontreal.ca>
* packages/xclip/xclip.el: Add tentative WSL support
(xclip-method): New method `powershell`.
(xclip-set-selection, xclip-get-selection):
Add corresponding implementation.
---
packages/xclip/xclip.el | 11 +++++++++++
1 file changed, 11 insertions(+)
diff --git a/packages/xclip/xclip.el b/packages/xclip/xclip.el
index 7e5cae7..71efda3 100644
--- a/packages/xclip/xclip.el
+++ b/packages/xclip/xclip.el
@@ -79,6 +79,8 @@ If non-nil `xclip-program' is ignored.")
(and (executable-find "wl-copy") 'wl-copy) ;github.com/bugaevc/wl-clipboard
(and (executable-find "termux-clipboard-get") 'termux-clipboard-get)
(and (fboundp 'x-create-frame) (getenv "DISPLAY") 'emacs)
+ (and (eq system-type 'gnu/linux) ;FIXME: How do we detect WSL?
+ (executable-find "powershell.exe") 'powershell)
'xclip)
"Method to use to access the GUI's clipboard.
Can be one of `pbpaste' for MacOS, `xclip' or `xsel' for X11,
@@ -90,6 +92,7 @@ and `getclip' under Cygwin, or `emacs' to use Emacs's GUI
code for that."
(const :tag "X11: xsel" xsel)
(const :tag "Wayland: wl-copy" wl-copy)
(const :tag "Termux: termux-clipboard-get/set" termux-clipboard-get)
+ (const :tag "WSL: clip.exe/powershell.exe" powershell)
(const :tag "X11: Emacs" emacs)))
(defcustom xclip-program (symbol-name xclip-method)
@@ -116,6 +119,9 @@ See also `x-set-selection'."
"pbcopy" nil
(replace-regexp-in-string "\\(.*\\)pbpaste" "\\1pbcopy"
xclip-program 'fixedcase))))
+ (`powershell
+ (when (memq type '(clipboard CLIPBOARD))
+ (start-process "clip.exe" nil "clip.exe")))
(`getclip
(when (memq type '(clipboard CLIPBOARD))
(start-process
@@ -164,6 +170,11 @@ See also `x-set-selection'."
(when (memq type '(clipboard CLIPBOARD))
(call-process xclip-program nil standard-output nil
"-Prefer" "txt")))
+ (`powershell
+ (when (memq type '(clipboard CLIPBOARD))
+ (let ((coding-system-for-read 'dos)) ;Convert CR->LF.
+ (call-process "powershell.exe" nil `(,standard-output nil) nil
+ "-command" "Get-Clipboard"))))
(`getclip
(when (memq type '(clipboard CLIPBOARD))
(call-process xclip-program nil standard-output nil)))
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [elpa] master a889e02: * packages/xclip/xclip.el: Add tentative WSL support,
Stefan Monnier <=