ox: Small refactoring

* lisp/ox.el (org-export-output-file-name): Small refactoring.
This commit is contained in:
Nicolas Goaziou 2015-11-08 16:44:26 +01:00
parent b8f100c14a
commit 75c93f7c21
1 changed files with 6 additions and 12 deletions

View File

@ -5983,21 +5983,15 @@ Return file name as a string."
;; property, assuming point is at beginning of said
;; sub-tree.
(file-name-sans-extension
(or (and subtreep
(org-entry-get
(save-excursion
(ignore-errors (org-back-to-heading) (point)))
"EXPORT_FILE_NAME" 'selective))
(or (and subtreep (org-entry-get nil "EXPORT_FILE_NAME" 'selective))
;; File name may be extracted from buffer's associated
;; file, if any.
(and visited-file (file-name-nondirectory visited-file))
;; Can't determine file name on our own: Ask user.
(let ((read-file-name-function
(and org-completion-use-ido 'ido-read-file-name)))
(read-file-name
"Output file: " pub-dir nil nil nil
(lambda (name)
(string= (file-name-extension name t) extension)))))))
(read-file-name
"Output file: " pub-dir nil nil nil
(lambda (name)
(string= (file-name-extension name t) extension))))))
(output-file
;; Build file name. Enforce EXTENSION over whatever user
;; may have come up with. PUB-DIR, if defined, always has
@ -6011,7 +6005,7 @@ Return file name as a string."
(t (concat (file-name-as-directory ".") base-name extension)))))
;; If writing to OUTPUT-FILE would overwrite original file, append
;; EXTENSION another time to final name.
(if (and visited-file (org-file-equal-p visited-file output-file))
(if (and visited-file (file-equal-p visited-file output-file))
(concat output-file extension)
output-file)))