Function: TeX-check-files

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

Signature

(TeX-check-files DERIVED ORIGINALS EXTENSIONS)

Documentation

Check if DERIVED is newer than any of the ORIGINALS.

Try each original with each member of EXTENSIONS, in all directories in TeX-check-path. Returns true if any of the ORIGINALS with any of the EXTENSIONS are newer than DERIVED. Will prompt to save the buffer of any ORIGINALS which are modified but not saved yet.

Source Code

;; Defined in ~/.emacs.d/elpa/auctex-14.1.2/tex.el
(defun TeX-check-files (derived originals extensions)
  "Check if DERIVED is newer than any of the ORIGINALS.
Try each original with each member of EXTENSIONS, in all directories
in `TeX-check-path'.  Returns true if any of the ORIGINALS with any of the
EXTENSIONS are newer than DERIVED.  Will prompt to save the buffer of any
ORIGINALS which are modified but not saved yet."
  (let (existingoriginals
        found
        (extensions (TeX-delete-duplicate-strings extensions))
        (buffers (buffer-list)))
    (dolist (path (TeX-delete-duplicate-strings
                   (mapcar (lambda (dir)
                             (expand-file-name (file-name-as-directory dir)))
                           (append
                            TeX-check-path
                            ;; In `TeX-command-default', this function is used to
                            ;; check whether bibliography databases are newer
                            ;; than generated *.bbl files, but bibliography
                            ;; database are relative to `TeX-master-directory'
                            ;; and the test can be run also from included files
                            ;; that are in directories different from
                            ;; `TeX-master-directory'.
                            (list (TeX-master-directory))))))
      (dolist (orig originals)
        (dolist (ext extensions)
          (let ((filepath (concat path orig "." ext)))
            (if (or (file-exists-p filepath)
                    (get-file-buffer filepath))
                (setq existingoriginals (cons filepath existingoriginals)))))))
    (while buffers
      (let* ((buffer (car buffers))
             (name (TeX-buffer-file-name buffer)))
        (setq buffers (cdr buffers))
        (if (and name (member name existingoriginals))
            (progn
              (and (buffer-modified-p buffer)
                   (or (not TeX-save-query)
                       (y-or-n-p (concat "Save file "
                                         (TeX-buffer-file-name  buffer)
                                         "? ")))
                   (with-current-buffer buffer (save-buffer)))))))
    (dolist (eo existingoriginals)
      (if (file-newer-than-file-p eo derived)
          (setq found t)))
    found))