Commit 1540e4e9 authored by Karl Heuer's avatar Karl Heuer
Browse files

(set-auto-mode): Recognize `#!/bin/env INTERPRETER' hack.

parent 1bdabbcd
......@@ -1108,12 +1108,14 @@ If `enable-local-variables' is nil, this function does not check for a
(funcall mode)
;; If we can't deduce a mode from the file name,
;; look for an interpreter specified in the first line.
;; As a special case, allow for things like "#!/bin/env perl",
;; which finds the interpreter anywhere in $PATH.
(let ((interpreter
(goto-char (point-min))
(if (looking-at "#! *\\([^ \t\n]+\\)")
(buffer-substring (match-beginning 1)
(match-end 1))
(if (looking-at "#! *\\([^ \t\n]*/bin/env +\\)?\\([^ \t\n]+\\)")
(buffer-substring (match-beginning 2)
(match-end 2))
;; Map interpreter name to a mode.
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment