Emacs: fixed sh and python interpreter when first line is empty

master
Pierre Neidhardt 2014-02-12 16:15:13 +01:00
parent e475d727a9
commit 2f08282b8a
2 changed files with 6 additions and 2 deletions

View File

@ -10,7 +10,9 @@ checked, and if no shabang is present, `python' will be used."
(defun python-version ()
"Returns whether we're running Python 2 or 3 according to the
shebang. System `python' is assumed by default."
(let ((firstline (car (split-string (buffer-string) "\n" t))))
(let ((firstline
(car
(split-string (buffer-substring-no-properties 1 (point-max)) "\n"))))
(if (not (string-match "^#!" firstline))
"python"
(cond

View File

@ -13,7 +13,9 @@ otherwise use 'sh-shell-file'."
"Use compile to run python programs."
(interactive)
(hack-local-variables)
(let ((firstline (car (split-string (buffer-string) "\n" t))))
(let ((firstline
(car
(split-string (buffer-substring-no-properties 1 (point-max)) "\n"))))
(let ((sh-interpreter
(if (not (string-match "^#!" firstline))
sh-shell-file