You can also tell Emacs to revert buffers automatically when their
visited files change on disk; @pxref{Auto Revert}.
+@vindex major-mode-remap-alist@r{, and reverting a buffer}
+ Note that reverting a buffer turns on the major mode appropriate for
+visiting the buffer's file, as described in @ref{Choosing Modes}. Thus,
+the major mode actually turned on as result of reverting a buffer
+depends on mode remapping, and could be different from the original mode
+if you customized @code{major-mode-remap-alist} in-between.
+
@node Auto Revert
@section Auto Revert: Keeping buffers automatically up-to-date
@cindex Global Auto Revert mode
files, HTML/XML/SGML files, PostScript files, and Unix style Conf
files.
+@cindex remapping of major modes
+@cindex major modes, remapping
@vindex major-mode-remap-alist
Once a major mode is found, Emacs does a final check to see if the
-mode has been remapped by @code{major-mode-remap-alist}, in which case
-it uses the remapped mode instead. This is used when several
+mode has been @dfn{remapped} by @code{major-mode-remap-alist}, in which
+case it uses the remapped mode instead. This is used when several
different major modes can be used for the same file type, so you can
-specify which mode you prefer.
+specify which mode you prefer. Note that this remapping affects the
+major mode found by all of the methods described above, so, for example,
+the mode specified by the first line of the file will not necessarily be
+the mode actually turned on in the buffer visiting the file. (This
+remapping also affects @code{revert-buffer}, @pxref{Reverting}.) When
+several modes are available for the same file type, you can tell Emacs
+about your major-mode preferences by customizing
+@code{major-mode-remap-alist}. For example, put this in your
+@file{~/.emacs} init file (@pxref{Init File})
+
+@lisp
+ (add-to-list 'major-mode-remap-alist '(c-mode . c-ts-mode))
+@end lisp
+
+@noindent
+to force Emacs to invoke @code{c-ts-mode} when @code{c-mode} is
+specified by @code{auto-mode-alist} or by file-local variables.
+Conversely,
+
+@lisp
+ (add-to-list 'major-mode-remap-alist '(c-mode))
+@end lisp
+
+@noindent
+will force Emacs to never remap @code{c-mode} to any other mode.
+
+ The default value of @code{major-mode-remap-alist} is @code{nil}, so
+no remapping takes place. However, loading some Lisp packages or
+features might introduce mode remapping, because Emacs assumes that
+loading those means the user prefers using an alternative mode. So for
+predictable behavior, we recommend that you always customize
+@code{major-mode-remap-alist} to express your firm preferences, because
+this variable overrides any remapping that Emacs might decide to perform
+internally.
@findex normal-mode
If you have changed the major mode of a buffer, you can return to
line and file-local variables list (if any). @xref{File Variables}.
If the buffer doesn't visit a file, the command processes only the
major mode specification, if any, in the @samp{-*-} line and in the
-file-local variables list.
+file-local variables list. @kbd{M-x normal-mode} takes the mode
+remapping into consideration, so if you customized
+@code{major-mode-remap-alist} after the buffer's major mode was chosen
+by Emacs, @code{normal-mode} could turn on a mode that is different from
+the one Emacs chose originally.
@vindex change-major-mode-with-file-name
The commands @kbd{C-x C-w} and @code{set-visited-file-name} change to