0

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:

`("html"
       :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).

3
  • 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
    Commented Feb 27, 2021 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. Commented Feb 27, 2021 at 22:11
  • In my understanding, the documentation is not wrong, because it didn't say it :include those files exclusively. Commented Feb 27, 2021 at 22:13

1 Answer 1

0

According to org-publish-project-alist documentation (emphasis mine):

The :include property may be used to include extra files.

This means that your project alist will match all org files in your directory plus any files included via :include property.

You can achieve desired result in somewhat hacky way by setting :base-extension to a dummy value that won't match any files:

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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.