Function: tex-uptodate-p

tex-uptodate-p is a byte-compiled function defined in tex-mode.el.gz.

Signature

(tex-uptodate-p FILE)

Documentation

Return non-nil if FILE is not uptodate w.r.t the document source files.

FILE is typically the output DVI or PDF file.

Source Code

;; Defined in /usr/src/emacs/lisp/textmodes/tex-mode.el.gz
(defun tex-uptodate-p (file)
  "Return non-nil if FILE is not uptodate w.r.t the document source files.
FILE is typically the output DVI or PDF file."
  ;; We should check all the files included !!!
  (and
   ;; Clearly, the target must exist.
   (file-exists-p file)
   ;; And the last run must not have asked for a rerun.
   ;; FIXME: this should check that the last run was done on the same file.
   (let ((buf (condition-case nil (tex-shell-buf) (error nil))))
     (when buf
       (with-current-buffer buf
	 (save-excursion
	   (goto-char (point-max))
	   (and (re-search-backward
                 (concat "(see the transcript file for additional information)"
                         "\\|^Output written on .*"
                         (regexp-quote (file-name-nondirectory file))
                         " (.*)\\.")
                 nil t)
		(> (save-excursion
                     ;; Usually page numbers are output as [N], but
                     ;; I've already seen things like
                     ;; [N{/var/lib/texmf/fonts/map/pdftex/updmap/pdftex.map}]
                     ;; as well as [N.N] (e.g. with 'acmart' style).
                     (or (re-search-backward
                          "\\[[0-9]+\\({[^}]*}\\|\\.[0-9]+\\)?\\]"
                          nil t)
			 (point-min)))
		   (save-excursion
		     (or (re-search-backward "Rerun" nil t)
			 (point-min)))))))))
   ;; And the input files must not have been changed in the meantime.
   (let ((files (if (and tex-use-reftex
			 (fboundp 'reftex-scanning-info-available-p)
			 (reftex-scanning-info-available-p))
		    (reftex-all-document-files)
		  (list (file-name-directory (expand-file-name file)))))
	 (ignored-dirs-re
	  (concat
	   (regexp-opt
	    (delq nil (mapcar (lambda (s) (if (eq (aref s (1- (length s))) ?/)
					 (substring s 0 (1- (length s)))))
			      completion-ignored-extensions))
	    t) "\\'"))
	 (uptodate t))
     (while (and files uptodate)
       (let ((f (pop files)))
	 (if (and (file-directory-p f)
		  ;; Avoid infinite loops.
		  (not (file-symlink-p f)))
	     (unless (string-match ignored-dirs-re f)
	       (setq files (nconc
                            (ignore-errors ;Not readable or something.
                              (directory-files f t tex-input-files-re))
			    files)))
	   (when (file-newer-than-file-p f file)
	     (setq uptodate nil)))))
     uptodate)))