It's probably a very basic question, but I am having a hard time finding an answer to it:
I am trying to make emacs look for a makefile somewhere in the parent directories and use it for compilation.
I found this function:
(defun desperately-compile ()
"Traveling up the path, find a Makefile and `compile'."
(interactive)
(when (locate-dominating-file default-directory "Makefile")
(with-temp-buffer
(cd (locate-dominating-file default-directory "Makefile"))
(compile "make -k"))))
and put it in my .emacs file, but I can't figure out how to call it. replacing the compile command doesn't seem to work and I'm not sure how to bind a key to it.
It would be best to call that function using "M-x compile" or "M-x desperate-compile", but I am open for suggestions.
thanks.
M-x
desperately-compile
work?desperately-compile
. It seems straight-forward and it does what I think it was intended to do: it runs make in the directory closest in the file tree to the currently opened file. If you need to bind it to a key, then, definitely,global-set-key
is the way to go. PS. I'll be voting on closing this question because I believe that it shows a lack of effort (the info you are asking for is very easy to find).