Created
February 6, 2012 14:56
-
-
Save codatory/1752533 to your computer and use it in GitHub Desktop.
My emacs init.el
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
;; emacs configuration | |
(push "/usr/local/bin" exec-path) | |
(setq make-backup-files nil) | |
(setq auto-save-default nil) | |
(setq-default tab-width 2) | |
(setq-default indent-tabs-mode nil) | |
(setq inhibit-startup-message t) | |
(setq tramp-default-method "scpx") | |
(fset 'yes-or-no-p 'y-or-n-p) | |
(delete-selection-mode t) | |
(blink-cursor-mode t) | |
(show-paren-mode t) | |
(column-number-mode t) | |
(global-linum-mode t) | |
(auto-compression-mode t) | |
(global-font-lock-mode t) | |
(auto-image-file-mode t) | |
(scroll-bar-mode -1) | |
(tool-bar-mode -1) | |
(set-fringe-style -1) | |
(tooltip-mode -1) | |
(if (>= emacs-major-version 24) | |
(load-theme 'tango)) | |
; derived from ELPA installation | |
; http://tromey.com/elpa/install.html | |
(defun eval-url (url) | |
(let ((buffer (url-retrieve-synchronously url))) | |
(save-excursion | |
(set-buffer buffer) | |
(goto-char (point-min)) | |
(re-search-forward "^$" nil 'move) | |
(eval-region (point) (point-max)) | |
(kill-buffer (current-buffer))))) | |
;; Load ELPA if Emacs < 24 | |
(add-to-list 'load-path "~/.emacs.d/elpa") | |
(defun install-elpa () | |
(eval-url "http://tromey.com/elpa/package-install.el")) | |
(if (require 'package nil t) | |
(progn | |
;; Emacs 24+ includes ELPA, but requires some extra setup | |
;; to use the (better) tromey repo | |
(if (>= emacs-major-version 24) | |
(setq package-archives (cons '("tromey" . "http://tromey.com/elpa/") package-archives))) | |
(package-initialize)) | |
(install-elpa)) | |
;; Add EL-GET to the path | |
(add-to-list 'load-path "~/.emacs.d/el-get/el-get") | |
;; Install el-get if it's not already | |
(defun install-el-get () | |
(eval-url | |
"https://github.com/dimitri/el-get/raw/master/el-get-install.el")) | |
(unless (require 'el-get nil t) | |
(install-el-get)) | |
;; hooks | |
(defun ruby-mode-hook () | |
(autoload 'ruby-mode "ruby-mode" nil t) | |
(add-to-list 'auto-mode-alist '("Capfile" . ruby-mode)) | |
(add-to-list 'auto-mode-alist '("Gemfile" . ruby-mode)) | |
(add-to-list 'auto-mode-alist '("Rakefile" . ruby-mode)) | |
(add-to-list 'auto-mode-alist '("\\.rake\\'" . ruby-mode)) | |
(add-to-list 'auto-mode-alist '("\\.rb\\'" . ruby-mode)) | |
(add-to-list 'auto-mode-alist '("\\.ru\\'" . ruby-mode)) | |
(add-hook 'ruby-mode-hook '(lambda () | |
(setq ruby-deep-arglist t) | |
(setq ruby-deep-indent-paren nil) | |
(setq c-tab-always-indent nil) | |
(require 'inf-ruby) | |
(require 'ruby-compilation) | |
(define-key ruby-mode-map (kbd "M-r") 'run-rails-test-or-ruby-buffer)))) | |
(defun rhtml-mode-hook () | |
(autoload 'rhtml-mode "rhtml-mode" nil t) | |
(add-to-list 'auto-mode-alist '("\\.erb\\'" . rhtml-mode)) | |
(add-to-list 'auto-mode-alist '("\\.rjs\\'" . rhtml-mode)) | |
(add-hook 'rhtml-mode '(lambda () | |
(define-key rhtml-mode-map (kbd "M-s") 'save-buffer)))) | |
(defun yaml-mode-hook () | |
(autoload 'yaml-mode "yaml-mode" nil t) | |
(add-to-list 'auto-mode-alist '("\\.yml$" . yaml-mode)) | |
(add-to-list 'auto-mode-alist '("\\.yaml$" . yaml-mode))) | |
(defun css-mode-hook () | |
(autoload 'css-mode "css-mode" nil t) | |
(add-hook 'css-mode-hook '(lambda () | |
(setq css-indent-level 2) | |
(setq css-indent-offset 2)))) | |
(defun is-rails-project () | |
(when (textmate-project-root) | |
(file-exists-p (expand-file-name "config/environment.rb" (textmate-project-root))))) | |
(defun run-rails-test-or-ruby-buffer () | |
(interactive) | |
(if (is-rails-project) | |
(let* ((path (buffer-file-name)) | |
(filename (file-name-nondirectory path)) | |
(test-path (expand-file-name "test" (textmate-project-root))) | |
(command (list ruby-compilation-executable "-I" test-path path))) | |
(pop-to-buffer (ruby-compilation-do filename command))) | |
(ruby-compilation-this-buffer))) | |
;; Sources for el-get | |
(setq el-get-sources | |
'((:name ruby-mode | |
:type elpa | |
:load "ruby-mode.el" | |
:after (lambda() (ruby-mode-hook))) | |
(:name inf-ruby :type elpa) | |
(:name ruby-compilation :type elpa) | |
(:name css-mode | |
:type elpa | |
:after (lambda() (css-mode-hook))) | |
(:name textmate | |
:type git | |
:url "git://github.com/defunkt/textmate.el" | |
:load "textmate.el" | |
:after (lambda() (textmate-mode))) | |
(:name rvm | |
:type git | |
:url "http://github.com/djwhitt/rvm.el.git" | |
:load "rvm.el" | |
:compile ("rvm.el") | |
:after (lambda() (rvm-use-default))) | |
(:name rhtml | |
:type git | |
:url "https://github.com/crazycode/rhtml.git" | |
:features rhtml-mode | |
:after (lambda() (rhtml-mode-hook))) | |
(:name yaml-mode | |
:type git | |
:url "http://github.com/yoshiki/yaml-mode.git" | |
:features yaml-mode | |
:after (lambda() (yaml-mode-hook))) | |
) | |
) | |
;; el-get recipies to install | |
(setq my-el-get-packages | |
(append | |
'(ack auto-indent coffee-mode diff-git dirtree drag-stuff egg el-get fixme-mode haml-mode git-modeline growl json markdown-mode nxhtml php-mode-improved python python-mode python-pep8 rainbow-delimiters random-idle-quote scala-mode scss-mode sql ssh-config whitespace) | |
(mapcar 'el-get-source-name el-get-sources))) | |
(el-get 'sync my-el-get-packages) | |
;; midnight mode | |
(require 'midnight) | |
;;kill buffers if they were last disabled more than this seconds ago | |
(setq clean-buffer-list-delay-special 900) | |
(defvar clean-buffer-list-timer nil | |
"Stores clean-buffer-list timer if there is one. You can disable clean-buffer-list by (cancel-timer clean-buffer-list-timer).") | |
;; run clean-buffer-list every 2 hours | |
(setq clean-buffer-list-timer (run-at-time t 7200 'clean-buffer-list)) | |
;; kill everything, clean-buffer-list is very intelligent at not killing | |
;; unsaved buffer. | |
(setq clean-buffer-list-kill-regexps | |
'("^.*$")) | |
;; keep these buffer untouched | |
;; prevent append multiple times | |
(defvar clean-buffer-list-kill-never-buffer-names-init | |
clean-buffer-list-kill-never-buffer-names | |
"Init value for clean-buffer-list-kill-never-buffer-names") | |
(setq clean-buffer-list-kill-never-buffer-names | |
(append | |
'("*Messages*" "*cmd*" "*scratch*" "*w3m*" "*w3m-cache*" "*Inferior Octave*") | |
clean-buffer-list-kill-never-buffer-names-init)) | |
;; prevent append multiple times | |
(defvar clean-buffer-list-kill-never-regexps-init | |
clean-buffer-list-kill-never-regexps | |
"Init value for clean-buffer-list-kill-never-regexps") | |
;; append to *-init instead of itself | |
(setq clean-buffer-list-kill-never-regexps | |
(append '("^\\*EMMS Playlist\\*.*$") | |
clean-buffer-list-kill-never-regexps-init)) | |
;; Interactive switch buffers | |
(iswitchb-mode 1) | |
(setq iswitchb-default-method 'samewindow) | |
(require 'edmacro) | |
(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 )))) | |
(add-hook 'iswitchb-define-mode-map-hook 'iswitchb-local-keys) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment