leah blogs

September 2004

18sep2004 · ETE - Errors To Emacs

I’ve spent the whole afternoon writing two small scripts. What did I do?

My desktop is basically one Emacs instance beneath one Aterm. (Well, there’s a lot of stuff around it, but that doesn’t matter here.) When I code, I write the programs in Emacs, and run them in Aterm. Switching between those two windows is easy, I simply press M-Tab. This is a feature by Enlightenment. However, when my code raises an unhandled exception, there was no easy way to jump directly to the error; I had to jump to and retype the line number of the erroneous file.

This has changed now. I simply run my programs as usual, but write ete before:

$ ete ruby fuckup.rb
fuckup.rb:1: undefined method `fuckup' for main:Object (NoMethodError)

To handle this (trivial) error, I simply switch to Emacs and type C-x :. Emacs will now load the output of ete and jump to the first (mostly only) error. I could use C-x ` if I had several errors. (Unlikely with Ruby, but maybe a C extension…)

You can download ete here: ete (shell script), ete.el (elisp).

On a side note, put this into your .emacs:

;; Make ruby-mode usable for hs-minor-mode.
(add-to-list 'hs-special-modes-alist
         (list 'ruby-mode
           (concat ruby-block-beg-re "\|{")
           (concat ruby-block-end-re "\|}")
           'ruby-forward-sexp nil))

Now open some lengthy Ruby file, and do:

M-x hs-minor-mode
M-x reveal-mode

Move over some defs, press C-c @ C-l (better rebind that :P), and be astonished moving your cursor in and out. ;-) Cool, eh?

NP: Velvet Revolver—Superhuman

Copyright © 2004–2022