Skip to content

Commit 03ea25b

Browse files
committed
Fix X clipboard functions for modern Emacs
1 parent 9abcd91 commit 03ea25b

File tree

1 file changed

+12
-10
lines changed

1 file changed

+12
-10
lines changed

personal/init-x.el

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,31 @@
11
;;; init-x.el --- Tweaks for X sessions.
22

3-
(when (eq window-system 'x)
3+
(when (eq (window-system) 'x)
44
;; Prevent kills from writing to clipboard (slow over remote X sessions).
5-
(setq interprogram-cut-function nil)
6-
(setq interprogram-paste-function nil)
5+
(setq select-enable-clipboard nil)
6+
(setq select-enable-primary nil)
77

88
;; Define new cut/copy/paste functions for when clipboard interaction is
99
;; actually desired.
1010
(defun x-cut ()
1111
(interactive)
12-
(let ((interprogram-cut-function
13-
'x-select-text))
12+
(let ((select-enable-clipboard t))
13+
(gui-set-selection 'CLIPBOARD
14+
(buffer-substring (region-beginning) (region-end)))
1415
(kill-region (region-beginning)
1516
(region-end))))
1617
(defun x-copy ()
1718
(interactive)
18-
(let ((interprogram-cut-function
19-
'x-select-text))
19+
(let ((select-enable-clipboard t))
20+
(gui-set-selection 'CLIPBOARD
21+
(buffer-substring (region-beginning) (region-end)))
2022
(kill-ring-save (region-beginning)
2123
(region-end))))
2224
(defun x-paste ()
2325
(interactive)
24-
(let ((interprogram-paste-function
25-
'x-cut-buffer-or-selection-value))
26-
(yank)))
26+
(let ((clipboard-content (gui-get-selection 'CLIPBOARD)))
27+
(when clipboard-content
28+
(insert clipboard-content))))
2729

2830
;; Bind cut/copy/paste to some useful keyboard shortcuts.
2931
(global-set-key [S-delete] 'x-cut)

0 commit comments

Comments
 (0)