Function: TeX-add-local-master
TeX-add-local-master is a byte-compiled function defined in tex.el.
Signature
(TeX-add-local-master)
Documentation
Add local variable for TeX-master.
Get major-mode from master file and enable it.
Source Code
;; Defined in ~/.emacs.d/elpa/auctex-14.1.2/tex.el
(defun TeX-add-local-master ()
"Add local variable for `TeX-master'.
Get `major-mode' from master file and enable it."
(when (and (TeX-buffer-file-name)
(string-match TeX-one-master
(file-name-nondirectory (TeX-buffer-file-name)))
(not buffer-read-only))
(goto-char (point-max))
(if (re-search-backward "^\\([^\n]+\\)Local Variables:"
(- (point-max) 3000) t)
(let ((prefix (TeX-match-buffer 1)))
(re-search-forward (regexp-quote (concat prefix
"End:")))
(beginning-of-line 1)
(insert prefix "TeX-master: " (prin1-to-string TeX-master) "\n"))
(let* ((mode (if (stringp TeX-master)
(with-current-buffer
(find-file-noselect
(TeX-master-file TeX-default-extension))
major-mode)
major-mode))
(comment-prefix (cond ((eq mode 'Texinfo-mode) "@c ")
((eq mode 'docTeX-mode) "% ")
(t "%%% ")))
(mode-string (concat (and (boundp 'japanese-TeX-mode) japanese-TeX-mode
"japanese-")
(substring (symbol-name mode) 0 -5))))
(newline)
(when (eq major-mode 'docTeX-mode)
(insert comment-prefix TeX-esc "endinput\n"))
(insert
comment-prefix "Local Variables:\n"
comment-prefix "mode: " mode-string "\n"
comment-prefix "TeX-master: " (prin1-to-string TeX-master) "\n"
comment-prefix "End:\n")
(unless (eq mode major-mode)
(funcall mode)
;; On Emacs 26 and later, no need to reparse local variables
;; in order to retain `TeX-master' because major mode
;; function runs `hack-local-variables' through
;; `run-mode-hooks'.
;; (hack-local-variables)
)))))