3

One thing I find myself doing a lot is every time I restart emacs, I have to retype the compilation command:

make XXX -f path-to-makefile/makefile

Sometimes I may also be working on different things at once, for example editing a .tex document and writing code, and I end up having to retype the compilation command as I switch from one to the other.

Is there a better way to do this? Can I somehow associate files with file-specific compilation commands that are known to emacs by default? Or is there some other approach that would improve my compilation workflow?

1 Answer 1

0

Sometimes I may also be working on different things at once, for example editing a .tex document and writing code, and I end up having to retype the compilation command as I switch from one to the other.

I have written a bit of elisp to help dealing with this by defining multiple compilation commands (in the sense of M-x), each associated with its own buffer and shell command.

Here is the relevant code: https://gist.github.com/ffevotte/6130884

With this configuration, I define 4 compilation commands, which I bind to the <F5>-<F8> keys, and I often use a workflow similar to the following:

  • <f5> (or M-x compile5): associated to make -k
  • <f6> (or M-x compile6): associated to make -k test
  • <f7> (or M-x compile7): associated to doxygen

every time I restart emacs, I have to retype the compilation command

This is something I don't do much (restarting Emacs). However, take a look at the compile-command variable. From the documentation (C-h v compile-command):

Last shell command used to do a compilation; default for next compilation.

Sometimes it is useful for files to supply local values for this variable.

(but please also read the warning about using this as a file-local variable.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .