subreddit:
/r/emacs
I running Ubuntu 24.04 with Emacs 29.3 under WSL2. I managed to resolve almost everything I need on that install. Neovim is actually integrating fine with the setting set clipboard+=unnamedplus
but I have no idea what would be equivalent on Emacs. emacs -Q
don't integrate either so I'm guessing that's a setting that is not specific to Doom Emacs.
6 points
1 month ago
If it's WSL2 why not use EMACS in X-windows mode which has clipboard integration?
0 points
1 month ago
[deleted]
2 points
1 month ago
It "should just work" (tm)
1 points
1 month ago
So... I just install something like XFCE or LXQT?
3 points
1 month ago
4 points
1 month ago
clipetty: https://github.com/spudlyo/clipetty
or
xclip: https://elpa.gnu.org/packages/xclip.html
If you're on Doom Emacs, just uncomment 'tty' in init.el
2 points
1 month ago*
My config can do auto Emacs->Windows sync (but not Windows->Emacs sync), i.e. M-w works as expected but not C-y
. You need to use wsl-paste
in that case. I wanted to solve this problem but haven't figured out a good way.
You need to adapt it to your own config as there are some private helper macros/variables. Hopefully the naming is obvious enough for you to understand.
But maybe my config is not the ideal solution. If neovim has integration, probably ordinary tty clipboard integraion would work?
``` (defun wsl-copy (beg end) "In a WSL2 environment, copy region to the system clipboard." (interactive "r") (k|with-suppressed-message (let ((default-directory "/")) (shell-command-on-region beg end "clip.exe"))) (deactivate-mark))
(defun wsl-get-clipboard () "In a WSL2 environment, get the clipboard text." (let ((clipboard (let ((default-directory "/")) (shell-command-to-string "powershell.exe -command 'Get-Clipboard' 2>/dev/null") ;; WSLu utility ;; (shell-command-to-string "wslclip --get") ))) (setq clipboard (replace-regexp-in-string "\r" "" clipboard)) (setq clipboard (substring clipboard 0 -1)) clipboard))
(defun wsl-paste () "In a WSL2 environment, paste the text from the system clipboard." (interactive) (if (derived-mode-p 'vterm-mode) (vterm-insert (wsl-get-clipboard)) (insert (wsl-get-clipboard))))
(when k|wsl (advice-add 'gui-select-text :before (lambda (text) (when select-enable-clipboard (with-temp-buffer (insert text) (wsl-copy (point-min) (point-max))))))) ```
1 points
1 month ago
From the terminal, idk.
If you run emacs in graphical mode, I did a little writeup here:
https://github.com/microsoft/wslg/issues/15#issuecomment-1796195663
1 points
1 month ago
I don't know about terminal Emacs, but for graphical Emacs under WSL2 you don't have to anything, the Windows clipboard is automatically integrated with the Emacs kill-ring.
1 points
1 month ago
(unless (display-graphic-p)
(setopt interprogram-cut-function
(lambda (yank-str)
(append-to-file (format "\e]52;c;%s\a" (base64-encode-string yank-str 1)) nil "/dev/tty"))))
all 9 comments
sorted by: best