diff --git a/.emacs.d/lisp/main.el b/.emacs.d/lisp/main.el index 2e7859ed..12b98616 100644 --- a/.emacs.d/lisp/main.el +++ b/.emacs.d/lisp/main.el @@ -217,6 +217,15 @@ ;; Compilation bindings and conveniences. (setq compilation-ask-about-save nil) +(eval-after-load 'compile + '(progn (make-variable-buffer-local 'compile-command) + ;; Making `compilation-directory' local only works with `recompile' + ;; and if `compile' is never used. In such a scenario, + ;; `compile-command' is not saved by `recompile' itself which adds a + ;; lot of bookkeeping. + ; (make-variable-buffer-local 'compilation-directory) + ; (make-variable-buffer-local 'compile-history) + )) ;; Don't set these bindings in mickey as we might have to override them from ;; mode hooks. (global-set-key (kbd "C-") 'compile) @@ -246,6 +255,10 @@ (unless (file-directory-p desktop-dirname) (make-directory desktop-dirname t)) (setq desktop-path `(,desktop-dirname)) + ;; TODO: `compile-history' should be buffer local but that does not work. + ;; http://user42.tuxfamily.org/compile-history-local/index.html + ;; http://stackoverflow.com/questions/22995203/one-compile-command-per-buffer-not-directory + ; (add-to-list 'desktop-locals-to-save 'compile-history) (add-to-list 'desktop-locals-to-save 'compile-command)) ;; GMP documentation diff --git a/.emacs.d/lisp/mode-cc.el b/.emacs.d/lisp/mode-cc.el index 15767dcd..9de07a07 100644 --- a/.emacs.d/lisp/mode-cc.el +++ b/.emacs.d/lisp/mode-cc.el @@ -19,8 +19,8 @@ provided.\n Requires `get-closest-pathname'." (hack-local-variables) (let ((makefile (get-closest-pathname))) (if (and makefile (not nomakefile)) - (set (make-local-variable 'compile-command) (concat "make -k -C " (shell-quote-argument (file-name-directory makefile)))) - (set (make-local-variable 'compile-command) + (setq compile-command (concat "make -k -C " (shell-quote-argument (file-name-directory makefile)))) + (setq compile-command (let ((c++-p (eq major-mode 'c++-mode)) (file (file-name-nondirectory buffer-file-name))) diff --git a/.emacs.d/lisp/mode-go.el b/.emacs.d/lisp/mode-go.el index 165e7697..bb74e030 100644 --- a/.emacs.d/lisp/mode-go.el +++ b/.emacs.d/lisp/mode-go.el @@ -38,7 +38,7 @@ Note that the -cover test flag is left out since it shifts line numbers." (interactive) - (set (make-local-variable 'compile-command) + (setq compile-command (if (go-buffer-in-gopath-p) (if (string-match "_test.[gG][oO]$" buffer-file-name) "go test -v -run ." diff --git a/.emacs.d/lisp/mode-lua.el b/.emacs.d/lisp/mode-lua.el index 8e588e7a..8408a6bc 100644 --- a/.emacs.d/lisp/mode-lua.el +++ b/.emacs.d/lisp/mode-lua.el @@ -5,6 +5,6 @@ (add-hook-and-eval 'lua-mode-hook (lambda () - (set (make-local-variable 'compile-command) (concat lua-default-application " " (shell-quote-argument buffer-file-name))))) + (setq compile-command (concat lua-default-application " " (shell-quote-argument buffer-file-name))))) (provide 'mode-lua) diff --git a/.emacs.d/lisp/mode-perl.el b/.emacs.d/lisp/mode-perl.el index 59179cfe..164741b8 100644 --- a/.emacs.d/lisp/mode-perl.el +++ b/.emacs.d/lisp/mode-perl.el @@ -5,6 +5,6 @@ (add-hook-and-eval 'perl-mode-hook (lambda () - (set (make-local-variable 'compile-command) (concat "perl " (shell-quote-argument buffer-file-name))))) + (setq compile-command (concat "perl " (shell-quote-argument buffer-file-name))))) (provide 'mode-perl) diff --git a/.emacs.d/lisp/mode-python.el b/.emacs.d/lisp/mode-python.el index c262c6b9..414bab79 100644 --- a/.emacs.d/lisp/mode-python.el +++ b/.emacs.d/lisp/mode-python.el @@ -8,7 +8,7 @@ (if (not (string-match "^#!" firstline)) python-shell-interpreter (substring firstline 2)))) - (set (make-local-variable 'compile-command) + (setq compile-command (concat interpreter " " (shell-quote-argument buffer-file-name))))) (add-hook-and-eval diff --git a/.emacs.d/lisp/mode-sh.el b/.emacs.d/lisp/mode-sh.el index 8a96c204..4090025c 100644 --- a/.emacs.d/lisp/mode-sh.el +++ b/.emacs.d/lisp/mode-sh.el @@ -47,7 +47,7 @@ The advantages of this function over the vanilla code are: ;; `buffer-file-name` seems to have a non-string type sometimes With `git ;; merge` and cause ediff to fail. Let's protect it. (when (stringp buffer-file-name) - (set (make-local-variable 'compile-command) (concat sh-shell-file " " (shell-quote-argument buffer-file-name))))) + (setq compile-command (concat sh-shell-file " " (shell-quote-argument buffer-file-name))))) (add-hook-and-eval 'sh-mode-hook diff --git a/.emacs.d/lisp/mode-tex.el b/.emacs.d/lisp/mode-tex.el index da8eda4f..1ef929ef 100644 --- a/.emacs.d/lisp/mode-tex.el +++ b/.emacs.d/lisp/mode-tex.el @@ -48,17 +48,17 @@ (basename (file-name-sans-extension (file-name-nondirectory local-master))) ;; Note: makeindex fails with absolute file names, we need relative names. (idxfile )) - (set (make-local-variable 'compile-command) - (concat - "cd " (if dirname (shell-quote-argument dirname) ".") " && " - (when (executable-find tex-index-command) - (concat tex-index-command " " (shell-quote-argument (concat basename ".idx")) "; ")) - (when (executable-find tex-bibtex-command) - (concat tex-bibtex-command " " (shell-quote-argument basename) "; ")) - tex-command - " " tex-start-options - " " tex-start-commands - " " (shell-quote-argument basename))))) + (setq compile-command + (concat + "cd " (if dirname (shell-quote-argument dirname) ".") " && " + (when (executable-find tex-index-command) + (concat tex-index-command " " (shell-quote-argument (concat basename ".idx")) "; ")) + (when (executable-find tex-bibtex-command) + (concat tex-bibtex-command " " (shell-quote-argument basename) "; ")) + tex-command + " " tex-start-options + " " tex-start-commands + " " (shell-quote-argument basename))))) (defun tex-clean () "Remove all TeX temporary files. This command should be safe,