diff options
| author | Karl Heuer <kwzh@gnu.org> | 1995-12-15 21:11:52 +0000 |
|---|---|---|
| committer | Karl Heuer <kwzh@gnu.org> | 1995-12-15 21:11:52 +0000 |
| commit | 1540e4e9cc1ca84acba6e3aaf848e50c0f0156c7 (patch) | |
| tree | 18a180b3dcecd39b9c1f636ee6ec317525b47557 /lisp/files.el | |
| parent | 1bdabbcd2581b028662fc49ef6e101475d34d686 (diff) | |
| download | emacs-1540e4e9cc1ca84acba6e3aaf848e50c0f0156c7.tar.gz | |
(set-auto-mode): Recognize `#!/bin/env INTERPRETER' hack.
Diffstat (limited to 'lisp/files.el')
| -rw-r--r-- | lisp/files.el | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/lisp/files.el b/lisp/files.el index 0f8f69c6bc4..11ed8883cb3 100644 --- a/lisp/files.el +++ b/lisp/files.el @@ -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 (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. |
