I have hundreds Org files under a directory hierarchy and would want to export only those recently modified in HTML to speed up the process. I have the following project alist that I feed up to org-publish:

       :base-directory        "~/Org/wiki"
       :base-extension        "org"
       :include               ,(my/org-files-to-publish)
       :with-broken-links     t
       :publishing-directory  "~/Org/wiki"
       :publishing-function   org-html-publish-to-html)

where (my/org-files-to-publish) returns recent Org files to export.

It seems that org-publish considers not only files of :include but also unconditionally those immediately under the root directory (e.g. ~/Org/wiki here).

Question: How to export exactly a list of Org files to HTML ?

As :exclude accepts only regex and not a files list, I can't find a reliable way to do what I want beside looping on (my/org-files-to-publish) using org-publish-file plus some extra stuff org-publish-projects does.

P.S. This theory is confirmed by checking the output of set-difference :test 'equal between org-publish-get-base-files PROJECT and (my/org-files-to-publish).

  • my/org-files-to-publish is only called once above: when you define org-publish-project-alist in the first place. Once that has been done, the :include list is set for the duration of the session. So the problem is NOT how to export exactly a list of Org files: you do that by setting the :include property. Your problem seems to be: how to dynamically change the :include property so that its value is the result of the function call. Am I understanding the problem correctly?
    – NickD
    Feb 27 at 18:45
  • @NickD Thanks for the comment. In fact, I do not use org-publish-project-alist, I use a project alist that I feed up to org-publishwhenever I'm publishing. So my/org-files-to-publish is called each time, and the list of files indeed changes dynamically. I print the list length to make sure this really happens. Now, no matter what list I'm exporting, it always exports and start by the first-level files unconditionally (even if the list doesn't include them). And this is because org-publish-projects (called by org-publish) includes them by calling org-publish-get-base-files. Feb 27 at 22:11
  • In my understanding, the documentation is not wrong, because it didn't say it :include those files exclusively. Feb 27 at 22:13

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.