|
1 | 1 | ;;; init-x.el --- Tweaks for X sessions. |
2 | 2 |
|
3 | | -(when (eq window-system 'x) |
| 3 | +(when (eq (window-system) 'x) |
4 | 4 | ;; 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) |
7 | 7 |
|
8 | 8 | ;; Define new cut/copy/paste functions for when clipboard interaction is |
9 | 9 | ;; actually desired. |
10 | 10 | (defun x-cut () |
11 | 11 | (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))) |
14 | 15 | (kill-region (region-beginning) |
15 | 16 | (region-end)))) |
16 | 17 | (defun x-copy () |
17 | 18 | (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))) |
20 | 22 | (kill-ring-save (region-beginning) |
21 | 23 | (region-end)))) |
22 | 24 | (defun x-paste () |
23 | 25 | (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)))) |
27 | 29 |
|
28 | 30 | ;; Bind cut/copy/paste to some useful keyboard shortcuts. |
29 | 31 | (global-set-key [S-delete] 'x-cut) |
|
0 commit comments