Created
January 18, 2011 21:00
-
-
Save mig/785133 to your computer and use it in GitHub Desktop.
Simple Emacs 24 configuration for Rails development
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) | |
(add-to-list 'load-path "~/.emacs.d") | |
(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) | |
(fset 'yes-or-no-p 'y-or-n-p) | |
(delete-selection-mode t) | |
(scroll-bar-mode -1) | |
(tool-bar-mode -1) | |
(blink-cursor-mode t) | |
(show-paren-mode t) | |
(column-number-mode t) | |
(set-fringe-style -1) | |
(tooltip-mode -1) | |
(set-frame-font "Menlo-16") | |
(load-theme 'tango) | |
(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))) | |
(require 'package) | |
(setq package-archives (cons '("tromey" . "http://tromey.com/elpa/") package-archives)) | |
(package-initialize) | |
(add-to-list 'load-path "~/.emacs.d/el-get/el-get") | |
(require '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") | |
(: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 'sync) |
Hey all
Thanks for the post, @mig and thanks for the help so far @genexp. I also followed instructions and got a similar result. I'll work through the issues and see if I can get it resolved on my own, but if in the meantime you have any advice, I'd appreciate it. I'm sure you're busy, so don't sweat it if not.
When I put in the above gist into my ~/.emacs.d/init.el and run M-x eval-buffer, the size of the text changes, etc, but it doesn't seem to be recognized. I don't get any warnings/errors, just no response.
Thanks!
Hey JT - I had a similar problem until I got el-get to work. Start
with the example here: https://github.com/dimitri/el-get under
"Advanced Setup with Local Recipes" and see how far you get. You
should see Emacs contact the elpa server and download a bunch of
packages if it works. If not, I think you probably have some problem
with your el-get install. Make sure its actually located in the
location noted in the file (I figure you checked that, but hey, I
actually made the mistake initially myself so who knows).
…On Tue, Feb 7, 2012 at 1:02 PM, JT Zemp ***@***.*** wrote:
Hey, @genexp.
Thanks for the post. I also followed instructions and got a similar result. I'll work through the issues and see if I can get it resolved on my own, but if in the meantime you have any advice, I'd appreciate it. I'm sure you're busy, so don't sweat it if not.
When I put in the above gist into my ~/.emacs.d/init.el and run M-x eval-buffer, the size of the text changes, etc, but it doesn't seem to be recognized. I don't get any warnings/errors, just no response.
Thanks!
---
Reply to this email directly or view it on GitHub:
https://gist.github.com/785133
Thanks for your sharing.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Hey @genexp, Thanks for the quick response.
Yes, I did follow the installation procedure outlined in the aforementioned blog post. I noticed that after I cloned the el-get repo into ~/.emacs.d/el-get (resulting in ~/.emacs.d/el-get/el-get) and ran eval-buffer, the cloned repo disappeared (resulting in ~/.emacs.d/el-get). I'm not sure if that's supposed to happen, but it certainly seems suspicious.
In case it helps, I'm on Emacs v24.0.93.
Thanks again for your help.
Tim