Emacs Shell Ansi Colors 2

Posted by ch0wda on December 13 2007 at 03:58 PM

In a previous post I mentioned a funky character encoding issue with my Emacs Autotest output. I finally looked into the cause and came across the solution. I just needed to enable ansi-colors in my Emacs shell.

In your .emacs file, add the following:

   ;; Add color to a shell running in emacs 'M-x shell'
   (autoload 'ansi-color-for-comint-mode-on "ansi-color" nil t)
   (add-hook 'shell-mode-hook 'ansi-color-for-comint-mode-on)

Cheap and easy. Now, you’ll get all the cool ansi colors, like the kids.

Emacs Autotest Integration

Posted by ch0wda on September 18 2007 at 10:30 AM

I’ve been read in several places about how to get emacs and autotest to play nicely together. This package runs a shell buffer just giving autotest’s output. It’s a nice way to automatically have that visual representation in the same window. It’s actually quite simple to do.

To begin with, you’ll need to download the autotest.el file and also a depencency, toggle.el. From there, I simply added the following to my .emacs file:

  ;; adding autotest integration
  (require 'toggle )
  (require 'autotest)

Restart emacs, and you should be good to go. Note, I also had to add the unit-test.el file, but that wasn’t mentioned anywhere on the wiki.

Navigate in emacs to a the root folder that you want to run autotest in and you can start this mode by typing:

M-x autotest
. Currently, my output is looking a little funny, I think it’s an encoding thing, but I think I can get the kinks worked out pretty soon. Also, make note that this will read the ~/.autotest file to start. A great resource on this nice piece of integration can be found on the emacs wiki.

That’s one less terminal that I’ll have going, meaning that more of my life will be spent in emacs, which is good.

Emacs Railsy-ness

Posted by ch0wda on April 18 2007 at 12:56 PM

For the most part, I followed the instructions at Dima’s Rails On Emacs page. This worked for the most part, however there were several gotchas that crept up as I was working my way through. Here’s what I did, that might be different than the other tutorials:

  1. I placed the snippets.el and find-recursive.el into the folder that I checked out the Rails on Emacs code. (Perhaps this is what he meant by install, but I originally had them in .emacs.d, and that was wrong.) ruby-inf.el did, however remain in .emacs.d
  2. I reinstalled ruby and installed ruby-elisp from synaptic. I did this because I read that when you install ruby on debian/ubuntu it will automatically install the necessary emacs modes.
  3. Tip After opening emacs, change your buffer to “Messages” it will have all the init information, and I found it very handy for debugging.

I’m also going to install the Emacs Code Browser, which is supposed to provide some parsing of files to show methods, and other view-related functions.

Here’s 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.
 '(standard-indent 2))
(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 "#000000" :foreground "#00ff00" :inverse-video nil :box nil :strike-through nil :overline nil :underline nil :slant normal :weight normal :height 164 :width normal :family "adobe-courier")))))
 ;; this line makes a file executable after saving it
 ;; (add-hook 'after-save-hook 'executable-make-buffer-file-executable-if-script-p)
(setq load-path (cons "~/.emacs.d/emacs-rails" load-path))
(require 'rails)

Resourceful Links

Switching Up My IDE

Posted by ch0wda on April 18 2007 at 10:31 AM

That’s it, I can’t stand the bloat that comes from all things java anymore. I’ve been a pretty religious Radrails user almost since it’s inception. I haven’t been too frustrated with the recent lack of development because it’s done what I need it to do. About 4 months ago, I switched from using Radrails proper to loading it into an existing version of Eclipse as a plugin because I wanted to load some other types of plugins, like one for Erlang support. (Thanks pragprog!) This was serviceable, but since I’m running Ubuntu in a VMWare machine on my laptop I need to conserve all the RAM I can. The JVM for Eclipse currently runs at 86MB when sitting still. Totally unacceptable for my needs.

So, if I’m off the Radrails/Eclipse stack, what should I use? Another popular IDE is JEdit, but since the “J” stands for java, I’m skipping it. I’ve decided to take the time and learn how to use emacs. I love the emphasis on hotkeys and simplicity. Since emacs has been around in some form since 1974, it’s super stable too. It just seems that there is so much more I can do, and quicker too, if I’m just willing to take the time to learn. I am. Plus, there just seems to be some serious street-cred for telling people that you’re an emacs user.

Installation Instructions for Ubuntu Edgy

Since most of the development that I’ll be doing in emacs will be Ruby/Rails related, I’ll want to install Dima’s Rails Emacs minor mode. WARNING: This requires emacs 22, which you’ll either need to compile, or find a package for. There is an Ubuntu package of emacs 22 currently available in the repositories. It’s called emacs-snapshot and the package was built from CVS sources on 20060915, so it’s not the latest sources, but it’s pretty close. Feisty Fawn, which is supposed to release tomorrow (4/19) also has this package, but it’s actually built on 20070407, so very recently. I’ll be upgrading to Feisty soon. Just do the following to install:
sudo apt-get install emacs-snapshot
As a final note, I like to keep all my programming utilities on the Gnome menu together, under the “Programming” heading. The emacs-snapshot package puts menu shortcut in Applications -> Accessories, so it required a little tweaking of the .desktop file. Fire up your favorite editor and edit /usr/share/applications/emacs-snapshot.desktop. Change line that begins with the word Categories to the following to move the shortcut to your Applications -> Programming section:
Categories=Application;Development;

I’ll take you through installing the Rails specific portions next time. Just to give a comparison, Eclipse uses 86MB of RAM just sitting there, while emacs uses only 11MB. I’m looking forward to getting my emacs pinky Why didn’t I switch sooner?