Anyone using arorem in emacs ?

Hi Again,

A quick bit of foot work yielded some answers:

http://dev.technomancy.us/phil/wiki/arorem

* C-c C-v switches between a controller action and the associated view
* C-c C-t switches between a controller and its functional test or a model and its unit test
* C-c C-s launches script/console in inferior-ruby-mode (like regular ruby-mode)
* The file arorem-abbrevs.el defines snippets that auto-expand

-Dan

Hi again,

I learned a little more.

I found out that if I type
%=
in an rhtml file,
arorem will transform it into
<%= -%>
I just bumped into this by mistake.

I’m not sure of any other code completion gizmos
have been baked in; I’d like to find the list.

And…
I found some abbreviations here:

arorem-abbrevs.el

This one looks interesting:

%ft

So, I type
%ft
into a list.rhtml file

Then do key strokes

C-x a e

and emacs transforms
%ft
into

<%= form_tag :action => “update” %>

<%= end_form_tag %>

So, that will save me some typing.

Also, I can use
arorem-abbrevs.el
as an informal index of rails syntax:

;;; arorem-abbrevs.el

;; Part of arorem - Another Ruby on Rails Emacs Mode
;; Uses snippet.el to set up auto-expanded abbreviations
;; Thanks to TextMate, Pete Kazmier, and Galinsky Dmitry

(snippet-with-abbrev-table 'arorem-abbrev-table
;; model
(“bt” . “belongs_to”)
(“hm” . “has_many”)
(“ho” . “has_one”)
;; controller renders
(“ra” . “render :action => “$${action}””)
(“ral” . “render :action => “$${action}”, :layout => “$${layoutname}””)
(“rf” . “render :file => “$${filepath}””)
(“rfu” . “render :file => “$${filepath}”, :use_full_path => $${false}”)
(“ri” . “render :inline => “$${<%= ‘hello’ %>}””)
(“ril” . “render :inline => “$${<%= ‘hello’ %>}”, :locals => { $${name} => “$${value}” }”)
(“rit” . “render :inline => “$${<%= ‘hello’ %>}”, :type => :$${rxml})”)
(“rl” . “render :layout => “$${layoutname}””)
(“rn” . “render :nothing => $${true}”)
(“rns” . “render :nothing => $${true}, :status => $${401}”)
(“rp” . “render :partial => “$${item}””)
(“rpc” . “render :partial => “$${item}”, :collection => $${items}”)
(“rpl” . “render :partial => “$${item}”, :locals => { :$${name} => “$${value}”}”)
(“rpo” . “render :partial => “$${item}”, :object => $${object}”)
(“rps” . “render :partial => “$${item}”, :status => $${500}”)
(“rt” . “render :text => “$${Text here…}””)
(“rtl” . “render :text => “$${Text here…}”, :layout => “$${layoutname}””)
(“rtlt” . “render :text => “$${Text here…}”, :layout => $${true}”)
(“rts” . “render :text => “$${Text here…}”, :status => $${401}”)
(“rcea” . “render_component :action => “$${index}””)
(“rcec” . “render_component :controller => “$${items}””)
(“rceca” . “render_component :controller => “$${items}”, :action => “$${index}””)
;; redirects
(“rea” . “redirect_to :action => “$${index}””)
(“reai” . “redirect_to :action => “$${show}”, :id => $${@item}”)
(“rec” . “redirect_to :controller => “$${items}””)
(“reca” . “redirect_to :controller => “$${items}”, :action => “$${list}””)
(“recai” . “redirect_to :controller => “$${items}”, :action => “$${show}”, :id => $${@item}”)
;; assertions
(“ae” . “assert_equal $${expected}, $${actual}”)
(“ann” . “assert_not_nil $${object}”)
(“ako” . “assert_kind_of $${class}, $${object}”)
(“ars” . “assert_response :$${success}”)
(“ar” . “assert_raises $${Exception} { $. }”)
(“art” . “assert_redirected_to :controller => “$${controller}””)
;; validations
(“va” . “validates_associated :$${attr}”)
(“vc” . “validates_confirmation_of :$${attr}”)
(“ve” . “validates_exclusion_of :$${attr}”)
(“vp” . “validates_presence_of :$${attr}”)
(“vu” . “validates_uniqueness_of :$${attr}”)
(“vn” . “validates_numericality_of :$${attr}”)
(“vf” . “validates_format_of :$${attr}, :with => /$${regex}/”)
;; misc
(“flash” . “flash[:$${notice}] = “$${Text here…}””)
(“logi” . “logger.info “$${Text here…}””)
(“par” . “params[:$${id}]”)
(“ses” . “session[:$${user}]”))

