Emacs: Fix compilation escaping and default folder

master
Pierre Neidhardt 2015-04-19 13:25:29 +02:00
parent eff7e306db
commit 6101531bcb
9 changed files with 14 additions and 13 deletions

View File

@ -67,6 +67,7 @@ If RUNHOOKS is non-nil (or with universal argument), run hooks in
`compilation-after-hook'."
(interactive "P")
(when (or runhooks (string= compile-command "make -k ")) (run-hooks 'compilation-before-hook))
(setq-default compilation-directory default-directory)
(recompile)
(when compilation-time-before-hide-window
(sit-for compilation-time-before-hide-window)

View File

@ -10,7 +10,7 @@
(local-set-key (kbd "C-c C-i") 'awk-if)
(local-set-key (kbd "C-c (") 'awk-function)
(local-set-key (kbd "C-c C-p") 'awk-printf)
(set (make-local-variable 'compile-command) (concat "awk " buffer-file-name))))
(set (make-local-variable 'compile-command) (concat "awk " (shell-quote-argument buffer-file-name)))))
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

View File

@ -25,17 +25,17 @@ provided.\n Requires `get-closest-pathname'."
(let ((makefile (get-closest-pathname)))
(if (and makefile
(not nomakefile))
(set (make-local-variable 'compile-command) (format "make -k -C %s" (file-name-directory makefile)))
(set (make-local-variable 'compile-command) (concat "make -k -C " (shell-quote-argument (file-name-directory makefile))))
(set (make-local-variable 'compile-command)
(let
((c++-p (eq major-mode 'c++-mode))
(file (file-name-nondirectory buffer-file-name)))
(format "%s %s -o %s %s %s %s"
(format "%s %s -o '%s' %s %s %s"
(if c++-p
(or (getenv "CXX") "g++")
(or (getenv "CC") "gcc"))
file
(file-name-sans-extension file)
(shell-quote-argument file)
(shell-quote-argument (file-name-sans-extension file))
(if c++-p
(or (getenv "CPPFLAGS") "-Wall -Wextra -Wshadow -DDEBUG=9 -g3 -O0")
(or (getenv "CFLAGS") "-ansi -pedantic -std=c99 -Wall -Wextra -Wshadow -DDEBUG=9 -g3 -O0"))

View File

@ -7,7 +7,7 @@
(lambda ()
(add-hook 'before-save-hook #'gofmt-before-save nil t)
(local-set-key (kbd "C-c m") 'go-main)
(set (make-local-variable 'compile-command) (concat "go run " buffer-file-name))))
(set (make-local-variable 'compile-command) (concat "go run " (shell-quote-argument buffer-file-name)))))
(define-skeleton go-main
"Insert main function with basic includes."

View File

@ -7,6 +7,6 @@
(add-hook-and-eval
'lua-mode-hook
(lambda ()
(set (make-local-variable 'compile-command) (format "lua '%s'" buffer-file-name))))
(set (make-local-variable 'compile-command) (concat "lua " (shell-quote-argument buffer-file-name)))))
(provide 'mode-lua)

View File

@ -7,6 +7,6 @@
(add-hook-and-eval
'perl-mode-hook
(lambda ()
(set (make-local-variable 'compile-command) (concat "perl " buffer-file-name))))
(set (make-local-variable 'compile-command) (concat "perl " (shell-quote-argument buffer-file-name)))))
(provide 'mode-perl)

View File

@ -19,7 +19,7 @@
"Use compile to run python programs."
(interactive)
(set (make-local-variable 'compile-command)
(concat (python-version) " " buffer-file-name)))
(concat (python-version) " " (shell-quote-argument buffer-file-name))))
(add-hook-and-eval
'python-mode-hook

View File

@ -46,7 +46,7 @@ The advantages of this function over the vanilla code are:
; (setq sh-shell-file (executable-find (symbol-name sh-shell)))
;; Convenient version.
(setq sh-shell-file (concat "/bin/" (symbol-name sh-shell)))
(set (make-local-variable 'compile-command) (concat sh-shell-file " " buffer-file-name)))
(set (make-local-variable 'compile-command) (concat sh-shell-file " " (shell-quote-argument buffer-file-name))))
;; sh-set-shell partly resets some of the font-lock config. We use this
;; workaround to restore it.

View File

@ -50,11 +50,11 @@
(idxfile ))
(set (make-local-variable 'compile-command)
(concat
"cd " (if dirname dirname ".") " && "
"cd " (if dirname (shell-quote-argument dirname) ".") " && "
(when (executable-find tex-index-command)
(concat tex-index-command " " (concat basename ".idx" ) " ; "))
(concat tex-index-command " " (shell-quote-argument (concat basename ".idx")) " ; "))
(when (executable-find tex-bibtex-command)
(concat tex-bibtex-command " " basename " ; "))
(concat tex-bibtex-command " " (shell-quote-argument basename) " ; "))
tex-command
" " tex-start-options
" " tex-start-commands