diff options
| author | Gerd Moellmann | 2000-08-08 18:32:10 +0000 |
|---|---|---|
| committer | Gerd Moellmann | 2000-08-08 18:32:10 +0000 |
| commit | 0720b68be2573f018c87fba04b28a01a8e112700 (patch) | |
| tree | 35ef96858c9a141eefb0778a572df7bdcd099c4c | |
| parent | 18aac618faea129e729838e837619f0f2f3d3530 (diff) | |
| download | emacs-0720b68be2573f018c87fba04b28a01a8e112700.tar.gz emacs-0720b68be2573f018c87fba04b28a01a8e112700.zip | |
(auto-mode-interpreter-regexp): New variable.
(set-auto-mode): Use it.
| -rw-r--r-- | lisp/files.el | 14 |
1 files changed, 12 insertions, 2 deletions
diff --git a/lisp/files.el b/lisp/files.el index b86b8d64004..1a7ddb872cf 100644 --- a/lisp/files.el +++ b/lisp/files.el | |||
| @@ -1513,6 +1513,17 @@ If it matches, mode MODE is selected.") | |||
| 1513 | When checking `inhibit-first-line-modes-regexps', we first discard | 1513 | When checking `inhibit-first-line-modes-regexps', we first discard |
| 1514 | from the end of the file name anything that matches one of these regexps.") | 1514 | from the end of the file name anything that matches one of these regexps.") |
| 1515 | 1515 | ||
| 1516 | (defvar auto-mode-interpreter-regexp | ||
| 1517 | "#![ \t]?\\([^ \t\n]*\ | ||
| 1518 | /bin/env[ \t]\\)?\\([^ \t\n]+\\)" | ||
| 1519 | "Regular expression matching interpreters, for file mode determination. | ||
| 1520 | This regular expression is matched against the first line of a file | ||
| 1521 | to determine the file's mode in `set-auto-mode' when Emacs can't deduce | ||
| 1522 | a mode from the file's name. If it matches, the file is assumed to | ||
| 1523 | be interpreted by the interpreter matched by the second group of the | ||
| 1524 | regular expression. The mode is then determined as the mode associated | ||
| 1525 | with that interpreter in `interpreter-mode-alist'.") | ||
| 1526 | |||
| 1516 | (defun set-auto-mode (&optional just-from-file-name) | 1527 | (defun set-auto-mode (&optional just-from-file-name) |
| 1517 | "Select major mode appropriate for current buffer. | 1528 | "Select major mode appropriate for current buffer. |
| 1518 | This checks for a -*- mode tag in the buffer's text, | 1529 | This checks for a -*- mode tag in the buffer's text, |
| @@ -1634,8 +1645,7 @@ and we don't even do that unless it would come from the file name." | |||
| 1634 | (let ((interpreter | 1645 | (let ((interpreter |
| 1635 | (save-excursion | 1646 | (save-excursion |
| 1636 | (goto-char (point-min)) | 1647 | (goto-char (point-min)) |
| 1637 | (if (looking-at "#![ \t]?\\([^ \t\n]*\ | 1648 | (if (looking-at auto-mode-interpreter-regexp) |
| 1638 | /bin/env[ \t]\\)?\\([^ \t\n]+\\)") | ||
| 1639 | (match-string 2) | 1649 | (match-string 2) |
| 1640 | ""))) | 1650 | ""))) |
| 1641 | elt) | 1651 | elt) |