Skip to content

Commit

Permalink
improve xclip
Browse files Browse the repository at this point in the history
  • Loading branch information
seagle0128 committed Dec 28, 2023
1 parent 639e9cd commit c1a6b7b
Showing 1 changed file with 11 additions and 8 deletions.
19 changes: 11 additions & 8 deletions lisp/init-edit.el
Original file line number Diff line number Diff line change
Expand Up @@ -416,14 +416,17 @@
(setq hs-set-up-overlay #'hs-display-code-line-counts))

;; Copy&paste GUI clipboard from text terminal
(use-package xclip
:init (xclip-mode 1)
:config
;; @see https://github.com/microsoft/wslg/issues/15#issuecomment-1796195663
(when (eq xclip-method 'wl-copy)
(setq interprogram-cut-function
(lambda (text)
(start-process "wl-copy" nil "wl-copy" "--trim-newline" "--type" "text/plain;charset=utf-8" text)))))
(unless sys/win32p
(use-package xclip
:hook (after-init . xclip-mode)
:config
(set-clipboard-coding-system 'gbk)

;; @see https://github.com/microsoft/wslg/issues/15#issuecomment-1796195663
(when (eq xclip-method 'wl-copy)
(setq interprogram-cut-function
(lambda (text)
(start-process "wl-copy" nil "wl-copy" "--trim-newline" "--type" "text/plain;charset=utf-8" text))))))

;; Open files as another user
(unless sys/win32p
Expand Down

4 comments on commit c1a6b7b

@liuhuihz
Copy link

@liuhuihz liuhuihz commented on c1a6b7b Dec 29, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(set-clipboard-coding-system 'gbk) 可能导致 linux 下粘贴乱码
在 init-base.el 有 (set-selection-coding-system 'utf-8) 。

@seagle0128
Copy link
Owner Author

@seagle0128 seagle0128 commented on c1a6b7b Dec 29, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

wsl 中不设置gbk粘贴会乱码。我改下试试。

See ee1981a

@liuhuihz
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

新年快乐!
新的提交修改好了,谢谢!
没用过 WSL , WSL 的 locale 设置是 GBK 吗?

@seagle0128
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

如果不设置GBK,从Windows拷贝中文到WSL中会乱码

Please sign in to comment.