summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNicolas Goaziou <n.goaziou@gmail.com>2013-05-08 14:01:45 (GMT)
committer Nicolas Goaziou <n.goaziou@gmail.com>2013-05-08 14:01:45 (GMT)
commit77368d13fa4f0fc1c1ef7dc0382a6042365eab29 (patch)
treedb3c63cbba1a5cbb167cf0a9e262f47808ffec6a
parent5a14001b5e06c2891a9fd711b25da18ca18d4ab2 (diff)
parent16f12e0aef9fab4bdc575ebee8c463846377ef8b (diff)
downloadorg-mode-77368d13fa4f0fc1c1ef7dc0382a6042365eab29.zip
org-mode-77368d13fa4f0fc1c1ef7dc0382a6042365eab29.tar.gz
Merge branch 'maint'
-rw-r--r--lisp/ox.el32
-rw-r--r--testing/lisp/test-ox.el50
2 files changed, 68 insertions, 14 deletions
diff --git a/lisp/ox.el b/lisp/ox.el
index bf14bfa..f28d969 100644
--- a/lisp/ox.el
+++ b/lisp/ox.el
@@ -1731,20 +1731,24 @@ process."
(lambda (cell)
(let ((prop (car cell)))
(unless (plist-member plist prop)
- (setq plist
- (plist-put
- plist
- prop
- ;; Eval default value provided. If keyword is a member
- ;; of `org-element-document-properties', parse it as
- ;; a secondary string before storing it.
- (let ((value (eval (nth 3 cell))))
- (if (not (stringp value)) value
- (let ((keyword (nth 1 cell)))
- (if (not (member keyword org-element-document-properties))
- value
- (org-element-parse-secondary-string
- value (org-element-restriction 'keyword)))))))))))
+ (let ((value (eval (nth 3 cell))))
+ ;; Only set property if default value is non-nil.
+ (when value
+ (setq plist
+ (plist-put
+ plist
+ prop
+ ;; If keyword belongs to
+ ;; `org-element-document-properties', parse
+ ;; default value as a secondary string before
+ ;; storing it.
+ (if (not (stringp value)) value
+ (let ((keyword (nth 1 cell)))
+ (if (not (member keyword
+ org-element-document-properties))
+ value
+ (org-element-parse-secondary-string
+ value (org-element-restriction 'keyword))))))))))))
all)
;; Return value.
plist))
diff --git a/testing/lisp/test-ox.el b/testing/lisp/test-ox.el
index 3ab24fb..a55ad53 100644
--- a/testing/lisp/test-ox.el
+++ b/testing/lisp/test-ox.el
@@ -268,6 +268,56 @@ Paragraph"
(progn (forward-line 2)
(plist-get (org-export-get-environment nil t) :title))))))
+(ert-deftest test-org-export/set-title ()
+ "Test title setting."
+ ;; If no title if specified, use file name.
+ (should
+ (apply
+ 'equal
+ (org-test-with-temp-text-in-file "Test"
+ (org-mode)
+ (let (org-export-registered-backends)
+ (org-export-define-backend 'test
+ '((template . (lambda (text info)
+ (org-export-data (plist-get info :title) info)))))
+ (list (org-export-as 'test)
+ (file-name-nondirectory
+ (file-name-sans-extension (buffer-file-name))))))))
+ ;; If no title is specified, and no file is associated to the
+ ;; buffer, use buffer's name.
+ (should
+ (apply
+ 'equal
+ (org-test-with-temp-text "Test"
+ (org-mode)
+ (let (org-export-registered-backends)
+ (org-export-define-backend 'test
+ '((template . (lambda (text info)
+ (org-export-data (plist-get info :title) info)))))
+ (list (org-export-as 'test) (buffer-name))))))
+ ;; If a title is specified, use it.
+ (should
+ (equal
+ "Title"
+ (org-test-with-temp-text-in-file "#+TITLE: Title\nTest"
+ (org-mode)
+ (let (org-export-registered-backends)
+ (org-export-define-backend 'test
+ '((template . (lambda (text info)
+ (org-export-data (plist-get info :title) info)))))
+ (org-export-as 'test)))))
+ ;; If an empty title is specified, do not set it.
+ (should
+ (equal
+ ""
+ (org-test-with-temp-text-in-file "#+TITLE:\nTest"
+ (org-mode)
+ (let (org-export-registered-backends)
+ (org-export-define-backend 'test
+ '((template . (lambda (text info)
+ (org-export-data (plist-get info :title) info)))))
+ (org-export-as 'test))))))
+
(ert-deftest test-org-export/handle-options ()
"Test if export options have an impact on output."
;; Test exclude tags for headlines and inlinetasks.