Function: bib-document-TeX-files
bib-document-TeX-files is a byte-compiled function defined in
bib-cite.el.
Signature
(bib-document-TeX-files)
Documentation
Return all tex input files associated with a *known* multi-file document.
For a multi-file document in auctex only. No checking is done that this is a real multi-file document. Sets global variable bib-document-TeX-files-warnings.
Source Code
;; Defined in ~/.emacs.d/elpa/auctex-14.1.2/bib-cite.el
;; I don't use this one because files are not returned in order...
;; (defun bib-document-TeX-files ()
;; ;; Return all tex input files associated with a known multi-file document.
;; (let ((master-directory (bib-master-directory))
;; (the-list (cons (file-name-nondirectory (TeX-master-file))
;; (TeX-style-list)))
;; ;; TeX-style-list returns "../master" for the main file if TeX-master
;; ;; was set like that. "../master" would not be found relative
;; ;; to the master-directory! So let's add it to the list w/o directory.
;; (the-result)
;; (the-file))
;; (while the-list
;; (setq the-file (expand-file-name (car the-list) master-directory))
;; (setq the-list (cdr the-list))
;; (and (not (string-match ".tex$" the-file))
;; (setq the-file (concat the-file ".tex")))
;; (and (file-readable-p the-file)
;; (not (member the-file the-result)) ;listed already?
;; (setq the-result (cons the-file the-result))))
;; the-result))
(defun bib-document-TeX-files ()
"Return all tex input files associated with a *known* multi-file document.
For a multi-file document in auctex only.
No checking is done that this is a real multi-file document.
Sets global variable bib-document-TeX-files-warnings."
(setq bib-document-TeX-files-warnings nil)
(let* ((masterfile (bib-master-file))
(dir (and masterfile (file-name-directory masterfile)))
(tex-buffer (get-buffer-create "*tex-document*"))
(the-list (list masterfile)))
(if (not masterfile)
(progn
(kill-buffer tex-buffer)
(error
"Sorry, but this is not a multi-file document (Try C-u C-c C-n if using AUCTeX)")))
(with-current-buffer tex-buffer
;; set its directory so relative includes work without expanding
(setq default-directory dir)
(insert-file-contents masterfile)
(goto-char (point-min))
(while (re-search-forward "^[ \t]*\\\\\\(input\\|include\\){\\(.*\\)}"
nil t)
(let ((the-file (match-string 2)))
(if (string-match ".sty$" the-file) ;Skip over style files!
nil
(if (and (not (file-readable-p (expand-file-name the-file dir)))
(not (string-match ".ltx$" the-file))
(file-readable-p
(expand-file-name (concat the-file ".ltx") dir)))
(setq the-file (concat the-file ".ltx")))
(if (and (not (file-readable-p (expand-file-name the-file dir)))
(not (string-match ".tex$" the-file)))
(setq the-file (concat the-file ".tex")))
(setq the-file (expand-file-name the-file dir))
(if (not (file-readable-p the-file))
(setq bib-document-TeX-files-warnings
(concat
bib-document-TeX-files-warnings
(format "Warning: File not found: %s" the-file)))
(setq the-list (cons (expand-file-name the-file dir) the-list))
(end-of-line)(insert "\n")
(insert-file-contents the-file))))))
(kill-buffer tex-buffer)
(nreverse the-list)))