1 (setq load-path (cons "~/.emacs.d/emacs" load-path))
4 (load "my-generic-stuff.el")
8 (add-to-list 'custom-theme-load-path "~/.emacs.d/themes")
9 (load-theme 'zenburn t)
13 (if (>= emacs-major-version 23)
14 (setq default-frame-alist '((font . "Inconsolata-12")))
16 "-Misc-Fixed-Medium-R-Normal--15-140-75-75-C-90-ISO8859-1"))
18 ;; (set-default-font "-unknown-Inconsolata-normal-normal-normal-*-16-*-*-*-m-8-iso10646-1")
20 (setq-default indent-tabs-mode nil)
22 (add-hook 'emacs-lisp-mode-hook
23 (lambda () (which-function-mode t)))
28 ;; Load authentication info from an external source. Put sensitive
29 ;; passwords and the like in here.
30 (load "~/.emacs.d/emacs/.erc-auth")
32 (require 'erc-services)
36 (setq erc-prompt-for-nickserv-password nil)
38 (setq erc-nickserv-passwords
39 `((freenode (("vu3rdd" . ,freenode-nick-pass)))
40 (debian (("vu3rdd" . ,debian-nick-pass)))))
42 (setq erc-autojoin-channels-alist
43 '((".*\\.freenode.net" "#racket" "#haskell")
44 (".*\\.oftc.net" "#debian-arm" "#debian" "#debian-devel")))
46 (global-set-key "\C-cef" (lambda () (interactive)
47 (erc :server "irc.freenode.net" :port "8000"
49 (global-set-key "\C-ced" (lambda () (interactive)
50 (erc :server "irc.debian.org" :port "6668"
53 (setq erc-user-full-name "Ramakrishnan Muthukrishnan")
54 (setq erc-email-userid "vu3rdd@gmail.com")
58 (setq erc-track-switch-direction 'importance)
60 ;; Only track my nick(s)
61 (defadvice erc-track-find-face (around erc-track-find-face-promote-query activate)
62 (if (erc-query-buffer-p)
63 (setq ad-return-value (intern "erc-current-nick-face"))
66 (setq erc-keywords '("vu3rdd" "rkrishnan"))
68 (setq erc-track-exclude-types '("JOIN" "NICK" "PART" "QUIT" "MODE"
69 "324" "329" "332" "333" "353" "477"))
71 (global-set-key (kbd "C-c SPC") 'erc-track-switch-buffer)
73 ;; erc notification via notify
74 (defun clean-message (s)
75 (setq s (replace-regexp-in-string "'" "'"
76 (replace-regexp-in-string "\"" """
77 (replace-regexp-in-string "&" "&"
78 (replace-regexp-in-string "<" "<"
79 (replace-regexp-in-string ">" ">" s)))))))
81 (defun call-libnotify (matched-type nick msg)
82 (let* ((cmsg (split-string (clean-message msg)))
83 (nick (first (split-string nick "!")))
84 (msg (mapconcat 'identity (rest cmsg) " ")))
85 (shell-command-to-string
86 (format "notify-send -t 5000 -u critical '%s says:' '%s'" nick msg))))
88 (add-hook 'erc-text-matched-hook 'call-libnotify)
91 (setq erc-log-insert-log-on-open nil)
92 (setq erc-log-channels t)
93 (setq erc-log-channels-directory "~/.erc/logs/")
94 (setq erc-save-buffer-on-part t)
95 (setq erc-save-queries-on-quit nil
96 erc-log-write-after-send t
97 erc-log-write-after-insert t)
98 (defadvice save-buffers-kill-emacs (before save-logs (arg) activate)
99 (save-some-buffers t (lambda () (when (and (eq major-mode 'erc-mode)
100 (not (null buffer-file-name)))))))
101 (add-hook 'erc-insert-post-hook 'erc-save-buffer-in-logs)
107 (setq scroll-conservatively 1)
108 (put 'upcase-region 'disabled nil)
110 (put 'downcase-region 'disabled nil)
115 (defun match-paren (arg)
116 "Go to the matching paren if on a paren; otherwise insert %."
118 (cond ((looking-at "\\s\(") (forward-list 1) (backward-char 1))
119 ((looking-at "\\s\)") (forward-char 1) (backward-list 1))
120 (t (self-insert-command (or arg 1)))))
122 ;; emacs window size according to screen resolution
123 ;; from stackoverflow.com
124 ;; - <http://stackoverflow.com/questions/92971/how-do-i-set-the-size-of-emacs-window>
125 (defun set-frame-size-according-to-resolution ()
129 ;; use 120 char wide window for largeish displays
130 ;; and smaller 80 column windows for smaller displays
131 ;; pick whatever numbers make sense for you
132 (if (> (x-display-pixel-width) 1280)
133 (add-to-list 'default-frame-alist (cons 'width 80))
134 (add-to-list 'default-frame-alist (cons 'width 78)))
135 ;; for the height, subtract a couple hundred pixels
136 ;; from the screen height (for panels, menubars and
137 ;; whatnot), then divide by the height of a char to
138 ;; get the height we want
139 (add-to-list 'default-frame-alist
140 (cons 'height (/ (- (x-display-pixel-height) 0) (frame-char-height)))))))
142 (set-frame-size-according-to-resolution)
146 ;; cut and paste with the rest of ecosystem in X
147 (setq x-select-enable-clipboard t)
150 (setq tramp-default-method "ssh")
153 (defun duplicate-current-line ()
155 (beginning-of-line nil)
158 (copy-region-as-kill b (point)))
159 (back-to-indentation))
161 ;; (global-set-key "\C-b" 'duplicate-current-line)
164 ;; Start GNUServe process when starting up. This lets us send new files
165 ;; to previously spawned emacs process.
167 ;(load "gnuserv-compat")
168 ;(load-library "gnuserv")
170 ;; When loading files reuse existing frames.
171 ;(setq gnuserv-frame (car (frame-list)))
174 (if (> emacs-major-version 20)
178 (require 'org-install)
179 (add-to-list 'auto-mode-alist '("\\.org$" . org-mode))
180 (define-key global-map "\C-cl" 'org-store-link)
181 (define-key global-map "\C-ca" 'org-agenda)
182 (define-key global-map "\C-cb" 'org-iswitchb)
183 (setq org-log-done 'time)
184 (setq org-startup-indented t)
186 (setq org-agenda-files (list "~/org/work.org"
192 "~/org/investments.org"))
194 ;; adapted from <http://doc.norang.ca/org-mode.html>
195 (setq org-todo-keywords '((sequence "TODO(t)"
199 (sequence "WAITING(w@/!)"
204 (setq org-todo-keyword-faces (quote (("TODO" :foreground "red" :weight bold)
205 ("STARTED" :foreground "blue" :weight bold)
206 ("DONE" :foreground "forest green" :weight bold)
207 ("WAITING" :foreground "orange" :weight bold)
208 ("SOMEDAY" :foreground "magenta" :weight bold)
209 ("CANCELLED" :foreground "forest green" :weight bold))))
212 ;; Set up the Common Lisp environment
213 ;(add-to-list 'load-path "/usr/share/common-lisp/source/slime/")
214 ;(setq inferior-lisp-program "/usr/bin/sbcl")
219 ;(autoload 'turn-on-cldoc-mode "cldoc" nil t)
222 (add-to-list 'load-path "~/src/clojure-mode")
223 (require 'clojure-mode)
225 ;; highlight parentheses mode
226 (require 'highlight-parentheses)
229 ;; http://stackoverflow.com/questions/2413047/how-do-i-get-rainbow-parentheses-in-emacs
230 ;; (setq hl-paren-colors
231 ;; '(;"#8f8f8f" ; this comes from Zenburn
232 ;; ; and I guess I'll try to make the far-outer parens look like this
233 ;; "orange1" "yellow1" "greenyellow" "green1"
234 ;; "springgreen1" "cyan1" "slateblue1" "magenta1" "purple"))
237 (add-to-list 'load-path "~/src/slime")
239 (eval-after-load "slime"
241 (setq slime-use-autodoc-mode nil)
242 (slime-setup '(inferior-slime
247 ;; slime-editing-commands
248 slime-fancy-inspector
251 ;; slime-highlight-edits
253 ;; slime-presentation-streams
254 ;; slime-presentations
259 ;;slime-typeout-frame
263 (setq slime-protocol-version 'ignore)
264 (setq slime-complete-symbol*-fancy t)
265 (setq slime-complete-symbol-function 'slime-fuzzy-complete-symbol)))
268 ;(setq inferior-lisp-program "~/src/sbcl/src/runtime/sbcl")
269 (add-to-list 'slime-lisp-implementations '(sbcl ("/usr/bin/sbcl")))
270 (setq slime-default-lisp 'sbcl)
272 (add-to-list 'load-path "~/src/swank-clojure-extra")
274 (setq swank-clojure-classpath (append (list "/usr/share/java/clojure.jar"
275 "~/src/swank-clojure/src"
277 (directory-files "/usr/share/java/"
281 (setq swank-clojure-extra-vm-args (list "-server"
284 "-Djava.net.preferIPv4Stack=true"
287 "-XX:CompileThreshold=1500"
288 "-XX:+UseConcMarkSweepGC"
290 "-XX:+ExplicitGCInvokesConcurrent"
291 "-XX:+CMSClassUnloadingEnabled"
292 "-XX:MaxPermSize=250m"
293 "-XX:+UseAdaptiveSizePolicy"
294 "-XX:+AggressiveOpts"
295 "-XX:+UseFastAccessorMethods"
296 "-XX:+UseFastEmptyMethods"
297 "-XX:+UseFastJNIAccessors"
299 "-XX:+UseCompressedOops"
300 "-XX:MaxInlineSize=1024"
301 "-XX:FreqInlineSize=1024"))
304 (setq swank-gauche-path "~/src/swank-gauche")
305 (setq swank-gauche-gauche-source-path nil)
307 (push swank-gauche-path load-path)
308 (require 'swank-gauche)
310 (add-to-list 'slime-lisp-implementations
311 '(gauche ("gosh") :init gauche-init :coding-system utf-8-unix))
313 (eval-after-load "slime"
315 (require 'swank-clojure-extra)
316 (add-to-list 'slime-lisp-implementations `(clojure ,(swank-clojure-cmd)
317 :init swank-clojure-init)
319 (add-hook 'slime-indentation-update-hooks 'swank-clojure-update-indentation)
320 (add-hook 'slime-repl-mode-hook 'swank-clojure-slime-repl-modify-syntax t)
321 (add-hook 'clojure-mode-hook 'swank-clojure-slime-mode-hook t)))
323 ;; enable cldoc for slime
324 ;; (dolist (hook '(lisp-mode-hook
325 ;; slime-repl-mode-hook))
326 ;; (add-hook hook 'turn-on-cldoc-mode))
328 ;; needed for overriding default method for invoking slime
329 (ad-activate 'slime-read-interactive-args)
332 (autoload 'paredit-mode "paredit"
333 "Minor mode for pseudo-structurally editing Lisp code." t)
335 (dolist (hook '(emacs-lisp-mode-hook
337 lisp-interaction-mode-hook
340 (add-hook hook #'(lambda ()
341 (highlight-parentheses-mode t)
345 (autoload 'clojure-test-mode "clojure-test-mode" "Clojure test mode" t)
346 (autoload 'clojure-test-maybe-enable "clojure-test-mode" "" t)
347 (add-hook 'clojure-mode-hook 'clojure-test-maybe-enable)
349 ;; pressing newline, should also indent automatically
350 ;; (global-set-key "\r" 'newline-and-indent)
353 (autoload 'flyspell-mode "flyspell" "On-the-fly spelling checker." t)
356 (defun switch-full-screen ()
358 (shell-command "wmctrl -r :ACTIVE: -btoggle,fullscreen"))
360 (global-set-key [f10] 'switch-full-screen)
362 ;; (defun fullscreen (&optional f)
364 ;; (set-frame-parameter f 'fullscreen
365 ;; (if (frame-parameter f 'fullscreen) nil 'fullboth)))
367 ;; (global-set-key [f10] 'fullscreen)
369 ;; (add-hook 'after-make-frame-functions 'fullscreen)
375 (autoload 'moz-minor-mode "moz" "Mozilla Minor and Inferior Mozilla Modes" t)
377 (add-hook 'espresso-mode-hook 'espresso-custom-setup)
378 (defun espresso-custom-setup ()
382 (setq browse-url-browser-function 'browse-url-generic
383 browse-url-generic-program "/usr/bin/iceweasel"
384 browse-url-new-window-flag t
385 browse-url-firefox-new-window-is-tab t)
386 (define-key global-map "\C-co" 'browse-url-at-point)
388 ;; nxml for editing xml files
389 (setq auto-mode-alist
390 (cons '("\\.\\(xml\\|xsl\\|rng\\|xhtml\\)\\'" . nxml-mode)
393 ;; completions enhancements
396 ;; Interactively Do Things mode
400 (setq ido-enable-flex-matching t)
401 (setq ido-enable-last-directory-history nil)
404 (when (require 'browse-kill-ring nil 'noerror)
405 (browse-kill-ring-default-keybindings))
407 ;; magit-status bound to Cx-g
408 (global-set-key (kbd "C-x g") 'magit-status)
413 ;; rainbox mode for CSS color highlighting
414 (require 'rainbow-mode)
416 ;; rudel (remote pairing/collaborative editing)
417 ;(add-to-list 'load-path "~/src/rudel")
418 ;(load-file "~/src/rudel/rudel-loaddefs.el")
420 (add-to-list 'auto-mode-alist '("\\.rkt$" . scheme-mode))
422 ;; scheme auto complete
423 (require 'scheme-complete)
424 (autoload 'scheme-smart-complete "scheme-complete" nil t)
425 (eval-after-load 'scheme
426 '(progn (define-key scheme-mode-map "\t" 'scheme-complete-or-indent)))
429 (add-to-list 'load-path "~/src/auto-complete/")
430 (require 'auto-complete)
431 (global-auto-complete-mode t)
433 ;; slime autocomplete
434 (add-to-list 'load-path "~/src/ac-slime/")
437 (set-default 'ac-sources 'ac-source-slime-simple)
438 (add-hook 'slime-mode-hook 'set-up-slime-ac)
439 (add-hook 'slime-repl-mode-hook 'set-up-slime-ac)
443 ;(setq scheme-program-name "racket")
444 ;(setq quack-default-program "racket -il racket/base")
445 ;(setq quack-switch-to-scheme-method 'other-window)
446 ;(setq quack-newline-behavior 'indent-newline-indent)
448 (defun racket-enter! ()
450 (comint-send-string (scheme-proc)
451 (format "(enter! (file \"%s\") #:verbose)\n" buffer-file-name))
452 (switch-to-scheme t))
453 (local-set-key "\C-c\C-v" 'racket-enter!)
456 (add-to-list 'load-path "~/src/company-mode")
457 (autoload 'company-mode "company" nil t)
459 ;; handle trailing whitespaces
460 ;(add-hook 'before-save-hook 'delete-trailing-whitespace)
462 ;; update copyright years before saving.
463 ;(add-hook 'before-save-hook 'copyright-update)
465 ;; la carte mode (access menu from keyboard)
468 ;;; Based on code by Rudi Schlatte.
469 ;;; Needs this library:
470 ;;; http://www.emacswiki.org/cgi-bin/wiki/XmlRpc
473 (defvar lisppaste-nick "vu3rdd")
474 (defvar lisppaste-channel "None")
475 (defvar lisppaste-colorize-as "Scheme")
476 (defvar lisppaste-prev-title "")
478 (defun lisppaste-region (region-begin region-end
479 &optional channel username title annotate)
481 (let* ((content (buffer-substring region-begin region-end))
483 (read-from-minibuffer "Channel: " lisppaste-channel)))
484 (username (or username (read-from-minibuffer "Nick: " lisppaste-nick)))
485 (title (or title (read-from-minibuffer "Title: " lisppaste-prev-title)))
486 (annotate (or annotate (string-to-number (read-from-minibuffer "Annotate? "))))
487 (colorize-as (if (zerop annotate) (read-from-minibuffer "Colorize as (empty for default): " lisppaste-colorize-as))))
488 (setf lisppaste-prev-title title)
489 (let* ((ret (xml-rpc-method-call "http://common-lisp.net:8185/RPC2" 'newpaste
490 channel username title content (or colorize-as annotate)))
491 (url-beg (search "http://" ret))
492 (url-end (and url-beg (search " " ret :start2 url-beg)))
493 (url (and url-end (substring ret url-beg url-end))))
495 (and url (browse-url url))
498 ;; (require 'color-theme-zenburn)
499 ;;(color-theme-zenburn)
501 (add-to-list 'load-path "~/.emacs.d/emacs/twittering-mode")
502 (require 'twittering-mode)
503 (add-hook 'twittering-edit-mode-hook (lambda () (ispell-minor-mode) (flyspell-mode)))
507 ;;; Use python-mode with files with these extensions
508 (add-to-list 'auto-mode-alist '("\\.py\\'" . python-mode))
509 (add-to-list 'auto-mode-alist '("\\.pyx\\'" . python-mode))
511 ;;; Turn on auto-complete in python shells
512 (add-hook 'inferior-python-mode-hook (lambda () (auto-complete-mode 1)))
514 ;;; Use python major mode if 'python' is in hashbang.
515 (add-to-list 'interpreter-mode-alist '("python" . python-mode))
517 ;;; Use python as the python interpreter (can be changed to "ipython" in time
519 (setq python-python-command "python")
521 ;;; Check files for pep8 mistakes
522 (autoload 'python-pep8 "python-pep8")
523 (autoload 'pep8 "python-pep8")
525 ;;; displays "\" at the end of lines that wrap
526 (setq longlines-show-hard-newlines t)
529 (setq auto-mode-alist
530 (append auto-mode-alist
531 '(("\\.[hg]s$" . haskell-mode)
532 ("\\.hic?$" . haskell-mode)
533 ("\\.hsc$" . haskell-mode)
534 ("\\.chs$" . haskell-mode)
535 ("\\.l[hg]s$" . literate-haskell-mode))))
536 (autoload 'haskell-mode "haskell-mode"
537 "Major mode for editing Haskell scripts." t)
538 (autoload 'literate-haskell-mode "haskell-mode"
539 "Major mode for editing literate Haskell scripts." t)
541 ;adding the following lines according to which modules you want to use:
542 (require 'inf-haskell)
544 (add-hook 'haskell-mode-hook 'turn-on-font-lock)
545 (add-hook 'haskell-mode-hook 'turn-on-haskell-ghci)
546 (add-hook 'haskell-mode-hook 'turn-on-haskell-doc-mode)
547 (add-hook 'haskell-mode-hook 'turn-on-haskell-indent)
548 (set-variable 'haskell-program-name "ghci")
551 (add-to-list 'load-path "/var/lib/chicken/6/")
552 (autoload 'chicken-slime "chicken-slime" "SWANK backend for Chicken" t)
553 (setq slime-csi-path "/usr/bin/csi")
554 (add-hook 'scheme-mode-hook
559 (autoload 'js2-mode "js2-mode" nil t)
560 (add-to-list 'auto-mode-alist '("\\.js$" . js2-mode))
563 (add-to-list 'load-path "~/src/swank-js/")
566 ;; geiser for Scheme programming
567 ;(load-file "~/src/geiser/elisp/geiser.el")
570 ;(setq geiser-guile-binary "racket")
571 ;(setq geiser-active-implementations '(racket))
575 (defun flymake-racket-init ()
576 (let* ((temp-file (flymake-init-create-temp-buffer-copy
577 'flymake-create-temp-inplace))
578 (local-file (file-relative-name
580 (file-name-directory buffer-file-name))))
581 (list "racket" (list "-qf" local-file))))
583 (push '("\\.rkt\\'" flymake-racket-init)
584 flymake-allowed-file-name-masks)
588 (autoload 'ghc-init "ghc" nil t)
589 (add-hook 'haskell-mode-hook
592 (require 'auto-complete-config)
593 (auto-complete-mode t)
594 (add-to-list 'ac-sources 'ac-source-ghc-mod)))
595 ;; haskell-mode hooks
596 (add-hook 'haskell-mode-hook 'capitalized-words-mode)
597 (add-hook 'haskell-mode-hook 'turn-on-haskell-decl-scan)
600 (autoload 'sml-mode "sml-mode" "Major mode for editing SML." t)
601 (autoload 'run-sml "sml-proc" "Run an inferior SML process." t)
603 ;; notmuch for email/searching
609 (setq message-send-mail-function 'message-send-mail-with-sendmail
610 mail-specify-envelope-from t ; Settings to work with msmtp
611 message-sendmail-f-is-evil nil
612 mail-envelope-from 'header
613 message-sendmail-envelope-from 'header
614 sendmail-program "/usr/bin/msmtp"
615 user-full-name "Ramakrishnan Muthukrishnan")
617 (setq message-kill-buffer-on-exit t) ; kill buffer after sending mail)
619 (setq notmuch-fcc-dirs "Gmail/Sent") ; stores sent mail to the specified directory
620 (setq message-directory "Gmail/Drafts") ; stores postponed messages to the specified directory