Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Newer
Older
100644 226 lines (185 sloc) 7.721 kB
8c2d3aa @dskang Ported config over to Emacs 24
authored
1 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
2 ;; Emacs user interface
3 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
4 ;; Use command key as meta
5 (setq mac-command-modifier 'meta)
6 (setq mac-option-modifier 'nil)
7
8 ;; Scroll one line at a time
9 (setq scroll-step 1)
10
11 ;; Don't ask for confirmation upon creating new buffer or file
12 (setq confirm-nonexistent-file-or-buffer 'nil)
13
14 ;; Turn off visible bell
15 (setq visible-bell nil)
16
17 ;; Ignore prompt when killing a process
18 (setq kill-buffer-query-functions
19 (remq 'process-kill-buffer-query-function
20 kill-buffer-query-functions))
21
84a20d9 @dskang Always show column number
authored
22 ; Display the column number in the status bar.
23 (setq column-number-mode t)
24
8c2d3aa @dskang Ported config over to Emacs 24
authored
25 ;; Change Emacs font size
b11743e @dskang Don't specify frame for font size
authored
26 (set-face-attribute 'default nil :height 100)
8c2d3aa @dskang Ported config over to Emacs 24
authored
27
4fdb0ca @dskang Start Emacs server
authored
28 ;; Start Emacs server
29 (server-start)
30
f0a7095 @dskang Added more packages and ERC settings
authored
31 ;; Make the minibuffer display unfinished commands instantly
32 (setq echo-keystrokes 0.001)
33
b6e6ff6 @dskang Added whitespace mode and dedicated windows
authored
34 ;; Dedicated windows
35 ;; http://dfan.org/blog/2009/02/19/emacs-dedicated-windows/
36 (defun toggle-current-window-dedication ()
37 "Toggles whether the selected window is dedicated."
38 (interactive)
39 (let* ((window (selected-window))
40 (dedicated (window-dedicated-p window)))
41 (set-window-dedicated-p window (not dedicated))
42 (message "Window %sdedicated to %s"
43 (if dedicated "no longer " "")
44 (buffer-name))))
45 (global-set-key "\C-cd" 'toggle-current-window-dedication)
46
d5c1fd8 @dskang Add time and date to status bar
authored
47 ;; Display date and time in status bar
48 (setq display-time-day-and-date t)
49 (display-time)
50
8c2d3aa @dskang Ported config over to Emacs 24
authored
51 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
52 ;; Evil mode
53 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
20bd4a7 @dskang Set evil variables before evil is loaded
authored
54 ;; Enable Evil mode in all buffers
8c2d3aa @dskang Ported config over to Emacs 24
authored
55 (evil-mode 1)
56
57 ;; Use 'jk' as ESC
58 ;; http://permalink.gmane.org/gmane.emacs.vim-emulation/684
59 (define-key evil-insert-state-map "j" #'cofi/maybe-exit)
60
61 (evil-define-command cofi/maybe-exit ()
62 :repeat change
63 (interactive)
64 (let ((modified (buffer-modified-p)))
65 (insert "j")
66 (let ((evt (read-event (format "Insert %c to exit insert state" ?k)
b6e6ff6 @dskang Added whitespace mode and dedicated windows
authored
67 nil 0.5)))
8c2d3aa @dskang Ported config over to Emacs 24
authored
68 (cond
69 ((null evt) (message ""))
70 ((and (integerp evt) (char-equal evt ?k))
b6e6ff6 @dskang Added whitespace mode and dedicated windows
authored
71 (delete-char -1)
72 (set-buffer-modified-p modified)
73 (push 'escape unread-command-events))
8c2d3aa @dskang Ported config over to Emacs 24
authored
74 (t (setq unread-command-events (append unread-command-events
b6e6ff6 @dskang Added whitespace mode and dedicated windows
authored
75 (list evt))))))))
38b8ece @dskang Add evil bindings for org mode
authored
76
77 ;; Set cursor color
78 (setq evil-default-cursor '("white" box))
79
8c2d3aa @dskang Ported config over to Emacs 24
authored
80 ;; Show red box if in Emacs mode
81 (setq evil-emacs-state-cursor '("red" box))
82
83 ;; Move using visual lines
84 (define-key evil-normal-state-map (kbd "j") 'evil-next-visual-line)
85 (define-key evil-normal-state-map (kbd "k") 'evil-previous-visual-line)
86
87 ;; General commands
88 (define-key evil-normal-state-map ",w" 'save-buffer) ; save
89 (define-key evil-normal-state-map ",q" 'kill-buffer) ; quit
90 (define-key evil-normal-state-map ",f" 'ido-find-file) ; find file
91 (define-key evil-normal-state-map ",b" 'ido-switch-buffer) ; show buffers
92 (define-key evil-normal-state-map ",o" 'org-agenda) ; show org agenda
93
94 ;; Lisp
95 (evil-define-key 'visual emacs-lisp-mode-map ",," 'eval-region)
96
38b8ece @dskang Add evil bindings for org mode
authored
97 ;; Org-mode
98 (defun always-insert-item ()
99 (interactive)
100 (if (not (org-in-item-p))
101 (insert "\n- ")
102 (org-insert-item)))
103
104 (add-hook 'org-mode-hook
105 (lambda ()
106 (evil-define-key 'normal org-mode-map "O" (lambda ()
107 (interactive)
108 (end-of-line)
109 (org-insert-heading t)
110 (evil-append nil)
111 ))
112
113 (evil-define-key 'normal org-mode-map "o" (lambda ()
114 (interactive)
115 (end-of-line)
116 (always-insert-item)
117 (evil-append nil)
118 ))
119
120 (evil-define-key 'normal org-mode-map "t" (lambda ()
121 (interactive)
122 (end-of-line)
123 (org-insert-todo-heading nil)
124 (evil-append nil)
125 ))
126
127 (evil-define-key 'normal org-mode-map "T" 'org-todo) ; mark a TODO item as DONE
128 (evil-define-key 'normal org-mode-map "-" 'org-cycle-list-bullet) ; change bullet style
129
130 (evil-define-key 'normal org-mode-map (kbd "M-l") 'org-metaright)
131 (evil-define-key 'normal org-mode-map (kbd "M-h") 'org-metaleft)
132 (evil-define-key 'normal org-mode-map (kbd "M-k") 'org-metaup)
133 (evil-define-key 'normal org-mode-map (kbd "M-j") 'org-metadown)
134 (evil-define-key 'normal org-mode-map (kbd "M-L") 'org-shiftmetaright)
135 (evil-define-key 'normal org-mode-map (kbd "M-H") 'org-shiftmetaleft)
136 (evil-define-key 'normal org-mode-map (kbd "M-K") 'org-shiftmetaup)
137 (evil-define-key 'normal org-mode-map (kbd "M-J") 'org-shiftmetadown)
138 ))
139
8c2d3aa @dskang Ported config over to Emacs 24
authored
140 ;; Add "j" and "k" keybindings to some Emacs modes
141 (add-hook 'org-mode-hook
142 (lambda ()
143 (define-key org-agenda-mode-map "j" 'evil-next-line)
144 (define-key org-agenda-mode-map "k" 'evil-previous-line)
145 ))
146
147 (add-hook 'package-menu-mode-hook
148 (lambda ()
149 (define-key package-menu-mode-map "j" 'evil-next-line)
150 (define-key package-menu-mode-map "k" 'evil-previous-line)
151 ))
152
153 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
154 ;; Tramp
155 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
156 (setq tramp-default-method "ssh")
157
158 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
159 ;; Shell
160 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
10fbe55 @dskang Add to exec-path
authored
161 ;; Don't allow shell prompt to be deleted
8c2d3aa @dskang Ported config over to Emacs 24
authored
162 (setq comint-prompt-read-only t)
163
f0a7095 @dskang Added more packages and ERC settings
authored
164 ;; Don't echo line in irb
165 (defun echo-false-comint ()
166 (setq comint-process-echoes t))
167 (add-hook 'inf-ruby-mode-hook 'echo-false-comint)
168
8c2d3aa @dskang Ported config over to Emacs 24
authored
169 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
170 ;; Indentation
171 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
10fbe55 @dskang Add to exec-path
authored
172 ;; Tab width
173 (setq-default tab-width 4)
174
8c2d3aa @dskang Ported config over to Emacs 24
authored
175 ;; Auto-indentation
176 (dolist (hook '(c-mode-hook
177 java-mode-hook
178 html-mode-hook
f0a7095 @dskang Added more packages and ERC settings
authored
179 rhtml-mode-hook
8c2d3aa @dskang Ported config over to Emacs 24
authored
180 css-mode-hook
181 php-mode-hook
182 js-mode-hook))
183 (add-hook hook '(lambda () (local-set-key "\C-m" 'reindent-then-newline-and-indent))))
184
b6e6ff6 @dskang Added whitespace mode and dedicated windows
authored
185 (add-hook 'python-mode-hook '(lambda ()
8c2d3aa @dskang Ported config over to Emacs 24
authored
186 (define-key python-mode-map "\C-m" 'newline-and-indent)))
57a77a2 @dskang Use the magic of el-get
authored
187
188 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
f0a7095 @dskang Added more packages and ERC settings
authored
189 ;; Programming style
190 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
191 ;; Turn on auto pairs globally
192 (electric-pair-mode)
193
b6e6ff6 @dskang Added whitespace mode and dedicated windows
authored
194 ;; Don't automatically compile after saving in SCSS mode
195 (setq scss-compile-at-save nil)
196
197 ;; Enable whitespace mode everywhere
198 (global-whitespace-mode 1)
199
5067450 @dskang Change Javascript indent style
authored
200 ;; Javascript indentation
201 (setq js-indent-level 2)
202
f0a7095 @dskang Added more packages and ERC settings
authored
203 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
204 ;; Org-mode
205 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
206 (define-key global-map "\C-cl" 'org-store-link)
207 (define-key global-map "\C-ca" 'org-agenda)
208 (setq org-agenda-files '("~/Dropbox/org/" "~/Dropbox/org/courses/"))
209
210 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
211 ;; ERC
57a77a2 @dskang Use the magic of el-get
authored
212 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
f0a7095 @dskang Added more packages and ERC settings
authored
213 (setq erc-fill-column 72)
214 ;; Ignore useless messages
215 (setq erc-track-exclude-types '("JOIN" "NICK" "PART" "QUIT" "MODE"
216 "324" "329" "332" "333" "338" "353" "477"))
1c30778 @dskang Add ERC logging
authored
217
218 ;; Save ERC logs
219 (setq erc-log-insert-log-on-open nil)
500367e @dskang Make erc log directory only one level deep so it auto-creates w/o pro…
authored
220 (setq erc-log-channels-directory "~/.erc/")
1c30778 @dskang Add ERC logging
authored
221 (setq erc-save-buffer-on-part nil
222 erc-save-queries-on-quit nil
223 erc-log-write-after-send t
224 erc-log-write-after-insert t)
d5c1fd8 @dskang Add time and date to status bar
authored
225
Something went wrong with that request. Please try again.