Emacs: fixed sh and python interpreter when first line is empty
parent
e475d727a9
commit
2f08282b8a
|
@ -10,7 +10,9 @@ checked, and if no shabang is present, `python' will be used."
|
||||||
(defun python-version ()
|
(defun python-version ()
|
||||||
"Returns whether we're running Python 2 or 3 according to the
|
"Returns whether we're running Python 2 or 3 according to the
|
||||||
shebang. System `python' is assumed by default."
|
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))
|
(if (not (string-match "^#!" firstline))
|
||||||
"python"
|
"python"
|
||||||
(cond
|
(cond
|
||||||
|
|
|
@ -13,7 +13,9 @@ otherwise use 'sh-shell-file'."
|
||||||
"Use compile to run python programs."
|
"Use compile to run python programs."
|
||||||
(interactive)
|
(interactive)
|
||||||
(hack-local-variables)
|
(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
|
(let ((sh-interpreter
|
||||||
(if (not (string-match "^#!" firstline))
|
(if (not (string-match "^#!" firstline))
|
||||||
sh-shell-file
|
sh-shell-file
|
||||||
|
|
Loading…
Reference in New Issue