Function: tex-guess-main-file
tex-guess-main-file is a byte-compiled function defined in
tex-mode.el.gz.
Signature
(tex-guess-main-file &optional ALL)
Documentation
Find a likely tex-main-file(var)/tex-main-file(fun).
Looks for hints in other buffers in the same directory or in
ALL other buffers. If ALL is sub only look at buffers in parent directories
of the current buffer.
Source Code
;; Defined in /usr/src/emacs/lisp/textmodes/tex-mode.el.gz
(defun tex-guess-main-file (&optional all)
"Find a likely `tex-main-file'.
Looks for hints in other buffers in the same directory or in
ALL other buffers. If ALL is `sub' only look at buffers in parent directories
of the current buffer."
(let ((dir default-directory)
(header-re tex-start-of-header))
(catch 'found
;; Look for a buffer with `tex-main-file' set.
(dolist (buf (if (consp all) all (buffer-list)))
(with-current-buffer buf
(when (and (cond
((null all) (equal dir default-directory))
((eq all 'sub) (string-prefix-p default-directory dir))
(t))
(stringp tex-main-file))
(throw 'found (expand-file-name tex-main-file)))))
;; Look for a buffer containing the magic `tex-start-of-header'.
(dolist (buf (if (consp all) all (buffer-list)))
(with-current-buffer buf
(when (and (cond
((null all) (equal dir default-directory))
((eq all 'sub) (string-prefix-p default-directory dir))
(t))
buffer-file-name
;; (or (easy-mmode-derived-mode-p 'latex-mode)
;; (easy-mmode-derived-mode-p 'plain-tex-mode))
(save-excursion
(save-restriction
(widen)
(goto-char (point-min))
(re-search-forward
header-re (+ (point) 10000) t))))
(throw 'found (expand-file-name buffer-file-name))))))))