]> git.rkrishnan.org Git - .emacs.d.git/blob - init.el
12b1e81397d9ed0827aaf622b42e88dfe00b841f
[.emacs.d.git] / init.el
1 (show-paren-mode 1)
2 ;; y-or-n instead of yes-or-no
3 (defalias 'yes-or-no-p 'y-or-n-p)
4
5 ;; Don't use messages that you don't rea
6 (setq make-backup-files nil)
7 (setq initial-scratch-message "")
8 (setq inhibit-startup-message t)
9
10 ;; cursor bar
11 (setq-default cursor-type '(bar . 2))
12
13 ;; column number
14 (column-number-mode 1)
15
16 ;; font
17 ;; (set-default-font "Inconsolata-12")
18
19 ;; Don't let Emacs hurt your ears
20 (setq visible-bell t)
21
22 ;; This is bound to f11 in Emacs 24.4
23 ;; (toggle-frame-fullscreen)
24 (custom-set-variables
25  ;; custom-set-variables was added by Custom.
26  ;; If you edit it by hand, you could mess it up, so be careful.
27  ;; Your init file should contain only one such instance.
28  ;; If there is more than one, they won't work right.
29  '(initial-frame-alist (quote ((fullscreen . maximized))))
30  '(send-mail-function (quote smtpmail-send-it)))
31 ;; Who use the bar to scroll?
32 (when (display-graphic-p)
33   (progn
34     (scroll-bar-mode 0)
35
36     (tool-bar-mode 0)
37     (menu-bar-mode 0)))
38
39 ; my-packages.el
40 (require 'package)
41 (add-to-list 'package-archives
42              '("melpa" . "http://melpa.milkbox.net/packages/") t)
43 (add-to-list 'package-archives
44              '("marmalade" . "http://marmalade-repo.org/packages/") t)
45 (package-initialize)
46
47 ; fetch the list of packages available
48 (unless package-archive-contents
49   (package-refresh-contents))
50
51 ;; make sure my list of packages are installed
52 (setq package-list '(go-mode
53                      rust-mode
54                      haskell-mode
55                      ghc
56                      restclient
57                      tangotango-theme
58                      fill-column-indicator
59                      paredit
60                      leuven-theme
61                      notmuch
62                      railscasts-theme
63                      racket-mode
64                      auto-complete
65                      magit
66                      ledger-mode))
67
68 ; install the missing packages
69 (dolist (package package-list)
70   (unless (package-installed-p package)
71     (package-install package)))
72
73 ;; tangotango
74 ;; (load-theme 'tangotango t)
75 ;; (load-theme 'railscasts t)
76 ;; (load-theme 'leuven t)
77
78 ;; erc
79 (require 'erc)
80 (require 'tls)
81 ;; (setq tls-program '("openssl s_client -connect %h:%p -no_ssl2 -ign_eof"))
82
83 (erc-autojoin-mode t)
84 (setq erc-autojoin-channels-alist
85   '((".*\\.freenode.net" "#tahoe-lafs")
86     (".*\\.oftc.net" "#LeastAuthority")
87     (".*\\.mozilla.org" "#rust-beginners")))
88
89 ;; check channels
90 (erc-track-mode t)
91 (setq erc-track-exclude-types '("JOIN" "NICK" "PART" "QUIT" "MODE"
92                                  "324" "329" "332" "333" "353" "477"))
93 ;; don't show any of this
94 (setq erc-hide-list '("JOIN" "PART" "QUIT" "NICK"))
95
96 (defun start-erc ()
97   "Connect to IRC."
98   (interactive)
99   (when (y-or-n-p "Do you want to start IRC? ")
100     (erc-tls :server "irc.mozilla.org" :port 6697 :nick "rkrishnan" :full-name "Ramakrishnan Muthukrishnan")
101     (erc-tls :server "irc.freenode.net" :port 6697 :nick "rkrishnan" :full-name "Ramakrishnan Muthukrishnan")
102     (erc-tls :server "irc.oftc.net" :port 6697 :nick "rkrishnan" :full-name "Ramakrishnan Muthukrishnan")))
103
104 ;; switch to ERC with Ctrl+c e
105 (global-set-key (kbd "C-c e") 'start-erc) ;; ERC
106
107 ;; haskell mode
108 (setenv "PATH" (concat "~/.cabal/bin:" (getenv "PATH")))
109 (add-to-list 'exec-path "~/.cabal/bin")
110 (add-hook 'haskell-mode-hook 'turn-on-haskell-doc-mode)
111
112 ;; haskell mode
113 (require 'haskell-interactive-mode)
114 (require 'haskell-process)
115 (add-hook 'haskell-mode-hook 'interactive-haskell-mode)
116
117 (custom-set-variables
118   '(haskell-process-suggest-remove-import-lines t)
119   '(haskell-process-auto-import-loaded-modules t)
120   '(haskell-process-log t)
121   '(haskell-process-type 'stack-ghci))
122
123 (define-key haskell-mode-map (kbd "C-c C-l") 'haskell-process-load-or-reload)
124 (define-key haskell-mode-map (kbd "C-`") 'haskell-interactive-bring)
125 (define-key haskell-mode-map (kbd "C-c C-t") 'haskell-process-do-type)
126 (define-key haskell-mode-map (kbd "C-c C-i") 'haskell-process-do-info)
127 (define-key haskell-mode-map (kbd "C-c C-c") 'haskell-process-cabal-build)
128 (define-key haskell-mode-map (kbd "C-c C-k") 'haskell-interactive-mode-clear)
129 (define-key haskell-mode-map (kbd "C-c c") 'haskell-process-cabal)
130 (define-key haskell-mode-map (kbd "SPC") 'haskell-mode-contextual-space)
131
132 ;; ghc-mod
133 (autoload 'ghc-init "ghc" nil t)
134 (autoload 'ghc-debug "ghc" nil t)
135 (setq ghc-debug t)
136 (add-hook 'haskell-mode-hook (lambda () (ghc-init)))
137
138 ;; ido
139 (setq ido-enable-flex-matching t)
140 (setq ido-everywhere t)
141 (ido-mode 1)
142
143 ;; disable tabs for indentation
144 (setq-default indent-tabs-mode nil)
145
146 ;; (require 'whitespace)
147 ;; (setq whitespace-style '(face lines-tail))
148 ;; (setq whitespace-line-column 80)
149 ;; (global-whitespace-mode t)
150
151 ;; ;; show trailing whitespaces
152 ;; (setq-default show-trailing-whitespace t)
153 ;; (setq-default indicate-empty-lines t)
154
155 ;; C style
156 (setq c-default-style "k&r"
157       c-basic-offset 4)
158
159 ;; hlint
160 (add-to-list 'load-path "~/.emacs.d/hs-lint")
161 (require 'hs-lint)
162 (defun my-haskell-mode-hook ()
163    (local-set-key "\C-cl" 'hs-lint))
164 (add-hook 'haskell-mode-hook 'my-haskell-mode-hook)
165
166 ;; gofmt
167 (add-hook 'before-save-hook #'gofmt-before-save)
168 (add-hook 'go-mode-hook (lambda ()
169                           (local-set-key (kbd "C-c C-r")
170                                          'go-remove-unused-imports)))
171 (add-hook 'go-mode-hook (lambda ()
172                           (local-set-key (kbd "C-c i")
173                                          'go-goto-imports)))
174
175 ;; asp
176 (add-to-list 'load-path "~/.emacs.d/asp-mode")
177 (autoload 'asp-mode "asp-mode")
178 (setq auto-mode-alist
179       (cons '("\\.asp\\'" . asp-mode) auto-mode-alist))
180
181 ;; line-number-mode
182 (global-linum-mode t)
183 (global-hl-line-mode 0)
184
185 ;; fci -- fill-column-indicator
186 (setq fci-rule-column 81)
187 (setq fci-rule-width 1)
188 (setq fci-rule-color "darkblue")
189
190 ;; turn off electric-indent-mode
191 (when (fboundp 'electric-indent-mode) (electric-indent-mode -1))
192
193 ;; notmuch
194 (setq mail-user-agent 'message-user-agent)
195 (setq user-mail-address "ram@rkrishnan.org"
196       user-full-name "Ramakrishnan Muthukrishnan")
197
198 ;; smtp
199 (setq smtpmail-stream-type 'ssl
200       smtpmail-smtp-server "mail.messagingengine.com"
201       smtpmail-smtp-service 465)
202
203 ;; addressbook
204 (require 'notmuch-address)
205 (setq notmuch-address-command "/usr/bin/notmuch-addrlookup")
206 (notmuch-address-message-insinuate)
207
208 (require 'smtpmail)
209 (setq message-send-mail-function 'smtpmail-send-it)
210 (require 'starttls)
211
212 ;; sign all emails
213 (add-hook 'message-setup-hook 'mml-secure-message-sign-pgp)
214
215 (custom-set-faces
216  ;; custom-set-faces was added by Custom.
217  ;; If you edit it by hand, you could mess it up, so be careful.
218  ;; Your init file should contain only one such instance.
219  ;; If there is more than one, they won't work right.
220  )
221
222 ;; auto complete
223 (ac-config-default)
224 (ac-linum-workaround)
225
226 ;; highlight todo
227 (add-hook 'prog-mode-hook 'highlight-todos)
228
229 ;; Ledger
230 (setq ledger-binary-path "~/.cabal/bin/hledger")
231
232 ;; golang
233 (setq exec-path (cons "/usr/local/go/bin" exec-path))
234 (add-to-list 'exec-path (concat (getenv "GOPATH") "/bin"))
235
236 (defun go-mode-setup ()
237   (go-eldoc-setup)
238   (setq gofmt-command "goimports")
239   (add-hook 'before-save-hook 'gofmt-before-save))
240
241 (add-hook 'go-mode-hook 'go-mode-setup)
242
243 ;; alias man to w.o.man
244 (defalias 'man 'woman)
245
246 ;; eshell aliases
247 (defun eshell/emacs (&rest args)
248   "open a file in emacs"
249   (if (null args)
250       (bury-buffer)
251     (mapc #'find-file (mapcar #'expand-file-name (eshell-flatten-list (reverse args))))))
252
253 ;(desktop-save-mode 1)
254