(snippet-with-abbrev-table 'arorem-rhtml-abbrev-table
;; view
("%ft" . “<%= form_tag :action => “$${update}” %>\n$.\n<%= end_form_tag %>”)
("%lia" . “<%= link_to “$${title}”, :action => “$${index}” %>”)
("%liai" . “<%= link_to “$${title}”, :action => “$${edit}”, :id => $${@item} %>”)
("%lic" . “<%= link_to “$${title}”, :controller => “$${items}” %>”)
("%lica" . “<%= link_to “$${title}”,
:controller => “$${items}”, :action => “$${index}” %>”)
("%licai" . “<%= link_to “$${title}”,
:controller => “$${items}”, :action => “$${edit}”, :id =>
$${@item} %>”)
("%h" . “<%=h $${@item} %>”)
("%if" . “<% if $${cond} -%>\n$.\n<% end -%>”)
("%ifel" . “<% if $${cond} -%>\n$.\n<% else -%>\n<% end -%>”)
("%unless" . “<% unless $${cond} -%>\n$.\n<% end -%>”)
("%" . “<%$. -%>”)
("%%" . “<%=$. %>”))

-Dan

ok,

I figured out how to hot-key to various locations in my rails tree.

step 1.
go to some random file in the tree,
list.rhtml
for example
type in this emacs command:
rails-minor-mode

Then to go someplace, try this emacs command

rails-nav:goto-

I saw these completions:

rails-nav:goto-controllers rails-nav:goto-helpers
rails-nav:goto-javascripts rails-nav:goto-layouts
rails-nav:goto-migrate rails-nav:goto-models
rails-nav:goto-stylesheets

I tried them out and they worked great.

Next, I used old-fashioned grep to tell me how they are tied to keys:

mac:~/.emacs.d/arorem maco$ grep C-c *el
arorem-rhtml.el: “\C-c\C-v” 'arorem-switch-view)
arorem.el: “\C-c\C-t” 'arorem-switch-test)
arorem.el: “\C-c\C-v” 'arorem-switch-view)
arorem.el: “\C-c\C-s” 'arorem-console)
inf-ruby.el: (define-key inferior-ruby-mode-map “\C-c\C-l” 'ruby-load-file)
inf-ruby.el: (define-key ruby-mode-map “\C-c\C-b” 'ruby-send-block)
inf-ruby.el: (define-key ruby-mode-map “\C-c\M-b” 'ruby-send-block-and-go)
inf-ruby.el: (define-key ruby-mode-map “\C-c\C-x” 'ruby-send-definition)
inf-ruby.el: (define-key ruby-mode-map “\C-c\M-x” 'ruby-send-definition-and-go)
inf-ruby.el: (define-key ruby-mode-map “\C-c\C-r” 'ruby-send-region)
inf-ruby.el: (define-key ruby-mode-map “\C-c\M-r” 'ruby-send-region-and-go)
inf-ruby.el: (define-key ruby-mode-map “\C-c\C-z” 'switch-to-ruby)
inf-ruby.el: (define-key ruby-mode-map “\C-c\C-l” 'ruby-load-file)
inf-ruby.el: (define-key ruby-mode-map “\C-c\C-s” 'run-ruby)
rails-for-rhtml.el: (local-set-key (kbd “\C-c p”) 'rails-rhtml:create-partial-from-selection)
rails-for-rhtml.el: (local-set-key (kbd “\C-c b”) 'rails-rhtml:create-helper-from-block))
rails-ui.el: ((kbd “\C-c g m”) 'rails-nav:goto-models)
rails-ui.el: ((kbd “\C-c g c”) 'rails-nav:goto-controllers)
rails-ui.el: ((kbd “\C-c g h”) 'rails-nav:goto-helpers)
rails-ui.el: ((kbd “\C-c g l”) 'rails-nav:goto-layouts)
rails-ui.el: ((kbd “\C-c g s”) 'rails-nav:goto-stylesheets)
rails-ui.el: ((kbd “\C-c g j”) 'rails-nav:goto-javascripts)
rails-ui.el: ((kbd “\C-c g g”) 'rails-nav:goto-migrate)
rails-ui.el: ((kbd "C-c ") 'rails-lib:run-primary-switch)
rails-ui.el: ((kbd "C-c ") 'rails-lib:run-secondary-switch)
rails-ui.el: ((kbd “\C-c s g c”) 'rails-generate-controller)
rails-ui.el: ((kbd “\C-c s g m”) 'rails-generate-model)
rails-ui.el: ((kbd “\C-c s g s”) 'rails-generate-scaffold)
rails-ui.el: ((kbd “\C-c s g g”) 'rails-generate-migration)
rails-ui.el: ((kbd “\C-c s d c”) 'rails-destroy-controller)
rails-ui.el: ((kbd “\C-c s d m”) 'rails-destroy-model)
rails-ui.el: ((kbd “\C-c s d s”) 'rails-destroy-scaffold)
rails-ui.el: ((kbd “\C-c s c”) 'rails-run-console)
rails-ui.el: ((kbd “\C-c s b”) 'rails-run-breakpointer)
rails-ui.el: ((kbd “\C-c s s”) 'rails-run-sql)
rails-ui.el: ((kbd “\C-c s r”) 'rails-rake)
rails-ui.el: ((kbd “\C-c s w”) 'rails-webrick:start)
rails-ui.el: ((kbd “\C-c f m”) 'rails-find-models)
rails-ui.el: ((kbd “\C-c f c”) 'rails-find-controller)
rails-ui.el: ((kbd “\C-c f h”) 'rails-find-helpers)
rails-ui.el: ((kbd “\C-c f l”) 'rails-find-layout)
rails-ui.el: ((kbd “\C-c f s”) 'rails-find-stylesheets)
rails-ui.el: ((kbd “\C-c f j”) 'rails-find-javascripts)
rails-ui.el: ((kbd “\C-c f g”) 'rails-find-migrate)
rails-ui.el: ((kbd “\C-c f v”) 'rails-find-view)
rails-ui.el: ((kbd “\C-c f d”) 'rails-find-db)
rails-ui.el: ((kbd “\C-c f p”) 'rails-find-public)
rails-ui.el: ((kbd “\C-c f o”) 'rails-find-config)
rails-ui.el: ((kbd “\C-c l”) 'rails-open-log)
rails-ui.el: ((kbd “\C-c \C-t”) 'rails-create-tags)
rails-ui.el: ((kbd "\C-c ") 'rails-webrick:auto-open-browser)
mac:~/.emacs.d/arorem maco$

All I need to do now is figure out how I tell emacs that
on my Mac, ruby is here:

/Applications/Locomotive2/Bundles/standardRailsSept2006.locobundle/powerpc/bin/ruby

not here:

/usr/bin/ruby

Anyone here know how to talk with emacs?

-Dan

oops,

I forgot to mention that
rails-minor-mode
started working after I added a line to my .emacs.

So, now my .emacs has three lines:

;; lines below spaz out emacs in /usr/bin but work with my purple emacs
(setq load-path (append '("~/.emacs.d/arorem") load-path))
(require 'arorem)
(require 'rails)

-Dan

Thanks a lot for this informative thread. I am using rails with emacs,
and was really looking for a nice rails mode.

raj

Thanks for the info Dan. I do use rails.el. I'll give this a try too.
Can you mix this with ecb? I really like ecb for its multi-pane views.

-bakki

uh,

I don’t know.

What are some good google keywords I can use to learn about ecb?

-Dan

Never mind,

I found it:

http://ecb.sourceforge.net/

"
ECB…

The informational windows can contain:

  • A directory tree,
  • a list of source files in the current directory,
  • a list of functions/classes/methods/… in the current file,
    (ECB uses the Semantic Bovinator, or Imenu, or etags, for getting this
    list so all languages supported by any of these tools are automatically
    supported by ECB too)
  • a history of recently visited files,
  • the Speedbar and
  • output from compilation (the compilation
    window) and other modes like help, grep etc. or whatever a user defines to be displayed in this window.
    As an added bonus, ECB makes sure to keep these informational windows visible, even when you use C-x 1 and similar commands.

"

ECB looks good.

I wonder if ‘Bovinator’ is a real word?

-Dan

Dear List:

you get ECB here:
http://ecb.sourceforge.net/

The readme says:

ECB requires the following packages:

  • Semantic, author version 1.4 or higher
  • Eieio, author version 0.17 or higher
  • speedbar, author version 0.14beta1 or higher

Download links for above 3 are there:

http://sourceforge.net/project/showfiles.php?group_id=17886

http://sourceforge.net/project/showfiles.php?group_id=17886&package_id=14926&release_id=154524

http://sourceforge.net/project/showfiles.php?group_id=17886&package_id=14925&release_id=104048

http://sourceforge.net/project/showfiles.php?group_id=17886&package_id=14924&release_id=80017

I made copies and put them here:

http://GoodJobFastCar.com/downloads/

-rw-r–r-- 1 peter peter 114994 Nov 26 14:11 speedbar-0.14beta4.tar.gz

-rw-r–r-- 1 peter peter 120643 Nov 26 14:10 eieio-0.17.tar.gz
-rw-r–r-- 1 peter peter 322819 Nov 26 14:05 semantic-1.4.4.tar.gz
-rw-r–r-- 1 peter peter 896382 Nov 26 13:55 ecb-2.32.tar.gz

http://GoodJobFastCar.com/downloads/speedbar-0.14beta4.tar.gz
http://GoodJobFastCar.com/downloads/eieio-0.17.tar.gz

http://GoodJobFastCar.com/downloads/semantic-1.4.4.tar.gz
http://GoodJobFastCar.com/downloads/ecb-2.32.tar.gz

…Peter

About ECB,

The first thing I installed was speedbar.

I plays well with rails editing tasks.

My installation recipe for speedbar:

  1. make note of where I put speedbar:
    I put it here:

/software/ecb/speedbar-0.14beta4/

  1. Add lines to my .emacs:

; ecb stuff
(add-to-list 'load-path “/software/ecb/speedbar-0.14beta4”)
(autoload 'speedbar-frame-mode “speedbar” “Popup a speedbar frame” t)

(autoload 'speedbar-get-focus “speedbar” “Jump to speedbar frame” t)
(global-set-key [(f4)] 'speedbar-get-focus)
;; HTML fancy chapter tags
(add-hook 'html-mode-hook (lambda () (require 'sb-html)))

  1. run
    eval-current-buffer
    while in .emacs

  2. Watch a window appear. It is named speedbar.
    It’s behavior is intuitive. Just ignore it while you
    do some editing. You will see that it changes and constantly

displays a list of files and folders near your editing activity.
Eventually you will see some file or directory in speedbar
that you will want so just click on it to get it. I consider
it a nice complement to my favorite emacs call which is

buffer-menu.

  1. Speed bar by itself is very useful when I edit files in
    a rails tree. These directories are just a quick click away:

app
components
config
db
doc
lang
lib

log
public
script
test
tmp
vendor

  1. Speed bar knows about methods in a .rb file.
    Each .rb file has a [+] drill-downer which I use
    to display methods. After I click on a method,
    emacs opens the .rb file right at that method; I like it.

Next, I’ll install
eieio-0.17.tar.gz

and see what that does.

…Peter

Hi Dan,

Looks like you found everything needed. I love ecb+emacs. On Debian I
use it with emacs21(X11) but on the Mac I use it with Aquamacs and it
works great on both.

-bakki

Well,

I installed eieio.

I did it by adding one line to my .emacs:

(add-to-list 'load-path “/software/ecb/eieio-0.17”)

I did not see any obvious changes to my emacs environment.

I found some documentation here:

http://cedet.sourceforge.net/info/eieio.html

I read :

EIEIO is a framework for writing object oriented applications in emacs lisp.

Today, I’m writing object oriented applications in ruby, not emacs lisp.

I’ll ignore eieio for now.

Next, I’ll study:

semantic-1.4.4.tar.gz

…Peter

Yep,

I installed semantic-1.4.4

  1. I added syntax to my .emacs:

(add-to-list 'load-path “/software/ecb/semantic-1.4.4”)
(setq semantic-load-turn-everything-on t)
(require 'semantic-load)

  1. I looked for keys:

mac:/software/ecb/semantic-1.4.4 maco$ grep define-key *el
semantic-bnf.el: (define-key semantic-bnf-map “\t” 'semantic-bnf-indent)
semantic-bnf.el: (define-key semantic-bnf-map “|” 'semantic-bnf-electric-punctuation)

semantic-bnf.el: (define-key semantic-bnf-map “;” 'semantic-bnf-electric-punctuation)
semantic-bnf.el: (define-key semantic-bnf-map “#” 'semantic-bnf-electric-punctuation)
semantic-bnf.el: (define-key semantic-bnf-map “%” 'semantic-bnf-electric-punctuation)

semantic-bnf.el: (define-key semantic-bnf-map “(” 'semantic-bnf-electric-punctuation)
semantic-bnf.el: (define-key semantic-bnf-map “)” 'semantic-bnf-electric-punctuation)
semantic-bnf.el: (define-key semantic-bnf-map “\C-c\C-c” 'semantic-bnf-generate-and-load-no-indent)

semantic-bnf.el: (define-key semantic-bnf-map “\C-cc” 'semantic-bnf-generate-and-load)
semantic-bnf.el: (define-key semantic-bnf-map “\C-cr” 'semantic-bnf-generate-one-rule)
semantic-bnf.el
: (define-key semantic-bnf-map “\M-\t” 'semantic-bnf-complete)
semantic-ia-sb.el: (define-key semantic-ia-sb-key-map “\C-m” 'speedbar-edit-line)
semantic-ia-sb.el: (define-key semantic-ia-sb-key-map “I” 'semantic-ia-sb-tag-info)

semantic-util-modes.el: (define-key km “\C-c,`” 'semantic-show-unmatched-syntax-next)
senator.el: (define-key km “i” 'senator-isearch-toggle-semantic-mode)
senator.el: (define-key km “j” 'senator-jump)

senator.el: (define-key km “p” 'senator-previous-token)
senator.el: (define-key km “n” 'senator-next-token)
senator.el: (define-key km “\t” 'senator-complete-symbol)
senator.el
: (define-key km " " 'senator-completion-menu-popup)
senator.el: (define-key km “\C-w” 'senator-kill-token)
senator.el: (define-key km “\M-w” 'senator-copy-token)
senator.el
: (define-key km “\C-y” 'senator-yank-token)
senator.el: (define-key km senator-prefix-key senator-prefix-map)
senator.el: (define-key km [(shift mouse-3)] 'senator-completion-menu-popup)
senator.el
: (define-key mode-line-mode-menu [senator-minor-mode]
senator.el:(define-key isearch-mode-map
mac:/software/ecb/semantic-1.4.4 maco$ grep set-key *el
mac:/software/ecb/semantic-1.4.4 maco$

I put an application.rb in my emacs buffer.

I ran senator-minor-mode

It told me:
application.rb was not setup for parsing.

More info about semantic is here:

http://cedet.sourceforge.net/semantic.shtml

…Peter

Next,

I installed

ecb-2.32.tar.gz

un packing it in /software/ecb/ecb232

Then I added 2 lines to my .emacs:

(add-to-list 'load-path “/software/ecb/ecb232”)
(require 'ecb)

After I did
eval-current-buffer

I looked at a
app/controllers/application.rb
file

A RubyOnRails item appeared in my menu bar
with a lot of different navigation items.

I put my cursor on this and tried:

‘Rails API doc at point’

It gave me an error:

Please configure variable rails-api-root

Some other items worked well though:

goto migrate
goto models
open development log
context sensitive snippets of syntax

search documentation

…Peter

Peter Smith
GoodJobFastCar@gmail.com

http://GoodJobFastCar.com

Anyway…
here is a recap of how I got ECB and arorem to work on my Mac.

-Get emacs 22.0.50.1
-Get arorem
-Get ecb
-Get eieio

-Get semantic
-Get speedbar

http://www.google.com/search?hl=en&q=emacs+22.0.50.1+os+x

http://GoodJobFastCar.com/downloads/arorem-2006-1126.tgz

http://GoodJobFastCar.com/downloads/ecb-2.32.tar.gz

http://GoodJobFastCar.com/downloads/eieio-0.17.tar.gz

http://GoodJobFastCar.com/downloads/semantic-1.4.4.tar.gz

http://GoodJobFastCar.com/downloads/speedbar-0.14beta4.tar.gz

Unpack the files somewhere convenient
(for me this place is /software/)

Add appropriate entries to .emacs:

(setq load-path (append '("/software/arorem") load-path))

(require 'arorem)
(require 'rails)
; ecb stuff
(add-to-list 'load-path “/software/ecb/speedbar-0.14beta4”)
(autoload 'speedbar-frame-mode “speedbar” “Popup a speedbar frame” t)

(autoload 'speedbar-get-focus “speedbar” “Jump to speedbar frame” t)
(global-set-key “\C-c f b” 'speedbar-get-focus)
;; HTML fancy chapter tags
(add-hook 'html-mode-hook (lambda () (require 'sb-html)))

(add-to-list 'load-path “/software/ecb/eieio-0.17”)
(add-to-list 'load-path “/software/ecb/semantic-1.4.4”)
(setq semantic-load-turn-everything-on t)
(require 'semantic-load)
(add-to-list 'load-path “/software/ecb/ecb232”)

(require 'ecb)

stop and start emacs

edit a .rb or .rhtml in a rails tree.

You should see a RubyOnRails entry in your emacs menu at the top.

At this point I usually give an emacs command in the command window:

speedbar

and the speedbar will appear which contains a convenient list of
files and directories near where I’m editing.

I actually find it a little more convenient than the
RubyOnRails menu.

Once I memorize the hot-keys, it will be even quicker:

rails-ui.el: ((kbd “\C-c f m”) 'rails-find-models)
rails-ui.el: ((kbd “\C-c f c”) 'rails-find-controller)
rails-ui.el: ((kbd “\C-c f h”) 'rails-find-helpers)

rails-ui.el: ((kbd “\C-c f l”) 'rails-find-layout)
rails-ui.el: ((kbd “\C-c f s”) 'rails-find-stylesheets)
rails-ui.el: ((kbd “\C-c f j”) 'rails-find-javascripts)
rails-ui.el: ((kbd “\C-c f g”) 'rails-find-migrate)

rails-ui.el: ((kbd “\C-c f v”) 'rails-find-view)
rails-ui.el: ((kbd “\C-c f d”) 'rails-find-db)
rails-ui.el: ((kbd “\C-c f p”) 'rails-find-public)
rails-ui.el: ((kbd “\C-c f o”) 'rails-find-config)

rails-ui.el: ((kbd “\C-c l”) 'rails-open-log)

…Peter

Peter Smith
GoodJobFastCar@gmail.com

http://GoodJobFastCar.com

Peter,

Once you have the modes enabled, you can see what key bindings are in
effect within Emacs. Do a 'C-h b' or 'M-x describe-bindings' to see
the current key bindings for that buffer.

- Hitesh