2013-10-07 20:01:45 +02:00
|
|
|
;;==============================================================================
|
|
|
|
;; Shell
|
|
|
|
;;==============================================================================
|
|
|
|
|
|
|
|
;; Allow comment indentation.
|
|
|
|
(setq sh-indent-comment t)
|
|
|
|
|
|
|
|
(setq sh-shell-file "/bin/sh")
|
|
|
|
|
|
|
|
(defun shell-set-interpreter ()
|
|
|
|
"If a shabang is present, use it as the shell interpreter,
|
|
|
|
otherwise use 'sh-shell-file'."
|
|
|
|
"Use compile to run python programs."
|
|
|
|
(interactive)
|
|
|
|
(hack-local-variables)
|
2014-02-12 16:15:13 +01:00
|
|
|
(let ((firstline
|
|
|
|
(car
|
|
|
|
(split-string (buffer-substring-no-properties 1 (point-max)) "\n"))))
|
2013-10-07 20:01:45 +02:00
|
|
|
(let ((sh-interpreter
|
|
|
|
(if (not (string-match "^#!" firstline))
|
|
|
|
sh-shell-file
|
|
|
|
(substring firstline 2))))
|
|
|
|
|
|
|
|
(set (make-local-variable 'compile-command)
|
|
|
|
(concat sh-interpreter " " buffer-file-name)))))
|
|
|
|
|
|
|
|
(add-hook
|
|
|
|
'sh-mode-hook
|
|
|
|
(lambda ()
|
|
|
|
(shell-set-interpreter)))
|
2014-02-12 17:48:29 +01:00
|
|
|
|
|
|
|
(provide 'mode-shell)
|