Mercurial > emacs
diff lisp/files.el @ 13737:3902b2781a8f
(set-auto-mode): Recognize `#!/bin/env INTERPRETER' hack.
author | Karl Heuer <kwzh@gnu.org> |
---|---|
date | Fri, 15 Dec 1995 21:11:52 +0000 |
parents | 40766c32c127 |
children | 16b681bc9286 |
line wrap: on
line diff
--- a/lisp/files.el Fri Dec 15 15:43:33 1995 +0000 +++ b/lisp/files.el Fri Dec 15 21:11:52 1995 +0000 @@ -1108,12 +1108,14 @@ (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 (save-excursion (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)) ""))) elt) ;; Map interpreter name to a mode.