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