Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Newer
Older
100644 93 lines (72 sloc) 3.752 kB
5fcb34d @technomancy initial commit
authored
1 ;;; starter-kit-bindings.el --- Set up some handy key bindings
2 ;;
3 ;; Part of the Emacs Starter Kit.
4
5 ;; TODO: switch to kbd invocations everywhere
6
7 ;; You know, like Readline.
8 (global-set-key "\C-\M-h" 'backward-kill-word)
9
10 ;; Align your code in a pretty way.
11 (global-set-key (kbd "C-x \\") 'align-regexp)
12
13 ;; Completion that uses many different methods to find options.
14 (global-set-key (kbd "M-/") 'hippie-expand)
15
16 ;; Perform general cleanup.
17 (global-set-key (kbd "C-c n") (lambda () (interactive)
18 (indent-buffer)
19 (delete-trailing-whitespace)
20 (untabify-buffer)))
21
22 ;; Turn on the menu bar for exploring new modes
23 (global-set-key [f1] 'menu-bar-mode)
24
25 ;; Use regex searches by default.
26 (global-set-key "\C-s" 'isearch-forward-regexp)
27 (global-set-key "\C-r" 'isearch-backward-regexp)
28 (global-set-key "\C-\M-s" 'isearch-forward)
29 (global-set-key "\C-\M-r" 'isearch-backward)
30
31 ;; Jump to a definition in the current file. (This is awesome.)
d7bdec6 @technomancy Rename some functions; remove mention of nxhtml until it's in ELPA.
authored
32 (global-set-key "\C-x\C-i" 'ido-imenu)
5fcb34d @technomancy initial commit
authored
33
34 ;; File finding
35 (global-set-key (kbd "C-x M-f") 'ido-find-file-other-window)
36 (global-set-key (kbd "C-x C-M-f") 'find-file-in-project)
37 (global-set-key (kbd "C-x f") 'recentf-ido-find-file)
38 (global-set-key (kbd "C-x C-p") 'find-file-at-point)
39 (global-set-key (kbd "C-c y") 'bury-buffer)
40 (global-set-key (kbd "C-c r") 'revert-buffer)
41 (global-set-key (kbd "M-`") 'file-cache-minibuffer-complete)
3967f4b @technomancy Remove ELPA'd ruby libs, clean up regen-autoloads.
authored
42 (global-set-key (kbd "C-x C-b") 'ibuffer)
5fcb34d @technomancy initial commit
authored
43
44 ;; Window switching. (C-x o goes to the next window)
45 (windmove-default-keybindings) ;; Shift+direction
46 (global-set-key "\C-xO" (lambda () (interactive) (other-window -1))) ;; back one
47 (global-set-key "\C-x\C-o" (lambda () (interactive) (other-window 2))) ;; forward two
48
49 ;; Start eshell or switch to it if it's active.
50 (global-set-key (kbd "C-x m") 'eshell)
51
52 ;; Start a new eshell even if one is active.
53 (global-set-key (kbd "C-x M") (lambda () (interactive) (eshell t)))
54
55 ;; Start a regular shell if you prefer that.
56 (global-set-key (kbd "C-x C-m") 'shell)
57
58 ;; Fetch the contents at a URL, display it raw.
59 (global-set-key (kbd "C-x h") 'view-url)
60
38ac75b @technomancy Remove cheat binding, use coding-hook.
authored
61 ;; Help should search more than just commands
5fcb34d @technomancy initial commit
authored
62 (global-set-key (kbd "C-h a") 'apropos)
63
eb9eeb5 @technomancy Move lisp bindings and add in JS stuff.
authored
64 ;; Should be able to eval-and-replace anywhere.
65 (global-set-key (kbd "C-c e") 'eval-and-replace)
66
5fcb34d @technomancy initial commit
authored
67 ;; Applications
68
69 (global-set-key (kbd "C-c j") (lambda () (interactive) (switch-or-start 'jabber-connect "*-jabber-*")))
70 (global-set-key (kbd "C-c g") (lambda () (interactive) (switch-or-start 'gnus "*Group*")))
38ac75b @technomancy Remove cheat binding, use coding-hook.
authored
71 (global-set-key (kbd "C-c i") (lambda () (interactive) (switch-or-start (lambda ()
72 (rcirc-connect "irc.freenode.net"))
5fcb34d @technomancy initial commit
authored
73 "*irc.freenode.net*")))
74 (global-set-key (kbd "C-c J") 'jabber-send-presence)
75 (global-set-key (kbd "C-c M-j") 'jabber-disconnect)
76 (global-set-key (kbd "C-x g") 'magit-status)
77
78 ;; This is a little hacky since VC doesn't support git add internally
4fb4321 @technomancy Fix vc binding to use prefix map.
authored
79 (eval-after-load 'vc
80 (define-key vc-prefix-map "i" '(lambda () (interactive)
81 (if (not (eq 'Git (vc-backend buffer-file-name)))
82 (vc-register)
83 (shell-command (format "git add %s" buffer-file-name))
84 (message "Staged changes.")))))
5fcb34d @technomancy initial commit
authored
85
86 ;; Activate occur easily inside isearch
87 (define-key isearch-mode-map (kbd "C-o")
88 (lambda () (interactive)
89 (let ((case-fold-search isearch-case-fold-search))
90 (occur (if isearch-regexp isearch-string (regexp-quote isearch-string))))))
91
92 (provide 'starter-kit-bindings)
93 ;;; starter-kit-bindings.el ends here
Something went wrong with that request. Please try again.