|
@@ -2962,38 +2962,44 @@ directory.
|
|
|
When optional argument VISIBLE-ONLY is non-nil, don't export
|
|
|
contents of hidden elements.
|
|
|
|
|
|
-Return file name as a string, or nil if it couldn't be
|
|
|
-determined."
|
|
|
- (let ((base-name
|
|
|
- ;; File name may come from EXPORT_FILE_NAME subtree 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" t))
|
|
|
- ;; File name may be extracted from buffer's associated
|
|
|
- ;; file, if any.
|
|
|
- (let ((visited-file (buffer-file-name (buffer-base-buffer))))
|
|
|
- (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))))))))
|
|
|
- ;; Build file name. Enforce EXTENSION over whatever user may have
|
|
|
- ;; come up with. PUB-DIR, if defined, always has precedence over
|
|
|
- ;; any provided path.
|
|
|
- (cond
|
|
|
- (pub-dir
|
|
|
- (concat (file-name-as-directory pub-dir)
|
|
|
- (file-name-nondirectory base-name)
|
|
|
- extension))
|
|
|
- ((file-name-absolute-p base-name) (concat base-name extension))
|
|
|
- (t (concat (file-name-as-directory ".") base-name extension)))))
|
|
|
+Return file name as a string."
|
|
|
+ (let* ((visited-file (buffer-file-name (buffer-base-buffer)))
|
|
|
+ (base-name
|
|
|
+ ;; File name may come from EXPORT_FILE_NAME subtree
|
|
|
+ ;; 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" t))
|
|
|
+ ;; 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)))))))
|
|
|
+ (output-file
|
|
|
+ ;; Build file name. Enforce EXTENSION over whatever user
|
|
|
+ ;; may have come up with. PUB-DIR, if defined, always has
|
|
|
+ ;; precedence over any provided path.
|
|
|
+ (cond
|
|
|
+ (pub-dir
|
|
|
+ (concat (file-name-as-directory pub-dir)
|
|
|
+ (file-name-nondirectory base-name)
|
|
|
+ extension))
|
|
|
+ ((file-name-absolute-p base-name) (concat base-name extension))
|
|
|
+ (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 (file-equal-p visited-file output-file))
|
|
|
+ (concat output-file extension)
|
|
|
+ output-file)))
|
|
|
|
|
|
(defun org-export-expand-include-keyword (&optional included dir)
|
|
|
"Expand every include keyword in buffer.
|