If you have changed the major mode of a buffer, you can return to
the major mode Emacs would have chosen automatically, by typing
@kbd{M-x normal-mode}. This is the same function that
-@code{find-file} calls to choose the major mode. It also processes
-the file's @samp{-*-} line or local variables list (if any).
-@xref{File Variables}.
+@code{find-file} calls to choose the major mode. If the buffer is
+visiting a file, this command also processes the file's @samp{-*-}
+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.
@vindex change-major-mode-with-file-name
The commands @kbd{C-x C-w} and @code{set-visited-file-name} change to
`enable-local-variables' is ignored if you run `normal-mode' interactively,
or from Lisp without specifying the optional argument FIND-FILE;
-in that case, this function acts as if `enable-local-variables' were t."
+in that case, this function acts as if `enable-local-variables' were t.
+
+If invoked in a buffer that doesn't visit a file, this function
+processes only the major mode specification in the -*- line and
+the local variables spec."
(interactive)
(kill-all-local-variables)
(unless delay-mode-hooks
Uses `hack-local-variables-apply' to apply the variables.
-See `hack-local-variables--find-variables' for the meaning of
-HANDLE-MODE.
-
If `enable-local-variables' or `local-enable-local-variables' is
nil, or INHIBIT-LOCALS is non-nil, this function disregards all
normal local variables. If `inhibit-local-variables-regexps'
Variables present in `permanently-enabled-local-variables' will
still be evaluated, even if local variables are otherwise
-inhibited."
+inhibited.
+
+If HANDLE-MODE is t, the function only checks whether a \"mode:\"
+is specified, and returns the corresponding mode symbol, or nil.
+In this case, try to ignore minor-modes, and return only a major-mode.
+If HANDLE-MODE is nil, the function gathers all the specified local
+variables. If HANDLE-MODE is neither nil nor t, the functions gathers
+all the specified local variables, but ignores any settings of \"mode:\"."
;; We don't let inhibit-local-variables-p influence the value of
;; enable-local-variables, because then it would affect dir-local
;; variables. We don't want to search eg tar files for file local
just adds the HOOKS to the list `delayed-mode-hooks'.
Otherwise, runs hooks in the sequence: `change-major-mode-after-body-hook',
`delayed-mode-hooks' (in reverse order), HOOKS, then runs
-`hack-local-variables', runs the hook `after-change-major-mode-hook', and
-finally evaluates the functions in `delayed-after-hook-functions' (see
+`hack-local-variables' (if the buffer is visiting a file),
+runs the hook `after-change-major-mode-hook', and finally
+evaluates the functions in `delayed-after-hook-functions' (see
`define-derived-mode').
Major mode functions should use this instead of `run-hooks' when