Variable: change-major-mode-with-file-name

change-major-mode-with-file-name is a customizable variable defined in files.el.gz.

Value

t

Documentation

Non-nil means C-x C-w (write-file) should set the major mode from the file name.

However, the mode will not be changed if
(1) a local variables list or the -*- line specifies a major mode, or
(2) the current major mode is a "special" mode,
    not suitable for ordinary files, or
(3) the new file name does not particularly specify any mode.

View in manual

Probably introduced at or before Emacs version 20.1.

Source Code

;; Defined in /usr/src/emacs/lisp/files.el.gz
(defcustom change-major-mode-with-file-name t
  "Non-nil means \\[write-file] should set the major mode from the file name.
However, the mode will not be changed if
\(1) a local variables list or the `-*-' line specifies a major mode, or
\(2) the current major mode is a \"special\" mode,
    not suitable for ordinary files, or
\(3) the new file name does not particularly specify any mode."
  :type 'boolean
  :group 'editing-basics)