Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Newer
Older
100644 218 lines (180 sloc) 7.578 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
8c2d3aa @dskang Ported config over to Emacs 24
authored
47 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
48 ;; Evil mode
49 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
20bd4a7 @dskang Set evil variables before evil is loaded
authored
50 ;; Enable Evil mode in all buffers
8c2d3aa @dskang Ported config over to Emacs 24
authored
51 (evil-mode 1)
52
53 ;; Use 'jk' as ESC
54 ;; http://permalink.gmane.org/gmane.emacs.vim-emulation/684
55 (define-key evil-insert-state-map "j" #'cofi/maybe-exit)
56
57 (evil-define-command cofi/maybe-exit ()
58 :repeat change
59 (interactive)
60 (let ((modified (buffer-modified-p)))
61 (insert "j")
62 (let ((evt (read-event (format "Insert %c to exit insert state" ?k)
b6e6ff6 @dskang Added whitespace mode and dedicated windows
authored
63 nil 0.5)))
8c2d3aa @dskang Ported config over to Emacs 24
authored
64 (cond
65 ((null evt) (message ""))
66 ((and (integerp evt) (char-equal evt ?k))
b6e6ff6 @dskang Added whitespace mode and dedicated windows
authored
67 (delete-char -1)
68 (set-buffer-modified-p modified)
69 (push 'escape unread-command-events))
8c2d3aa @dskang Ported config over to Emacs 24
authored
70 (t (setq unread-command-events (append unread-command-events
b6e6ff6 @dskang Added whitespace mode and dedicated windows
authored
71 (list evt))))))))
38b8ece @dskang Add evil bindings for org mode
authored
72
73 ;; Set cursor color
74 (setq evil-default-cursor '("white" box))
75
8c2d3aa @dskang Ported config over to Emacs 24
authored
76 ;; Show red box if in Emacs mode
77 (setq evil-emacs-state-cursor '("red" box))
78
79 ;; Move using visual lines
80 (define-key evil-normal-state-map (kbd "j") 'evil-next-visual-line)
81 (define-key evil-normal-state-map (kbd "k") 'evil-previous-visual-line)
82
83 ;; General commands
84 (define-key evil-normal-state-map ",w" 'save-buffer) ; save
85 (define-key evil-normal-state-map ",q" 'kill-buffer) ; quit
86 (define-key evil-normal-state-map ",f" 'ido-find-file) ; find file
87 (define-key evil-normal-state-map ",b" 'ido-switch-buffer) ; show buffers
88 (define-key evil-normal-state-map ",o" 'org-agenda) ; show org agenda
89
90 ;; Lisp
91 (evil-define-key 'visual emacs-lisp-mode-map ",," 'eval-region)
92
38b8ece @dskang Add evil bindings for org mode
authored
93 ;; Org-mode
94 (defun always-insert-item ()
95 (interactive)
96 (if (not (org-in-item-p))
97 (insert "\n- ")
98 (org-insert-item)))
99
100 (add-hook 'org-mode-hook
101 (lambda ()
102 (evil-define-key 'normal org-mode-map "O" (lambda ()
103 (interactive)
104 (end-of-line)
105 (org-insert-heading t)
106 (evil-append nil)
107 ))
108
109 (evil-define-key 'normal org-mode-map "o" (lambda ()
110 (interactive)
111 (end-of-line)
112 (always-insert-item)
113 (evil-append nil)
114 ))
115
116 (evil-define-key 'normal org-mode-map "t" (lambda ()
117 (interactive)
118 (end-of-line)
119 (org-insert-todo-heading nil)
120 (evil-append nil)
121 ))
122
123 (evil-define-key 'normal org-mode-map "T" 'org-todo) ; mark a TODO item as DONE
124 (evil-define-key 'normal org-mode-map "-" 'org-cycle-list-bullet) ; change bullet style
125
126 (evil-define-key 'normal org-mode-map (kbd "M-l") 'org-metaright)
127 (evil-define-key 'normal org-mode-map (kbd "M-h") 'org-metaleft)
128 (evil-define-key 'normal org-mode-map (kbd "M-k") 'org-metaup)
129 (evil-define-key 'normal org-mode-map (kbd "M-j") 'org-metadown)
130 (evil-define-key 'normal org-mode-map (kbd "M-L") 'org-shiftmetaright)
131 (evil-define-key 'normal org-mode-map (kbd "M-H") 'org-shiftmetaleft)
132 (evil-define-key 'normal org-mode-map (kbd "M-K") 'org-shiftmetaup)
133 (evil-define-key 'normal org-mode-map (kbd "M-J") 'org-shiftmetadown)
134 ))
135
8c2d3aa @dskang Ported config over to Emacs 24
authored
136 ;; Add "j" and "k" keybindings to some Emacs modes
137 (add-hook 'org-mode-hook
138 (lambda ()
139 (define-key org-agenda-mode-map "j" 'evil-next-line)
140 (define-key org-agenda-mode-map "k" 'evil-previous-line)
141 ))
142
143 (add-hook 'package-menu-mode-hook
144 (lambda ()
145 (define-key package-menu-mode-map "j" 'evil-next-line)
146 (define-key package-menu-mode-map "k" 'evil-previous-line)
147 ))
148
149 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
150 ;; Tramp
151 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
152 (setq tramp-default-method "ssh")
153
154 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
155 ;; Shell
156 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
10fbe55 @dskang Add to exec-path
authored
157 ;; Don't allow shell prompt to be deleted
8c2d3aa @dskang Ported config over to Emacs 24
authored
158 (setq comint-prompt-read-only t)
159
f0a7095 @dskang Added more packages and ERC settings
authored
160 ;; Don't echo line in irb
161 (defun echo-false-comint ()
162 (setq comint-process-echoes t))
163 (add-hook 'inf-ruby-mode-hook 'echo-false-comint)
164
8c2d3aa @dskang Ported config over to Emacs 24
authored
165 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
166 ;; Indentation
167 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
10fbe55 @dskang Add to exec-path
authored
168 ;; Tab width
169 (setq-default tab-width 4)
170
8c2d3aa @dskang Ported config over to Emacs 24
authored
171 ;; Auto-indentation
172 (dolist (hook '(c-mode-hook
173 java-mode-hook
174 html-mode-hook
f0a7095 @dskang Added more packages and ERC settings
authored
175 rhtml-mode-hook
8c2d3aa @dskang Ported config over to Emacs 24
authored
176 css-mode-hook
177 php-mode-hook
178 js-mode-hook))
179 (add-hook hook '(lambda () (local-set-key "\C-m" 'reindent-then-newline-and-indent))))
180
b6e6ff6 @dskang Added whitespace mode and dedicated windows
authored
181 (add-hook 'python-mode-hook '(lambda ()
8c2d3aa @dskang Ported config over to Emacs 24
authored
182 (define-key python-mode-map "\C-m" 'newline-and-indent)))
57a77a2 @dskang Use the magic of el-get
authored
183
184 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
f0a7095 @dskang Added more packages and ERC settings
authored
185 ;; Programming style
186 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
187 ;; Turn on auto pairs globally
188 (electric-pair-mode)
189
b6e6ff6 @dskang Added whitespace mode and dedicated windows
authored
190 ;; Don't automatically compile after saving in SCSS mode
191 (setq scss-compile-at-save nil)
192
193 ;; Enable whitespace mode everywhere
194 (global-whitespace-mode 1)
195
f0a7095 @dskang Added more packages and ERC settings
authored
196 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
197 ;; Org-mode
198 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
199 (define-key global-map "\C-cl" 'org-store-link)
200 (define-key global-map "\C-ca" 'org-agenda)
201 (setq org-agenda-files '("~/Dropbox/org/" "~/Dropbox/org/courses/"))
202
203 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
204 ;; ERC
57a77a2 @dskang Use the magic of el-get
authored
205 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
f0a7095 @dskang Added more packages and ERC settings
authored
206 (setq erc-fill-column 72)
207 ;; Ignore useless messages
208 (setq erc-track-exclude-types '("JOIN" "NICK" "PART" "QUIT" "MODE"
209 "324" "329" "332" "333" "338" "353" "477"))
1c30778 @dskang Add ERC logging
authored
210
211 ;; Save ERC logs
212 (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
213 (setq erc-log-channels-directory "~/.erc/")
1c30778 @dskang Add ERC logging
authored
214 (setq erc-save-buffer-on-part nil
215 erc-save-queries-on-quit nil
216 erc-log-write-after-send t
217 erc-log-write-after-insert t)
Something went wrong with that request. Please try again.