Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

can I change emacs' default compile command?

Emacs defaults to the command make -k when I run compile. However, I pretty much never think it's useful to have make continue after errors, so I always remove the -k flag. Is there a way to change the default in my .emacs so that it's just make?

like image 332
Steve Avatar asked Jan 05 '11 20:01

Steve


People also ask

How do I compile in Emacs?

To compile a program in Emacs, type Escape followed by x followed by compile, or use the pull down "tool" menu and select compile.

Can you run code in Emacs?

Emacs can run compilers for noninteractive languages such as C and Fortran as inferior processes, feeding the error log into an Emacs buffer. It can also parse the error messages and show you the source lines where compilation errors occurred.


2 Answers

(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.

like image 83
cristobalito Avatar answered Oct 07 '22 14:10

cristobalito


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.

like image 40
Stefan van der Walt Avatar answered Oct 07 '22 14:10

Stefan van der Walt