tags:

views:

567

answers:

3

I have been learning to use Emacs for a little while now. So far liking it a lot.

My problem is that for little C codes I prefer using Rake instead of Make. However flymake does not seem to want anything else than Make. As it complains that it can not find Makefile. From the command line Rake is used in the same way as Make so I was wondering if there was some emacs configuration I could enter to allow Rake to be used by flymake?

To correct a bit what I am doing. I'm not actually editing a Rakefile. And flymake-ruby does not help at all. I'm working with C code. I just use RAKE to compile the c code using gcc instead of MAKE.

A: 

Rake is Ruby syntax, so simply turning on the flymake for rby in the file should do it. This link is to someone's elisp code for doing this. the EmacsWiki has a lot on it as well. (In fact, you should be reading the EmacsWiki in general, lots of useful stuff there.)

Charlie Martin
Thanks for EmacsWiki. Will read that.What you pointed to me however was for ruby-mode. I'm talking about c-mode. I'm just using the Rake build system instead of Make to build the C code. When I try to use flymake it complains that it can't find Makefile. But I want it to use Rakefile.
Jon Gretar
A: 

To continue with what Charlie said, the FlymakeRuby node on EmacsWiki has exactly the code you need, including the bits to enable it on rakefiles.

genehack
No I have the flymake Ruby installed. And all it does is allow me to enter flymake-mode when editing a Rakefile. But thats not what I am doing. I'm not editing a Ruby file but a C file.I just want flymake to use rake to compile the C files instead of make.
Jon Gretar
+1  A: 

Right, got it now; sorry about the earlier confusion.

Taking a quick look through flymake.el, for *.c files, the 'make' invocation ultimately comes from here:

(defun flymake-get-make-cmdline (source base-dir)
  (list "make"
    (list "-s"
          "-C"
          base-dir
          (concat "CHK_SOURCES=" source)
          "SYNTAX_CHECK_MODE=1"
          "check-syntax")))

That gets called by flymake-simple-make-init, which is called because that's what *.c files are mapped to by flymake-allowed-file-name-masks.

So, the right answer would be to modify flymake-allowed-file-name-masks to map *.c files to a different init defun, then write that defun to call rake the way you want. There are a bunch of those defuns already written for various things, and most of them are pretty short and sweet -- so even if you don't know Emacs Lisp, you could probably get something to work with a minimum of futzing. (The really really right answer would be to change flymake-simple-make-init so that the command name was read from a defcustom variable, then submit that change back upstream...)

The quick-and-dirty answer, given that you said all you need to do is call 'rake' with the same args as 'make', would be to grab a copy of flymake.el, stick it early in your load-path, and munge the 'make' string in flymake-get-make-cmdline to read 'rake' instead. That'll at least get you to the next step...

genehack