Emacs: Make 'compile-command' buffer local globally
parent
510b229ee7
commit
801ed23820
|
@ -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-<f10>") '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
|
||||
|
|
|
@ -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)))
|
||||
|
|
|
@ -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 ."
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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,
|
||||
|
|
Loading…
Reference in New Issue