]> git.rkrishnan.org Git - .emacs.d.git/blob - init.el
flycheck, company-mode
[.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                      company-mode
65                      flycheck
66                      flycheck-haskell
67                      magit
68                      ledger-mode))
69
70 ; install the missing packages
71 (dolist (package package-list)
72   (unless (package-installed-p package)
73     (package-install package)))
74
75 ;; tangotango
76 ;; (load-theme 'tangotango t)
77 ;; (load-theme 'railscasts t)
78 ;; (load-theme 'leuven t)
79
80 ;; erc
81 (require 'erc)
82 (require 'tls)
83 ;; (setq tls-program '("openssl s_client -connect %h:%p -no_ssl2 -ign_eof"))
84
85 (erc-autojoin-mode t)
86 (setq erc-autojoin-channels-alist
87   '((".*\\.freenode.net" "#tahoe-lafs")
88     (".*\\.oftc.net" "#LeastAuthority")
89     (".*\\.mozilla.org" "#rust-beginners")))
90
91 ;; check channels
92 (erc-track-mode t)
93 (setq erc-track-exclude-types '("JOIN" "NICK" "PART" "QUIT" "MODE"
94                                  "324" "329" "332" "333" "353" "477"))
95 ;; don't show any of this
96 (setq erc-hide-list '("JOIN" "PART" "QUIT" "NICK"))
97
98 (defun start-erc ()
99   "Connect to IRC."
100   (interactive)
101   (when (y-or-n-p "Do you want to start IRC? ")
102     (erc-tls :server "irc.mozilla.org" :port 6697 :nick "rkrishnan" :full-name "Ramakrishnan Muthukrishnan")
103     (erc-tls :server "irc.freenode.net" :port 6697 :nick "rkrishnan" :full-name "Ramakrishnan Muthukrishnan")
104     (erc-tls :server "irc.oftc.net" :port 6697 :nick "rkrishnan" :full-name "Ramakrishnan Muthukrishnan")))
105
106 ;; switch to ERC with Ctrl+c e
107 (global-set-key (kbd "C-c e") 'start-erc) ;; ERC
108
109 ;; haskell mode
110 (setenv "PATH" (concat "~/.cabal/bin:" (getenv "PATH")))
111 (add-to-list 'exec-path "~/.cabal/bin")
112 (add-hook 'haskell-mode-hook 'turn-on-haskell-doc-mode)
113
114 ;; haskell mode
115 (require 'haskell-interactive-mode)
116 (require 'haskell-process)
117 (add-hook 'haskell-mode-hook 'interactive-haskell-mode)
118
119 (custom-set-variables
120   '(haskell-process-suggest-remove-import-lines t)
121   '(haskell-process-auto-import-loaded-modules t)
122   '(haskell-process-log t)
123   '(haskell-process-type 'stack-ghci))
124
125 (define-key haskell-mode-map (kbd "C-c C-l") 'haskell-process-load-or-reload)
126 (define-key haskell-mode-map (kbd "C-`") 'haskell-interactive-bring)
127 (define-key haskell-mode-map (kbd "C-c C-t") 'haskell-process-do-type)
128 (define-key haskell-mode-map (kbd "C-c C-i") 'haskell-process-do-info)
129 (define-key haskell-mode-map (kbd "C-c C-c") 'haskell-process-cabal-build)
130 (define-key haskell-mode-map (kbd "C-c C-k") 'haskell-interactive-mode-clear)
131 (define-key haskell-mode-map (kbd "C-c c") 'haskell-process-cabal)
132 (define-key haskell-mode-map (kbd "SPC") 'haskell-mode-contextual-space)
133
134 ;; ghc-mod
135 (autoload 'ghc-init "ghc" nil t)
136 (autoload 'ghc-debug "ghc" nil t)
137 (setq ghc-debug t)
138 (add-hook 'haskell-mode-hook (lambda () (ghc-init)))
139
140 ;; ido
141 (setq ido-enable-flex-matching t)
142 (setq ido-everywhere t)
143 (ido-mode 1)
144
145 ;; disable tabs for indentation
146 (setq-default indent-tabs-mode nil)
147
148 ;; (require 'whitespace)
149 ;; (setq whitespace-style '(face lines-tail))
150 ;; (setq whitespace-line-column 80)
151 ;; (global-whitespace-mode t)
152
153 ;; ;; show trailing whitespaces
154 ;; (setq-default show-trailing-whitespace t)
155 ;; (setq-default indicate-empty-lines t)
156
157 ;; C style
158 (setq c-default-style "k&r"
159       c-basic-offset 4)
160
161 ;; hlint
162 (add-to-list 'load-path "~/.emacs.d/hs-lint")
163 (require 'hs-lint)
164 (defun my-haskell-mode-hook ()
165    (local-set-key "\C-cl" 'hs-lint))
166 (add-hook 'haskell-mode-hook 'my-haskell-mode-hook)
167
168 ;; gofmt
169 (add-hook 'before-save-hook #'gofmt-before-save)
170 (add-hook 'go-mode-hook (lambda ()
171                           (local-set-key (kbd "C-c C-r")
172                                          'go-remove-unused-imports)))
173 (add-hook 'go-mode-hook (lambda ()
174                           (local-set-key (kbd "C-c i")
175                                          'go-goto-imports)))
176
177 ;; asp
178 (add-to-list 'load-path "~/.emacs.d/asp-mode")
179 (autoload 'asp-mode "asp-mode")
180 (setq auto-mode-alist
181       (cons '("\\.asp\\'" . asp-mode) auto-mode-alist))
182
183 ;; line-number-mode
184 (global-linum-mode t)
185 (global-hl-line-mode 0)
186
187 ;; fci -- fill-column-indicator
188 (setq fci-rule-column 81)
189 (setq fci-rule-width 1)
190 (setq fci-rule-color "darkblue")
191
192 ;; turn off electric-indent-mode
193 (when (fboundp 'electric-indent-mode) (electric-indent-mode -1))
194
195 ;; notmuch
196 (setq mail-user-agent 'message-user-agent)
197 (setq user-mail-address "ram@rkrishnan.org"
198       user-full-name "Ramakrishnan Muthukrishnan")
199
200 ;; smtp
201 (setq smtpmail-stream-type 'ssl
202       smtpmail-smtp-server "mail.messagingengine.com"
203       smtpmail-smtp-service 465)
204
205 ;; addressbook
206 (require 'notmuch-address)
207 (setq notmuch-address-command "/usr/bin/notmuch-addrlookup")
208 (notmuch-address-message-insinuate)
209
210 (require 'smtpmail)
211 (setq message-send-mail-function 'smtpmail-send-it)
212 (require 'starttls)
213
214 ;; sign all emails
215 (add-hook 'message-setup-hook 'mml-secure-message-sign-pgp)
216
217 (custom-set-faces
218  ;; custom-set-faces was added by Custom.
219  ;; If you edit it by hand, you could mess it up, so be careful.
220  ;; Your init file should contain only one such instance.
221  ;; If there is more than one, they won't work right.
222  )
223
224 ;; company mode for auto completion
225 (add-hook 'after-init-hook 'global-company-mode)
226
227 ;; highlight todo
228 ;; (add-hook 'prog-mode-hook 'highlight-todos)
229
230 ;; Ledger
231 (setq ledger-binary-path "~/.cabal/bin/hledger")
232
233 ;; golang
234 (setq exec-path (cons "/usr/local/go/bin" exec-path))
235 (add-to-list 'exec-path (concat (getenv "GOPATH") "/bin"))
236
237 (defun go-mode-setup ()
238   (go-eldoc-setup)
239   (setq gofmt-command "goimports")
240   (add-hook 'before-save-hook 'gofmt-before-save))
241
242 (add-hook 'go-mode-hook 'go-mode-setup)
243
244 ;; alias man to w.o.man
245 (defalias 'man 'woman)
246
247 ;; eshell aliases
248 (defun eshell/emacs (&rest args)
249   "open a file in emacs"
250   (if (null args)
251       (bury-buffer)
252     (mapc #'find-file (mapcar #'expand-file-name (eshell-flatten-list (reverse args))))))
253
254 ;(desktop-save-mode 1)
255