]> code.delx.au - gnu-emacs/blobdiff - man/major.texi
Version 3.09
[gnu-emacs] / man / major.texi
index fa44b87303167dd1f15d357894babb23b53331ac..23e0f8e116f77b4d62b648e8d817dd1fe99df6cf 100644 (file)
@@ -98,6 +98,21 @@ the element has the form @code{(@var{regexp} @var{mode-function}
 @var{mode-function}, Emacs discards the suffix that matched
 @var{regexp} and searches the list again for another match.
 
+@vindex magic-mode-alist
+  Sometimes the major mode is determined from the way the file's text
+begins.  The variable @code{magic-mode-alist} controls this.  Its value
+is a list of elements of this form:
+
+@example
+(@var{regexp} . @var{mode-function})
+@end example
+
+@noindent
+This looks like an element of @code{auto-mode-alist}, but it doesn't work
+the same: this @var{regexp} is matched against the text at the start
+of the buffer, not against the file name.  @code{magic-mode-alist}
+takes priority over @code{auto-mode-alist}.
+
   You can specify the major mode to use for editing a certain file by
 special text in the first nonblank line of the file.  The
 mode name should appear in this line both preceded and followed by
@@ -161,7 +176,8 @@ mode is taken from the previously current buffer.
 mode Emacs would choose automatically: use the command @kbd{M-x
 normal-mode} to do this.  This is the same function that
 @code{find-file} calls to choose the major mode.  It also processes
-the file's local variables list (if any).
+the file's @samp{-*-} line or local variables list (if any).
+@xref{File Variables}.
 
 @vindex change-major-mode-with-file-name
   The commands @kbd{C-x C-w} and @code{set-visited-file-name} change to