Mercurial > emacs
changeset 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 | 4e7c5362c9bd |
children | 2727d8b0758d |
files | lisp/files.el |
diffstat | 1 files changed, 5 insertions(+), 3 deletions(-) [+] |
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.