DZone Snippets is a public source code repository. Easily build up your personal collection of code snippets, categorize them with tags / keywords, and share them with the world

Snippets has posted 5883 posts at DZone. View Full User Profile

.emacs File For Rails Development

05.27.2008
| 5853 views |
  • submit to reddit
        A .emacs Emacs initialization file for editing rails projects.
All depending libraries are stored in the ~/.elisp directory.

.elisp directory:

color-theme-6.6.0
ecb-2.32
eieio-0.17
emacs-rails
semantic-1.4.4
speedbar-0.14beta4
color-theme.el
find-recursive.el
ido.el
inf-ruby.el
psvn.el
ruby-electric.el
ruby-mode.el
ruby-style.el
rubydb2x.el
rubydb3x.el
snippet.el


(setq load-path (cons "~/.elisp" load-path))

;; Setup initial emacs frames (windows) location and size
(setq default-frame-alist
      '((wait-for-wm . nil)
	(top . 0) (left . 0)
	(width . 85) (height . 40)
	(background-color . "gray15")
	(foreground-color . "limegreen")
	(cursor-color . "LightGoldenrod")
	(mouse-color . "yellow")
        ))
(setq initial-frame-alist 
      '((top . 30) (left . 300)
        (width . 110) (height . 55)
        )
      )

;; loads ido for easy buff switching.
(require 'ido)
(ido-mode t)

;; loads ruby-mode.
(setq load-path (cons "~/.elisp/ruby-mode" load-path))
(autoload 'ruby-mode "ruby-mode" "Load ruby-mode")
(add-hook 'ruby-mode-hook 'turn-on-font-lock)

;; loads emacs-rails.
(require 'snippet)
(require 'find-recursive)
(setq load-path (cons "~/.elisp/emacs-rails" load-path))
(defun try-complete-abbrev (old)
  (if (expand-abbrev) t nil))

(setq hippie-expand-try-functions-list
      '(try-complete-abbrev
        try-complete-file-name
        try-expand-dabbrev))

(require 'rails)

;; associate ruby-mode with .rb and .rhtml files
(add-to-list 'auto-mode-alist '("\.rb$" . ruby-mode))
(add-to-list 'auto-mode-alist '("\.rhtml$". html-mode))

;; make #! scripts executable after saving them
(add-hook 'after-save-hook 'executable-make-buffer-file-executable-if-script-p)

;; loads svn mode.
;;(require 'psvn)

;; If you have own color scheme and don't like to use emacs default
;; I recommend to use this package:
;; http://www.emacswiki.org/cgi-bin/wiki.pl?ColorTheme
(require 'color-theme)
(setq color-theme-is-global t)
(color-theme-gray30)

;; These lines are required for ECB
(add-to-list 'load-path "~/.elisp/eieio-0.17")
(add-to-list 'load-path "~/.elisp/speedbar-0.14beta4")
(add-to-list 'load-path "~/.elisp/semantic-1.4.4")
(setq semantic-load-turn-everything-on t)
(require 'semantic-load)
;; This installs ecb - it is activated with M-x ecb-activate
(add-to-list 'load-path "~/.elisp/ecb-2.32")
(require 'ecb-autoloads)
(setq ecb-layout-name "left14")
(setq ecb-layout-window-sizes (quote (("left14" (0.2564102564102564 . 0.6949152542372882) (0.2564102564102564 . 0.23728813559322035)))))