After last week rediscovering emacs’ M-x compile, and using it almost non-stop whilst hacking on filtergen, I got frustrated each time I used a fresh emacs and had to tell it to use scons -D instead of make (I’ve bound F7 to compile, which doesn’t prompt for the invocation command).
So here’s a bit of emacs lisp for your ~/.xemacs/init.el (or .emacs if you so desire) that alters compile-command for each buffer based on the existence of build system files:
1
2
3
4
5
6
7
8
| ;; If we're in a SCons build tree, set the compile-command correctly.
;; The cond can be extended for other build system files, too.
(add-hook 'c-mode-common-hook
(lambda ()
(cond ((or (file-exists-p "SConstruct")
(file-exists-p "SConscript"))
(set (make-local-variable 'compile-command)
"scons -D")))))
|
Share and enjoy!