Function: org-publish-cache-file-needs-publishing

org-publish-cache-file-needs-publishing is a byte-compiled function defined in ox-publish.el.gz.

Signature

(org-publish-cache-file-needs-publishing FILENAME &optional PUB-DIR PUB-FUNC BASE-DIR)

Documentation

Check the timestamp of the last publishing of FILENAME.

Return non-nil if the file needs publishing. Also check if any included files have been more recently published, so that the file including them will be republished as well.

Source Code

;; Defined in /usr/src/emacs/lisp/org/ox-publish.el.gz
(defun org-publish-cache-file-needs-publishing
    (filename &optional pub-dir pub-func _base-dir)
  "Check the timestamp of the last publishing of FILENAME.
Return non-nil if the file needs publishing.  Also check if
any included files have been more recently published, so that
the file including them will be republished as well."
  (unless org-publish-cache
    (error
     "`org-publish-cache-file-needs-publishing' called, but no cache present"))
  (let* ((key (org-publish-timestamp-filename filename pub-dir pub-func))
	 (pstamp (org-publish-cache-get key))
	 (org-inhibit-startup t)
	 included-files-mtime)
    (when (equal (file-name-extension filename) "org")
      (let ((case-fold-search t))
	(with-temp-buffer
          (delay-mode-hooks
            (org-mode)
            (insert-file-contents filename)
	    (goto-char (point-min))
	    (while (re-search-forward "^[ \t]*#\\+INCLUDE:" nil t)
	      (let ((element (org-element-at-point)))
                (when (org-element-type-p element 'keyword)
		  (let* ((value (org-element-property :value element))
                         (include-filename
			  (and (string-match "\\`\\(\".+?\"\\|\\S-+\\)" value)
			       (let ((m (org-strip-quotes
                                         (match-string 1 value))))
                                 ;; Ignore search suffix.
                                 (if (string-match "::.*?\\'" m)
				     (substring m 0 (match-beginning 0))
				   m)))))
		    (when include-filename
		      (push (org-publish-cache-mtime-of-src
			     (expand-file-name include-filename (file-name-directory filename)))
			    included-files-mtime))))))))))
    (or (null pstamp)
	(let ((mtime (org-publish-cache-mtime-of-src filename)))
	  (or (time-less-p pstamp mtime)
	      (cl-some (lambda (ct) (time-less-p mtime ct))
		       included-files-mtime))))))