forked from technomancy/emacs-starter-kit
-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathinit-x.el
More file actions
42 lines (38 loc) · 1.49 KB
/
init-x.el
File metadata and controls
42 lines (38 loc) · 1.49 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
;;; init-x.el --- Tweaks for X sessions.
(when (eq (window-system) 'x)
;; Prevent kills from writing to clipboard (slow over remote X sessions).
(setq select-enable-clipboard nil)
(setq select-enable-primary nil)
;; Define new cut/copy/paste functions for when clipboard interaction is
;; actually desired.
(defun x-cut ()
(interactive)
(let ((select-enable-clipboard t))
(gui-set-selection 'CLIPBOARD
(buffer-substring (region-beginning) (region-end)))
(kill-region (region-beginning)
(region-end))))
(defun x-copy ()
(interactive)
(let ((select-enable-clipboard t))
(gui-set-selection 'CLIPBOARD
(buffer-substring (region-beginning) (region-end)))
(kill-ring-save (region-beginning)
(region-end))))
(defun x-paste ()
(interactive)
(let ((clipboard-content (gui-get-selection 'CLIPBOARD)))
(when clipboard-content
(insert clipboard-content))))
;; Bind cut/copy/paste to some useful keyboard shortcuts.
(global-set-key [S-delete] 'x-cut)
(global-set-key [S-backspace] 'x-cut)
(global-set-key [S-kp-delete] 'x-cut)
(global-set-key [C-insert] 'x-copy)
(global-set-key [s-backspace] 'x-copy)
(global-set-key [C-H-help] 'x-copy)
(global-set-key [S-insert] 'x-paste)
(global-set-key [H-S-help] 'x-paste)
(global-set-key [s-mouse-2] 'x-paste)
;; Fix old issue with bitmap font rendering.
(setq x-use-underline-position-properties nil))