I'm setting up emacs as my ruby development environment. I run tests by doing M-x compile and then rake test. I've set up compile-error-regexp-alist appropriately so that the resulting compile buffer can recognize test failures and make them clickable, but I'm facing trouble getting compile-find-file to use the correct directory to find the file from. Suppose I'm visiting the file proj-home/test/ruby-test-file.rb and hit M-x compile and then use "rake test" for the compile-command. The resultant compile-buffer has "proj-home/test/" set as the default-directory while the rake test output has errors user [./test/ruby-test-file.rb:nn]. So when compile-find-file tries to find the file specified in the error message, it looks in "proj-home/test/./test/ruby-test-file.rb" which is obviously wrong.
How do I make compile-find-file to look in the right place? I've spent quite some time debugging the functions and reading through the function definitions in compile.el, but no joy yet. One thing that did surprise me is that running rake test from inside a shell cd'd to "proj-home/test" correctly runs the tests (even tho' the Rakefile is in "proj-home" and not "proj-home/test"), so it looks like rake has some intelligence built-in which allows it to search up the directory tree and find the Rakefile in parent directories.
This intelligence in rake might be confusing emacs as to what is the current directory it should use.
The emacs wiki here: http://www.emacswiki.org/emacs/CompileCommand has a code snippet to find a file by searching parent directories (under "Running Make with the closest Makefile"), but I still haven't figured out if/where I need to use that code snippet.