[ANN] Emacs rails.el

Features:

  • Management WEBrick - start, stop
  • Viewing log files
  • Abbrev from TextMate
  • Switching between View/Action

http://www.emacswiki.org/cgi-bin/emacs/rails.el

I’m new to emacs, how should I enable this mode?
I’ve copied rails.el and all ruby’s el files to
C:\emacs-21.3\lisp\progmodes and edited the .emacs file, but there is
a problem.
I have syntax coloring, but an strange auto-complete, it autocomplete
everything, lisp command, dir and files, etc.

What’s wrong in my conif? May anyone help me, please?

Thanks

Here is my .emacs file:

(custom-set-variables
;; custom-set-variables was added by Custom – don’t edit or cut/paste
it!
;; Your init file should contain only one such instance.
'(case-fold-search t)
'(current-language-environment “Latin-1”)
'(default-frame-alist (quote ((mouse-color . “black”) (tool-bar-lines
. 0) (menu-bar-lines . 1) (background-color . “black”)
(foreground-color . “white”) (cursor-color . “orange”) (cursor-type .
box) (active-alpha . 0.875) (inactive-alpha . 0.75))))
'(default-input-method “latin-1-prefix”)
'(global-font-lock-mode t nil (font-lock))
'(pop-up-frames nil))
(custom-set-faces
;; custom-set-faces was added by Custom – don’t edit or cut/paste it!
;; Your init file should contain only one such instance.
'(default ((t (:stipple nil :background “black” :foreground “white”
:inverse-video nil :box nil :strike-through nil :overline nil
:underline nil :slant normal :weight normal :height 111 :width normal
:family “outline-consolas”))))
'(cursor ((t (:background “orange”))))
'(mouse ((t (:background “black”)))))

