Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
tree: 5af15cf5b6
Fetching contributors…

Cannot retrieve contributors at this time

1497 lines (1237 sloc) 49.992 kb
;; -*- mode: emacs-lisp; indent-tabs-mode: nil -*-
;;.emacs file for Nelson Elhage (nelhage@mit.edu)
;; Requires emacs 22 or higher
(add-to-list 'load-path "~/.elisp")
(cd "~/.elisp")
(load "~/.elisp/subdirs.el")
(cd "~")
(require 'uniquify)
(require 'utils)
(require 'structured)
(require 'dirvars)
;;Global key bindings
(global-set-key (kbd "<deletechar>") 'backward-delete-char)
(global-set-key (kbd "ESC <deletechar>") 'backward-kill-word)
(global-set-key (kbd "C-z") nil)
(global-set-key "\M-g" 'goto-line)
(global-set-key "\C-m" 'newline-and-indent)
(global-set-key "\M-k" 'kill-word)
(global-set-key "\C-cc" 'compile)
(global-set-key "\C-a" 'beginning-of-line-dwim)
(global-set-key "\C-co" 'other-window)
(global-set-key [f5] 'call-last-kbd-macro)
(global-set-key (kbd "TAB") 'indent-and-complete-symbol-generic)
(global-set-key (kbd "M-r") 're-search-backward)
(global-set-key (kbd "M-s") 're-search-forward)
; (global-set-key [up] 'increment-number-at-point)
; (global-set-key [down] 'decrement-number-at-point)
(global-set-key (kbd "C-x C-c") 'server-edit)
(setq window-number-prefix "\C-c")
(require 'window-number)
(window-number-mode 1)
(setq display-time-24hr-format t)
; (global-set-key (kbd "C-x 4 C-f") 'window-number-find-file)
; (global-set-key (kbd "C-x 4 f") 'window-number-find-file)
(setq lpr-switches '("-h"))
(setq ps-left-header '(ps-get-buffer-name user-full-name))
(setq woman-use-own-frame nil)
(fset 'rm 'delete-file)
(fset 'mv 'rename-file)
(fset 'cp 'copy-file)
(fset 'mkdir 'make-directory)
(fset 'rmdir 'delete-directory)
(condition-case nil
(progn
;; Apparently I'm not supposed to set this globally, but if you're not
;; going to tell me why, too bad.
(setq epa-armor t)
(require 'epa-file)
(epa-file-enable))
('file-error . nil))
(autoload 'nethack "nethack" "Play Nethack." t)
(setq nethack-program "/usr/games/nethack-lisp")
;; DocView / Image Viewer
(eval-after-load 'doc-view
'(progn
(define-key doc-view-mode-map (kbd "C-v") 'doc-view-scroll-up-or-next-page)
(define-key doc-view-mode-map (kbd "M-v") 'doc-view-scroll-down-or-previous-page)
(define-key doc-view-mode-map (kbd "C-e") 'image-eol)
(define-key doc-view-mode-map (kbd "C-a") 'image-bol)
(define-key doc-view-mode-map (kbd "C-c t") 'doc-view-open-text)))
(eval-after-load 'compile
'(progn
(let ((ent (assq 'gcc-include compilation-error-regexp-alist-alist)))
(when ent
(setcar (cdr ent) "^\\(?:In file included\\| \\) from \\(.+?\\):\\([0-9]+\\)\\(:[0-9]+\\)?\\(?:\\(:\\)\\|\\(,\\)\\)?")
(setcdr (cdr ent) (list 1 2 nil '(4 . 5)))))))
(defun strip-lf ()
(interactive)
(save-excursion
(replace-string "
" "" nil (point-min) (point-max))))
(defvar complete-symbol-function nil "Function to be called to
complete a symbol in the current buffer. Should perform
completion at point and return. If nil, the current mode is
unable to perform symbol completion.")
(make-variable-buffer-local 'complete-symbol-function)
(defun indent-and-complete-symbol-generic ()
"Indent the current line and perform symbol completion using
`complete-symbol-function'. First indent the line, and if
indenting doesn't move point, complete the symbol at point."
(interactive)
(let ((pt (point)))
(funcall indent-line-function)
(when (and (not (null complete-symbol-function))
(= pt (point))
(save-excursion (re-search-backward "[^() \n\t\r]+\\=" nil t))
(or (looking-at "\\Sw")
(= (point) (point-max))))
(funcall complete-symbol-function))))
;;Set up fonts and colors
(when (fboundp 'global-font-lock-mode)
(setq font-lock-face-attributes
'((font-lock-comment-face "OrangeRed")
(font-lock-function-name-face "#5555AA")
(font-lock-keyword-face "Cyan1")
(font-lock-string-face "orange")))
(require 'font-lock)
(require 'whitespace)
(when (facep 'whitespace-tab)
(set-face-background 'whitespace-tab "#111133"))
(setq whitespace-style '(face trailing tabs))
(global-whitespace-mode 1)
(set-face-attribute 'font-lock-comment-face nil :slant 'italic)
(setq font-lock-maximum-decoration t
font-lock-global-modes '(not magit-mode w3m-mode term-mode))
(global-font-lock-mode 1))
(defun safe-set-face-attribute (face frame &rest args)
(when (facep face)
(apply 'set-face-attribute face frame args)))
(eval-after-load 'diff-mode
'(progn
(safe-set-face-attribute 'diff-refine-change nil :background "gray20")
(safe-set-face-attribute 'diff-file-header nil :background "gray40")
(safe-set-face-attribute 'diff-removed-face nil :foreground "red")
(safe-set-face-attribute 'diff-added-face nil :foreground "green")))
(eval-after-load 'flymake
'(progn
(global-set-key (kbd "C-c f") (make-sparse-keymap))
(global-set-key (kbd "C-c f n") 'my-flymake-goto-next-error)
(global-set-key (kbd "C-c f p") 'my-flymake-goto-prev-error)
(global-set-key (kbd "C-c f .") 'flymake-display-err-menu-for-current-line)
(set-face-attribute 'flymake-errline nil
:underline "OrangeRed")
(set-face-attribute 'flymake-warnline nil
:underline "cyan")
(set-face-background 'flymake-errline nil)
(set-face-background 'flymake-warnline nil)))
(defun my-flymake-goto-next-error ()
(interactive)
(flymake-goto-next-error)
(message (get-char-property (point) 'help-echo)))
(defun my-flymake-goto-prev-error ()
(interactive)
(flymake-goto-prev-error)
(message (get-char-property (point) 'help-echo)))
(defun my-echo-help-text ()
(let ((help-echo (get-char-property (point) 'help-echo)))
(when (and help-echo flymake-mode)
(message help-echo))))
(setq my-echo-help-timer (run-with-idle-timer 1 t 'my-echo-help-text))
(defvar default-font "Ubuntu Mono-10" "The default font")
(when window-system
(let ((backups (list "Mono-9"
"-adobe-courier-medium-r-*-*-12-*-*-*-*-70-iso8859-1")))
(while (and backups (not (font-info default-font)))
(setq default-font (car backups))
(setq backups (cdr backups)))))
(setq default-frame-alist
`((menu-bar-lines . 0)
(font . ,default-font)
(foreground-color . "#AAA")
(background-color . "black")
(background-mode . 'dark)
(vertical-scroll-bars . nil)
(tool-bar-lines . 0)))
(defun set-projector-faces ()
(interactive)
(set-face-attribute 'default nil
:height 150
:foreground "black"
:background "white")
(set-face-attribute 'font-lock-comment-face nil
:foreground "dark green")
(set-face-attribute 'font-lock-keyword-face nil
:foreground "blue"
:weight 'bold)
(set-face-attribute 'font-lock-string-face nil
:foreground "dark red")
(set-face-attribute 'pesche-tab nil
:background "white")
(set-face-attribute 'pesche-space nil
:background "white"))
(defun set-normal-faces ()
(interactive)
(set-face-attribute 'default nil
:foreground "#AAA"
:background "black")
(set-face-attribute 'font-lock-comment-face nil
:foreground "OrangeRed")
(set-face-attribute 'font-lock-keyword-face nil
:foreground "Cyan1"
:weight 'normal)
(set-face-attribute 'font-lock-string-face nil
:foreground "orange")
(set-frame-font default-font t)
(set-face-attribute 'pesche-tab nil
:background "#113")
(set-face-attribute 'pesche-space nil
:background "#311"))
(defun safe-funcall (func &rest args)
"Call FUNC on ARGS if and only if FUNC is defined as a function."
(when (fboundp func) (apply func args)))
(setq inhibit-startup-message t)
(safe-funcall 'set-scroll-bar-mode nil)
(safe-funcall 'tool-bar-mode -1)
(safe-funcall 'auto-compression-mode 1)
(safe-funcall 'column-number-mode 1)
(safe-funcall 'fringe-mode '(0 . nil))
(safe-funcall 'menu-bar-mode 0)
; (safe-funcall 'display-time-mode)
; (safe-funcall 'display-battery-mode)
(transient-mark-mode 0)
(setq c-basic-offset 4
mouse-wheel-follow-mouse nil
mouse-wheel-progressive-speed nil
confirm-kill-emacs 'yes-or-no-p
x-select-enable-clipboard t
uniquify-buffer-name-style 'post-forward-angle-brackets
outline-regexp "\\s *\\*+"
comint-prompt-read-only t
diff-switches "-u"
compile-command "find-makefile"
pop-up-windows nil)
(eval-after-load 'grep
'(progn
(grep-apply-setting 'grep-use-null-device nil)
(grep-apply-setting 'grep-command "gr -nH -e ")
(defun grep-default-command ()
grep-command)))
(defun chomp (str)
"Chomp leading and tailing whitespace from STR."
(while (string-match "\\`\n+\\|^\\s-+\\|\\s-+$\\|\n+\\'"
str)
(setq str (replace-match "" t t str)))
str)
(eval-after-load 'calc
'(progn
(defadvice calc (around calc-pop-up-windows)
(let ((pop-up-windows t))
ad-do-it))
(ad-activate 'calc)
(define-key calc-mode-map (kbd "C-/") 'calc-undo)))
(setq-default tab-width 8
truncate-lines t
truncate-partial-width-windows nil
indent-tabs-mode nil)
(setq tramp-default-method "ssh")
;; (require 'paren)
;; (when (fboundp 'show-paren-mode)
;; (setq show-paren-delay 0)
;; (show-paren-mode 1))
(require 'shell)
(add-hook 'shell-mode-hook 'ansi-color-for-comint-mode-on)
(add-hook 'shell-mode-hook 'my-shell-mode-hook)
(defun inferior-process-cwd (buffer)
(let ((proc (get-buffer-process buffer)))
(if proc
(let ((pid (process-id proc)))
(file-symlink-p (concat "/proc/" (int-to-string pid) "/cwd"))))))
(defun shell-mode-chdir (line)
(let ((wd (inferior-process-cwd (current-buffer))))
(when wd (cd wd)))
line)
(defun my-shell-mode-hook ()
(shell-dirtrack-mode 0)
(add-hook 'comint-preoutput-filter-functions 'shell-mode-chdir))
(defun named-shell (name directory)
(interactive "MShell name: \nDIn directory: ")
(switch-to-buffer (concat "*" name "*"))
(cd directory)
(shell (current-buffer)))
(defun filter-trailing-whitespace (string)
(replace-regexp-in-string "\[ \t\]+$" "" string))
(add-hook 'term-mode-hook 'my-term-mode-hook)
(defun my-term-mode-hook ()
(add-hook 'buffer-substring-filters 'filter-trailing-whitespace))
(defun maybe-browse-url-at-point ()
(interactive)
(let ((url (thing-at-point 'url)))
(if (and url
(string-match "^https?://.*\\..*" url))
(browse-url-at-point))))
(defun term-send-c-space ()
(interactive)
(term-send-raw-string "\0"))
(eval-after-load 'term
'(progn
(setq term-default-bg-color 'unspecified)
(setq term-default-fg-color 'unspecified)
;;(define-key term-raw-map (kbd "C-x M-x") 'execute-extended-command)
(define-key term-raw-map (kbd "<mouse-4>") 'term-send-up)
(define-key term-raw-map (kbd "<mouse-5>") 'term-send-down)
(define-key term-raw-map (kbd "C-SPC") 'term-send-c-space)
;; (define-key term-raw-map (kbd "ESC") 'term-send-raw-meta)
(define-key term-raw-map (kbd "C-/") 'term-send-undo)
(define-key term-raw-map (kbd "<mouse-1>") 'maybe-browse-url-at-point)
(let ((i 1))
(while (<= i 12)
(define-key term-raw-map (vector (make-symbol (concat "f" (int-to-string i))))
'my-term-send-fN)
(setq i (+ i 1))))
(defun my-term-send-fN ()
(interactive)
(let ((evt last-input-event))
(when (and (symbolp evt)
(string-match "^f\\([0-9]+\\)" (symbol-name evt)))
(let ((n (string-to-int (match-string 1 (symbol-name evt)))))
(message "%s" n)
(term-send-raw-string
(format "\eO%c" (+ ?O n)))))))
(defun term-send-raw-meta ()
(interactive)
(let ((char last-input-event))
(when (symbolp last-input-event)
;; Convert `return' to C-m, etc.
(let ((tmp (get char 'event-symbol-elements)))
(when tmp
(setq char (car tmp)))
(when (symbolp char)
(setq tmp (get char 'ascii-character))
(when tmp
(setq char tmp)))))
(setq char (logand char (lognot ?\M-\^@)))
(term-send-raw-string (if (and (numberp char)
(> char 127)
(< char 256))
(make-string 1 char)
(format "\e%c" char)))))))
(defun term-send-undo ()
(interactive)
(term-send-raw-string (kbd "^_")))
(defun named-term (name directory)
(interactive "MTerminal name: \nDIn directory: ")
(let ((default-directory directory))
(ansi-term (getenv "SHELL") name)))
(add-to-list 'auto-mode-alist (cons "bash-fc-[0-9]+$" 'sh-mode))
(defun dedicate-window (&optional window)
(interactive)
(if (null window)
(setq window (get-buffer-window (current-buffer))))
(set-window-dedicated-p window t))
(defun undedicate-window (&optional window)
(interactive)
(if (null window)
(setq window (get-buffer-window (current-buffer))))
(set-window-dedicated-p window nil))
(require 'mmm-auto)
(setq mmm-global-mode 'maybe
mmm-submode-decoration-level 0)
(require 'dired-x)
(safe-funcall 'dired-omit-mode 1)
(setq dired-listing-switches "-l")
(global-set-key "\C-x\C-b" 'ibuffer-list-buffers)
(require 'ido)
(ido-mode 1)
(ido-everywhere 1)
(setq ido-auto-merge-work-directories-length -1
ido-max-directory-size (* 256 1024)
ido-enable-flex-matching t
)
(defun my-ido-keys ()
(mapc (lambda (K)
(let* ((key (car K)) (fun (cdr K)))
(define-key ido-completion-map (edmacro-parse-keys key) fun)))
'(("<right>" . ido-next-match)
("<left>" . ido-prev-match)
("<up>" . ignore )
("<down>" . ignore )
("\C-n" . ido-next-match)
("\C-p" . ido-prev-match))))
(add-hook 'ido-minibuffer-setup-hook 'my-ido-keys)
; (require 'iswitchb)
; (iswitchb-mode nil)
;
; (defadvice iswitchb-visit-buffer (before iswitchb-undedicate-window)
; (undedicate-window))
; (ad-activate 'iswitchb-visit-buffer)
;
; (defun iswitchb-local-keys ()
; (mapc (lambda (K)
; (let* ((key (car K)) (fun (cdr K)))
; (define-key iswitchb-mode-map (edmacro-parse-keys key) fun)))
; '(("<right>" . iswitchb-next-match)
; ("<left>" . iswitchb-prev-match)
; ("<up>" . ignore )
; ("<down>" . ignore )
; ("\C-n" . iswitchb-next-match)
; ("\C-p" . iswitchb-prev-match))))
;
; (add-hook 'iswitchb-minibuffer-setup-hook 'iswitchb-local-keys)
(defun my-find-file (arg)
(interactive "P")
(call-interactively (if arg 'my-git-find-file 'ido-find-file)))
(global-set-key (kbd "C-x C-f") 'my-find-file)
(defun my-git-wc-root ()
(expand-file-name
(chomp (shell-command-to-string "git rev-parse --show-cdup"))))
(defun git-grep ()
(interactive)
(let ((grep-command "git grep -nH -e ")
(default-directory (my-git-wc-root)))
(call-interactively 'grep)))
(defun my-git-find-file ()
"Use ido to select a file from the git repo"
(interactive)
(let* ((my-project-root (my-git-wc-root))
(git-dir (chomp (shell-command-to-string "git rev-parse --git-dir")))
(project-files
(split-string
(shell-command-to-string
(concat "git --git-dir "
(shell-quote-argument git-dir)
" ls-files -c -o"))
"\n")))
;; populate hash table (display repr => path)
(setq tbl (make-hash-table :test 'equal))
(let (ido-list)
(mapc (lambda (path)
;; format path for display in ido list
(setq key path)
;; strip project root
(setq key (replace-regexp-in-string my-project-root "" key))
;; remove trailing | or /
(setq key (replace-regexp-in-string "\\(|\\|/\\)$" "" key))
(puthash key (expand-file-name (concat my-project-root "/" path)) tbl)
(push key ido-list))
project-files)
(let ((ido-decorations (quote ("\n-> " "" "\n " "\n ..." "[" "]" " [No match]" " [Matched]" " [Not readable]" " [Too big]" " [Confirm]")))
(truncate-lines nil))
(find-file (gethash (ido-completing-read "files: " ido-list) tbl))))))
(require 'windmove)
(windmove-default-keybindings)
;;Templates
(require 'template)
(template-initialize)
(setq template-auto-insert t)
(setq template-auto-update nil)
(add-to-list 'template-expansion-alist
(list "AUTHOR"
'(insert (concat
user-full-name
" <" user-mail-address "> "))))
(defun define-bracket-keys ()
(interactive)
(local-set-key "{" 'insert-brackets)
(local-set-key "}" 'insert-close))
;;Version control
(defmacro advise-to-save-windows (func)
`(progn
(defadvice ,func (around ,(intern (concat (symbol-name func) "-save-windows")))
(save-window-excursion ad-do-it))
(ad-activate ',func)))
(advise-to-save-windows vc-revert-buffer)
(setq vc-delete-logbuf-window nil)
(defun safe-require (feature)
"Require FEATURE, failing silently if it does not exist"
(condition-case nil
(require feature)
('file-error . nil)))
(safe-require 'psvn)
; (safe-require 'vc-svk)
(safe-require 'vc-git)
(safe-require 'git)
(when (featurep 'vc-git) (add-to-list 'vc-handled-backends 'git))
(require 'magit)
(require 'magit-svn)
(global-set-key (kbd "C-c g") 'magit-status)
; (eval-after-load 'magit
; '(progn
; (set-face-background 'magit-item-highlight "grey8")
; (set-face-attribute 'magit-diff-add nil
; :foreground 'unspecified
; :inherit diff-added-face)
; (set-face-attribute 'magit-diff-del nil
; :foreground 'unspecified
; :inherit diff-removed-face)
; (set-face-attribute 'magit-diff-none nil
; :foreground 'unspecified
; :inherit diff-context-face)
; ;(require 'magit-svn)
; ))
(condition-case nil
(progn
(require 'vc-hg)
(add-to-list 'vc-handled-backends 'hg))
('file-error . nil))
(load-library "dvc-load")
(setq xgit-use-index 'always
dvc-tips-enabled nil)
;;Perl configuration
(defalias 'perl-mode 'cperl-mode)
(add-hook 'cperl-mode-hook 'my-perl-mode-hook)
(setq cperl-invalid-face nil
cperl-font-lock t
cperl-indent-parens-as-block t
cperl-indent-level 4
cperl-continued-statement-offset 0
cperl-brace-offset -2
cperl-indent-region-fix-constructs nil)
(put 'cperl-indent-level 'safe-local-variable 'integerp)
(autoload 'perldoc "perl-utils" "Look up documentation on a perl module" t)
(autoload 'run-perl "inf-perl" "Run perl interactively" t)
(setq inf-perl-shell-program "/usr/bin/re.pl")
(defun my-perl-mode-hook ()
(require 'perl-utils)
(local-set-key "\C-cp" 'perl-check-pod)
(local-set-key "{" 'perl-insert-brackets)
(local-set-key "}" 'insert-close)
(local-set-key "\C-c\C-d" (make-sparse-keymap))
(local-set-key "\C-c\C-dh" 'cperl-perldoc)
(local-set-key "\C-ct" 'perl-add-test)
(local-set-key (kbd "C-M-\\") 'indent-region)
(local-set-key "\C-c\C-v" 'cperl-build-manpage)
(local-set-key "\C-c\C-c" 'cperl-build-manpage)
(setq indent-tabs-mode nil))
(add-to-list 'template-expansion-alist
(list "PERL_PACKAGE"
'(insert (perl-guess-package
(concat (car template-file)
(cadr template-file))))))
(add-to-list 'auto-mode-alist (cons "\\.t$" 'perl-mode))
(add-to-list 'auto-mode-alist (cons "\\.xs$" 'c-mode))
;;Python mode
(when (load "flymake" t)
(defun flymake-pylint-init ()
(let* ((temp-file (flymake-init-create-temp-buffer-copy
'flymake-create-temp-inplace))
(local-file (file-relative-name
temp-file
(file-name-directory buffer-file-name))))
(list "epylint" (list local-file))))
(add-to-list 'flymake-allowed-file-name-masks
'("\\.py\\'" flymake-pylint-init)))
(add-to-list 'interpreter-mode-alist (cons "python2.4" 'python-mode))
(add-to-list 'interpreter-mode-alist (cons "python2.5" 'python-mode))
(add-to-list 'auto-mode-alist (cons "SConscript$" 'python-mode))
(add-to-list 'auto-mode-alist (cons "SConstruct$" 'python-mode))
(eval-after-load 'python
'(progn
(define-key python-mode-map (kbd "M-TAB") 'dabbrev-expand)))
(defun pydoc (word)
"Run `pydoc' on WORD and display it in a buffer"
(interactive "Mpydoc entry: ")
(require 'man)
(let ((manual-program "pydoc"))
(Man-getpage-in-background word)))
;;JSIM mode
(autoload 'jsim-mode "jsim" nil t)
(setq auto-mode-alist (cons '("\.jsim$" . jsim-mode) auto-mode-alist))
(add-to-list 'auto-mode-alist (cons "\.uasm$" 'uasm-mode))
(defun uasm-mode ()
(interactive)
(make-local-variable 'asm-comment-char)
(setq asm-comment-char ?|)
(asm-mode))
;;PHP mode
(add-to-list 'auto-mode-alist '("\\.php[34s]?$" . php-mode))
(add-to-list 'magic-mode-alist '("<\\?php" . php-mode))
(autoload 'php-mode "php-mode" "Major mode for editing php." t)
;;Smarty template mode
(require 'smarty-mode)
;;CSS mode
(setq c-emacs-features nil) ;;; Workaround a bug in css-mode.el
(add-to-list 'auto-mode-alist '("\\.css$" . css-mode))
(autoload 'css-mode "css-mode" "Major mode for editing CSS files" t)
;;OCaml
(add-to-list 'auto-mode-alist '("\\.ml[iylp]?$" . caml-mode))
(autoload 'caml-mode "caml" "Major mode for editing Caml code." t)
(autoload 'run-caml "inf-caml" "Run an inferior Caml process." t)
;;Lua
(add-to-list 'auto-mode-alist '("\\.lua" . lua-mode))
(add-to-list 'interpreter-mode-alist '("lua" . lua-mode))
(autoload 'lua-mode "lua-mode" "Major mode for editing Lua code." t)
(add-hook 'caml-mode-hook 'my-caml-mode-hook)
(defun my-caml-mode-hook ()
(require 'caml-font))
;;C and c derivatives
(defun my-c-mode-common-hook ()
;; my customizations for all of c-mode, c++-mode, objc-mode, java-mode
(c-set-offset 'substatement-open 0)
(setq c-basic-offset 4
dabbrev-case-fold-search nil
complete-symbol-function 'dabbrev-completion)
(cscope-minor-mode))
(require 'xcscope)
(add-hook 'c-mode-common-hook 'my-c-mode-common-hook)
(add-hook 'c-mode-common-hook 'define-bracket-keys)
(define-key cscope:map (kbd "C-c .") 'cscope-find-global-definition-no-prompting)
(define-key cscope:map (kbd "C-c *") 'cscope-pop-mark)
(setq cscope-do-not-update-database t)
(defun pidof (name)
(with-temp-buffer
(if (zerop (shell-command (concat "pidof " name) (current-buffer)))
(string-to-number (buffer-string))
nil)))
(defun smells-like-c++ ()
(when (string-match "\\.h\\'" (buffer-name))
(save-excursion
(goto-char (point-min))
(if (re-search-forward "\\s \\(class\\|template\\|using\\)" nil t)
t))))
(add-to-list 'magic-mode-alist
'(smells-like-c++ . c++-mode))
;;;Java
(add-hook 'java-mode-hook 'define-bracket-keys)
(add-hook 'java-mode-hook 'my-java-mode-hook)
(defun my-java-mode-hook ()
(setq *javadoc-base-url* "file:///usr/share/doc/sun-java5-doc/html/api/")
(require 'javadoc)
(require 'java-utils)
(javadoc-load-classes)
(define-key java-mode-map "\C-c\C-d" (make-sparse-keymap))
(define-key java-mode-map "\C-c\C-dh" 'javadoc-lookup-class)
(make-local-variable 'dabbrev-case-fold-search))
;;; ANTLR
(autoload 'antlr-mode "antlr-mode" nil t)
(setq auto-mode-alist (cons '("\\.g\\'" . antlr-mode) auto-mode-alist))
;; Javascript
(autoload 'moz-minor-mode "moz" "Mozilla Minor and Inferior Mozilla Modes" t)
(autoload 'js2-mode "js2" nil t)
(add-to-list 'auto-mode-alist '("\\.js$" . js2-mode))
(add-to-list 'interpreter-mode-alist '("node" . js2-mode))
; (add-hook 'js2-mode-hook 'moz-minor-mode)
(add-hook 'js2-mode-hook 'js2-enter-mirror-mode)
(add-hook 'js2-mode-hook 'my-js2-mode-hook)
; (add-hook 'js2-mode-hook 'define-bracket-keys)
(setq js2-use-font-lock-faces t
js2-allow-keywords-as-property-names t
js2-mode-show-strict-warnings nil
js2-bounce-indent-p t)
(defadvice js2-enter-key (after js2-enter-key-indent)
(let ((js2-bounce-indent-flag nil))
(js2-indent-line)))
; (ad-activate 'js2-enter-key)
(eval-after-load 'js2-mode
'(progn
(set-face-attribute 'js2-warning-face nil :underline "cyan")
(set-face-attribute 'js2-error-face nil :underline "OrangeRed")))
(defun my-js2-mode-hook ()
(local-set-key (kbd "C-a") 'beginning-of-line-dwim)
(local-set-key (kbd "C-x `") 'next-error)
(local-set-key (kbd "M-TAB") 'dabbrev-completion)
(setq forward-sexp-function nil))
(put 'js2-basic-offset 'safe-local-variable 'integerp)
(defun my-javascript-mode-hook ()
(require 'moz))
(require 'coffee-mode)
(add-to-list 'auto-mode-alist '("\\.coffee$" . coffee-mode))
(add-to-list 'auto-mode-alist '("Cakefile" . coffee-mode))
;;;LaTeX
(add-hook 'latex-mode-hook 'my-latex-mode-hook)
(add-hook 'LaTeX-mode-hook 'my-latex-mode-hook)
(add-hook 'TeX-mode-hook 'my-latex-mode-hook)
(add-hook 'tex-mode-hook 'my-latex-mode-hook)
(defun my-latex-mode-hook ()
(require 'reftex)
(local-set-key "{" '(lambda ()
(interactive)
(let ((parens-require-spaces nil))
(insert-pair))))
(local-set-key "}" 'insert-close)
(reftex-mode 1)
(flyspell-mode 1))
(load-library "auctex")
(load-library "preview-latex")
(eval-after-load 'tex
'(progn
(setq TeX-command-list
(cons '("Gv" "gv %s.ps" TeX-run-background t t :help "Run gv on postscript")
TeX-command-list))
(setq TeX-command-list
(cons '("Evince" "evince %s.ps" TeX-run-background t t :help "Run evince on postscript")
TeX-command-list))
(setq TeX-command-list
(cons '("xpdf" "xpdf %s.pdf" TeX-run-background t t :help "Run xpdf on PDF")
TeX-command-list))
(setq TeX-command-list
(cons '("PDF" "dvipdf %s.dvi" TeX-run-background t t :help "Generate a PDF")
TeX-command-list))
(setq TeX-command-list
(cons '("PDFLatex" "pdflatex %s.tex" TeX-run-background t t :help "Run pdflatex")
TeX-command-list))
(let ((pdfview (assoc-string "^pdf$" TeX-output-view-style)))
(setcdr (cdr pdfview) (list "evince %o")))
(setq TeX-print-command "pdf2ps %s.pdf - | lpr -P%p -h")
(TeX-global-PDF-mode)))
(defun TeX-count-words ()
(interactive)
(save-excursion
(shell-command-on-region (point-min) (point-max) "detex | wc -w")))
(eval-after-load 'info
'(progn
(setq Info-directory-list
(cons "~/.elisp/auctex/doc" Info-default-directory-list))
(define-key Info-mode-map "B" 'Info-history-back)
(define-key Info-mode-map "F" 'Info-history-forward)))
;;;Lisps
;;;Scheme
(defun pretty-lambdas ()
(font-lock-add-keywords
nil `(("\\<lambda\\>"
(0 (progn (compose-region (match-beginning 0) (match-end 0)
,(make-char 'greek-iso8859-7 107))
nil))))))
(require 'quack)
(setq quack-programs '()
quack-fontify-style 'emacs)
(defmacro define-scheme-implementation (name &optional args)
`(setq quack-programs (cons ,(if args (concat name " " args) name) quack-programs)))
; `(defun ,(intern (concat "scheme-use-" name)) ()
; (interactive)
; (setq scheme-program-name ,(concat name " " (or args "")))))
(define-scheme-implementation "mzscheme")
(define-scheme-implementation "mechanics")
(define-scheme-implementation "guile" "--debug -- -emacs")
(define-scheme-implementation "mit-scheme")
(define-scheme-implementation "kawa")
(define-scheme-implementation "csi")
(define-scheme-implementation "scheme48")
(define-scheme-implementation "racket")
(add-to-list 'auto-mode-alist
(cons (concat "/\\."
(regexp-opt '("guile"
"mzscheme"
"kawarc.scm"
"scheme.init"
"edwin") t)
"$") 'scheme-mode))
(add-to-list 'auto-mode-alist
(cons "\\.arc$" 'scheme-mode))
(autoload 'run-scheme "cmuscheme" "Run an inferior scheme process." t)
(setq save-abbrevs nil)
(defun my-scheme-mode-hook ()
(pretty-lambdas)
(setq complete-symbol-function 'dabbrev-completion))
(add-hook 'scheme-mode-hook 'define-lisp-keys t)
(add-hook 'inferior-scheme-mode-hook 'define-lisp-keys t)
(add-hook 'scheme-mode-hook 'my-scheme-mode-hook)
(add-hook 'inferior-scheme-mode-hook 'my-scheme-mode-hook)
(setq comint-scroll-to-bottom-on-ouput t)
;;;SLIME
(autoload 'slime "slime" t t)
(autoload 'slime-connect "slime" t t)
(eval-after-load 'slime
'(progn
(slime-setup '(slime-repl slime-js))
(add-hook 'js2-mode-hook
(lambda ()
(slime-js-minor-mode 1)))))
(defadvice slime (around slime-switch-to-repl-if-connected)
(if (safe-funcall 'slime-connected-p)
(slime-switch-to-output-buffer)
ad-do-it))
(ad-activate 'slime)
(setq slime-startup-animation nil
slime-complete-symbol-function 'slime-complete-symbol*)
(defun slime-use-sbcl ()
(interactive)
(setq inferior-lisp-program "sbcl"))
(defun slime-use-cmucl ()
(interactive)
(setq inferior-lisp-program "cmucl"))
(slime-use-sbcl)
(autoload 'slime-selector "slime" "" t)
(add-to-list 'auto-mode-alist
(cons (concat "/\\."
(regexp-opt '("sbclrc"
"cmucl-init"
"clrc") t)
"$") 'lisp-mode))
(add-hook 'lisp-mode-hook 'my-lisp-mode-hook)
(add-hook 'lisp-mode-hook 'define-slime-keys)
(add-hook 'lisp-mode-hook 'my-lisp-mode-common-hook)
(add-hook 'lisp-mode-hook 'pretty-lambdas)
(add-hook 'slime-repl-mode-hook 'define-slime-keys)
(add-hook 'slime-repl-mode-hook 'my-lisp-mode-common-hook)
(add-hook 'slime-repl-mode-hook 'pretty-lambdas)
(defun my-lisp-mode-hook ()
(unless (safe-funcall 'slime-connected-p)
(save-excursion (slime)))
(slime-mode t)
(setq complete-symbol-function slime-complete-symbol-function))
(setq common-lisp-hyperspec-root "file:///usr/share/doc/hyperspec/")
(add-to-list 'auto-mode-alist (cons "\\.asd\\'" 'lisp-mode))
;;;elisp
(add-hook 'emacs-lisp-mode-hook 'define-elisp-keys)
(add-hook 'emacs-lisp-mode-hook 'my-lisp-mode-common-hook)
(add-hook 'emacs-lisp-mode-hook 'pretty-lambdas)
(add-hook 'lisp-interaction-mode-hook 'define-elisp-keys)
(add-hook 'lisp-interaction-mode-hook 'my-lisp-mode-common-hook)
(add-hook 'lisp-interaction-mode-hook 'pretty-lambdas)
;;Lisp keybindings
(global-set-key (kbd "C-c s") 'slime-selector)
(defun define-lisp-keys ()
;; (local-set-key "[" 'insert-parentheses)
;; (local-set-key "]" (lambda () (interactive) (insert-close "")))
;; (local-set-key "(" (lambda () (interactive) (insert "[")))
;; (local-set-key ")" (lambda () (interactive) (insert "]")))
(local-set-key "(" 'insert-parentheses)
(local-set-key ")" 'insert-close)
(local-set-key (kbd "M-t") 'transpose-sexps)
(local-set-key (kbd "M-b") 'backward-sexp)
(local-set-key (kbd "M-f") 'forward-sexp)
(local-set-key (kbd "M-a") 'beginning-of-defun)
(local-set-key (kbd "M-e") 'end-of-defun)
(local-set-key (kbd "M-_") 'unwrap-next-sexp)
(local-set-key (kbd "M-q") 'indent-sexp)
(local-set-key (kbd "M-(") 'blink-matching-open)
(local-set-key (kbd "M-u") 'backward-up-list)
(local-set-key (kbd "M-d") 'down-list)
(local-set-key (kbd "M-k") 'kill-sexp)
(local-set-key (kbd "M-DEL") 'backward-kill-sexp)
(local-set-key (kbd "DEL") 'backspace-unwrap-sexp)
(local-set-key (kbd "C-M-q") 'fill-paragraph)
(local-set-key (kbd "TAB") 'indent-and-complete-symbol-generic))
(defun define-slime-keys ()
; (define-lisp-keys)
; (setq lisp-indent-function 'common-lisp-indent-function)
(local-set-key (kbd "TAB") 'slime-indent-and-complete-symbol))
(defun define-elisp-keys ()
(define-lisp-keys)
(setq complete-symbol-function 'lisp-complete-symbol))
(defun my-lisp-mode-common-hook ()
(setq indent-tabs-mode nil))
;; proto
(require 'proto-mode)
(add-hook 'proto-mode-hook 'define-lisp-keys)
;;;Haskell
(require 'haskell-mode)
(require 'inf-haskell)
(add-hook 'haskell-mode-hook 'turn-on-haskell-doc-mode)
(add-hook 'haskell-mode-hook 'turn-on-haskell-indent)
(add-to-list 'auto-mode-alist (cons "\\.l?hsc?$" 'haskell-mode))
(setq haskell-program-name "ghci")
;; ruby
(autoload 'ruby-mode "ruby-mode" "" t)
(add-to-list 'auto-mode-alist (cons "\\.rb$" 'ruby-mode))
(add-to-list 'auto-mode-alist (cons "Rakefile$" 'ruby-mode))
(add-to-list 'auto-mode-alist (cons "Gemfile$" 'ruby-mode))
(add-to-list 'interpreter-mode-alist (cons "ruby" 'ruby-mode))
(autoload 'run-ruby "inf-ruby" "Run an inferior ruby process" t)
(autoload 'inf-ruby-keys "inf-ruby" "Set local key defs for inf-ruby in ruby-mode")
(add-hook 'ruby-mode-hook 'inf-ruby-keys)
(add-hook 'ruby-mode-hook 'my-ruby-mode-hook)
(defun my-ruby-mode-hook ()
nil)
(eval-after-load 'ruby-mode
'(progn
(define-key ruby-mode-map (kbd "M-TAB") 'dabbrev-expand)))
;; Matlab
(autoload 'matlab-mode "matlab" "Enter MATLAB mode." t)
(setq auto-mode-alist (cons '("\\.m\\'" . matlab-mode) auto-mode-alist))
(autoload 'matlab-shell "matlab" "Interactive MATLAB mode." t)
(fset 'run-matlab 'matlab-shell)
(setq matlab-shell-command "octave")
(setq matlab-shell-command-switches '())
;; YAML
(autoload 'yaml-mode "yaml-mode" "Enter YAML Mode" t)
(add-to-list 'auto-mode-alist (cons "\\.ya?ml$" 'yaml-mode))
;; LLVM development
(let ((llvm-el (expand-file-name "~/code/llvm/utils/emacs")))
(when (file-exists-p llvm-el)
(load-file (concat llvm-el "/emacs.el"))
(add-to-list 'load-path llvm-el)
(require 'llvm-mode)
(require 'tablegen-mode)))
;; Apache mode
(autoload 'apache-mode "apache-mode" nil t)
(add-to-list 'auto-mode-alist '("\\.htaccess\\'" . apache-mode))
(add-to-list 'auto-mode-alist '("httpd\\.conf\\'" . apache-mode))
(add-to-list 'auto-mode-alist '("srm\\.conf\\'" . apache-mode))
(add-to-list 'auto-mode-alist '("access\\.conf\\'" . apache-mode))
(add-to-list 'auto-mode-alist '("sites-\\(available\\|enabled\\)/" . apache-mode))
;; google calendar client
(load-library "g")
(setq g-user-email "nelhage@gmail.com")
(setq g-html-handler 'browse-url-of-buffer)
;; Mediawiki
(require 'mediawiki)
(setq mediawiki-site-alist '())
;;Evil DOS file endings, eeeeeeeeevil
(add-hook 'find-file-hook 'find-file-check-line-endings)
;; smerge-mode
(eval-after-load "smerge-mode"
'(progn
(set-face-background 'smerge-refined-change "#003333")
(setq smerge-base-re "^|||||||.*\n")))
(defun sm-try-smerge ()
(save-excursion
(goto-char (point-min))
(when (re-search-forward "^<<<<<<< " nil t)
(smerge-mode 1))))
(add-hook 'find-file-hook 'sm-try-smerge t)
(defun dos-file-endings-p ()
(string-match "dos" (symbol-name buffer-file-coding-system)))
(defun find-file-check-line-endings ()
(when (dos-file-endings-p)
;(set-buffer-file-coding-system 'undecided-unix)
;(set-buffer-modified-p nil)
))
;;nxml-mode
(load "~/.elisp/nxml/rng-auto.el")
(fset 'xml-mode 'nxml-mode)
(add-to-list 'auto-mode-alist
(cons (concat "\\."
(regexp-opt '("xml" "xsd" "sch"
"rng" "xslt" "svg"
"rss" "plist" "html"
"xhtml") t) "\\'")
'nxml-mode))
(add-to-list 'magic-mode-alist
(cons "<\\?xml" 'nxml-mode))
(add-hook 'nxml-mode-hook 'my-nxml-mode-hook)
(defun my-nxml-mode-hook ()
(local-set-key (kbd "C-c C-e") 'nxml-finish-element)
(local-set-key (kbd "C-M-f") 'nxml-forward-element)
(local-set-key (kbd "C-M-b") 'nxml-backward-element)
(local-set-key (kbd "C-M-u") 'nxml-up-element)
(local-set-key (kbd "C-M-d") 'nxml-down-element)
(local-set-key (kbd "M-k") 'nxml-kill-element)
(local-set-key (kbd "C-c ]") 'nxml-finish-element)
(setq next-error-function 'nxml-next-error))
(defun nxml-next-error (arg reset)
(if reset (rng-first-error))
(rng-next-error arg))
(defadvice nxml-up-element (after nxml-up-element-goto-start)
"Make nxml-up-element go to the start, not end, of the
surrounding xml expression"
(nxml-backward-element))
(ad-activate 'nxml-up-element)
(defun nxml-kill-element ()
(interactive)
(let ((start (point)))
(nxml-forward-element)
(kill-region start (point))))
;;;psgml-mode
; (autoload 'sgml-mode "psgml" "Major mode to edit SGML files." t)
; (autoload 'xml-mode "psgml" "Major mode to edit XML files." t)
(setq sgml-set-face t
sgml-indent-data t
sgml-auto-activate-dtd t)
;;; Zen Coding
(autoload 'zencoding-mode "zencoding-mode" "Minor mode to enable Zen coding")
; (add-hook 'sgml-mode-hook 'zencoding-mode)
; (add-hook 'nxml-mode-hook 'zencoding-mode)
;;;Mason-mode
(defun mason-mode ()
(interactive)
(html-mode)
(mmm-ify-by-class 'mason))
;;Jifty mason components
(add-to-list 'auto-mode-alist '("web/templates/[^.]*$" . mason-mode))
(add-to-list 'magic-mode-alist `(,(concat
"<%" (regexp-opt '("args" "init") t) ">")
. mason-mode))
(add-to-list 'magic-mode-alist '("\\`<&" . mason-mode))
;(mmm-add-mode-ext-class 'sgml-mode "web/templates/[^.]*$" 'mason)
;; html
(add-hook 'html-mode-hook 'my-html-mode-hook)
(defun my-html-mode-hook ()
(local-set-key (kbd "C-c C-e") 'sgml-close-tag))
;; dot-mode
(add-to-list 'auto-mode-alist '("\\.dot\\'" . graphviz-dot-mode))
(autoload 'graphviz-dot-mode "graphviz-dot-mode" "Major mode for editing Graphviz dot files" t)
(eval-after-load 'graphviz-dot-mode
'(progn
(define-key graphviz-dot-mode-map (kbd ";") 'self-insert-command)
(define-key graphviz-dot-mode-map (kbd "C-c C-c") 'graphviz-dot-preview)))
;;; ESS
; (require 'ess-site)
; (ess-restore-asm-extns)
(setq-default backup-inhibited t)
;; puppet
(autoload 'puppet-mode "puppet-mode" "Major mode for editing puppet manifests")
(add-to-list 'auto-mode-alist '("\\.pp$" . puppet-mode))
;; markdown
(autoload 'markdown-mode "markdown-mode.el"
"Major mode for editing Markdown files" t)
(setq auto-mode-alist
(cons '("\\.md$" . markdown-mode) auto-mode-alist))
;;; ADD NEW LANGUAGE MODES HERE
;;;Mail
(defun fetchmail ()
(interactive)
(shell-command "fetchmail"))
(add-hook 'message-mode-hook 'auto-fill-mode)
(add-hook 'message-mode-hook 'my-mail-mode-hook)
(add-hook 'message-mode-hook 'flyspell-mode)
(defun my-mail-mode-hook ()
(local-set-key (kbd "C-c a") 'mail-attach-file)
(local-set-key (kbd "C-c TAB") 'bbdb-complete-name)
(local-set-key (kbd "C-c C-]") 'mail-dont-send)
(local-set-key (kbd "TAB") 'mail-complete-for-tab-command)
(setq fill-column 69))
(defun mail-complete-for-tab-command ()
(interactive)
(if (save-excursion
(beginning-of-line)
(looking-at (concat
"^" (regexp-opt '("To" "Cc" "Bcc" "From") t ) ":")))
(bbdb-complete-name)))
(add-to-list 'magic-mode-alist (cons "\\`From:" 'mail-mode) t)
(add-hook 'message-send-hook 'my-message-delete-draft)
(defun my-message-delete-draft ()
(condition-case nil
(delete-file (buffer-file-name))
('file-error . nil)))
;; notmuch
; (condition-case nil
; (progn
; (add-to-list 'load-path "/home/nelhage/code/notmuch/emacs/")
; (require 'notmuch)
; (require 'notmuch-hello)
; (setq notmuch-fcc-dirs '(("sent-mail")))
; (require 'notmuch-maildir-fcc)
;
; (setq notmuch-command "/home/nelhage/sw/notmuch/bin/notmuch"
; notmuch-search-oldest-first nil)
; (define-key notmuch-show-mode-map (kbd "<backtab>") 'notmuch-show-previous-button)
; (define-key notmuch-show-mode-map (kbd "S") 'my-notmuch-show-mark-spam)
; (define-key notmuch-show-mode-map (kbd "A") 'notmuch-show-open-or-close-all)
; (define-key notmuch-show-mode-map (kbd "q") 'notmuch-show-return-to-search)
; (add-hook 'notmuch-show-hook 'my-notmuch-show-hook)
;
; (define-key notmuch-hello-mode-map (kbd "g") 'notmuch-hello-update)
;
; (define-key notmuch-search-mode-map (kbd "g") 'notmuch-search-refresh-view)
; (define-key notmuch-search-mode-map (kbd "j") 'notmuch-search-next-thread)
; (define-key notmuch-search-mode-map (kbd "k") 'notmuch-search-previous-thread)
; (define-key notmuch-search-mode-map (kbd "S") 'my-notmuch-search-mark-spam)
;
; ;(global-set-key (kbd "C-c n") 'notmuch)
; )
; ('file-error . nil))
;
; (defun my-notmuch-show-hook ()
; (setq buffer-invisibility-spec
; (delete-if (lambda (s)
; (string= (symbol-name s)
; "notmuch-show-header"))
; buffer-invisibility-spec)))
;
; (defun my-notmuch-search-mark-spam ()
; (interactive)
; (notmuch-search-add-tag "spam")
; (notmuch-search-archive-thread))
;
; (defun my-notmuch-show-mark-spam ()
; (interactive)
; (notmuch-show-add-tag "spam")
; (notmuch-show-archive-thread))
;;BBDB
(require 'bbdb)
(require 'bbdb-autoloads)
(bbdb-initialize)
(add-hook 'bbdb-after-change-hook (lambda (arg) (bbdb-save-db nil nil)))
(setq user-mail-address "nelhage@nelhage.com"
mail-envelope-from 'header
mail-specify-envelope-from t
message-sendmail-envelope-from 'header
mail-host-address "mit.edu"
sendmail-program "/usr/bin/msmtp")
;;vm
(add-to-list 'auto-mode-alist
(cons "/\\.vm$" 'emacs-lisp-mode))
(autoload 'vm "vm" "Start VM on your primary inbox." t)
(autoload 'vm-other-frame "vm" "Like `vm' but starts in another frame." t)
(autoload 'vm-visit-folder "vm" "Start VM on an arbitrary folder." t)
(autoload 'vm-visit-virtual-folder "vm" "Visit a VM virtual folder." t)
(autoload 'vm-mode "vm" "Run VM major mode on a buffer" t)
(autoload 'vm-mail "vm" "Send a mail message using VM." t)
(autoload 'vm-submit-bug-report "vm" "Send a bug report about VM." t)
(setq notmuch-saved-searches '(("inbox" . "tag:inbox")
("todo" . "tag:todo")
("llvmdev" . "to:llvmdev@cs.uiuc.edu")
("llvm-commits" . "to:llvm-commits")
("lldb" . "to:lldb-dev@cs.uiuc.edu")
("clang" . "to:cfe-dev@cs.uiuc.edu")
("clang-commits" . "to:cfe-commits@cs.uiuc.edu")
("git" . "vger.kernel.org")))
;;Mailcrypt
(require 'mailcrypt)
(mc-setversion "gpg")
(require 'pgg)
;;elscreen
(require 'elscreen)
(when elscreen-display-tab
(elscreen-toggle-display-tab))
(define-key elscreen-map (kbd "SPC") 'elscreen-next)
(define-key elscreen-map (kbd "C-z") 'elscreen-swap)
(setq ediff-split-window-function 'split-window-horizontally)
;; Org mode
(setq org-directory "~/nelhage/org")
(require 'org-mobile)
(setq org-hide-leading-stars t
org-log-done 'time
org-agenda-files (list (concat org-directory "/todo.org")
(concat org-directory "/stripe.org"))
org-agenda-window-setup 'current-window
org-agenda-restore-windows-after-quit t
org-default-notes-file (concat org-directory "/notes.org")
org-remember-templates
'(("Todo" ?t "* TODO %?\n" "todo.org" "Tasks")
("Stripe" ?s "* TODO %?\n" "stripe.org" "Stripe")
("Buy" ?b "* TODO %?" "todo.org" "To Buy"))
org-agenda-custom-commands
'(("W" "Work agenda" agenda ""
((org-agenda-files
(list (concat org-directory "/stripe.org")))))
("O" "Other agenda" agenda ""
((org-agenda-files
(list (concat org-directory "/todo.org"))))))
org-agenda-skip-deadline-if-done t
org-agenda-skip-scheduled-if-done t
org-agenda-todo-keyword-format "%-6s"
org-agenda-todo-ignore-deadlines t
org-todo-keywords
'((sequence "TODO" "INPROGRESS" "PENDING-REVIEW" "NEEDS-TESTING" "|" "DONE")
(sequence "|" "CANCELLED" "DELEGATED"))
org-deadline-warning-days 0
org-return-follows-link t
org-mobile-inbox-for-pull (concat org-directory "/mobile.org")
org-mobile-directory "~/Dropbox/org/mobile"
line-move-visual nil)
(eval-after-load 'org-agenda
'(progn
(set-face-attribute 'org-todo nil
:inverse-video nil)))
(defun org-agenda-skip-future-scheduled ()
(let ((end (save-excursion (progn (outline-next-heading) (1- (point))))))
(when (re-search-forward org-scheduled-time-regexp end t)
(let ((ss (match-string 1))
(sd (org-time-string-to-absolute (match-string 1))))
(if (> sd (calendar-absolute-from-gregorian date))
end)))))
; (setq org-agenda-skip-function 'org-agenda-skip-future-scheduled)
(org-remember-insinuate)
(global-set-key (kbd "C-c r") 'org-remember)
(global-set-key (kbd "C-c a") 'org-agenda)
(eval-after-load 'org
'(progn
(define-key org-mode-map (kbd "C-c t") 'org-todo)
(define-key org-mode-map (kbd "M-TAB") 'org-cycle)
(define-key org-mode-map (kbd "M-p") 'outline-backward-same-level)
(define-key org-mode-map (kbd "M-n") 'outline-forward-same-level)
;(define-key org-mode-map (kbd "RET") 'org-meta-return)
(set-face-foreground 'org-todo "#FF6666")
(set-face-foreground 'org-done "#00FF00")))
;; SES mode
(add-hook 'ses-mode-hook 'my-ses-mode-hook)
(defun my-ses-mode-hook ()
(whitespace-mode -1))
;;Livejournal
(autoload 'lj-login "ljupdate" "Log in to Livejournal" t)
;;Disabled commands
(put 'upcase-region 'disabled nil)
(put 'downcase-region 'disabled nil)
(put 'scroll-left 'disabled nil)
;;Setup my working emacs session
(add-hook 'emacs-startup-hook 'my-startup-hook)
(defun my-startup-hook ()
(set-frame-font default-font t)
(server-start)
(require 'edit-server)
(edit-server-start)
(find-file-noselect "~/.elisp/dot-emacs")
(save-window-excursion (shell))
(setup-terminals))
;;; Misc stuff
(defun jifty-dev ()
(interactive)
(named-shell "jifty-test" "~/code/jifty/trunk")
(named-shell "jifty" "~/code/jifty/trunk"))
(defun jifty-app-dev (name path)
(interactive "MApplication Name: \nDIn directory: ")
(named-shell name path)
(named-shell (concat name "-server") path)
(named-shell (concat name "-test") path)
(switch-to-buffer (concat "*" name "*")))
(require 'kerberos)
(setq asm-comment-char ?\;)
(add-hook 'asm-mode-hook 'my-asm-mode-hook)
(defun my-asm-mode-hook ()
(define-key asm-mode-map (kbd "#") 'self-insert-command))
(add-to-list 'auto-mode-alist (cons "/Makefrag$" 'makefile-mode))
(add-to-list 'auto-mode-alist (cons "^Makefile" 'makefile-mode))
(require 'w3m-load)
; (autoload 'w3m "w3m" "w3m" t t)
; (autoload 'w3m-find-file "w3m" "w3m" t t)
(add-hook 'w3m-mode-hook 'my-w3m-mode-hook)
(defun my-w3m-mode-hook ()
(local-set-key (kbd "C-c t") 'w3m-view-this-url-new-session))
;; (eval-after-load "w3m"
;; (progn
;; (set-face-font 'w3m-default-face "Sans-8")
;; (set-face-foreground 'w3m-default-face "#000000")
;; (set-face-background 'w3m-default-face "#FFFFFF")
;; (set-face-foreground 'w3m-anchor-face "#3333FF")))
(defun w3m-other-window (url &optional new-window)
(other-window 1)
(w3m url))
(defun w3m-other-window-new-session (url &optional new-window)
(other-window 1)
(w3m url t))
;(setq browse-url-browser-function 'w3m-other-window-new-session)
(setq browse-url-browser-function 'browse-url-generic
browse-url-generic-program "google-chrome"
w3m-home-page "http://google.com")
(put 'asm-comment-char 'safe-local-variable 'characterp)
(put 'c-indentation-style 'safe-local-variable 'symbolp)
(autoload 'minutes "sipb-minutes"
"Loads a minutes template into a buffer if none exists else switches to it" t)
(autoload 'sipb-minutes-mode "sipb-minutes"
"Major mode for editing SIPB minutes files." t)
(eval-after-load 'sipb-minutes
'(progn
(add-to-list 'auto-mode-alist
(cons "minutes.[0-9]\\{4\\}-[0-9]\\{2\\}-[0-9]\\{2\\}$" 'sipb-minutes-mode))))
(defvar initial-terminals
'((term "nelhage.com" "~/")
(shell "linux-2.6" "~/code/linux")
(shell "barnowl-dev" "~/code/barnowl")
(shell "llvm-dev" "~/code/llvm")
;; (shell "mysql" "~/")
(term "mutt-nelhage" "~/")
(term "mutt-stripe" "~/")
(term "stripe-dev" "~/stripe")
(term "devbox" "~/stripe/pay-server")
(shell "pay-dev" "~/stripe/pay-server")
(shell "remote-control" "~/stripe/remote-control")
(shell "puppet-config" "~/stripe/puppet-config"))
"Terminals to create initially")
(defun setup-terminals ()
(interactive)
(dolist (spec initial-terminals)
(destructuring-bind (type name dir) spec
(when (and (not (get-buffer (concat "*" name "*")))
(file-exists-p dir))
(case type
(term
(named-term name dir))
(shell
(named-shell name dir)))))))
(defun sql-updates ()
(interactive)
(let ((sql-mysql-program "mysql.updates"))
(sql-mysql)))
Jump to Line
Something went wrong with that request. Please try again.