Skip to content

Instantly share code, notes, and snippets.

@cpbotha
Last active January 28, 2022 13:56
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save cpbotha/fdd2c5ab3d22a33679c546323ea3bc0b to your computer and use it in GitHub Desktop.
Save cpbotha/fdd2c5ab3d22a33679c546323ea3bc0b to your computer and use it in GitHub Desktop.
;; as of 2021-12-19 with latest master pgtk emacs on non-store WSL I can copy
;; text from other apps into Emacs, but I can't copy text from Emacs into other
;; apps, and so I use this work-around with wl-copy.
;; original value of interprogram-cut-function was gui-select-text.
;; you need to have the wl-clipboard package installed for the wl-copy tool.
;; update 2022-01-28: this work-around still required with WSL 0.51.2.0
(when (getenv "WAYLAND_DISPLAY")
(setq
interprogram-cut-function
(lambda (text)
;; strangest thing: gui-select-text leads to gui-set-selection 'CLIPBOARD
;; text -- if I eval that with some string, it mostly lands on the wayland
;; clipboard, but not when it's invoked from this context.
;; (gui-set-selection 'CLIPBOARD text)
;; without the charset=utf-8 in type, emacs / wl-copy will crash when you paste emojis into a windows app
(start-process "wl-copy" nil "wl-copy" "--trim-newline" "--type" "text/plain;charset=utf-8" text))))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment