Stack trace back

40 views
Skip to first unread message

pedz

unread,
Feb 11, 2011, 11:34:14 AM2/11/11
to Rails On Emacs
I probably should research this more but I'm hoping to get some easy
answers.

On my laptop where I develop Rails apps, I have one app using
Passenger and another app using Thin and I have things set up so I can
go to:

http://localhost/app_name/path/for/app

The app on the laptop is running in "development" mode.

I might be talked out of this. The reason I do it this way is so I
can test a more complete stack. e.g. when I switch from Mongrel to
Thin, I can test it locally and get the bugs out not just with the
Rails app but also with how I have it hooked in to Thin or Passenger.

My question is, when I hit an error, I get the usual Rails stack
showing me where the error is. I'm sure the same stack is in the
development log.

Is there a way (or what is the easiest way) to get emacs using rinari
to parse the stack so I can click and be taken to where the error
occurred in the Rails app?

Chris Thompson

unread,
Feb 11, 2011, 11:53:37 AM2/11/11
to emacs-o...@googlegroups.com
do you mean something other than find-file-at-point ?

pedz

unread,
Feb 11, 2011, 12:56:25 PM2/11/11
to Rails On Emacs
Well, the trace back is in the browser (not in my emacs window). And
if I edit the development log and try find-file-at-point, it doesn't
seem to understand what I'm asking it to do.

Tobias Crawley

unread,
Feb 11, 2011, 6:50:01 PM2/11/11
to emacs-o...@googlegroups.com
pedz:

I wrote a gem to help with this situation: https://github.com/tobias/open_exception

It will automatically open the error and the stack for you in emacs if it is included in the app and configured. I don't actually use it anymore, and I haven't tried it with rails 3, but feel free to take it for a spin and let me know if you find any issues.

Toby

pedz

unread,
Feb 13, 2011, 5:57:52 PM2/13/11
to Rails On Emacs
Thanks. I'll try it out.

I'm interested in recreating the way that Merb use to do it but by
modifying rails at a lower point. Merb use to write each line as a
link using a "txmt" protocol. You could teach Firefox what to do with
it. On the Mac, that would be sent as an Apple Event which you could
catch and process. I had it hooked up back a few years ago but then
never stayed working with Merb. I was hoping the Rails / Merb merge
would bring it over but looks like they left it behind.

Thank you again,
Perry


On Feb 11, 5:50 pm, Tobias Crawley <tcraw...@gmail.com> wrote:
> pedz:
>
> I wrote a gem to help with this situation:https://github.com/tobias/open_exception
>
> <https://github.com/tobias/open_exception>It will automatically open the
> error and the stack for you in emacs if it is included in the app and
> configured. I don't actually use it anymore, and I haven't tried it with
> rails 3, but feel free to take it for a spin and let me know if you find any
> issues.
>
> Toby
>

Steve Purcell

unread,
Feb 14, 2011, 3:22:11 AM2/14/11
to emacs-o...@googlegroups.com
Install José Valim's "footnotes" plugin, which makes every line in the
stacktrace clickable with a txmt:// URL:

https://github.com/josevalim/rails-footnotes

Then, if you're on a Mac, check out my article on how to make emacs
handle the txmt URLs:

http://www.sanityinc.com/articles/open-txmt-urls-from-rails-in-emacs-on-osx

-Steve

pedz

unread,
Feb 14, 2011, 12:59:57 PM2/14/11
to Rails On Emacs
I was looking for that! I found references to it. There was a bug
report in the old Rails system that got lost.

Thanks!

On Feb 14, 2:22 am, Steve Purcell <st...@sanityinc.com> wrote:
> Install José Valim's "footnotes" plugin, which makes every line in the
> stacktrace clickable with a txmt:// URL:
>
> https://github.com/josevalim/rails-footnotes
>
> Then, if you're on a Mac, check out my article on how to make emacs
> handle the txmt URLs:
>
> http://www.sanityinc.com/articles/open-txmt-urls-from-rails-in-emacs-...
>
> -Steve

pedz

unread,
Feb 14, 2011, 10:20:34 PM2/14/11
to Rails On Emacs
If anyone else wants to do this, here are the various pieces.

First, follow Steve's pointers above.

Second, if you have GNU Emacs version 23 *and* you are on a Mac,
you need to follow this thread:

http://lists.gnu.org/archive/html/help-gnu-emacs/2011-02/msg00204.html

It changes the new Cocoa based NextStep Emacs back to being Carbon
based (those terms may be all screwed up because I don't really get
what the
difference is). If you have GNU Emacs version 22, you don't need to
do this.

Third, you need this little snippet that I developed a while back:

http://groups.google.com/group/merb/browse_thread/thread/b647138d9fe79a74

Fourth, get an error stack trace after all this and click on it.
Firefox will ask you which
application to spawn and point it towards Emacs.app. I think in my
case, I
already had a txmt protocol entry in my Firefox config. If you need
help setting up
that part of it, there are "How Tos" on the net but they are kinda
hard to find.

What this gives you is what is mostly a normal development stack in
the browser
window but the lines for the stack have hyperlinks that use "txmt" as
their protocol.
FF can be taught to send that to emacs. On the Mac, it does this via
Apple Events.
The changes in part 2 allow emacs to receive Apple Events (or more of
them
perhaps) and the snippet from part 3 is where the event gets
interpreted to
be a specific file and line number.

If you are not running on a Mac, I don't know how Firefox sends the
request
to another application. It may just do a fork / exec. It may be that
the
better place to send it in that case is emacsclient.
Reply all
Reply to author
Forward
0 new messages