diff --git a/lisp/ox.el b/lisp/ox.el index 9cf62078a..77cafb20d 100644 --- a/lisp/ox.el +++ b/lisp/ox.el @@ -6417,6 +6417,20 @@ Return file name as a string." "Output file: " pub-dir nil nil nil (lambda (n) (string= extension (file-name-extension n t)))))) extension)) + (pub-dir (or pub-dir + (and subtreep (org-entry-get + nil "EXPORT_PUB_DIR" 'selective)) + (org-with-point-at (point-min) + (catch :found + (let ((case-fold-search t)) + (while (re-search-forward + "^[ \t]*#\\+EXPORT_PUB_DIR:[ \t]+\\S-" + nil t) + (let ((element (org-element-at-point))) + (when (eq 'keyword (org-element-type element)) + (throw :found + (org-element-property + :value element)))))))))) (output-file ;; Build file name. Enforce EXTENSION over whatever user ;; may have come up with. PUB-DIR, if defined, always has