From 2f08282b8a26e0bca51ba6ea51b27be5f02edbd5 Mon Sep 17 00:00:00 2001 From: Pierre Neidhardt Date: Wed, 12 Feb 2014 16:15:13 +0100 Subject: [PATCH] Emacs: fixed sh and python interpreter when first line is empty --- .emacs.d/mode-python.el | 4 +++- .emacs.d/mode-shell.el | 4 +++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/.emacs.d/mode-python.el b/.emacs.d/mode-python.el index 884ac3bf..c0b9f216 100644 --- a/.emacs.d/mode-python.el +++ b/.emacs.d/mode-python.el @@ -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 diff --git a/.emacs.d/mode-shell.el b/.emacs.d/mode-shell.el index f11bdaaa..e5179f47 100644 --- a/.emacs.d/mode-shell.el +++ b/.emacs.d/mode-shell.el @@ -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