mirror of
https://git.savannah.gnu.org/git/emacs/org-mode.git
synced 2025-01-18 18:51:52 +00:00
ox-publish: Correctly return document title
* lisp/ox-publish.el (org-publish-find-title): Fix title when no #+TITLE property is provided. * lisp/ox.el (org-export-store-default-title): Remove-function. (org-export--default-title): Remove variable. (org-export-options-alist): Do not use a default value. (org-export--get-buffer-attributes): Store a default title. (org-export-as): Apply function removal. (org-export--get-global-options): Do not set a property with an explicitely nil value.
This commit is contained in:
parent
74750b0839
commit
c82cb4f75e
@ -805,17 +805,16 @@ Default for SITEMAP-FILENAME is 'sitemap.org'."
|
||||
(and (not reset) (org-publish-cache-get-file-property file :title nil t))
|
||||
(let* ((org-inhibit-startup t)
|
||||
(visiting (find-buffer-visiting file))
|
||||
(buffer (or visiting (find-file-noselect file)))
|
||||
title)
|
||||
(buffer (or visiting (find-file-noselect file))))
|
||||
(with-current-buffer buffer
|
||||
(org-mode)
|
||||
(setq title
|
||||
(or (org-element-interpret-data
|
||||
(plist-get (org-export-get-environment) :title))
|
||||
(file-name-nondirectory (file-name-sans-extension file)))))
|
||||
(unless visiting (kill-buffer buffer))
|
||||
(org-publish-cache-set-file-property file :title title)
|
||||
title)))
|
||||
(let ((title
|
||||
(let ((property (plist-get (org-export-get-environment) :title)))
|
||||
(if property (org-element-interpret-data property)
|
||||
(file-name-nondirectory (file-name-sans-extension file))))))
|
||||
(unless visiting (kill-buffer buffer))
|
||||
(org-publish-cache-set-file-property file :title title)
|
||||
title)))))
|
||||
|
||||
(defun org-publish-find-date (file)
|
||||
"Find the date of FILE in project.
|
||||
|
31
lisp/ox.el
31
lisp/ox.el
@ -117,7 +117,7 @@
|
||||
(:section-numbers nil "num" org-export-with-section-numbers)
|
||||
(:select-tags "SELECT_TAGS" nil org-export-select-tags split)
|
||||
(:time-stamp-file nil "timestamp" org-export-time-stamp-file)
|
||||
(:title "TITLE" nil org-export--default-title space)
|
||||
(:title "TITLE" nil nil space)
|
||||
(:with-archived-trees nil "arch" org-export-with-archived-trees)
|
||||
(:with-author nil "author" org-export-with-author)
|
||||
(:with-clocks nil "c" org-export-with-clocks)
|
||||
@ -1701,7 +1701,9 @@ Assume buffer is in Org mode. Narrowing, if any, is ignored."
|
||||
;; Return final value.
|
||||
plist))))
|
||||
;; Read options in the current buffer.
|
||||
(setq plist (funcall get-options buffer-file-name nil))
|
||||
(setq plist
|
||||
(funcall get-options
|
||||
(and buffer-file-name (list buffer-file-name)) nil))
|
||||
;; Parse keywords specified in `org-element-document-properties'.
|
||||
(mapc (lambda (keyword)
|
||||
;; Find the property associated to the keyword.
|
||||
@ -1719,19 +1721,11 @@ Assume buffer is in Org mode. Narrowing, if any, is ignored."
|
||||
(defun org-export--get-buffer-attributes ()
|
||||
"Return properties related to buffer attributes, as a plist."
|
||||
;; Store full path of input file name, or nil. For internal use.
|
||||
(list :input-file (buffer-file-name (buffer-base-buffer))))
|
||||
|
||||
(defvar org-export--default-title nil) ; Dynamically scoped.
|
||||
(defun org-export-store-default-title ()
|
||||
"Return default title for current document, as a string.
|
||||
Title is extracted from associated file name, if any, or buffer's
|
||||
name."
|
||||
(setq org-export--default-title
|
||||
(or (let ((visited-file (buffer-file-name (buffer-base-buffer))))
|
||||
(and visited-file
|
||||
(let ((visited-file (buffer-file-name (buffer-base-buffer))))
|
||||
(list :input-file visited-file
|
||||
:title (if (not visited-file) (buffer-name (buffer-base-buffer))
|
||||
(file-name-sans-extension
|
||||
(file-name-nondirectory visited-file))))
|
||||
(buffer-name (buffer-base-buffer)))))
|
||||
(file-name-nondirectory visited-file))))))
|
||||
|
||||
(defun org-export--get-global-options (&optional backend)
|
||||
"Return global export options as a plist.
|
||||
@ -1743,8 +1737,9 @@ process."
|
||||
(all (append (and backend (org-export-backend-options backend))
|
||||
org-export-options-alist)))
|
||||
(dolist (cell all plist)
|
||||
(let ((prop (car cell)))
|
||||
(unless (plist-member plist prop)
|
||||
(let ((prop (car cell))
|
||||
(default-value (nth 3 cell)))
|
||||
(unless (or (not default-value) (plist-member plist prop))
|
||||
(setq plist
|
||||
(plist-put
|
||||
plist
|
||||
@ -2945,10 +2940,6 @@ Return code as a string."
|
||||
(and body-only 'body-only))))
|
||||
(org-export--get-buffer-attributes)))
|
||||
tree)
|
||||
;; Store default title in `org-export--default-title' so that
|
||||
;; `org-export-get-environment' can access it from buffer's
|
||||
;; copy and then add it properly to communication channel.
|
||||
(org-export-store-default-title)
|
||||
;; Update communication channel and get parse tree. Buffer
|
||||
;; isn't parsed directly. Instead, a temporary copy is
|
||||
;; created, where include keywords, macros are expanded and
|
||||
|
Loading…
Reference in New Issue
Block a user