-
Notifications
You must be signed in to change notification settings - Fork 0
/
screen.el
69 lines (67 loc) · 2.49 KB
/
screen.el
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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
;; This file was written (I think) by Andreas Marschke, you can find it at
;; https://github.com/andreas-marschke/emacs-config/blob/master/rc/emacs-rc-screen.el
;; No license supplied, so copyright is his :)
;;
;; With Screen between Emacs and the "real" terminal, it doesn't occur
;; to Emacs to translate some keybindings. Teach it about a handful
;; that are important to me (because paredit uses them). Don't bother
;; looking at $COLORTERM, since after screen -xRR or screen -dRR, it
;; will be inaccurate.
(mapc (lambda (x)
(define-key function-key-map (car x) (cdr x)))
(nconc
;; rxvt-unicode
'(("\e[1~" . [home])
("\e[4~" . [end])
("\e[5~" . [prior])
("\e[6~" . [next])
("\e[a" . [S-up])
("\e[b" . [S-down])
("\e[c" . [S-right])
("\e[d" . [S-left])
("\eOa" . [C-up])
("\eOb" . [C-down])
("\eOc" . [C-right])
("\eOd" . [C-left])
("\eOm" . [kp-subtract])
("\eOj" . [kp-multiply])
("\eOo" . [kp-divide])
("\eOM" . [kp-enter]))
;; xterm
'(("\e[1;3A" . [M-up])
("\e[1;3B" . [M-down])
("\e[1;3C" . [M-right])
("\e[1;3D" . [M-left])
("\e[1;5A" . [C-up])
("\e[1;5B" . [C-down])
("\e[1;5C" . [C-right])
("\e[1;5D" . [C-left]))
;; libvte (gnome-terminal, xfce4-terminal)
'(("\eO3A" . [M-up])
("\eO3B" . [M-down])
("\eO3C" . [M-right])
("\eO3D" . [M-left])
("\eO5A" . [C-up])
("\eO5B" . [C-down])
("\eO5C" . [C-right])
("\eO5D" . [C-left])
("\eO7A" . [C-M-up])
("\eO7B" . [C-M-down])
("\eO7C" . [C-M-right])
("\eO7D" . [C-M-left])
("\e[Z" . [S-iso-lefttab]))))
;; Every time any command is run, reify the frame title. If it has
;; changed, tell screen what the new title is.
(when (fboundp 'format-mode-line)
(defvar frame-title nil)
(add-hook 'post-command-hook
(lambda ()
(when (or (not (featurep 'multi-tty))
(and (featurep 'multi-tty)
(tty-type)
(string-match "\\`screen" (tty-type))))
(let ((frame-title* (format-mode-line frame-title-format)))
(unless (equal frame-title frame-title*)
(send-string-to-terminal
(concat "\ek" (setq frame-title frame-title*) "\e\\"))))))))
(provide 'screen)