Ruby on Rails with GNU Emacs
- http://wiki.rubygarden.org/Ruby/page/show/InstallingEmacsExtensions
- http://rubyforge.org/projects/emacs-rails/
(autoload 'ruby-mode "ruby-mode" "Load ruby-mode")
(add-to-list 'auto-mode-alist '("\\.rb\\'" . ruby-mode))
(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)
Using ri-emacs for read rdoc documents
;; If you use cocoa emacs, you need set darwinports path. (setenv "PATH" (concat "/opt/local/bin/:/usr/local/bin:" (getenv "PATH"))) (setf rails-api-root "/opt/local/lib/ruby/gems/1.8/doc/") (setq ri-ruby-script "/path_to_install_ri_emacs/ri-emacs.rb") (autoload 'ri "ri-ruby" nil t) (add-hook 'ruby-mode-hook (lambda () (local-set-key "\C-h" 'ri) (local-set-key "\M-\C-i" 'ri-ruby-complete-symbol) (local-set-key "\C-c\C-h" 'ri-ruby-show-args) ))
Using mmm-mode for edit rhtml files.
(require 'mmm-mode)
(require 'mmm-auto)
(setq mmm-global-mode 'maybe)
(setq mmm-submode-decoration-level 2)
(set-face-background 'mmm-output-submode-face "LightBlue")
(set-face-background 'mmm-code-submode-face "LightGray")
(set-face-background 'mmm-comment-submode-face "LightYellow")
(set-face-background 'mmm-special-submode-face "Yellow")
(mmm-add-classes
'((erb-code
:submode ruby-mode
:match-face (("<%#" . mmm-comment-submode-face)
("<%=" . mmm-output-submode-face)
("<%" . mmm-code-submode-face))
:front "<%[#=]?"
:back "%>"
:insert ((?% erb-code nil @ "<%" @ " " _ " " @ "%>" @)
(?# erb-comment nil @ "<%#" @ " " _ " " @ "%>" @)
(?= erb-expression nil @ "<%=" @ " " _ " " @ "%>" @))
)))
(mmm-add-classes
'((gettext
:submode gettext-mode
:front "_(['\"]"
:face mmm-special-submode-face
:back "[\"'])")))
(mmm-add-classes
'((html-script
:submode javascript-mode
:front "<script>"
:back "</script>")))
(add-to-list 'auto-mode-alist '("\\.rhtml$" . html-mode))
(add-hook 'html-mode-hook
(lambda ()
(setq mmm-classes '(erb-code html-js html-script gettext embedded-css))
(mmm-mode-on)))
(add-to-list 'mmm-mode-ext-classes-alist '(ruby-mode nil gettext))
(global-set-key [f8] 'mmm-parse-buffer)
If you are using Emacs version 22, you need following patch to mmm-vars.el.
diff -ru mmm-mode-0.4.8/mmm-vars.el mmm-mode-0.4.8.new/mmm-vars.el
--- mmm-mode-0.4.8/mmm-vars.el 2004-06-16 07:14:18.000000000 -0700
+++ mmm-mode-0.4.8.new/mmm-vars.el 2007-02-22 12:20:01.000000000 -0800
@@ -287,7 +287,16 @@
c-type-prefix-key
comment-end
comment-start
- comment-start-skip))
+ comment-start-skip
+
+ c-block-prefix-charset
+ c-nonlabel-token-key
+ c-block-stmt-1-key
+ c-label-kwds-regexp
+ c-prefix-spec-kwds-re
+ c-decl-hangon-key
+ c-type-decl-suffix-key
+ ))
;; Skeleton insertion
skeleton-transformation
;; Abbrev mode
