# HG changeset patch # User Karl Heuer # Date 819061912 0 # Node ID 3902b2781a8f2c2feaf06984689f9435d56b160f # Parent 4e7c5362c9bd5bf37bb3818257fd85d60c0785a5 (set-auto-mode): Recognize `#!/bin/env INTERPRETER' hack. diff -r 4e7c5362c9bd -r 3902b2781a8f lisp/files.el --- 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.