can I change emacs' default compile command?

Since I need different compilers for different modes, I make use of the following snippet (here shown for javascript):

(require 'compile)
(add-hook 'js-mode-hook
          (lambda ()
            (set (make-local-variable 'compile-command)
                 (format "jshint %s" (file-name-nondirectory buffer-file-name)))))

This runs "jshint " as my compile command. I can then add hooks to other languages as well, and customize each according to my needs.


(setq compile-command "make") 

or similar in your .emacs should suffice.

For more info, type

C-h f compile

which describes what variables are used when M-x compile is called.

In there, you should see it calls compile-command and a

C-h v compile-command

tells you this defaults to "make -k". All above is a simplification, but all the info should be in those commands should you need to dig further.