Function: TeX-tex-mode
TeX-tex-mode is an autoloaded, interactive and byte-compiled function
defined in tex.el.
Signature
(TeX-tex-mode)
Documentation
Call suitable AUCTeX major mode for editing TeX or LaTeX files.
Tries to guess whether this file is for plain TeX or LaTeX.
The algorithm is as follows:
1) If the file is empty or TeX-force-default-mode is not set to nil,
TeX-default-mode is chosen.
2) If non-commented out content matches with regular expression in
TeX-format-list, use the associated major mode. For example,
if \documentclass or \begin{, \section{, \part{ or \chapter{ is
found, LaTeX-mode is selected.
3) Otherwise, use TeX-default-mode.
By default, TeX-format-list has a fallback entry for
plain-TeX-mode, thus non-empty file which didn't match any
other entries will enter plain-TeX-mode.
Key Bindings
Source Code
;; Defined in ~/.emacs.d/elpa/auctex-14.1.2/tex.el
;;;###autoload
(defun TeX-tex-mode ()
"Call suitable AUCTeX major mode for editing TeX or LaTeX files.
Tries to guess whether this file is for plain TeX or LaTeX.
The algorithm is as follows:
1) If the file is empty or `TeX-force-default-mode' is not set to nil,
`TeX-default-mode' is chosen.
2) If non-commented out content matches with regular expression in
`TeX-format-list', use the associated major mode. For example,
if \\documentclass or \\begin{, \\section{, \\part{ or \\chapter{ is
found, `LaTeX-mode' is selected.
3) Otherwise, use `TeX-default-mode'.
By default, `TeX-format-list' has a fallback entry for
`plain-TeX-mode', thus non-empty file which didn't match any
other entries will enter `plain-TeX-mode'."
;; This is a dispatch function meaningful only as target of
;; `auto-mode-alist' and `major-mode-remap-alist'. Hence we don't
;; use `define-derived-mode'. Note that it isn't a proper major
;; mode and it actually makes little sense to specify this for
;; "mode:" tag of file local variable.
(interactive)
(funcall (if (or (equal (buffer-size) 0)
TeX-force-default-mode)
TeX-default-mode
(save-excursion
(goto-char (point-min))
(let ((comment-start-skip ;Used by TeX-in-comment
(concat
"\\(\\(^\\|[^\\\n]\\)\\("
(regexp-quote TeX-esc)
(regexp-quote TeX-esc)
"\\)*\\)\\(%+ *\\)"))
(entry TeX-format-list)
answer case-fold-search)
(while (and entry (not answer))
(if (re-search-forward (nth 2 (car entry))
10000 t)
(if (not (TeX-in-comment))
(setq answer (nth 1 (car entry))))
(setq entry (cdr entry))))
(if answer
answer
TeX-default-mode))))))