forked from eschulte/emacs-starter-kit
-
Notifications
You must be signed in to change notification settings - Fork 0
/
starter-kit-bindings.org~
408 lines (323 loc) · 14.2 KB
/
starter-kit-bindings.org~
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
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
#+TITLE: Starter Kit Bindings
#+OPTIONS: toc:nil num:nil ^:nil
This is part of the [[file:starter-kit.org][Emacs Starter Kit]].
* Starter Kit Bindings
Key Bindings.
** Mac commands
My carry-over stuff--influenced by Mac and Aquamacs
#+begin_src emacs-lisp
(defvar aqm-keys-minor-mode-map (make-keymap) "aqm-keys-minor-mode keymap.")
(define-minor-mode aqm-keys-minor-mode
"A minor mode for converting aquamacs emacs to emacs 23 (cocoa)"
t " aqm" 'aqm-keys-minor-mode-map)
(aqm-keys-minor-mode 1) ;; activate
;; recentf, kill buffer
(define-key aqm-keys-minor-mode-map (kbd "C-x C-r") 'recentf-open-files)
;(define-key aqm-keys-minor-mode-map (kbd "C-l") 'recenter-top-bottom)
(define-key aqm-keys-minor-mode-map (kbd "C-c C-w") 'kill-this-buffer)
(define-key aqm-keys-minor-mode-map (kbd "S-w") 'kill-this-buffer)
;; Full screen
(define-key aqm-keys-minor-mode-map (kbd "s-<return>") 'ns-toggle-fullscreen)
(define-key aqm-keys-minor-mode-map (kbd "s-}") 'tabbar-forward-tab)
(define-key aqm-keys-minor-mode-map (kbd "s-{") 'tabbar-backward-tab)
(define-key aqm-keys-minor-mode-map (kbd "s-c") 'clipboard-kill-ring-save)
(define-key aqm-keys-minor-mode-map (kbd "s-v") 'cua-paste)
#+end_src
** Programming keys
#+source: programming keys
#+begin_src emacs-lisp
(defvar myProgramming-keys-minor-mode-map (make-keymap) "myProgramming-keys-minor-mode keymap.")
(define-minor-mode myProgramming-keys-minor-mode
"A minor mode for programming"
t " prog" 'myProgramming-keys-minor-mode-map)
(define-key myProgramming-keys-minor-mode-map (kbd "C-<tab>") 'ff-find-other-file )
;; (define-key myProgramming-keys-minor-mode-map (kbd "M-'") 'comment-kill)
(define-key myProgramming-keys-minor-mode-map (kbd "M-]") 'my-toggle-selective-display)
(add-hook 'c-mode-common-hook '(lambda ()
(myProgramming-keys-minor-mode 1)
))
#+end_src
*** Matlab
#+source: Matlab
#+begin_src emacs-lisp
; (mapcar (lambda(x)(car(rassq x minor-mode-map-alist)))(current-minor-mode-maps))
(define-key matlab-mode-map (kbd "M-;") 'comment-dwim)
(defun matlab-set-dwim-comment
"Change matlab comment to dwim comment"
(interactive)
(lambda ()
(define-key matlab-mode-map (kbd "M-;") 'comment-dwim)))
;; '(lambda ()
;; (define-key delphi-mode-map "\C-ch" 'delphi-help)
;; (define-key delphi-mode-map "\C-c\C-p" 'delphi-after-point)
;; (define-key delphi-mode-map "\C-c\C-mi" 'delphi-go-to-method-implementation)
;; (define-key delphi-mode-map "\C-c\C-md" 'delphi-go-to-method-definition)
;; (define-key delphi-mode-map "\C-c\C-mc" 'delphi-complete-method)
;; (define-key delphi-mode-map "\C-c\C-p" 'delphi-go-after-point)))
#+end_src
** Lisp Keys
#+source: lisp keys
#+begin_src emacs-lisp
;; (define-globalized-minor-mode global-paredit-mode paredit-mode paredit-mode)
;; (global-paredit-mode t)
(defvar myLisp-keys-minor-mode-map (make-keymap) "myLisp-keys-minor-mode keymap.")
(define-minor-mode myLisp-keys-minor-mode
"A minor mode for programming"
t " myCL" 'myLisp-keys-minor-mode-map)
(define-key myLisp-keys-minor-mode-map (kbd "C-#") 'slime)
(define-key myLisp-keys-minor-mode-map (kbd "S-s") (lambda () (interactive) (insert "[]") (backward-char 1)))
(define-key myLisp-keys-minor-mode-map (kbd "S-d") (lambda () (interactive) (insert "()") (backward-char 1)))
(define-key myLisp-keys-minor-mode-map (kbd "S-f") (lambda () (interactive) (insert "{}") (backward-char 1)))
(add-hook 'lisp-mode-hook '(lambda ()
(myLisp-keys-minor-mode 1)
))
(add-hook 'scheme-mode-hook '(lambda ()
(myLisp-keys-minor-mode 1)
))
#+end_src
** Chris keys
#+source: Chris-keys
#+begin_src emacs-lisp
(defvar chris-keys-minor-mode-map (make-keymap) "chris-keys-minor-mode keymap.")
(define-minor-mode chris-keys-minor-mode
"A minor mode so that my key settings override annoying major modes."
t " wcb" 'chris-keys-minor-mode-map)
(chris-keys-minor-mode 1)
;; Fastnav
(define-key chris-keys-minor-mode-map "\M-z" 'zap-up-to-char-forward)
(define-key chris-keys-minor-mode-map "\M-Z" 'zap-up-to-char-backward)
;; (define-key chris-keys-minor-mode-map "\M-i" 'sprint-forward)
;; (define-key chris-keys-minor-mode-map "\M-I" 'sprint-backward)
(define-key chris-keys-minor-mode-map "\M-i" 'jump-to-char-forward)
(define-key chris-keys-minor-mode-map "\M-I" 'jump-to-char-backward)
(define-key chris-keys-minor-mode-map (kbd "C-.") 'repeat-complex-command)
; (define-key chris-keys-minor-mode "\M-i" 'ido-goto-symbol)
;; Files
(define-key chris-keys-minor-mode-map (kbd "C-c C-r") 'revert-buffer)
(define-key chris-keys-minor-mode-map (kbd "C-c f") 'ffap)
(define-key chris-keys-minor-mode-map "\M-s" 'anything)
(define-key chris-keys-minor-mode-map "\C-xaf" 'anything-for-files)
;; Autocomplete
(define-key chris-keys-minor-mode-map (kbd "M-<tab>") 'auto-complete)
;; (define-key chris-keys-minor-mode-map (kbd "<tab>") 'auto-complete)
#+end_src
*** For moving around in and resizing Windows/buffers
#+source: windows and buffers
#+begin_src emacs-lisp
;; Resize Windows
(define-key chris-keys-minor-mode-map (kbd "S-C-<left>") 'shrink-window-horizontally)
(define-key chris-keys-minor-mode-map (kbd "S-C-<right>") 'enlarge-window-horizontally)
(define-key chris-keys-minor-mode-map (kbd "S-C-<down>") 'enlarge-window)
(define-key chris-keys-minor-mode-map (kbd "S-C-<up>") 'shrink-window)
;; Select Windows
;; (define-key chris-keys-minor-mode-map (kbd "S-M-<right>") 'select-next-window)
;; (define-key chris-keys-minor-mode-map (kbd "S-M-<left>") 'select-previous-window)
;; Scrolling
(global-set-key "\M-\S-n" 'gcm-scroll-down)
(global-set-key "\M-\S-p" 'gcm-scroll-up)
(global-set-key (kbd "M-n") 'big-move-down) ; Defined in defuns, along with transparency functions
(global-set-key (kbd "M-p") 'big-move-up)
;; Transparency
(global-set-key (kbd "C-!") 'transparency-set-value)
;; The two below let for smooth transparency control
(global-set-key (kbd "C-~") 'transparency-increase)
(global-set-key (kbd "C-`") 'transparency-decrease)
#+end_src
*** My word editing
Bindings for editing in the trenches.
#+source: words
#+begin_src emacs-lisp
(define-key chris-keys-minor-mode-map (kbd "C-S-<tab>") 'tabbar-backward)
; see if this is already taken care of in starter kit
;; (define-key chris-keys-minor-mode-map (kbd "C-j") 'newline-and-indent)
;; reindent-then-newline-and-indent)
; ; this messes up 'RET' for some reason
;;; Killing and copying Commands
(define-key chris-keys-minor-mode-map (kbd "C-S-k") 'kill-whole-line)
(define-key chris-keys-minor-mode-map (kbd "C-M-<backspace>") 'backward-kill-sexp)
(define-key chris-keys-minor-mode-map (kbd "C-M-}") 'kill-paragraph)
(define-key chris-keys-minor-mode-map (kbd "C-M-{") 'backward-kill-paragraph)
(define-key chris-keys-minor-mode-map "\C-x\C-k" 'kill-ring-save)
(define-key chris-keys-minor-mode-map "\C-c\C-y" 'copy-whole-line)
(define-key chris-keys-minor-mode-map "\C-c\C-k" 'copy-line)
(define-key chris-keys-minor-mode-map "\C-w" 'backward-kill-word)
(define-key chris-keys-minor-mode-map "\M-w" 'kill-region)
(define-key chris-keys-minor-mode-map "\C-h" 'backward-delete-char)
;;; To replace the help command
(define-key chris-keys-minor-mode-map (kbd "C-S-?") 'help-command)
(define-key chris-keys-minor-mode-map (kbd "M-?") 'help-command)
;;; Get rid of weird toggle-input replacement
(define-key chris-keys-minor-mode-map (kbd "<f3>") 'toggle-input-method)
;;; Evaluating
(define-key chris-keys-minor-mode-map "\M-j" 'eval-last-sexp)
(define-key chris-keys-minor-mode-map "\M-'" 'toggle-letter-case)
#+end_src
*** Isearch keys
Mostly to make it consistent with setup for other modes.
#+source: isearch
#+begin_src emacs-lisp
(define-key isearch-mode-map "\C-h" 'isearch-delete-char)
(define-key isearch-mode-map "\C-y" 'isearch-yank-word)
(define-key isearch-mode-map "\C-g" 'isearch-exit)
#+end_src
*** Ido keys
#+source: ido
#+begin_src emacs-lisp
(add-hook 'ido-define-mode-map-hook 'ido-my-keys)
(defun ido-my-keys ()
"Set up the keymap for `ido'."
;; backspace functions
(define-key ido-mode-map "\C-h" 'ido-delete-backward-updir)
(define-key ido-mode-map "\C-w" 'ido-delete-backward-word-updir)
(define-key ido-mode-map [backspace] 'ido-up-directory)
;; http://people.ku.edu/~syliu/shredderyin/ido.html
)
#+end_src
** You know, like Readline.
#+begin_src emacs-lisp
(global-set-key (kbd "C-M-h") 'backward-kill-word)
#+end_src
** Align your code in a pretty way.
#+begin_src emacs-lisp
(global-set-key (kbd "C-x \\") 'align-regexp)
#+end_src
** Completion that uses many different methods to find options.
#+begin_src emacs-lisp
(global-set-key (kbd "M-/") 'hippie-expand)
#+end_src
** Perform general cleanup.
#+begin_src emacs-lisp
(global-set-key (kbd "C-c n") 'cleanup-buffer)
#+end_src
** Turn on the menu bar for exploring new modes
#+begin_src emacs-lisp
(global-set-key [f1] 'menu-bar-mode)
#+end_src
** Font size
#+begin_src emacs-lisp
(define-key global-map (kbd "C-+") 'text-scale-increase)
(define-key global-map (kbd "C--") 'text-scale-decrease)
(define-key global-map (kbd "s-=") 'text-scale-increase)
(define-key global-map (kbd "s--") 'text-scale-decrease)
#+end_src
** Use regex searches by default.
#+begin_src emacs-lisp
(global-set-key (kbd "C-s") 'isearch-forward-regexp)
(global-set-key (kbd "\C-r") 'isearch-backward-regexp)
(global-set-key (kbd "C-M-s") 'isearch-forward)
(global-set-key (kbd "C-M-r") 'isearch-backward)
#+end_src
** Jump to a definition in the current file. (This is awesome.)
#+begin_src emacs-lisp
(global-set-key (kbd "C-x C-i") 'ido-imenu)
#+end_src
** File finding
#+begin_src emacs-lisp
(global-set-key (kbd "C-x M-f") 'ido-find-file-other-window)
(global-set-key (kbd "C-x C-M-f") 'find-file-in-project)
(global-set-key (kbd "C-x f") 'recentf-ido-find-file)
(global-set-key (kbd "C-x C-p") 'find-file-at-point)
(global-set-key (kbd "C-c y") 'bury-buffer)
(global-set-key (kbd "C-c r") 'revert-buffer)
(global-set-key (kbd "M-`") 'file-cache-minibuffer-complete)
(global-set-key (kbd "C-x C-b") 'ibuffer)
#+end_src
** Window switching and resizing. (C-x o goes to the next window)
#+begin_src emacs-lisp
(windmove-default-keybindings) ;; Shift+direction
(global-set-key (kbd "C-x O") (lambda () (interactive) (other-window -1))) ;; back one
(global-set-key (kbd "C-x C-o") (lambda () (interactive) (other-window 2))) ;; forward two
#+end_src
** Indentation help
#+begin_src emacs-lisp
(global-set-key (kbd "C-x ^") 'join-line)
#+end_src
** Start eshell or switch to it if it's active.
#+begin_src emacs-lisp
(global-set-key (kbd "C-x m") 'eshell)
#+end_src
** Start a new eshell even if one is active.
#+begin_src emacs-lisp
(global-set-key (kbd "C-x M") (lambda () (interactive) (eshell t)))
#+end_src
** Start a regular shell if you prefer that.
#+begin_src emacs-lisp
(global-set-key (kbd "C-x M-m") 'shell)
#+end_src
** If you want to be able to M-x without meta
#+begin_src emacs-lisp
(global-set-key (kbd "C-x C-m") 'execute-extended-command)
#+end_src
** Fetch the contents at a URL, display it raw.
#+begin_src emacs-lisp
(global-set-key (kbd "C-x h") 'view-url)
#+end_src
** Help should search more than just commands
#+begin_src emacs-lisp
(global-set-key (kbd "C-h a") 'apropos)
#+end_src
** Should be able to eval-and-replace anywhere.
#+begin_src emacs-lisp
(global-set-key (kbd "C-c e") 'eval-and-replace)
#+end_src
** Applications
#+begin_src emacs-lisp
(global-set-key (kbd "C-c j") (lambda () (interactive) (switch-or-start 'jabber-connect "*-jabber-*")))
(global-set-key (kbd "C-c g") (lambda () (interactive) (switch-or-start 'gnus "*Group*")))
(global-set-key (kbd "C-c i") (lambda () (interactive) (switch-or-start (lambda ()
(rcirc-connect "irc.freenode.net"))
"*irc.freenode.net*")))
(global-set-key (kbd "C-c J") 'jabber-send-presence)
(global-set-key (kbd "C-c M-j") 'jabber-disconnect)
(global-set-key (kbd "C-x g") 'magit-status)
#+end_src
** This is a little hacky since VC doesn't support git add internally
#+begin_src emacs-lisp
(eval-after-load 'vc
(define-key vc-prefix-map "i" '(lambda () (interactive)
(if (not (eq 'Git (vc-backend buffer-file-name)))
(vc-register)
(shell-command (format "git add %s" buffer-file-name))
(message "Staged changes.")))))
#+end_src
** Activate occur easily inside isearch
#+begin_src emacs-lisp
(define-key isearch-mode-map (kbd "C-o")
(lambda () (interactive)
(let ((case-fold-search isearch-case-fold-search))
(occur (if isearch-regexp isearch-string (regexp-quote isearch-string))))))
#+end_src
** Closing
#+begin_src emacs-lisp
(provide 'starter-kit-bindings)
;;; starter-kit-bindings.el ends here
#+end_src
** Org-mode
Two global binding for Org-mode (see [[file:starter-kit-org.org][starter-kit-org]])
The [[http://orgmode.org/manual/Agenda-Views.html#Agenda-Views][Org-mode agenda]] is good to have close at hand
#+begin_src emacs-lisp
(define-key global-map "\C-ca" 'org-agenda)
#+end_src
Org-mode supports [[http://orgmode.org/manual/Hyperlinks.html#Hyperlinks][links]], this command allows you to store links
globally for later insertion into an Org-mode buffer. See
[[http://orgmode.org/manual/Handling-links.html#Handling-links][Handling-links]] in the Org-mode manual.
#+begin_src emacs-lisp
(define-key global-map "\C-cl" 'org-store-link)
#+end_src
** Magit
It's to the point now where I almost can't use git without magit.
- [[http://zagadka.vm.bytemark.co.uk/magit/][Homepage]]
- [[http://zagadka.vm.bytemark.co.uk/magit/magit.html][Manual]]
- [[http://groups.google.com/group/magit/][Mailing list]]
#+begin_src emacs-lisp
(require 'magit)
(define-key global-map "\M-\C-g" 'magit-status)
#+end_src
#+resname:
: magit-status
** Rgrep
Rgrep is infinitely useful in multi-file projects.
(see [[elisp:(describe-function 'rgrep)]])
#+begin_src emacs-lisp
(define-key global-map "\C-x\C-r" 'rgrep)
#+end_src