Variable: auto-mode-interpreter-regexp

auto-mode-interpreter-regexp is a variable defined in files.el.gz.

Value

"#![    ]*\\([^         \n]*/bin/env[   ]*\\(?:\\(?:-[0a-z]*S[  ]*\\|--split-string=\\)\\(?:-[^         \n]+[   ]+\\)*\\(?:[^   \n]+=[^         \n]*[   ]+\\)*\\)?\\)?\\([^     \n]+\\)"

Documentation

Regexp matching interpreters, for file mode determination.

This regular expression is matched against the first line of a file to determine the file's mode in set-auto-mode. If it matches, the file is assumed to be interpreted by the interpreter matched by the second group of the regular expression. The mode is then determined as the mode associated with that interpreter in interpreter-mode-alist.

Probably introduced at or before Emacs version 21.1.

Source Code

;; Defined in /usr/src/emacs/lisp/files.el.gz
(defvar auto-mode-interpreter-regexp
  (purecopy
   (concat
    "#![ \t]*"
    ;; Optional group 1: env(1) invocation.
    "\\("
    "[^ \t\n]*/bin/env[ \t]*"
    ;; Within group 1: possible -S/--split-string and environment
    ;; adjustments.
    "\\(?:"
    ;; -S/--split-string
    "\\(?:-[0a-z]*S[ \t]*\\|--split-string=\\)"
    ;; More env arguments.
    "\\(?:-[^ \t\n]+[ \t]+\\)*"
    ;; Interpreter environment modifications.
    "\\(?:[^ \t\n]+=[^ \t\n]*[ \t]+\\)*"
    "\\)?"
    "\\)?"
    ;; Group 2: interpreter.
    "\\([^ \t\n]+\\)"))
  "Regexp matching interpreters, for file mode determination.
This regular expression is matched against the first line of a file
to determine the file's mode in `set-auto-mode'.  If it matches, the file
is assumed to be interpreted by the interpreter matched by the second group
of the regular expression.  The mode is then determined as the mode
associated with that interpreter in `interpreter-mode-alist'.")