Function: TeX-mode

TeX-mode is a byte-compiled function defined in tex.el.

Signature

(TeX-mode)

Documentation

Base mode for AUCTeX major modes except Texinfo mode.

Not intended for direct use for user.

In addition to any hooks its parent mode text-mode might have run, this mode runs the hook TeX-mode-hook, as the final or penultimate step during initialization.

" TeX-insert-quote
$ TeX-insert-dollar
C-M-i TeX-complete-symbol
C-c " TeX-uncomment
C-c # TeX-normal-mode
C-c % TeX-comment-or-uncomment-paragraph
C-c ' TeX-comment-or-uncomment-paragraph
C-c : comment-or-uncomment-region
C-c ; comment-or-uncomment-region
C-c ? TeX-documentation-texdoc
C-c C-a TeX-command-run-all
C-c C-b TeX-command-buffer(var)/TeX-command-buffer(fun)
C-c C-c TeX-command-master
C-c C-d TeX-save-document
C-c C-f TeX-font
C-c C-k TeX-kill-job
C-c C-l TeX-recenter-output-buffer
C-c C-n TeX-normal-mode
C-c C-o C-f TeX-fold-mode(var)/TeX-fold-mode(fun)
C-c C-r TeX-command-region
C-c C-t C-b TeX-toggle-debug-bad-boxes
C-c C-t C-p TeX-PDF-mode(var)/TeX-PDF-mode(fun)
C-c C-t C-r TeX-pin-region
C-c C-t C-s TeX-source-correlate-mode(var)/TeX-source-correlate-mode(fun)
C-c C-t C-w TeX-toggle-debug-warnings
C-c C-t C-x TeX-toggle-suppress-ignored-warnings
C-c C-t TAB TeX-interactive-mode(var)/TeX-interactive-mode(fun)
C-c C-v TeX-view
C-c C-w TeX-toggle-debug-bad-boxes
C-c RET TeX-insert-macro
C-c TAB TeX-goto-info-page
C-c ^ TeX-home-buffer
C-c _ TeX-master-file-ask
C-c ` TeX-next-error
C-c { TeX-insert-braces(var)/TeX-insert-braces(fun)
C-c } up-list
C-x ` TeX-next-error
C-x n g TeX-narrow-to-group
M-g p TeX-previous-error
RET TeX-newline
\ TeX-insert-backslash
^ TeX-insert-sub-or-superscript
_ TeX-insert-sub-or-superscript

Probably introduced at or before Emacs version 18.45.

Source Code

;; Defined in ~/.emacs.d/elpa/auctex-14.1.2/tex.el
;; Delete alias predefined in tex-mode.el.
;;;###autoload (if (eq (symbol-function 'TeX-mode) 'tex-mode)
;;;###autoload     (defalias 'TeX-mode nil))
(define-derived-mode TeX-mode text-mode "TeX"
  "Base mode for AUCTeX major modes except Texinfo mode.

Not intended for direct use for user."
  :abbrev-table nil
  :after-hook (TeX-mode-cleanup)
  :interactive nil

  (setq TeX-mode-p t)
  (setq TeX-output-extension (if TeX-PDF-mode "pdf" "dvi"))
  (setq indent-tabs-mode nil)

  ;; Ispell support
  (setq-local ispell-parser 'tex)

  ;; Redefine some standard variables
  (make-local-variable 'paragraph-start)
  (make-local-variable 'paragraph-separate)
  (setq-local comment-start "%")
  (setq-local comment-start-skip
              (concat "\\(\\(^\\|[^\\\n]\\)\\("
                      (regexp-quote TeX-esc)
                      (regexp-quote TeX-esc)
                      "\\)*\\)\\(%+[ \t]*\\)"))
  (setq-local comment-end-skip "[ \t]*\\(\\s>\\|\n\\)")
  (setq-local comment-use-syntax t)
  (setq-local comment-padding " ")
  ;; Removed as commenting in (La)TeX is done with one `%' not two
  ;; (make-local-variable 'comment-add)
  ;; (setq comment-add 1) ;default to `%%' in comment-region
  (setq-local comment-indent-function #'TeX-comment-indent)
  (setq-local comment-multi-line nil)
  (make-local-variable 'compile-command)
  (unless (boundp 'compile-command)
    (setq compile-command "make"))
  (setq-local words-include-escapes nil)

  ;; Make TAB stand out
  ;;  (make-local-variable 'buffer-display-table)
  ;;  (setq buffer-display-table (if standard-display-table
  ;;                             (copy-sequence standard-display-table)
  ;;                           (make-display-table)))
  ;;  (aset buffer-display-table ?\t (apply 'vector (append "<TAB>" nil)))

  (funcall TeX-install-font-lock)

  ;; We want this to be early in the list, so we do not add it before
  ;; we enter TeX mode the first time.
  (add-hook 'write-contents-functions #'TeX-safe-auto-write nil t)

  ;; Minor modes
  (when TeX-source-correlate-mode
    (TeX-source-correlate-mode 1))

  ;; Prettify Symbols mode
  (require 'tex-mode)
  (setq-local prettify-symbols-alist tex--prettify-symbols-alist)
  (add-function :override (local 'prettify-symbols-compose-predicate)
                #'TeX--prettify-symbols-compose-p)

  ;; Standard Emacs completion-at-point support
  (add-hook 'completion-at-point-functions
            #'TeX--completion-at-point nil t)

  ;; Let `TeX-master-file' be called after a new file was opened and
  ;; call `TeX-update-style' on any file opened.  (The addition to the
  ;; hook has to be made here because its local value will be deleted
  ;; by `kill-all-local-variables' if it is added e.g. in `tex-mode'.)
  ;;
  ;; `TeX-update-style' has to be called before
  ;; `global-font-lock-mode', which may also be specified in
  ;; `find-file-hook', gets called.  Otherwise style-based
  ;; fontification will break (in XEmacs).  That means, `add-hook'
  ;; cannot be called with a non-nil value of the APPEND argument.
  ;;
  ;; `(TeX-master-file nil nil t)' has to be called *before*
  ;; `TeX-update-style' as the latter will call `TeX-master-file'
  ;; without the `ask' bit set.
  (add-hook 'find-file-hook
            (lambda ()
              ;; Check if we are looking at a new or shared file.
              (when (or (not (file-exists-p (TeX-buffer-file-name)))
                        (eq TeX-master 'shared))
                (TeX-master-file nil nil t))
              (TeX-update-style t)) nil t))