>From 13c92b87b728da134a73ef173be8957453ef90a6 Mon Sep 17 00:00:00 2001 From: Ruben Maher Date: Sat, 25 Jul 2015 16:54:28 +0930 Subject: [PATCH] org-export-output-file-name: respect :output-file There is a property :output-file defined in the communications channel but it is ignored by `org-export-output-file-name'. * lisp/ox.el (org-export-output-file-name): Add optional argument EXT-PLIST, and try to get `base-name' from its property `:output-file' if SUBTREEP is nil or there was no EXPORT_FILE_NAME at point. * lisp/ox-publish.el (org-publish-org-to): Provide PLIST when calling `org-export-output-file-name'. --- --- lisp/ox-publish.el | 2 +- lisp/ox.el | 10 +++++++++- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/lisp/ox-publish.el b/lisp/ox-publish.el index 951f0fe..25086cd 100644 --- a/lisp/ox-publish.el +++ b/lisp/ox-publish.el @@ -579,7 +579,7 @@ Return output file name." (work-buffer (or visitingp (find-file-noselect filename)))) (prog1 (with-current-buffer work-buffer (let ((output-file - (org-export-output-file-name extension nil pub-dir)) + (org-export-output-file-name extension nil pub-dir plist)) (body-p (plist-get plist :body-only))) (org-export-to-file backend output-file nil nil nil body-p diff --git a/lisp/ox.el b/lisp/ox.el index b06211b..110094b 100644 --- a/lisp/ox.el +++ b/lisp/ox.el @@ -5892,7 +5892,8 @@ or FILE." (or (and (functionp post-process) (funcall post-process file)) file)))))) -(defun org-export-output-file-name (extension &optional subtreep pub-dir) +(defun org-export-output-file-name + (extension &optional subtreep pub-dir ext-plist) "Return output file's name according to buffer specifications. EXTENSION is a string representing the output file extension, @@ -5905,6 +5906,9 @@ of subtree at point. When optional argument PUB-DIR is set, use it as the publishing directory. +With optional argument SUBTREEP nil and EXT-PLIST non-nil, try to get +the value of `:output-file' from EXT-PLIST. + Return file name as a string." (let* ((visited-file (buffer-file-name (buffer-base-buffer))) (base-name @@ -5917,6 +5921,10 @@ Return file name as a string." (save-excursion (ignore-errors (org-back-to-heading) (point))) "EXPORT_FILE_NAME" t)) + ;; SUBTREEP is nil or there was no EXPORT_FILE_NAME at + ;; point. Try to get the file name from EXT-PLIST if + ;; it is there. + (plist-get ext-plist :output-file) ;; File name may be extracted from buffer's associated ;; file, if any. (and visited-file (file-name-nondirectory visited-file)) -- 2.4.5