Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Newer
Older
100644 97 lines (76 sloc) 4.015 kb
5fcb34d Phil Hagelberg 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.)
32 (global-set-key "\C-x\C-i" 'ido-goto-symbol)
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 Phil Hagelberg Remove ELPA'd ruby libs, clean up regen-autoloads.
authored
42 (global-set-key (kbd "C-x C-b") 'ibuffer)
5fcb34d Phil Hagelberg 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 ;; Lisp
50 (define-key read-expression-map (kbd "TAB") 'lisp-complete-symbol)
51 (define-key lisp-mode-shared-map (kbd "RET") 'reindent-then-newline-and-indent)
52 (define-key lisp-mode-shared-map (kbd "C-\\") 'lisp-complete-symbol)
53 (define-key lisp-mode-shared-map (kbd "C-c s") 'my-eval-and-replace)
54 (define-key lisp-mode-shared-map (kbd "C-c v") 'eval-buffer)
55
56 ;; Start eshell or switch to it if it's active.
57 (global-set-key (kbd "C-x m") 'eshell)
58
59 ;; Start a new eshell even if one is active.
60 (global-set-key (kbd "C-x M") (lambda () (interactive) (eshell t)))
61
62 ;; Start a regular shell if you prefer that.
63 (global-set-key (kbd "C-x C-m") 'shell)
64
65 ;; Fetch the contents at a URL, display it raw.
66 (global-set-key (kbd "C-x h") 'view-url)
67
38ac75b Phil Hagelberg Remove cheat binding, use coding-hook.
authored
68 ;; Help should search more than just commands
5fcb34d Phil Hagelberg initial commit
authored
69 (global-set-key (kbd "C-h a") 'apropos)
70
71 ;; Applications
72
73 (global-set-key (kbd "C-c j") (lambda () (interactive) (switch-or-start 'jabber-connect "*-jabber-*")))
74 (global-set-key (kbd "C-c g") (lambda () (interactive) (switch-or-start 'gnus "*Group*")))
38ac75b Phil Hagelberg Remove cheat binding, use coding-hook.
authored
75 (global-set-key (kbd "C-c i") (lambda () (interactive) (switch-or-start (lambda ()
76 (rcirc-connect "irc.freenode.net"))
5fcb34d Phil Hagelberg initial commit
authored
77 "*irc.freenode.net*")))
78 (global-set-key (kbd "C-c J") 'jabber-send-presence)
79 (global-set-key (kbd "C-c M-j") 'jabber-disconnect)
80 (global-set-key (kbd "C-x g") 'magit-status)
81
82 ;; This is a little hacky since VC doesn't support git add internally
4fb4321 Phil Hagelberg Fix vc binding to use prefix map.
authored
83 (eval-after-load 'vc
84 (define-key vc-prefix-map "i" '(lambda () (interactive)
85 (if (not (eq 'Git (vc-backend buffer-file-name)))
86 (vc-register)
87 (shell-command (format "git add %s" buffer-file-name))
88 (message "Staged changes.")))))
5fcb34d Phil Hagelberg initial commit
authored
89
90 ;; Activate occur easily inside isearch
91 (define-key isearch-mode-map (kbd "C-o")
92 (lambda () (interactive)
93 (let ((case-fold-search isearch-case-fold-search))
94 (occur (if isearch-regexp isearch-string (regexp-quote isearch-string))))))
95
96 (provide 'starter-kit-bindings)
97 ;;; starter-kit-bindings.el ends here
Something went wrong with that request. Please try again.