]> git.rkrishnan.org Git - .emacs.d.git/blob - init.el
0fdc0676c9df8216119f6476bd9d5022fdaf738e
[.emacs.d.git] / init.el
1 (setq load-path (cons "~/.emacs.d/emacs" load-path))
2
3 ;; color themes
4 (add-to-list 'custom-theme-load-path "~/.emacs.d/themes")
5 ;(load-theme 'zenburn t)
6
7 (require 'package)
8 (package-initialize)
9 (add-to-list 'package-archives '("melpa" . "http://melpa.milkbox.net/packages/") t)
10
11 (load "my-c-mode.el")
12 (load "my-generic-stuff.el")
13 (load "my-search.el")
14 (load "my-erc.el")
15 (load "my-org-mode.el")
16 (load "my-slime.el")
17 (load "my-twitter.el")
18 (load "my-python.el")
19 (load "my-haskell.el")
20 (load "my-swank-js.el")
21
22 ;; setup font
23 (if (>= emacs-major-version 23)
24     (setq default-frame-alist '((font . "Inconsolata-14")))
25   (set-default-font
26    "-Misc-Fixed-Medium-R-Normal--15-140-75-75-C-90-ISO8859-1"))
27
28 (setq-default indent-tabs-mode nil)
29 (add-hook 'emacs-lisp-mode-hook
30           (lambda () (which-function-mode t)))
31
32 ;; iswitch
33 (iswitchb-mode 1)
34
35 ;; smooth scroll
36 (setq scroll-conservatively 1)
37 (put 'upcase-region 'disabled nil)
38 (put 'downcase-region 'disabled nil)
39
40 ;; cscope
41 (require 'xcscope)
42
43 (defun match-paren (arg)
44   "Go to the matching paren if on a paren; otherwise insert %."
45   (interactive "p")
46   (cond ((looking-at "\\s\(") (forward-list 1) (backward-char 1))
47         ((looking-at "\\s\)") (forward-char 1) (backward-list 1))
48         (t (self-insert-command (or arg 1)))))
49
50 ;; emacs window size according to screen resolution
51 ;; from stackoverflow.com
52 ;;  - <http://stackoverflow.com/questions/92971/how-do-i-set-the-size-of-emacs-window>
53 (defun set-frame-size-according-to-resolution ()
54   (interactive)
55   (if window-system
56       (progn
57         ;; use 120 char wide window for largeish displays
58         ;; and smaller 80 column windows for smaller displays
59         ;; pick whatever numbers make sense for you
60         (if (> (x-display-pixel-width) 1280)
61             (add-to-list 'default-frame-alist (cons 'width 80))
62           (add-to-list 'default-frame-alist (cons 'width 78)))
63         ;; for the height, subtract a couple hundred pixels
64         ;; from the screen height (for panels, menubars and
65         ;; whatnot), then divide by the height of a char to
66         ;; get the height we want
67         (add-to-list 'default-frame-alist
68                      (cons 'height (/ (- (x-display-pixel-height) 0) (frame-char-height)))))))
69
70 (set-frame-size-according-to-resolution)
71
72 ;; tramp
73 (require 'tramp)
74  (setq tramp-default-method "ssh")
75
76 ;; cut and paste with the rest of ecosystem in X
77 (setq x-select-enable-clipboard t)
78
79 ;; remove toolbar
80 (if (> emacs-major-version 20)
81     (tool-bar-mode -1))
82
83 ;; clojure mode
84 (add-to-list 'load-path "~/.emacs.d/vendor/clojure-mode")
85 (require 'clojure-mode)
86
87 ;; highlight parentheses mode
88 (require 'highlight-parentheses)
89
90 ;; rainbow effect
91 ;; http://stackoverflow.com/questions/2413047/how-do-i-get-rainbow-parentheses-in-emacs
92 ;; (setq hl-paren-colors
93 ;;       '(;"#8f8f8f" ; this comes from Zenburn
94 ;;                    ; and I guess I'll try to make the far-outer parens look like this
95 ;;         "orange1" "yellow1" "greenyellow" "green1"
96 ;;         "springgreen1" "cyan1" "slateblue1" "magenta1" "purple"))
97
98 ;; paredit
99 (autoload 'paredit-mode "paredit"
100   "Minor mode for pseudo-structurally editing Lisp code." t)
101
102 (dolist (hook '(emacs-lisp-mode-hook
103                 lisp-mode-hook
104                 lisp-interaction-mode-hook
105                 clojure-mode-hook
106                 scheme-mode-hook))
107   (add-hook hook #'(lambda ()
108                      (highlight-parentheses-mode t)
109                      (paredit-mode +1))))
110 ;; clojure-test-mode
111 (autoload 'clojure-test-mode "clojure-test-mode" "Clojure test mode" t)
112 (autoload 'clojure-test-maybe-enable "clojure-test-mode" "" t)
113 (add-hook 'clojure-mode-hook 'clojure-test-maybe-enable)
114
115 ;; flyspell
116 (autoload 'flyspell-mode "flyspell" "On-the-fly spelling checker." t)
117
118 ;;; fullscreen mode
119 (defun switch-full-screen ()
120   (interactive)
121   (shell-command "wmctrl -r :ACTIVE: -btoggle,fullscreen"))
122
123 (global-set-key [f10] 'switch-full-screen)
124
125 ;; gist integration
126 (require 'gist)
127
128 ;; browse url
129 (setq browse-url-browser-function 'browse-url-firefox
130 ;      browse-url-generic-program "/usr/bin/iceweasel"
131       browse-url-new-window-flag  t
132       browse-url-firefox-new-window-is-tab t)
133 (define-key global-map "\C-co" 'browse-url-at-point)
134
135 ;; nxml for editing xml files
136 (setq auto-mode-alist
137       (cons '("\\.\\(xml\\|xsl\\|rng\\|xhtml\\)\\'" . nxml-mode)
138             auto-mode-alist))
139
140 ;; completions enhancements
141 (icomplete-mode t)
142
143 ;; Interactively Do Things mode
144 (require 'ido)
145
146 (ido-mode t)
147 (setq ido-enable-flex-matching t)
148 (setq ido-enable-last-directory-history nil)
149
150 ;; browse kill ring
151 (when (require 'browse-kill-ring nil 'noerror)
152   (browse-kill-ring-default-keybindings))
153
154 ;; rainbox mode for CSS color highlighting
155 (require 'rainbow-mode)
156
157 (add-to-list 'auto-mode-alist '("\\.rkt$" . scheme-mode))
158
159 ;; scheme auto complete
160 (require 'scheme-complete)
161 (autoload 'scheme-smart-complete "scheme-complete" nil t)
162 (eval-after-load 'scheme
163   '(progn (define-key scheme-mode-map "\t" 'scheme-complete-or-indent)))
164
165 ;; autocomplete
166 (add-to-list 'load-path "~/.emacs.d/vendor/popup/")
167 (add-to-list 'load-path "~/.emacs.d/vendor/auto-complete/")
168 (require 'auto-complete)
169
170 (set-default 'ac-sources
171              '(ac-source-abbrev
172                ac-source-dictionary
173                ac-source-yasnippet
174                ac-source-words-in-buffer
175                ac-source-words-in-same-mode-buffers
176                ac-source-semantic))
177
178 (dolist (m '(c-mode c++-mode java-mode))
179   (add-to-list 'ac-modes m))
180
181 (global-auto-complete-mode t)
182
183 ;; slime autocomplete
184 (add-to-list 'load-path "~/.emacs.d/vendor/ac-slime/")
185
186 (require 'ac-slime)
187 (set-default 'ac-sources 'ac-source-slime-simple)
188 (add-hook 'slime-mode-hook 'set-up-slime-ac)
189 (add-hook 'slime-repl-mode-hook 'set-up-slime-ac)
190
191 ;; scheme/quack
192 ;(require 'quack)
193 ;(setq scheme-program-name "racket")
194 ;(setq quack-default-program "racket -il racket/base")
195 ;(setq quack-switch-to-scheme-method 'other-window)
196 ;(setq quack-newline-behavior 'indent-newline-indent)
197
198 (defun racket-enter! ()
199   (interactive)
200   (comint-send-string (scheme-proc)
201         (format "(enter! (file \"%s\") #:verbose)\n" buffer-file-name))
202   (switch-to-scheme t))
203 (local-set-key "\C-c\C-v" 'racket-enter!)
204
205 ;; company-mode
206 (add-to-list 'load-path "~/.emacs.d/vendor/company-mode")
207 (autoload 'company-mode "company" nil t)
208
209 ;; handle trailing whitespaces
210 ;(add-hook 'before-save-hook 'delete-trailing-whitespace)
211
212 ;; update copyright years before saving.
213 ;(add-hook 'before-save-hook 'copyright-update)
214
215 ;; la carte mode (access menu from keyboard)
216 (require 'lacarte)
217
218 ;;; Based on code by Rudi Schlatte.
219 ;;; Needs this library:
220 ;;; http://www.emacswiki.org/cgi-bin/wiki/XmlRpc
221 (require 'xml-rpc)
222
223 (defvar lisppaste-nick "vu3rdd")
224 (defvar lisppaste-channel "None")
225 (defvar lisppaste-colorize-as "Scheme")
226 (defvar lisppaste-prev-title "")
227
228 (defun lisppaste-region (region-begin region-end
229                                       &optional channel username title annotate)
230   (interactive "r")
231   (let* ((content (buffer-substring region-begin region-end))
232          (channel (or channel
233                       (read-from-minibuffer "Channel: " lisppaste-channel)))
234          (username (or username (read-from-minibuffer "Nick: " lisppaste-nick)))
235          (title (or title (read-from-minibuffer "Title: " lisppaste-prev-title)))
236          (annotate (or annotate (string-to-number (read-from-minibuffer "Annotate? "))))
237          (colorize-as (if (zerop annotate) (read-from-minibuffer "Colorize as (empty for default): " lisppaste-colorize-as))))
238     (setf lisppaste-prev-title title)
239     (let* ((ret (xml-rpc-method-call "http://common-lisp.net:8185/RPC2" 'newpaste
240                                      channel username title content (or colorize-as annotate)))
241            (url-beg (search "http://" ret))
242            (url-end (and url-beg (search " " ret :start2 url-beg)))
243            (url (and url-end (substring ret url-beg url-end))))
244       (print ret)
245       (and url (browse-url url))
246       (or url ret))))
247
248 ;;; displays "\" at the end of lines that wrap
249 (setq longlines-show-hard-newlines t)
250
251 ;; javascript mode
252 (autoload 'js2-mode "js2-mode" nil t)
253 (add-to-list 'auto-mode-alist '("\\.js$" . js2-mode))
254
255 ;; geiser for Scheme programming
256 ;(load-file "~/src/geiser/elisp/geiser.el")
257
258 ;; geiser racket
259 ;(setq geiser-guile-binary "racket")
260 ;(setq geiser-active-implementations '(racket))
261
262 ;; flymake
263 (require 'flymake)
264 (defun flymake-racket-init ()
265   (let* ((temp-file (flymake-init-create-temp-buffer-copy
266                      'flymake-create-temp-inplace))
267          (local-file (file-relative-name
268                       temp-file
269                       (file-name-directory buffer-file-name))))
270     (list "racket" (list "-qf" local-file))))
271
272 (push '("\\.rkt\\'" flymake-racket-init)
273       flymake-allowed-file-name-masks)
274
275
276 ;; ghc-mod
277 (autoload 'ghc-init "ghc" nil t)
278 (add-hook 'haskell-mode-hook
279           (lambda ()
280             (ghc-init)
281             (require 'auto-complete-config)
282             (auto-complete-mode t)
283             (add-to-list 'ac-sources 'ac-source-ghc-mod)))
284 ;; haskell-mode hooks
285 (add-hook 'haskell-mode-hook 'capitalized-words-mode)
286 (add-hook 'haskell-mode-hook 'turn-on-haskell-decl-scan)
287
288 ;; sml
289 (autoload 'sml-mode "sml-mode" "Major mode for editing SML." t)
290 (autoload 'run-sml "sml-proc" "Run an inferior SML process." t)
291
292 (require 'gnus-art)
293
294 ;; sending email
295 (setq message-send-mail-function 'message-send-mail-with-sendmail
296       mail-specify-envelope-from t      ; Settings to work with msmtp
297       message-sendmail-f-is-evil nil  
298       mail-envelope-from 'header
299       message-sendmail-envelope-from 'header
300       sendmail-program "/usr/bin/msmtp"
301       user-full-name "Ramakrishnan Muthukrishnan")
302
303 (setq message-kill-buffer-on-exit t) ; kill buffer after sending mail)
304
305
306 ;; cursor
307 (setq-default cursor-type '(bar . 2))
308 (set-cursor-color "#ff0000")
309
310 ;; color theme
311
312 ;; wombat color theme
313 ;(set-background-color "Black")
314 (set-background-color "#242424")
315 ;(set-foreground-color "White")
316 (set-foreground-color "#f6f3e8")
317 (set-cursor-color "Red")
318 ;(set-cursor-color "#656565")
319 (set-mouse-color "LightSkyBlue")
320 (setq font-lock-maximum-decoration t)
321 (set-face-foreground 'font-lock-comment-face "#99968b")
322 (set-face-italic-p 'font-lock-comment-face t)
323 (set-face-foreground 'font-lock-doc-face "#99968b")
324 (set-face-italic-p 'font-lock-doc-face t)
325 (set-face-foreground 'font-lock-constant-face "#e5786d")
326 (set-face-foreground 'font-lock-string-face "#95e454")
327 (set-face-italic-p 'font-lock-string-face t)
328 (set-face-foreground 'font-lock-variable-name-face "#cae682")
329 (set-face-foreground 'font-lock-function-name-face "#cae682")
330 (set-face-foreground 'font-lock-type-face "#cae682")
331 (set-face-foreground 'font-lock-builtin-face "#8ac6f2")
332 (set-face-foreground 'font-lock-keyword-face "#8ac6f2")
333 (set-face-foreground 'font-lock-preprocessor-face "#e5786d")
334 (set-face-foreground 'font-lock-negation-char-face "#e7f6da")
335 (set-face-foreground 'link "#8ac6f2")
336 (set-face-bold-p 'link t)
337 (set-face-underline-p 'link t)
338 (show-paren-mode t)
339 (set-face-foreground 'show-paren-match-face "#f6f3e8")
340 (set-face-background 'show-paren-match-face "#857b6f")
341 (set-face-bold-p 'show-paren-match t)
342 (set-face-foreground 'region "#f6f3e8")
343 (set-face-background 'region "#444444")
344 (set-face-foreground 'lazy-highlight "black")
345 (set-face-background 'lazy-highlight "yellow")
346
347 ;; color theme from Lau Jenson
348 (defun color-theme-dark-bliss ()
349   ""
350   (interactive)
351   (color-theme-install
352    '(color-theme-dark-bliss
353      ((foreground-color . "#eeeeee")
354       (background-color . "#001122")
355       (background-mode . dark)
356       (cursor-color . "#ccffcc"))
357      (bold ((t (:bold t))))
358      (bold-italic ((t (:italic t :bold t))))
359      (default ((t (nil))))
360
361      (font-lock-builtin-face ((t (:foreground "#f0f0aa"))))
362      (font-lock-comment-face ((t (:italic t :foreground "#aaccaa"))))
363      (font-lock-delimiter-face ((t (:foreground "#aaccaa"))))
364      (font-lock-constant-face ((t (:bold t :foreground "#ffaa88"))))
365      (font-lock-doc-string-face ((t (:foreground "#eeccaa"))))
366      (font-lock-doc-face ((t (:foreground "#eeccaa"))))
367      (font-lock-reference-face ((t (:foreground "#aa99cc"))))
368      (font-lock-function-name-face ((t (:foreground "#ffbb66"))))
369      (font-lock-keyword-face ((t (:foreground "#ccffaa"))))
370      (font-lock-preprocessor-face ((t (:foreground "#aaffee"))))
371      (font-lock-string-face ((t (:foreground "#bbbbff")))))))
372
373 ;; (color-theme-dark-bliss)
374
375 ;; notmuch
376 (setq gnus-inhibit-images nil)
377 (add-to-list 'load-path "~/.emacs.d/emacs/notmuch")
378 (setq notmuch-command "/Users/rkrishnan/bin/remote-notmuch.sh")
379 (require 'notmuch)
380 (when (memq window-system '(mac ns))
381   (exec-path-from-shell-initialize)
382   (setq starttls-use-gnutls t)
383   (setq starttls-gnutls-program "gnutls-cli")
384   (setq starttls-extra-arguments nil)
385   )
386 (setq smtpmail-starttls-credentials '(("rkrishnan.org" 587 nil nil))
387       smtpmail-auth-credentials (expand-file-name "~/.authinfo")
388       smtpmail-default-smtp-server "rkrishnan.org"
389       smtpmail-smtp-server "rkrishnan.org"
390       smtpmail-smtp-service 587)
391
392 (setq notmuch-fcc-dirs nil)
393 (add-hook 'message-header-setup-hook
394     (lambda () (insert (format "Bcc: %s <%s>\n"
395                 (notmuch-user-name)
396                 (notmuch-user-primary-email)))))
397
398 ;; addressbook
399 (require 'notmuch-address)
400 (setq notmuch-address-command "~/bin/addrlookup")
401 (notmuch-address-message-insinuate)
402
403 (require 'smtpmail)
404 (setq message-send-mail-function 'smtpmail-send-it)
405 (require 'starttls)
406
407 ;; sign all emails
408 ;(add-hook 'message-setup-hook 'mml-secure-message-sign-pgpmime)
409
410 (setq default-frame-alist
411       '((font . "Menlo-13")
412         (width . 80)))
413