-
Notifications
You must be signed in to change notification settings - Fork 0
/
uppercut.el
165 lines (150 loc) · 4.34 KB
/
uppercut.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
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
(defun uc-scroll-one-down (n)
(interactive "p")
;;(previous-line n)
(scroll-down-line n)
)
(defun uc-scroll-one-up (n)
(interactive "p")
;; (next-line n)
(scroll-up-line n)
)
(defun uc-scroll-many-down (n)
(interactive "p")
;;(previous-line n)
(scroll-down-line 5)
)
(defun uc-scroll-many-up (n)
(interactive "p")
;; (next-line n)
(scroll-up-line 5)
)
(defun uc-kill-or-cut (n)
(interactive "p")
(if (use-region-p)
(kill-region (region-beginning) (region-end) t)
(kill-line)
)
)
(defun uc-mark-till-end-of-line ()
(interactive)
(end-of-line)
(setq mark-active t)
)
(defun uc-drag-this (n)
(interactive "p")
(let (buff deactivate-mark start end)
(if (not(use-region-p))
(list
(end-of-line)
(push-mark (line-beginning-position))
)
)
(if (< (point) (mark))
(list
(setq end (mark))
(setq start (point))
(push-mark start)
(goto-char end)
)
)
(if (= (point) (line-beginning-position))
(left-char 1)
)
(setq end (line-end-position))
(goto-char (region-beginning))
(push-mark (line-beginning-position))
(goto-char end)
(right-char 1)
(setq buff
(buffer-substring-no-properties
(region-beginning)
(region-end)
)
)
(delete-region
(region-beginning)
(region-end)
)
(beginning-of-line)
(forward-line n)
(beginning-of-line)
(setq start (point))
(insert buff)
(left-char 1)
(setq end (line-end-position))
(indent-region start end)
(push-mark start)
(setq mark-active t)
)
)
(defun uc-drag-this-up ()
(interactive)
(uc-drag-this -1)
)
(defun uc-drag-this-down ()
(interactive)
(uc-drag-this 1)
)
(defun uc-add-line-below ()
(interactive)
(list
(move-end-of-line 1)
(newline 1)
(indent-for-tab-command)
)
)
(define-minor-mode uppercut-mode
"My personal keybindings"
:global t
:lighter " uppercut"
:keymap (let
((map (make-keymap)))
(define-key map (kbd "H-o") 'Control-X-prefix)
(define-key map (kbd "H-i") (kbd "<up>"))
(define-key map (kbd "H-<tab>") (kbd "<tab>"))
(define-key map (kbd "H-j") (kbd "<left>"))
(define-key map (kbd "H-k") (kbd "<down>"))
(define-key map (kbd "H-l") (kbd "<right>"))
(define-key map (kbd "H-I") (kbd "S-<up>"))
(define-key map (kbd "H-J") (kbd "S-<left>"))
(define-key map (kbd "H-K") (kbd "S-<down>"))
(define-key map (kbd "H-L") (kbd "S-<right>"))
(define-key map (kbd "H-:") 'uc-mark-till-end-of-line)
(define-key map (kbd "C-H-i") (kbd "C-<up>"))
(define-key map (kbd "C-H-k") (kbd "C-<down>"))
(define-key map (kbd "C-H-j") (kbd "C-<left>"))
(define-key map (kbd "C-H-l") (kbd "C-<right>"))
(define-key map (kbd "M-H-i") 'backward-paragraph)
(define-key map (kbd "M-H-k") 'forward-paragraph)
(define-key map (kbd "M-H-l") (kbd "M-<right>"))
(define-key map (kbd "M-H-j") (kbd "M-<left>"))
(define-key map (kbd "C-M-H-i") (kbd "M-H-<up>"))
(define-key map (kbd "C-M-H-k") (kbd "M-H-<down>"))
(define-key map (kbd "C-M-H-j") (kbd "M-H-<left>"))
(define-key map (kbd "C-M-H-l") (kbd "M-H-<right>"))
(define-key map (kbd "H-u") 'undo-only)
(define-key map (kbd "H-x") 'uc-kill-or-cut)
(define-key map (kbd "H-M-x") 'kill-whole-line)
(define-key map (kbd "H-y") 'yank)
(define-key map (kbd "H-M-y") 'yank-pop)
(define-key map (kbd "H-SPC") 'set-mark-command)
(define-key map (kbd "H-s") 'uc-scroll-one-up)
(define-key map (kbd "H-w") 'uc-scroll-one-down)
(define-key map (kbd "H-M-s") 'uc-scroll-many-up)
(define-key map (kbd "H-M-w") 'uc-scroll-many-down)
;; (define-key map (kbd "M-<up>") 'uc-scroll-one-down)
;; (define-key map (kbd "M-<down>") 'uc-scroll-one-up)
(define-key map (kbd "M-H-<up>") 'uc-drag-this-up)
(define-key map (kbd "M-H-<down>") 'uc-drag-this-down)
(define-key map (kbd "M-H-I") 'uc-drag-this-up)
(define-key map (kbd "M-H-K") 'uc-drag-this-down)
(define-key map (kbd "M-H-L") (kbd "M-S-<right>"))
(define-key map (kbd "M-H-J") (kbd "M-S-<left>"))
(define-key map (kbd "H-<return>") 'uc-add-line-below)
(define-key map (kbd "H-h") 'move-beginning-of-line)
(define-key map (kbd "H-;") 'move-end-of-line)
map
)
)
(add-hook 'prog-mode-hook 'uppercut-mode)
(provide 'foo-mode)