comparison .emacs @ 77:45d7441d0cf2

Modularize .emacs
author Augie Fackler <durin42@gmail.com>
date Thu, 09 Apr 2009 13:39:20 -0500
parents 2b2a667092fd
children 8aa70b521063
comparison
equal deleted inserted replaced
76:2b2a667092fd 77:45d7441d0cf2
2 ; Places I've stolen from: 2 ; Places I've stolen from:
3 ; Karl Fogel: http://svn.red-bean.com/repos/kfogel/trunk 3 ; Karl Fogel: http://svn.red-bean.com/repos/kfogel/trunk
4 ; Dave Anderson: 4 ; Dave Anderson:
5 5
6 (add-to-list 'load-path (expand-file-name "~/.elisp")) 6 (add-to-list 'load-path (expand-file-name "~/.elisp"))
7 ; Better buffer switching and file loading (load first in case we need the
8 ; * Messages * buffer)
9 (require 'ido)
10 (setq ido-enable-flex-matching t)
11 (ido-mode t)
12
13 (require 'python-mode)
14 (require 'ipython)
15
16 (require 'show-wspace)
17
18 (require 'mercurial)
19
20 ; improved diff mode
21 (require 'diff-mode-)
22
23 (require 'midnight)
24
25 ; Clojure
26 (require 'clojure-auto)
27 (add-to-list 'auto-mode-alist '("\\.clj$" . clojure-mode))
28
29 (require 'textmate)
30 (textmate-mode)
31 (textmate-also-ignore "eggs|cover|daisy|.*.pyc")
32
33 ; yaml
34 (require 'yaml-mode)
35 (add-to-list 'auto-mode-alist '("\\.yml$" . yaml-mode))
36
37
38 (require 'nose)
39 7
40 ; Start the server so that emacsclient will work 8 ; Start the server so that emacsclient will work
41 ; TODO: is there a way to *not* start a server if one was already running? 9 ; TODO: is there a way to *not* start a server if one was already running?
42 (server-start) 10 (server-start)
43 11
44 ; All lines should end in a newline 12 (let ((settings-files (concat (getenv "HOME") "/.elisp/settings")))
45 (setq require-final-newline t) 13 (mapc '(lambda (p) (load (concat settings-files "/" p)))
14 (directory-files settings-files nil ".*el$")))
46 15
47 ; disable tabs 16 (if (file-regular-p (expand-file-name (concat (getenv "HOME")
48 (setq tab-width 4) 17 "/.emacs-machine.el")))
49 (setq-default indent-tabs-mode nil)
50
51 ; use tab for indent or complete
52 (defun indent-or-expand (arg)
53 "Either indent according to mode, or expand the word preceding
54 point."
55 (interactive "*P")
56 (if (and
57 (or (bobp) (= ?w (char-syntax (char-before))))
58 (or (eobp) (not (= ?w (char-syntax (char-after))))))
59 (dabbrev-expand arg)
60 (indent-according-to-mode)))
61
62 (defun af-tab-fix ()
63 (local-set-key [tab] 'indent-or-expand))
64
65 ;; add hooks for modes you want to use the tab completion for:
66 (set-variable 'af-cleanup-whitespace t)
67 (add-hook 'c-mode-hook 'af-tab-fix)
68 (add-hook 'sh-mode-hook 'af-tab-fix)
69 (add-hook 'emacs-lisp-mode-hook 'af-tab-fix)
70 (add-hook 'clojure-mode-hook 'af-tab-fix)
71 (add-hook 'rst-mode-hook '(lambda ()
72 (make-variable-buffer-local 'af-cleanup-whitespace)
73 (set-variable 'af-cleanup-whitespace nil)))
74
75 (autoload 'js2-mode "js2" nil t)
76 (add-to-list 'auto-mode-alist '("\\.js$" . js2-mode))
77 (add-hook 'js2-mode-hook 'af-tab-fix)
78
79 (defun af-python-mode-hook ()
80 ; highlight tabs in Python
81 (make-variable-buffer-local 'font-lock-mode-hook)
82 (add-hook 'font-lock-mode-hook 'show-ws-highlight-tabs)
83 (make-variable-buffer-local 'python-indent)
84 (if (and buffer-file-name (string-match "melange" buffer-file-name))
85 (set-variable 'python-indent 2))
86 (af-tab-fix)
87 )
88 (add-hook 'python-mode-hook 'af-python-mode-hook)
89
90
91 ; text-mode tries to use M-s for something other than my save shortcut.
92 ; That's evil. Stop it from doing that.
93 (add-hook 'text-mode-hook '(lambda ()
94 (define-key text-mode-map "\M-s"
95 'save-buffer)))
96
97 ; Cleanup whitespace before saves.
98 (add-hook 'before-save-hook '(lambda ()
99 (if af-cleanup-whitespace (whitespace-cleanup))))
100
101 ; Disable that startup screen
102 (setq inhibit-startup-message t)
103
104 ; Basically everything I do is in version control, stop saving backup files
105 (setq make-backup-files nil)
106
107 ; Set some pretty colors that are gentler on my eyes
108 (setq default-frame-alist
109 '((width . 80)
110 (cursor-color . "white")
111 (cursor-type . box)
112 (foreground-color . "white")
113 (background-color . "black")
114 )
115 )
116 ; always highlight matching paren
117 (show-paren-mode 1)
118
119 ;; Automatically revert unedited files that change on the underlying
120 ;; system.
121 (global-auto-revert-mode)
122
123 ;; Key Bindings
124 ; M-backspace kills the current buffer
125 (global-set-key [(meta backspace)] 'kill-this-buffer)
126 ; Save early and often, with only one keystroke
127 (global-set-key [(meta s)] 'save-buffer)
128 ; Typing tab is for lesser editors, make hitting return do that
129 (global-set-key "\C-m" 'newline-and-indent)
130 ; M-l makes more sense to me for jumping to a line
131 (global-set-key "\M-l" 'goto-line)
132 ; Sometimes C-h is what Backspace sends in a terminal, and I never use C-h
133 (global-set-key "\C-h" 'backward-delete-char-untabify)
134 ; M-t is what I want for the textmate file finding
135 (global-set-key [(meta t)] 'textmate-goto-file)
136 (global-set-key [(meta z)] 'textmate-find-in-project-type)
137 (global-set-key [(meta m)] 'iconify-or-deiconify-frame)
138 (global-set-key [(control backspace)] 'kill-word)
139
140
141 (if (file-regular-p (expand-file-name (concat (getenv "HOME") "/.emacs-machine.el")))
142 (load (expand-file-name "~/.emacs-machine.el"))) 18 (load (expand-file-name "~/.emacs-machine.el")))