ambevar-dotfiles/.emacs.d/mode-shell.el

33 lines
927 B
EmacsLisp
Raw Normal View History

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)
(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)