Mercurial > dotfiles
changeset 77:45d7441d0cf2
Modularize .emacs
author | Augie Fackler <durin42@gmail.com> |
---|---|
date | Thu, 09 Apr 2009 13:39:20 -0500 |
parents | 2b2a667092fd |
children | 5e1439dd9ee1 |
files | .elisp/settings/10.require.el .elisp/settings/40.modes.el .elisp/settings/50.preferences.el .elisp/settings/90.keybindings.el .emacs .hgrc |
diffstat | 6 files changed, 123 insertions(+), 130 deletions(-) [+] |
line wrap: on
line diff
new file mode 100644 --- /dev/null +++ b/.elisp/settings/10.require.el @@ -0,0 +1,24 @@ +;; 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) +(require 'diff-mode-) +(require 'midnight) + +(require 'clojure-auto) +(add-to-list 'auto-mode-alist '("\\.clj$" . clojure-mode)) + +(require 'textmate) +(textmate-mode) +(textmate-also-ignore "eggs|cover|daisy|.*.pyc") + +(require 'yaml-mode) +(add-to-list 'auto-mode-alist '("\\.yml$" . yaml-mode)) + +(require 'nose)
new file mode 100644 --- /dev/null +++ b/.elisp/settings/40.modes.el @@ -0,0 +1,45 @@ +; 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)))
new file mode 100644 --- /dev/null +++ b/.elisp/settings/50.preferences.el @@ -0,0 +1,32 @@ +;; All lines should end in a newline +(setq require-final-newline t) + +;; disable tabs +(setq tab-width 4) +(setq-default indent-tabs-mode nil) + +;; 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)
new file mode 100644 --- /dev/null +++ b/.elisp/settings/90.keybindings.el @@ -0,0 +1,16 @@ +;; 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)
--- a/.emacs +++ b/.emacs @@ -4,139 +4,15 @@ ; Dave Anderson: (add-to-list 'load-path (expand-file-name "~/.elisp")) -; 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)) - - -(require 'nose) ; 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) - +(let ((settings-files (concat (getenv "HOME") "/.elisp/settings"))) + (mapc '(lambda (p) (load (concat settings-files "/" p))) + (directory-files settings-files nil ".*el$"))) -(if (file-regular-p (expand-file-name (concat (getenv "HOME") "/.emacs-machine.el"))) +(if (file-regular-p (expand-file-name (concat (getenv "HOME") + "/.emacs-machine.el"))) (load (expand-file-name "~/.emacs-machine.el")))