Created
April 8, 2013 17:30
-
-
Save ruediger/5338669 to your computer and use it in GitHub Desktop.
compile buffer stuff
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
;; Compile-Buffer | |
(setq compilation-scroll-output 'first-error) | |
(defmacro my-compile-command (compiler flags) | |
"Create mode hook to generate `compile-command'." | |
`(lambda () | |
(flyspell-prog-mode) | |
(unless (or (file-exists-p "Makefile") | |
(local-variable-p 'compile-command) | |
(not buffer-file-name)) | |
(set (make-local-variable 'compile-command) | |
(format "%s %s %s" | |
,compiler ,flags | |
(file-name-nondirectory buffer-file-name)))))) | |
(add-hook 'c-mode-hook (my-compile-command | |
(or (getenv "CC") "gcc") | |
(or (getenv "CFLAGS") | |
"-pipe -std=c11 -pedantic-errors -Wall -Wextra -g3"))) | |
(add-hook 'c++-mode-hook (my-compile-command | |
(or (getenv "CXX") "g++") | |
(or (getenv "CXXFLAGS") | |
"-pipe -std=c++11 -pedantic-errors -Wall -Wextra -Weffc++ -g3"))) | |
(add-hook 'fortran-mode-hook (my-compile-command | |
(or (getenv "FORTRANC") "gfortran") | |
(or (getenv "FORTRANFLAGS") | |
"-pipe -pedantic-errors -Wall -Wextra -g3"))) | |
(global-set-key '[f9] 'compile) | |
(global-set-key '[f8] '(lambda () | |
(interactive) | |
(when (file-exists-p "Makefile") | |
(let ((tmp compile-command)) | |
(compile "make clean") | |
(setq compile-command tmp))))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment