Next: , Previous: template-simple, Up: Top


10 Smart compile commands

cperl-mode recommend using mode-compile, but I don't like mode-compile. Instead, smart-compile+.el does a good job. But I found it is not easy to customize smart-compile+, because the user variables are separated for a language. So I rewrite it to compile-dwim(again, I like dwim).

— User Option: compile-dwim-alist

Settings for certain file type. A list like which has form (TYPE CONDITION COMPILE-COMMAND RUN-COMMAND EXE-FILE).

TYPE is the language type to distinguish from others.

CONDITION is a list of predicates constituted by operator “or”. The predicates can be (name . REGEXP) or (mode . MAJOR-MODE) to test the file name match REGEXP or major-mode eq MAJOR-MODE.

In COMPILE-COMMAND and RUN-COMMAND, these format specifications are available:

     
       %i  interpreter name
       %F  absolute pathname
       %f  file name without directory
       %n  file name without extention
       %e  extention of file name

The interpreter is the program in the shebang line. If the program is valid(test with `executable-find'), then use this program, otherwise, use interpreter in `interpreter-mode-alist' according to the major mode.

EXE-FILE control whether should run compile command before actual run or should recompile again because EXE-FILE is older than source file. Usually, script language don't need to set EXE-FILE.

— User Option: compile-dwim-check-tools

Whether checking makefile or ant or else. Default is turn on. You can also change the value locally by make-local-variable in mode-hook for certain files.