view .emacs @ 73:b84c4cac3148

Add custom _subversion that works with svn 1.5 and later.
author Augie Fackler <durin42@gmail.com>
date Thu, 09 Apr 2009 13:24:38 -0500
parents 5c25d3dc29ab
children fd369b708cbe
line wrap: on
line source

;; Augie Fackler's .emacs file
; Places I've stolen from:
;  Karl Fogel: http://svn.red-bean.com/repos/kfogel/trunk
;  Dave Anderson:

(setq load-path (cons (expand-file-name "~/.elisp") load-path))
; Better buffer switching and file loading (load first in case we need the
; * Messages * buffer)
(require 'ido)
(setq ido-enable-flex-matching t)
(ido-mode t)

(require 'python-mode)
(require 'ipython)

(require 'show-wspace)

(require 'mercurial)

; improved diff mode
(require 'diff-mode-)

(require 'midnight)

; Clojure
(require 'clojure-auto)
(add-to-list 'auto-mode-alist '("\\.clj$" . clojure-mode))

(require 'textmate)
(textmate-mode)
(textmate-also-ignore "eggs|cover|daisy|.*.pyc")

; yaml
(require 'yaml-mode)
(add-to-list 'auto-mode-alist '("\\.yml$" . yaml-mode))


; Start the server so that emacsclient will work
; TODO: is there a way to *not* start a server if one was already running?
(server-start)

; All lines should end in a newline
(setq require-final-newline t)

; disable tabs
(setq tab-width 4)
(setq-default indent-tabs-mode nil)

; use tab for indent or complete
(defun indent-or-expand (arg)
  "Either indent according to mode, or expand the word preceding
point."
  (interactive "*P")
  (if (and
       (or (bobp) (= ?w (char-syntax (char-before))))
       (or (eobp) (not (= ?w (char-syntax (char-after))))))
      (dabbrev-expand arg)
    (indent-according-to-mode)))

(defun af-tab-fix ()
  (local-set-key [tab] 'indent-or-expand))

;; add hooks for modes you want to use the tab completion for:
(set-variable 'af-cleanup-whitespace t)
(add-hook 'c-mode-hook          'af-tab-fix)
(add-hook 'sh-mode-hook         'af-tab-fix)
(add-hook 'emacs-lisp-mode-hook 'af-tab-fix)
(add-hook 'clojure-mode-hook    'af-tab-fix)
(add-hook 'rst-mode-hook '(lambda ()
                            (make-variable-buffer-local 'af-cleanup-whitespace)
                            (set-variable 'af-cleanup-whitespace nil)))

(autoload 'js2-mode "js2" nil t)
(add-to-list 'auto-mode-alist '("\\.js$" . js2-mode))
(add-hook 'js2-mode-hook 'af-tab-fix)

(defun af-python-mode-hook ()
  ; highlight tabs in Python
  (make-variable-buffer-local 'font-lock-mode-hook)
  (add-hook 'font-lock-mode-hook 'show-ws-highlight-tabs)
  (make-variable-buffer-local 'python-indent)
  (if (and buffer-file-name (string-match "melange" buffer-file-name))
     (set-variable 'python-indent 2))
  (af-tab-fix)
)
(add-hook 'python-mode-hook 'af-python-mode-hook)


; text-mode tries to use M-s for something other than my save shortcut.
; That's evil. Stop it from doing that.
(add-hook 'text-mode-hook '(lambda ()
                             (define-key text-mode-map "\M-s"
                               'save-buffer)))

; Cleanup whitespace before saves.
(add-hook 'before-save-hook '(lambda ()
                               (if af-cleanup-whitespace (whitespace-cleanup))))

; Disable that startup screen
(setq inhibit-startup-message t)

; Basically everything I do is in version control, stop saving backup files
(setq make-backup-files nil)

; Set some pretty colors that are gentler on my eyes
(setq default-frame-alist
      '((width . 80)
        (cursor-color . "white")
        (cursor-type . box)
        (foreground-color . "white")
        (background-color . "black")
        )
      )
; always highlight matching paren
(show-paren-mode 1)

;; Automatically revert unedited files that change on the underlying
;; system.
(global-auto-revert-mode)

;; Key Bindings
; M-backspace kills the current buffer
(global-set-key [(meta backspace)] 'kill-this-buffer)
; Save early and often, with only one keystroke
(global-set-key [(meta s)] 'save-buffer)
; Typing tab is for lesser editors, make hitting return do that
(global-set-key "\C-m" 'newline-and-indent)
; M-l makes more sense to me for jumping to a line
(global-set-key "\M-l" 'goto-line)
; Sometimes C-h is what Backspace sends in a terminal, and I never use C-h
(global-set-key "\C-h" 'backward-delete-char-untabify)
; M-t is what I want for the textmate file finding
(global-set-key [(meta t)] 'textmate-goto-file)
(global-set-key [(meta z)] 'textmate-find-in-project-type)
(global-set-key [(meta m)] 'iconify-or-deiconify-frame)
(global-set-key [(control backspace)] 'kill-word)