-
Notifications
You must be signed in to change notification settings - Fork 0
/
key-config-paddy.el
207 lines (156 loc) · 5.94 KB
/
key-config-paddy.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
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
(defun paddy-do-paren-key-switching ()
(setq my-key-pairs
'(
;(?! ?1) (?@ ?2) (?# ?3) (?$ ?4) (?% ?5)
;(?^ ?6) (?& ?7) (?* ?8) (?( ?9) (?) ?0)
;(?- ?_) (?\" ?') (?{ ?[) (?} ?]) ; (?| ?\\)
;(?[ ?{) (?] ?})
(?( ?[) (?) ?])
;(?( ?{) (?) ?})
;(?{ ?[) (?} ?])
))
(defun my-key-swap (key-pairs)
(if (eq key-pairs nil)
(message "Keyboard zapped!! Shift-F10 to restore!")
(progn
(keyboard-translate (caar key-pairs) (cadar key-pairs))
(keyboard-translate (cadar key-pairs) (caar key-pairs))
(my-key-swap (cdr key-pairs))
)
))
(defun my-key-restore (key-pairs)
(interactive)
(if (eq key-pairs nil)
(message "Keyboard restored!! F10 to Zap!")
(progn
(keyboard-translate (caar key-pairs) (caar key-pairs))
(keyboard-translate (cadar key-pairs) (cadar key-pairs))
(my-key-restore (cdr key-pairs))
)
))
(my-key-swap my-key-pairs))
(cond
((string-match "GNU" (emacs-version))
(cond
((string-match "linux" system-configuration)
(if (file-exists-p "~/.emacs-gnu-linux")
(progn
(message "loading GNU Emacs customizations for Linux")
(load-file "~/.emacs-gnu-linux"))))
((string-match "darwin" (emacs-version))
(progn
(message "mac")
(setq mac-option-modifier 'super)
(setq mac-command-modifier 'meta)
(paddy-do-paren-key-switching)
t
))
) ; matched GNU
))
;Eventually these should be JDEE mode only
;(global-unset-key "\M-?") ;; I don't know what this is bound to now
;(global-set-key "\M-'" 'jde-complete-in-line)
;(global-set-key "\M-\"" 'jde-complete-menu)
(global-set-key (kbd "M-\\") 'delete-horizontal-space)
(global-unset-key (kbd "C-\\")) ;; I never toggle input method
(global-unset-key (kbd "M-o")) ;; I never want to set-face-font but I often accidently type this when I want s-o
;notsure
;;;;;window movement keys
(defun _paddy-enlarge-window-horizontal ()
(interactive)
(enlarge-window 1 1))
(defun _paddy-shrink-window-horizontal ()
(interactive)
(shrink-window 1 1))
(global-unset-key (kbd "M-`") )
(global-set-key (kbd "s-P") 'enlarge-window)
(global-set-key (kbd "s-p") 'windmove-up)
(global-set-key (kbd "s-N") 'shrink-window)
(global-set-key (kbd "s-n") 'windmove-down)
(global-set-key (kbd "s-F") '_paddy-enlarge-window-horizontal)
(global-set-key (kbd "s-f") 'windmove-right)
(global-set-key (kbd "s-B") '_paddy-shrink-window-horizontal)
(global-set-key (kbd "s-b") 'windmove-left)
(global-set-key (kbd "s-w") 'delete-window)
(global-set-key (kbd "s-o") 'other-window)
;;;;;;;;;buffer movement commands ---anything
;(global-set-key '[C-tab] 'bs-cycle-next)
;(global-set-key '[C-S-tab] 'bs-cycle-previous)
(global-unset-key '[C-tab])
(global-unset-key '[C-S-tab])
(defun my-switch-to-buffer (buffer-or-name)
(interactive
(list (read-buffer-to-switch "Switch to buffer: ") ))
(switch-to-buffer buffer-or-name t t))
(global-set-key (kbd "C-x b") 'my-switch-to-buffer)
(global-set-key (kbd "s-g") 'find-grep)
(global-set-key (kbd "s-w") 'delete-window)
(global-set-key (kbd "s-o") 'other-window)
(global-set-key '[s-return] 'other-window)
(global-set-key '[s-tab] 'other-window)
(global-set-key (kbd "s-s") 'split-window-horizontally)
(global-set-key (kbd "s-=") 'balance-windows)
(global-set-key (kbd "s-S") 'split-window-vertically)
(global-set-key (kbd "s-3") 'split-window-horizontally)
(global-set-key (kbd "s-2") 'split-window-vertically)
;;(global-set-key (kbd "s-'") 'new-shell)
(global-unset-key (kbd "s-'"))
(global-set-key (kbd "s-;") 'new-shell)
(global-set-key "\C-x\C-F" 'find-file)
(global-unset-key (kbd "C-S-F"))
(global-set-key (kbd "C-x C-S-f") 'find-file-other-window)
;--anything
(global-set-key (kbd "s-a") 'anything)
(global-set-key (kbd "s-\\") 'anything)
;(global-set-key (kbd "s-`") 'anything)
(global-set-key (kbd "s-x") 'paddy-M-x-anything)
(global-set-key (kbd "M-x") 'execute-extended-command)
(global-set-key (kbd "M-y") 'anything-show-kill-ring)
(global-set-key (kbd "C-h g") 'help-paddy-goto-function)
(define-key isearch-mode-map (kbd "C-y") 'isearch-yank-kill)
;;;;;;;;;;editting commands
(global-set-key (kbd "C-=") 'unexpand-abbrev)
(global-set-key (kbd "s-r") '(lambda ()
(interactive)
(revert-buffer)))
(global-set-key (kbd "M-S-g") 'goto-line)
(global-set-key (kbd "S-M-g") 'goto-line)
; Yegge advice
(global-unset-key (kbd "C-w") )
(global-set-key (kbd "C-w") 'backward-kill-word)
(global-unset-key (kbd "C-S-w") )
(global-set-key (kbd "C-S-w") 'kill-word)
(defun paddy-kill-from-begining-of-line ()
(interactive)
(move-beginning-of-line 1)
(kill-line))
(global-set-key (kbd "C-S-k") 'paddy-kill-from-begining-of-line)
(global-set-key (kbd "C-k") 'kill-line)
;(global-set-key "\C-x\C-k" 'kill-region)
;(global-set-key "\C-c\C-k" 'kill-region)
(global-set-key (kbd "C-x C-k") 'kill-region)
(global-set-key (kbd "C-j") 'kill-region)
(global-set-key (kbd "C-c C-k") 'kill-region)
(global-set-key (kbd "s-M-f") 'find-file-at-point)
(global-set-key (kbd "C-s-f") 'paddy-put-buffer-filename-in-killring)
(global-set-key (kbd "s-C-x C-k") 'copy-region-as-kill)
;; Nice shell features.
(add-hook 'shell-mode-hook 'n-shell-mode-hook)
(defun n-shell-mode-hook ()
"Shell mode customizations."
(local-set-key '[up] 'n-shell-up1line)
(local-set-key '[down] 'n-shell-down1ine)
;(local-set-key '[(shift tab)] 'comint-next-matching-input-from-input)
;(setq comint-input-sender 'n-shell-simple-send)
)
(defun n-shell-up1line()
"Insert previous input if we are at the command line"
(interactive)
(if (not (comint-after-pmark-p)) ( forward-line -1)
(comint-previous-input 1) ))
(defun n-shell-down1ine()
"Insert next input if we are at the command line"
(interactive)
(if (not (comint-after-pmark-p)) (forward-line 1)
(comint-next-input 1) ))
(provide 'key-config-paddy)