有shebang的无扩展名文件打开就是sh-mode,但是magic-mode-alist里没有?

我有一个开头是#!/bin/bash的文件,没有扩展名,打开就是sh-mode,但是我的magic-mode-alist里面并没有相关配置,为什么能做到打开就是sh-mode?

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

Value
"#![ 	]?\\([^ 	\n]*/bin/env[ 	]\\)?\\([^ 	\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.

Shebang的自动设置major mode是另一套系统,不归magic-mode-alist管理

3 个赞