summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNicolas Goaziou <n.goaziou@gmail.com>2013-08-08 15:22:08 (GMT)
committer Nicolas Goaziou <n.goaziou@gmail.com>2013-08-08 16:45:39 (GMT)
commitc82cb4f75e42bb1d0eadd13f18967a17598b8d65 (patch)
tree3a95d83443843954b30745ef4d3d9251b5432829
parent74750b083958c446b93d9fd0fcd161ccb965aa9d (diff)
downloadorg-mode-c82cb4f75e42bb1d0eadd13f18967a17598b8d65.zip
org-mode-c82cb4f75e42bb1d0eadd13f18967a17598b8d65.tar.gz
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.
-rw-r--r--lisp/ox-publish.el17
-rw-r--r--lisp/ox.el31
2 files changed, 19 insertions, 29 deletions
diff --git a/lisp/ox-publish.el b/lisp/ox-publish.el
index f02b95a..463dc56 100644
--- a/lisp/ox-publish.el
+++ b/lisp/ox-publish.el
@@ -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.
diff --git a/lisp/ox.el b/lisp/ox.el
index 061b8dc..6427007 100644
--- a/lisp/ox.el
+++ b/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