(autoload 'ruby-mode “ruby-mode” “Mode for editing ruby source files” t)
(setq auto-mode-alist (append '(("\.rb$" . ruby-mode))
auto-mode-alist))
(setq interpreter-mode-alist (append '((“ruby” . ruby-mode))
interpreter-mode-alist))

(autoload 'run-ruby “inf-ruby” “Run an inferior Ruby process”)
(autoload 'inf-ruby-keys “inf-ruby” “Set local key defs for inf-ruby
in ruby-mode”)
(add-hook 'ruby-mode-hook
'(lambda ()
(inf-ruby-keys)
))

;;(require 'ruby-electric)
(require 'rails)

dima wrote:

Features:

  • Management WEBrick - start, stop
  • Viewing log files
  • Abbrev from TextMate
  • Switching between View/Action

http://www.emacswiki.org/cgi-bin/emacs/rails.el

I love it! Just made some adjustments for rjs templates, keep up the
good
work!

Zsombor

Human D. wrote:

I’m new to emacs, how should I enable this mode?
I’ve copied rails.el and all ruby’s el files to
C:\emacs-21.3\lisp\progmodes and edited the .emacs file, but there is
a problem.
I have syntax coloring, but an strange auto-complete, it autocomplete
everything, lisp command, dir and files, etc.

What’s wrong in my conif? May anyone help me, please?

I do not know in what a problem, just in case here my fragment .emacs


(autoload 'ruby-mode “ruby-mode” “Ruby editing mode.” t)
(setq auto-mode-alist (cons '("\.rb$" . ruby-mode) auto-mode-alist))
(setq auto-mode-alist (cons '("\.rhtml$" . html-mode)
auto-mode-alist))

(modify-coding-system-alist 'file “\.rb$” 'utf-8-dos)
(modify-coding-system-alist 'file “\.rhtml$” 'utf-8-dos)

(require 'rails)

(add-hook 'ruby-mode-hook
(lambda()
(add-hook 'local-write-file-hooks
'(lambda()
(save-excursion
(untabify (point-min) (point-max))
(delete-trailing-whitespace)
)))
(set (make-local-variable 'indent-tabs-mode) 'nil)
(set (make-local-variable 'tab-width) 2)
(imenu-add-to-menubar “IMENU”)
(require 'ruby-electric)
(ruby-electric-mode t)
))

Your Lisp coding style is really weird…all those )'s on separate lines
;-).

I’m going to love this, because, until now, I have not used a
Rails-aware editor.

Thanks!

Jules

dima wrote:

Features:

  • Management WEBrick - start, stop
  • Viewing log files
  • Abbrev from TextMate
  • Switching between View/Action

http://www.emacswiki.org/cgi-bin/emacs/rails.el

New location of a file
https://opensvn.csie.org/mvision/emacs/.emacs.d/rails.el
Changes:

  • Added support RJS templates
  • Added navigation on configuration files in the menu
  • rails now run a minor-mode

dima wrote:

Features:

  • Management WEBrick - start, stop
  • Viewing log files
  • Abbrev from TextMate
  • Switching between View/Action

http://www.emacswiki.org/cgi-bin/emacs/rails.el
Hm. I’m getting errors when trying to view a log file:

Symbol's function definition is void: rails-make-menu.

Any idea how I could fix this?

– stefan


For rails performance tuning, see: http://railsexpress.de/blog
Subscription: railsexpress.de

dima wrote:

Hm. I’m getting errors when trying to view a log file:

Symbol’s function definition is void: rails-make-menu.

Any idea how I could fix this?
Already fixed, update you copy from
https://opensvn.csie.org/mvision/emacs/.emacs.d/rails.el

hm. now I get:

Compiling file c:/Programme/emacs-21.3/site-lisp/rails.el at Tue Feb 07
00:21:06 2006
!! File error ((“Cannot open load file” “snippet”))

when trying to byte-compile rails.el

– stefan


For rails performance tuning, see: http://railsexpress.de/blog
Subscription: railsexpress.de

Hei Stefan!

Tue, 07 Feb 2006, Stefan K. skrev:

http://www.emacswiki.org/cgi-bin/emacs/rails.el
Compiling file c:/Programme/emacs-21.3/site-lisp/rails.el at Tue Feb 07
00:21:06 2006
!! File error ((“Cannot open load file” “snippet”))

when trying to byte-compile rails.el

~/lisp$ wget http://cryptocracy.hn.org/~cartel/elisp/snippet.el

in your .emacs:
(load “~/lisp/snippet.el”)
(load “~/lisp/rails.el”)
(require 'rails)

  • Henrik

Henrik Ormåsen wrote:

when trying to byte-compile rails.el

  • Henrik

Thx. Now I only need a way to get color coding working for log views in
emacs …

– stefan


For rails performance tuning, see: http://railsexpress.de/blog
Subscription: railsexpress.de

Hello, Stefan K.!
on 06.02.2006 16:42

dima wrote:

Features:

  • Management WEBrick - start, stop
  • Viewing log files
  • Abbrev from TextMate
  • Switching between View/Action

http://www.emacswiki.org/cgi-bin/emacs/rails.el
Hm. I’m getting errors when trying to view a log file:

Symbol’s function definition is void: rails-make-menu.

Any idea how I could fix this?
Already fixed, update you copy from
https://opensvn.csie.org/mvision/emacs/.emacs.d/rails.el

rails.el is too cool! but I found a bit problem.

Although a view path will be set to “adminpage” from camel named
controller
such as “AdminPageController”, it should be “admin_page” in Rails rule.

The following patch fixes this problem.
http://rails.wota.jp/pubs/patches/rails-el-underscore.patch

thanks.

– Maiha

Thx. Now I only need a way to get color coding working for log views in
emacs …

If you find out how to make emacs interpret the ANSI codes as colors,
please let me know :slight_smile:

cheers
Gerret

Hello, Maiha Ishimura!
on 07.02.2006 15:21

– Maiha

I merge you patch.
Big thanks!

On 2/7/06, Gerret A. [email protected] wrote:

Thx. Now I only need a way to get color coding working for log views in
emacs …

If you find out how to make emacs interpret the ANSI codes as colors,
please let me know :slight_smile:

There’s ansi-color.el [1]. AFAIK it’s been part of the GNU Emacs distro
since v 21. Works for me with shell-mode, but I haven’t tried
configuring
it with other items (like rails log files).

Cheers,
/Nick

[1] EmacsWiki: ansi-color.el

Hello, Nick S.!
on 07.02.2006 19:03

please let me know :)

There’s ansi-color.el [1]. AFAIK it’s been part of the GNU Emacs distro
since v 21. Works for me with shell-mode, but I haven’t tried
configuring it with other items (like rails log files).

Cheers,
/Nick

[1] EmacsWiki: ansi-color.el
Thanks for assistance.
rails.el now display color logs:)

Looks terrific. Two nits so far (emacs 21.3.1):

When I hit ‘ctrl-t’ I end up with:

“Symbol’s value as variable is void: html-mode-abbrev-table” the first
time. The second time I hit ctrl-t it works.

Also, I’ve included ‘snippet.el’ but can’t trigger abbreviation
expansion with TAB. Ideas?


from my .emacs:
;rails mode

(require 'snippet)

(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))

(add-hook 'ruby-mode-hook
(lambda()
(add-hook 'local-write-file-hooks
'(lambda()
(save-excursion
(untabify (point-min) (point-max))
(delete-trailing-whitespace)
)))
(set (make-local-variable 'indent-tabs-mode) 'nil)
(set (make-local-variable 'tab-width) 2)
(imenu-add-to-menubar “IMENU”)
(require 'ruby-electric)
(ruby-electric-mode t)
))

(require 'rails)

San wrote :
| Also, I’ve included ‘snippet.el’ but can’t trigger abbreviation
| expansion with TAB. Ideas?

Hi,

In fact I also had a problem to make snippet work with ruby-mode: the
TAB does not work for expansion whereas any other key works. This is
IMHO related to the ruby-mode only (note that I also have problemn with
snippet + c-mode, but not related to the TAB key :wink:


Frederick R. aka Sleeper – [email protected]

Don’t diddle code to make it faster - find a better algorithm.
- The Elements of Programming Style (Kernighan & Plaugher)

Hello, San!
on 08.02.2006 0:02

Looks terrific. Two nits so far (emacs 21.3.1):

When I hit ‘ctrl-t’ I end up with:

“Symbol’s value as variable is void: html-mode-abbrev-table” the first
time. The second time I hit ctrl-t it works.

try add in you .emacs this line, if not exists
(setq auto-mode-alist (cons '("\.rhtml$" . html-mode)
auto-mode-alist))

Also, I’ve included ‘snippet.el’ but can’t trigger abbreviation
expansion with TAB. Ideas?

rec - not work?

Hmm… no ideas
I’m using emacs from cvs 22.0.50.1 (2005/11/26), do not see this problem

While we’re on the rails+emacs topic –

I’m still looking for a good way to auto-indent rhtml files in an
emacs buffer. Currently I use ruby-mode, ruby-electric and rails mode.
rhtml indentation is a real pain to keep like this.

If any of you have found a way to auto-indent rhtml I’d love to hear
about it.

cheers
Gerret