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