-
Notifications
You must be signed in to change notification settings - Fork 2
/
init-bindings.el
215 lines (167 loc) · 7.94 KB
/
init-bindings.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
208
209
210
211
212
213
214
215
;; ----------------------------------------------------------------------
;; File: init-bindings.el - setup my key bindings in emacs
;; Part of my emacs configuration (see ~/.emacs or init.el)
;;
;; Creation: 08 Jan 2010
;; Time-stamp: <Thu 2011-01-20 16:44 svarrette>
;;
;; Copyright (c) 2010 Sebastien Varrette <[email protected]>
;; http://varrette.gforge.uni.lu
;;
;; More information about Emacs Lisp:
;; http://www.emacswiki.org/emacs/EmacsLisp
;; ----------------------------------------------------------------------
;; This file is NOT part of GNU Emacs.
;;
;; This program is free software: you can redistribute it and/or modify
;; it under the terms of the GNU General Public License as published by
;; the Free Software Foundation, either version 3 of the License, or
;; (at your option) any later version.
;;
;; This program is distributed in the hope that it will be useful,
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
;; GNU General Public License for more details.
;;
;; You should have received a copy of the GNU General Public License
;; along with this program. If not, see <http://www.gnu.org/licenses/>.
;; ----------------------------------------------------------------------
;; === Specific Aquamacs configuration ===
(Aquamacs
(osx-key-mode -1)
(setq
ns-command-modifier 'meta ; Apple/Command key is Meta
ns-alternate-modifier nil ; Option is the Mac Option key
;;ns-use-mac-modifier-symbols nil ; display standard Emacs (and not standard Mac) modifier symbols)
)
)
;; === Buffer switching ===
;; C-x b permits to switch among the buffer by entering a buffer name,
;; with completion.
;; See http://www.emacswiki.org/emacs/IswitchBuffers
(require 'iswitchb)
(iswitchb-mode t)
;; to ignore the *...* special buffers from the list
(setq iswitchb-buffer-ignore '("^ " "*Buffer"))
;; Move from one buffer to another using 'C-<' and 'C->'
;(load "cyclebuffer" nil 't)
;(global-set-key (kbd "C-<") 'cyclebuffer-forward)
;(global-set-key (kbd "C->") 'cyclebuffer-backward)
(global-set-key (kbd "C-<") 'previous-buffer)
(global-set-key (kbd "C->") 'next-buffer)
;; === Window switching ===
(global-set-key [C-prior] 'other-window)
(global-set-key [C-next] 'other-window)
;; === Font size ===
;; I may prefer C-+ and C-- for window enlarge/schrink
(define-key global-map (kbd "C-+") 'text-scale-increase)
(define-key global-map (kbd "C--") 'text-scale-decrease)
;; === Multi speed mouse scrolling ===
;; scroll: normal speed
;; Ctrl + scroll: high speed
;; Shift + scroll: low speed
(defun up-slightly () (interactive) (scroll-up 5))
(defun down-slightly () (interactive) (scroll-down 5))
(global-set-key [mouse-4] 'down-slightly)
(global-set-key [mouse-5] 'up-slightly)
(defun up-one () (interactive) (scroll-up 1))
(defun down-one () (interactive) (scroll-down 1))
(global-set-key [S-mouse-4] 'down-one)
(global-set-key [S-mouse-5] 'up-one)
(defun up-a-lot () (interactive) (scroll-up))
(defun down-a-lot () (interactive) (scroll-down))
(global-set-key [C-mouse-4] 'down-a-lot)
(global-set-key [C-mouse-5] 'up-a-lot)
;; === Navigation ===
(global-set-key [kp-home] 'beginning-of-buffer) ; [Home]
(global-set-key [home] 'beginning-of-buffer) ; [Home]
(global-set-key [kp-end] 'end-of-buffer) ; [End]
(global-set-key [end] 'end-of-buffer) ; [End]
;; goto next error (raised in the compilation buffer typically)
(global-set-key (kbd "C-x n") 'next-error)
(global-set-key (kbd "C-x p") 'previous-error)
(global-set-key (kbd "M-n") 'goto-line) ; goto line number
;; ECB
(global-set-key [(f2)] 'ecb-toggle) ; Activate ECB (see ~/.emacs.d/init-cedet)
;; Shell pop
(global-set-key [(f3)] 'shell-pop)
;; Speedbar
;(global-set-key [(f4)] 'speedbar-get-focus) ; jump to speedbar frame
;;(require 'sr-speedbar)
;;(speedbar 1)
;; (global-set-key [(f4)] 'sr-speedbar-toggle) ; jump to speedbar frame
;; find matching parenthesis (% command in vim: Go to the matching parenthesis,
;; if on parenthesis; otherwise, insert '%')
;; see ~/.emacs.d/init-defuns.el
;; in practice, it's annoying when writing a C code with printf format so I
;; decided to rebind it to something different that '%'
(global-set-key (kbd "C-c C-p") 'match-paren)
;; Jump to a definition in the current file. (This is awesome.)
(global-set-key (kbd "C-x C-i") 'ido-imenu)
;; === Compilation ===
(global-set-key (kbd "C-x C-e") 'smart-compile)
(define-key ruby-mode-map [remap ruby-send-last-sexp ] nil)
;; === Kill this buffer ===
(global-set-key (kbd "C-q") 'kill-this-buffer)
;; === Launch a shell ===
(global-set-key (kbd "C-!") 'shell)
;; === Re-indent the full file (quite useful) ===
(global-set-key (kbd "C-c i") 'indent-buffer) ; see ~/.emacs.d/init-defuns
;; === yank and indent copied region ===
(global-set-key (kbd "M-v") 'yank-and-indent)
;; === Search [and replace] ===
; Use regex searches by default.
(global-set-key (kbd "C-s") 'isearch-forward)
(global-set-key (kbd "\C-r") 'isearch-backward)
(global-set-key (kbd "C-M-s") 'isearch-forward-regexp)
(global-set-key (kbd "C-M-r") 'isearch-backward-regexp)
(global-set-key (kbd "M-q") 'query-replace)
;; === Instant messaging ===
;; see http://www.emacswiki.org/emacs/CategoryChatClient
;; TO BE TRIED LATER
;(global-set-key (kbd "C-c j") (lambda () (interactive) (switch-or-start 'jabber-connect "*-jabber-*")))
;(global-set-key (kbd "C-c M-j") 'jabber-disconnect)
;(global-set-key (kbd "C-c i")
; (lambda () (interactive)
; (switch-or-start (lambda () (rcirc-connect "irc.freenode.net"))
; "*irc.freenode.net*")))
;; === Emacs Org ===
;; An Emacs Mode for Notes, Project Planning, and Authoring
;; see http://www.emacswiki.org/emacs/OrgMode
(define-key global-map "\C-cl" 'org-store-link)
(define-key global-map "\C-ca" 'org-agenda)
;; === Flyspell ===
(global-set-key (kbd "C-c C-i w") 'ispell-word)
(global-set-key (kbd "C-c C-i b") 'ispell-buffer)
;; ===============================
;; BINDINGS INDUCED BY SUB-MODES
;; ===============================
;; * comment and uncomment a region in a buffer is done via 'M-;'
;; * LaTeX-mode: see AucTeX manual.
;; Some additionnal notes:
;; - make a LaTeX reference (to a label) by pressing `C-c )'
;; - insert a label by pressing `C-c (' (or `C-('
;; - insert a citation by pressing `C-c [' (or `C-['
;; - hit `C-c ='; the buffer will split into 2 and in the top half you
;; will see a TOC, hitting `l' there will show all the labels and cites.
;; * C-x d open dired (for directory browsing), see ~/.emacs.d/dired-refcard.gnu.pdf
;; Note: I bind 'p' once on a file to run the 'open' command on this file
;; See ~/.emacs.d/init-emodes.el (section Dired)
;; * SVN: see menu Tools/Version Control (C-x v v to commit for instance)
;; * GIT (i.e. magit): see ~/.emacs.d/init-emodes.el
;; * Programming stuff:
;; Most useful:
;; - 'C-t C-t' to invoke a template from tempo (see ~/.emacs.d/tempo-c-cpp.el)
;; - 'M-<ret>' to invoke a template from Yasnippet (see ~/.emacs.d/init-emodes.el)
;; - 'C-<ret>' to invoke semantic menu (see ~/.emacs.d/init-cedet.el)
;; * CEDET: see ~/.emacs.d/init-cedet.el
;; * nxHtml: see ~/.emacs.d/init-emodes.el, in particular C-<ret> is bind in
;; this case to popup the complete-tag menu very useful when editing some
;; [x]html file
(provide 'init-bindings)
;; ----------------------------------------------------------------------
;; eof
;;
;; Local Variables:
;; mode: lisp
;; End: