[from now] 2012/05/29 04:04:57

diff --git c/.gitignore i/.gitignore
index 00b5b19..182333e 100644
--- c/.gitignore
+++ i/.gitignore
@@ -1,9 +1,30 @@
 *
 !.gitignore

-!d0tfiles
+!d0tfiles/

-!zsh
+!emacs.d/
+emacs.d/*
+!emacs.d/README.md
+
+!emacs.d/init.el
+!emacs.d/customize.el
+
+!emacs.d/bin/
+!emacs.d/modules/
+!emacs.d/themes/
+!emacs.d/vendor/
+
+!emacs.d/tmp/
+emacs.d/tmp/*
+!emacs.d/tmp/.gitkeep
+
+!emacs.d/var/
+emacs.d/var/*
+!emacs.d/var/.gitkeep
+
+
+!zsh/
 zsh/*
 !zsh/README.md
 !zsh/zshrc
@@ -17,7 +38,7 @@ zsh/*
 !zsh/zshrc.d/

-!vim
+!vim/
 vim/*
 !vim/README.md
 !vim/vimrc
diff --git c/emacs.d/customize.el i/emacs.d/customize.el
new file mode 100644
index 0000000..65c1927
--- /dev/null
+++ i/emacs.d/customize.el
@@ -0,0 +1,12 @@
+(custom-set-variables
+ ;; custom-set-variables was added by Custom.
+ ;; If you edit it by hand, you could mess it up, so be careful.
+ ;; Your init file should contain only one such instance.
+ ;; If there is more than one, they won't work right.
+ '(custom-safe-themes (quote ("7cced48b557e24937f437e59c7f6a6cea5ace4e603377beb5067d0b2c27b4b7d" default))))
+(custom-set-faces
+ ;; custom-set-faces was added by Custom.
+ ;; If you edit it by hand, you could mess it up, so be careful.
+ ;; Your init file should contain only one such instance.
+ ;; If there is more than one, they won't work right.
+ )
diff --git c/emacs.d/init.el i/emacs.d/init.el
new file mode 100644
index 0000000..6ec29bf
--- /dev/null
+++ i/emacs.d/init.el
@@ -0,0 +1,644 @@
+;;; -*- Coding: utf-8-unix; Mode: Emacs-Lisp; -*-
+
+;;; init.el
+(setq user-full-name "Kaz Yoshihara"
+      user-mail-address "m at kroneko dot com")
+;; (setq debug-on-error t)
+(setq debug-on-error nil)
+
+(when (> 23 emacs-major-version)
+  (setq user-emacs-directory "~/.emacs.d"))
+
+(setq emacsd user-emacs-directory
+      emacsd-modules (expand-file-name "modules/" user-emacs-directory)
+      emacsd-scripts (expand-file-name "scripts/" user-emacs-directory)
+      emacsd-private (expand-file-name "private/" user-emacs-directory)
+      emacsd-var (expand-file-name "var/" user-emacs-directory)
+      emacsd-tmp (expand-file-name "tmp/" user-emacs-directory)
+      emacsd-vendor (expand-file-name "vendor/" user-emacs-directory)
+      emacsd-vendor (expand-file-name "vendor/" user-emacs-directory))
+(setq custom-file (concat emacsd "custom.el"))
+
+(require 'package)
+(add-to-list 'package-archives
+             '("melpa" . "http://melpa.milkbox.net/packages/") t)
+(add-to-list 'package-archives
+             '("marmalade" . "http://marmalade-repo.org/packages/") t)
+(package-initialize)
+(setq url-http-attempt-keepalives nil)
+(unless package-archive-contents
+  (message "%s" "Refreshing package database.")
+  (package-refresh-contents))
+(unless (require 'melpa nil t) (package-install 'melpa)
+        (require 'melpa))
+
+(defmacro deflocal (name value &optional docstring)
+  `(progn
+     (defvar ,name ,value ,docstring)
+     (make-variable-buffer-local ',name)))
+
+(progn
+  (defun kk-turn-on-local-column-number-mode ()
+    (make-local-variable 'column-number-mode)
+    (column-number-mode t))
+  (defun kk-turn-on-whitespace () (whitespace-mode +1))
+  (defun kk-turn-off-whitespace () (whitespace-mode -1))
+  (defun kk-turn-on-linum-mode () (linum-mode +1))
+  (defun kk-turn-off-linum-mode () (linum-mode -1))
+  (defun kk-turn-on-ac () (auto-complete-mode +1))
+  (defun kk-turn-off-ac () (auto-complete-mode -1))
+  (defun kk-turn-on-abbrev () (abbrev-mode +1))
+  (defun kk-turn-off-abbrev () (abbrev-mode -1))
+  (defun kk-indent-buffer ()
+    (interactive)
+    (indent-region (point-min) (point-max)))
+  (defun kk-indent-region-or-buffer ()
+    (interactive)
+    (save-excursion
+      (if (region-active-p)
+          (progn (indent-region
+                  (region-beginning) (region-end))
+                 (message "Indented selected region."))
+        (progn (kk-indent-buffer)
+               (message "Indented buffer.")))))
+  (defun kk-untabify-buffer ()
+    (interactive)
+    (untabify (point-min) (point-max)))
+  (defun kk-cleanup-buffer ()
+    (interactive)
+    (kk-indent-buffer)
+    (kk-untabify-buffer)
+    (whitespace-cleanup))
+
+  (defun kk-paredit-nonlisp ()
+    (interactive)
+    (set (make-local-variable 'paredit-space-for-delimiter-predicates)
+         '((lambda (endp delimiter) nil)))
+    (paredit-mode +1))
+  (defun kk-add-watchwords () (font-lock-add-keywords nil '(("\\<\\(FIX\\(ME\\)?\\|TODO\\|HACK\\|REFACTOR\\|NOCOMMIT\\)" 1 font-lock-warning-face t))))) ;; TURN_ON/OFFs
+
+(setq linum-format "%3d")
+(setq whitespace-style '(trailing lines space-before-tab indentation)
+      whitespace-line-column 120
+      whitespace-global-mode nil
+      whitespace-silent t)
+
+(setq visible-bell nil)
+(setq ring-bell-function '(lambda ()))
+
+
+(add-hook 'prog-mode-hook 'kk-add-watchwords)
+;; (add-hook 'prog-mode-hook 'kk-local-comment-auto-fill)
+
+(unless
+    (require 'evil nil t) (viper-mode))
+(progn
+  (require 'evil)
+  (evil-mode +1)
+  (require 'surround)
+  (global-surround-mode +1)
+  (setq evil-default-state 'normal)
+  (setq evil-auto-indent t)
+  (setq evil-shift-width 4)
+  (setq evil-search-wrap t)
+
+  (setq evil-want-C-u-scroll t)
+  (setq evil-want-C-w-in-emacs-state t)
+  (setq evil-want-fine-undo t)
+
+  ;; evil cursors
+  (setq evil-default-cursor '("white" hbar))
+  (setq evil-normal-state-cursor '("gray50" hbar))
+  (setq evil-insert-state-cursor '("gray90" bar))
+  (setq evil-visual-state-cursor '("gray20" box))
+  (setq evil-motion-state-cursor '("black" hbar))
+  (setq evil-replace-state-cursor '("red" hollow))
+  (setq evil-operator-state-cursor '("black" box))
+
+  (define-key evil-normal-state-map (kbd "SPC") 'evil-toggle-fold)
+
+  (evil-declare-key 'normal emacs-lisp-mode-map
+		  (kbd "E") 'eval-buffer
+		  (kbd "=") 'eval-last-sexp)) ;; EVIL
+
+(progn
+  (setq darwin-p (eq system-type 'darwin)
+        is-darwin darwin-p
+        ns-p (featurep 'ns)
+        has-ns ns-p
+        carbon-p (eq window-system 'mac)
+        linux-p (eq system-type 'gnu/linux))) ;; system-type predicates
+(progn
+  (when darwin-p
+    (setq mac-function-modifier 'hyper
+          mac-option-modifier 'meta
+          mac-command-modifier 'meta
+          mac-right-option-modifier 'alt
+          mac-right-command-modifier 'super
+          menu-bar-mode +1
+          mac-allow-anti-aliasing +1
+          system-name (car (split-string system-name "\\.")))
+    (when has-ns
+      (global-set-key (kbd "M-RET") 'ns-toggle-fullscreen)))) ;; Darwin
+
+
+(defmacro set-path (list-var list)
+  (list 'mapc `(lambda (x)
+                 (when (file-accessible-directory-p x)
+                   (add-to-list ',list-var x)))
+        list))
+(set-path load-path (list emacsd
+                          emacsd-modules
+                          emacsd-scripts
+                          emacsd-vendor))
+(set-path exec-path
+          (list "~/bin"
+                "/usr/local/bin"
+                "/usr/local/sbin"
+                "/opt/local/bin"
+                "/opt/local/sbin"
+                "/sbin/"
+                "/bin/"
+                "/usr/bin/"
+                "/usr/sbin/"
+                "/Developer/Tools"))
+
+(progn
+  (defun add-auto-mode (mode &rest patterns)
+    "Add entries to `auto-mode-alist' to use `MODE' for all given file `PATTERNS'."
+    (dolist (pattern patterns)
+      (add-to-list 'auto-mode-alist (cons pattern mode))))) ;; Helper Functions
+
+(defun string-all-matches (regex str &optional group)
+  "Find all matches for `REGEX' within `STR'.
+Returning the full match string or group `GROUP'."
+  (let ((result nil)
+        (pos 0)
+        (group (or group 0)))
+    (while (string-match regex str pos)
+      (push (match-string group str) result)
+      (setq pos (match-end group)))
+    result))
+(defun string-rtrim (str)
+  "Remove trailing whitespace from `STR'."
+  (replace-regexp-in-string "[ \t\n]*$" "" str))
+
+(setq-default save-place t)
+(setq save-place-file (concat emacsd-tmp "places"))
+(require 'saveplace)
+
+(global-hl-line-mode +1)
+
+(progn
+  (require 'tramp)
+  (setq tramp-default-method 'ssh)) ;;TRAMP
+
+;; save recent files
+(setq recentf-save-file (concat emacsd-tmp "recentf")
+      recentf-max-saved-items 200
+      recentf-max-menu-items 15)
+(recentf-mode t)
+
+(setq backup-directory-alist
+      `(("." . ,(concat emacsd-tmp "backups"))))
+(setq version-control t)
+(setq kept-new-versions 3)
+(setq kept-old-versions 3)
+(setq delete-old-versions t)
+(setq delete-auto-save-files t)
+(setq auto-save-timeout 30
+      auto-save-interval 200)
+
+(require 'uniquify)
+(setq uniquify-buffer-name-style 'forward)
+(defun auto-recompile-el-buffer ()
+  (interactive)
+  (when (and (eq major-mode 'emacs-lisp-mode)
+	     (file-exists-p (byte-compile-dest-file buffer-file-name)))
+    (byte-compile-file buffer-file-name)))
+(add-hook 'after-save-hook 'auto-recompile-el-buffer)
+
+
+(setq-default line-spacing 1)
+
+(progn
+  (let* ((size 15)
+         (asciifont "Ricty")
+         (jpfont "Hiragino Maru Gothic ProN")
+         (h (* size 10))
+         (fontspec (font-spec :family asciifont))
+         (fontspec-jp (font-spec :family jpfont)))
+
+    (set-face-attribute 'default nil :family asciifont :height h)
+    (set-fontset-font nil 'japanese-jisx0213.2004-1 fontspec-jp)
+    (set-fontset-font nil 'japanese-jisx0213-2 fontspec-jp)
+    (set-fontset-font nil 'katakana-jisx0201 fontspec-jp)
+    (set-fontset-font nil '(#x3040 . #x309F) fontspec-jp)
+    (set-fontset-font nil '(#x0080 . #x024F) fontspec)
+    (set-fontset-font nil '(#x0370 . #x03FF) fontspec))) ;; fonts
+
+(setq-default buffers-menu-max-size 30)
+
+(tool-bar-mode 0)
+(scroll-bar-mode 0)
+
+(setq backup-by-copying t)
+(setq inhibit-startup-message t)
+(setq initial-scratch-message nil)
+
+(line-number-mode t)
+(column-number-mode t)
+;;; (require 'time)
+;;; (setq display-time-24hr-format t)
+(display-time-mode -1)
+
+(mouse-avoidance-mode 'banish)
+
+(setq frame-title-format "%b")
+(global-set-key (kbd "C-x C-b") 'buffer-menu)
+
+(setq-default tab-width 4)
+(setq-default indent-tabs-mode nil)
+(setq next-line-add-newlines nil)
+
+(setq scroll-conservatively 10000)
+;; (setq scroll-margin 10)
+(setq scroll-preserve-screen-position t)
+(setq comint-scroll-show-maximum-output t)
+
+(setq confirm-kill-emacs 'y-or-n-p)
+
+(defun comment-line-dwim (&optional arg)
+  "Replacement for the comment-dwim command.
+
+If no region is selected and current line is not blank
+and we are not at the end of the line,
+then comment current line.
+Otherwise, it inserts comment at the end of the line."
+  (interactive "*P")
+  (comment-normalize-vars)
+  (if (and (not (region-active-p)) (not (looking-at "[ \t]*$")))
+      (comment-or-uncomment-region
+       (line-beginning-position) (line-end-position))
+    (comment-dwim arg)))
+(global-set-key "\M-;" 'comment-line-dwim)
+
+(show-paren-mode t)
+;; (show-paren-style)
+;; - parenthesis (default)
+;;   highlights "()"
+;; (setq show-paren-style 'parenthesis)
+;; - expression
+;;   highlights inside "()"
+(setq show-paren-style 'expression)
+;; - mixed
+;;   if it fits screen highlight "()"
+;;   otherwise iniside
+;; (setq show-paren-style 'mixed)
+
+(when darwin-p
+  (setq mac-function-modifier 'hyper)
+  (setq mac-option-modifier 'meta)
+  (setq mac-command-modifier 'meta)
+  (setq mac-right-option-modifier 'alt)
+  (setq mac-right-command-modifier 'super)
+  (menu-bar-mode +1)
+  (set-face-font 'default "Envy Code R-13")
+;;  (set-face-font 'default "RictyDiscord-13")
+;;  (set-face-font 'default "RictyDiscord-16")
+;;  (set-face-font 'default "Envy Code R-16")
+  (setq mac-allow-anti-aliasing +1)
+  (setq system-name (car (split-string system-name "\\.")))
+  (when has-ns
+    (global-set-key (kbd "M-RET") 'ns-toggle-fullscreen)))
+
+(require 'auto-complete)
+(require 'auto-complete-config)
+(setq ac-auto-start nil)
+(global-auto-complete-mode -1)
+(setq ac-dwim nil)
+(define-key ac-completing-map (kbd "C-n") 'ac-next)
+(define-key ac-completing-map (kbd "C-p") 'ac-previous)
+(setq tab-always-indent 'complete)
+(add-to-list 'completion-styles 'initials t)
+(defun set-auto-complete-as-completion-at-point-function ()
+  (setq completion-at-point-function '(auto-complete)))
+(add-hook 'auto-complete-mode-hook 'set-auto-complete-as-completion-at-point-function)
+(set-default 'ac-sources
+             '(ac-source-directory
+               ac-source-words-in-buffer
+               ac-source-words-in-same-mode-buffers
+               ac-source-words-in-all-buffer))
+(ac-config-default)
+
+;; Org
+(setq org-modules '(org-bibtex))
+
+(setq org-log-done t
+      org-completion-use-ido t
+      org-edit-timestamp-dowm-means-later t
+      org-agenda-start-on-weekday nil
+      org-agenda-span 14
+      org-agenda-include-diary t
+      org-agenda-window-setup 'current-window
+      org-fast-tag-selection-sigle-key 'expert
+      org-export-kill-product-buffer-when-displayed t
+      org-tags-column 80)
+
+(setq org-log-done 'time)
+(setq org-log-into-drawer t)
+
+;; Save the running clock and all clock history when exiting Emacs, load it on startup
+(setq org-clock-persistence-insinuate t)
+(setq org-clock-persist t)
+(setq org-clock-in-resume t)
+
+(define-key global-map (kbd "C-c l") 'org-store-link)
+(setq org-directory "~/gd/_org")
+(require 'org-export-generic)
+(org-set-generic-type
+ "html5" '(:file-suffix ".html"
+           :key-binding ?H
+           :title-prefix (concat "<!DOCTYPE html>" "\n"
+                                 "<html lang=\"en\">" "\n"
+                                 "  " "<head>" "\n"
+                                 "<meta charset=\"UTF-8\"/" "\n")
+           :title-format "<title>%s</title>\n"
+           :title-suffix "</head>\n<body>\n"
+           :date-export nil
+           :toc-export nil
+           :body-header-section-numbers nil
+           :body-section-header-format (concat "<section title="\"%s\"">" "\n"
+                                               "<header>" "\n" "%s" "\n" "</header>")
+           :body-line-export-preformated t
+           :body-line-fixed-prefix "<pre>\n"
+           :body-line-fixed-suffix "</pre>\n"
+
+           :body-line-format "%s"))
+
+(require 'org-annotate-file)
+(setq org-annotate-file-add-search t)
+(setq org-annotate-file-storage-file "~/gd/_org/annotated.org")
+(global-set-key (kbd "C-c C-l") 'org-annotate-file)
+
+(setq org-babel-load-languages '((emacs-lisp . t)
+                                 (css . t)))
+
+;; (require 'deft)
+;; (setq deft-directory "~/gd/_org")
+;; (setq deft-time-format " %m-%d-%Y %H:%M:%S")
+;; (setq deft-extension "org")
+;; (setq deft-text-mode 'org-mode)
+;; (setq deft-use-filename-as-title t)
+;; (global-set-key [f8] 'deft)
+
+(global-set-key (kbd "C-x C-m") 'execute-extended-command)
+;; (iswitchb-mode -1)
+
+(ido-mode t)
+(ido-everywhere t)
+(ido-ubiquitous-mode t)
+(setq ido-enable-prefix nil)
+(setq ido-enable-flex-matching t)
+(setq ido-create-new-buffer 'always)
+(setq ido-max-prospects 10)
+(setq ido-use-filename-at-point 'always)
+(setq ido-auto-merge-work-directories-length 0)
+(setq ido-use-virtual-buffers t)
+(setq ido-default-file-method 'selected-window)
+
+(icomplete-mode +1)
+
+(set-default 'imenu-auto-rescan t)
+
+(smex-initialize)
+(global-set-key "\M-x" 'smex)
+(global-set-key "\C-x \C-m" 'smex)
+(setq smex-save-file (concat emacsd-tmp "smex"))
+
+(require 'yasnippet)
+(yas/global-mode +1)
+
+(require 'midnight)
+
+(require 'smart-tab)
+(global-smart-tab-mode +1)
+
+;; (add-to-list 'load-path (concat emacsd-vendor "ebib"))
+;; (require 'ebib)
+
+(setq org-hide-leading-stars nil)
+(setq org-odd-levels-only nil)
+(setq org-cycle-separator-lines 0)
+(setq org-blank-before-new-entry '((heading)
+                                   (plain-list-item)))
+
+(setq org-id-method 'uuidgen)
+
+(setq org-completeion-use-ido t)
+(global-set-key "\C-cl" 'org-store-link)
+(global-set-key "\C-ca" 'org-agenda)
+(global-set-key (kbd "<f12>") 'org-agenda)
+(setq org-agenda-files '("~/gd/_org/refile.org"
+                         "~/gd/_org/todo.org"))
+(global-set-key "\C-cb" 'org-iswitchb)
+
+(setq org-link-abbrev-alist
+      '(("bib" . "~/gd/share/bib/refs.bib::%s")
+        ("notes" . "~/gd/share/org/notes.org::#%s")
+        ("papers" . "~/gd/share/pdfs/%s.pdf")))
+
+(defun org-mode-reftex-setup ()
+  (load-library "reftex")
+  (and (buffer-file-name) (file-exists-p (buffer-file-name))
+       (progn
+         (global-auto-revert-mode t)
+         (reftex-parse-all)
+         (reftex-set-cite-format
+          '((?b . "[[bib:%1][%1-bib]]")
+            (?n . "[[notes:%1][%1-notes]]")
+            (?p . "[[papers:%1][%1-paper]]")
+            (?t . "%t")
+            (?h . "** %t\n:PROPERTIES:\n:Custom_ID: %1\nEND:\n[[papers:%1][%1-paper]]")))))
+  (define-key org-mode-map (kbd "C-c )") 'reftex-citation)
+  (define-key org-mode-map (kbd "C-c (") 'org-mode-reftex-search))
+
+(add-hook 'org-mode-hook 'org-mode-reftex-setup)
+
+(defun org-mode-reftex-search ()
+  (interactive)
+  (org-open-link-from-string (format "[[notes:%s]]" (reftex-citation t))))
+(add-hook 'org-mode-hook
+          (lambda ()
+            (make-variable-buffer-local 'yas/trigger-key)
+            (setq yas/trigger-key [tab])
+            (define-key yas/keymap [tab] 'yas/next-field-group)))
+
+(add-to-list 'custom-theme-load-path "~/.emacs.d/themes")
+
+;; revert buffers automatically when underlying files are changed externally
+(global-auto-revert-mode t)
+
+;; hippie expand is dabbrev expand on steroids
+(setq hippie-expand-try-functions-list '(try-expand-dabbrev
+                                         try-expand-dabbrev-all-buffers
+                                         try-expand-dabbrev-from-kill
+                                         try-complete-file-name-partially
+                                         try-complete-file-name
+                                         try-expand-all-abbrevs
+                                         try-expand-list
+                                         try-expand-line
+                                         try-complete-lisp-symbol-partially
+                                         try-complete-lisp-symbol))
+
+(setq bookmark-default-file (concat user-emacs-directory "bookmarks"))
+(setq bookmark-save-flag +1)
+
+(add-hook 'text-mode-hook 'turn-on-auto-fill)
+
+(blink-cursor-mode -1)
+
+(if (fboundp 'fringe-mode)
+    (fringe-mode 4))
+
+(fset 'yes-or-no-p 'y-or-n-p)
+
+(load-theme 'zenburn t)
+
+(add-to-list 'safe-local-variable-values '(lexical-binding . t))
+(add-to-list 'safe-local-variable-values '(whitespace-line-column . 80))
+
+(random t) ;; send the random-number generator
+
+(progn
+  (add-hook 'emacs-lisp-mode-hook 'turn-on-eldoc-mode))
+(define-key read-expression-map (kbd "TAB") 'lisp-complete-symbol)
+(define-key lisp-mode-shared-map (kbd "RET") 'reindent-then-newline-and-indent)
+
+(dolist (mode '(sheme emacs-lisp lisp clojure clojurescript))
+  (add-hook (intern (concat (symbol-name mode) "-mode-hook"))
+            'paredit-mode))
+
+(dolist (mode '(clojure clojurescript))
+  (add-hook (intern (concat (symbol-name mode) "-mode-hook"))
+            'eldoc-mode))
+
+(dolist (mode '(js js2 js3))
+  (add-hook (intern (concat (symbol-name mode) "-mode-hook"))
+            'kk-paredit-nonlisp))
+(setq js3-hilight-level 3)
+(setq js3-auto-indent-p t)
+(setq js3-enter-indents-newline t)
+(setq js3-indent-on-enter-key t)
+(setq js3-strict-missing-semi-warning t)
+(setq js3-indent-level 2)
+(setq js3-lazy-operators t)
+(setq js3-lazy-dots t)
+
+
+;; gnus
+(setq gnus-ignored-newsgroups "")
+(setq gnus-select-method
+      '(nnimap "gmail"
+               (nnimap-address "imap.gmail.com")
+               (nnimap-server-port 993)
+               (nnimap-stream ssl)))
+;; (setq mm-discouraged-alternatives '("text/html" "text/richtext"))
+
+(add-to-list 'load-path (concat emacsd-vendor "mew"))
+(autoload 'mew "mew" nil t)
+(autoload 'mew-send "mew" nil t)
+(setq read-mail-command 'mew)
+(autoload 'mew-user-agent-compose "mew" nil t)
+(if (boundp 'mail-user-agent)
+    (setq mail-user-agent 'mew-user-agent))
+
+(if (fboundp 'define-mail-user-agent)
+    (define-mail-user-agent
+      'mew-user-agent
+      'mew-user-agent-compose
+      'mew-draft-send-message
+      'mew-draft-kill
+      'mew-send-hook))
+
+(set-face-attribute hl-line-face nil :underline t)
+
+;; coffeescript
+(add-to-list 'auto-mode-alist '("\\.coffee$" . coffee-mode))
+(add-to-list 'auto-mode-alist '("Cakefile" . coffee-mode))
+(defun set-tab-width2 ()
+  (set (make-local-variable 'tab-width) 2))
+(add-hook 'coffee-mode-hook
+          '(lambda() (set-tab-width2)))
+
+(add-to-list 'load-path (concat emacsd-vendor "soy-mode"))
+(require 'soy-mode)
+(add-to-list 'auto-mode-alist '("\\.soy$" . soy-mode))
+
+(defun clojure-correct-ns ()
+  "Returns the namespace name that the file should have."
+ (let* ((nsname ())
+        (dirs (reverse (split-string (buffer-file-name) "/")))
+        (aftersrc nil))
+   (dolist (dir dirs)
+     (when (not aftersrc)
+       (if (or (string= dir "src")
+               (string= dir "test")) (setq aftersrc t)
+         (setq nsname (append nsname (list dir "."))))))
+   (when nsname
+     (replace-regexp-in-string "_" "-"
+                               (substring
+                                (apply 'concat (reverse nsname))
+                                1 -4)))))
+(defun clojure-update-ns ()
+  "Updates the namespace of the current buffer. Useful if a file has been renamed."
+  (interactive)
+  (let ((nsname (clojure-correct-ns)))
+    (when nsname
+      (clojure-find-ns) ;; function defined in clojure-mode
+      (replace-match nsname nil nil nil 4))))
+
+(defun earmuffy (&optional arg)
+  (interactive "P")
+  (let* ((variable (thing-at-point 'sexp))
+         (bounds (bounds-of-thing-at-point 'sexp))
+         (current-point (point))
+         (earmuffed-variable (concat "*" variable "*")))
+    (save-excursion)
+    (kill-region (car bounds) (cdr bounds))
+    ;; unearmuffy
+    (if arg (progn (insert (substring variable 1 (- (length variable) 1)))
+                   (goto-char (- current-point 1)))
+      ;; earmuffy
+      (progn (insert earmuffed-variable)
+             (goto-char (+ current-point 1))))))
+
+(progn
+  (add-hook 'Info-mode-hook
+            (lambda ()
+              (local-set-key "j" 'next-line)
+              (local-set-key "k" 'previous-line)
+
+              (local-set-key "l" 'forward-word)
+              (local-set-key "h" 'backward-word)
+
+              (local-set-key " " 'Info-scroll-up)
+              (local-set-key "b" 'Info-scroll-down)
+
+              (local-set-key "g" 'beginning-of-buffer)
+              (local-set-key "G" 'end-of-buffer)
+
+              (local-set-key "J" (lambda () (interactive) (scroll-up 1)))
+              (local-set-key "K" (lambda () (interactive) (scroll-down 1)))
+              (local-set-key "H" 'Info-history-back)
+              (local-set-key "L" 'Info-history-forward)
+
+              (local-set-key "o" 'Info-follow-nearest-node)
+              (local-set-key "n" 'Info-next-reference)
+              (local-set-key "N" 'Info-prev-reference))))
+
+;;(define-key dired-mode-map "j" 'dired-next-line)
+;;(define-key dired-mode-map "k" 'dired-previous-line)
+
+(require 'server)
+(unless (server-running-p) (server-start))