ox: Change scope for `org-export-with-timestamps'

* lisp/ox.el (org-export-with-timestamps): Only applies to isolated
  timestamps, i.e. timestamps in a paragraph containing only
  timestamps and empty strings.
(org-export--skip-p): Skip timestamps according to new behaviour.
* testing/lisp/test-ox.el: Update tests.
This commit is contained in:
Nicolas Goaziou 2013-04-14 22:20:16 +02:00 committed by Bastien Guerry
parent 2c46ecee4f
commit 60aa1682ce
2 changed files with 67 additions and 31 deletions

View File

@ -726,9 +726,15 @@ also be set with the OPTIONS keyword, e.g. \"timestamp:nil\"."
(defcustom org-export-with-timestamps t (defcustom org-export-with-timestamps t
"Non nil means allow timestamps in export. "Non nil means allow timestamps in export.
It can be set to `active', `inactive', t or nil, in order to It can be set to any of the following values:
export, respectively, only active timestamps, only inactive ones, t export all timestamps.
all of them or none. `active' export active timestamps only.
`inactive' export inactive timestamps only.
nil do not export timestamps
This only applies to timestamps isolated in a paragraph
containing only timestamps. Other timestamps are always
exported.
This option can also be set with the OPTIONS keyword, e.g. This option can also be set with the OPTIONS keyword, e.g.
\"<:nil\"." \"<:nil\"."
@ -2022,19 +2028,24 @@ a tree with a select tag."
(not (org-export-get-previous-element blob options)))) (not (org-export-get-previous-element blob options))))
(table-row (org-export-table-row-is-special-p blob options)) (table-row (org-export-table-row-is-special-p blob options))
(timestamp (timestamp
(case (plist-get options :with-timestamps) ;; `:with-timestamps' only applies to isolated timestamps
;; No timestamp allowed. ;; objects, i.e. timestamp objects in a paragraph containing only
('nil t) ;; timestamps and whitespaces.
;; Only active timestamps allowed and the current one isn't (when (let ((parent (org-export-get-parent-element blob)))
;; active. (and (memq (org-element-type parent) '(paragraph verse-block))
(active (not (org-element-map parent
(not (memq (org-element-property :type blob) (cons 'plain-text
'(active active-range)))) (remq 'timestamp org-element-all-objects))
;; Only inactive timestamps allowed and the current one isn't (lambda (obj)
;; inactive. (or (not (stringp obj)) (org-string-nw-p obj)))
(inactive options t))))
(not (memq (org-element-property :type blob) (case (plist-get options :with-timestamps)
'(inactive inactive-range)))))))) ('nil t)
(active
(not (memq (org-element-property :type blob) '(active active-range))))
(inactive
(not (memq (org-element-property :type blob)
'(inactive inactive-range)))))))))
;;; The Transcoder ;;; The Transcoder

View File

@ -394,21 +394,46 @@ Paragraph"
(org-test-with-temp-text "[0/0]" (org-test-with-temp-text "[0/0]"
(org-test-with-backend test (org-test-with-backend test
(org-export-as (org-export-as
'test nil nil nil '(:with-statistics-cookies nil)))))) 'test nil nil nil '(:with-statistics-cookies nil)))))))
;; Timestamps.
(org-test-with-temp-text "[2012-04-29 sun. 10:45]<2012-04-29 sun. 10:45>" (ert-deftest test-org-export/with-timestamps ()
(org-test-with-backend test "Test `org-export-with-timestamps' specifications."
(should ;; t value.
(equal (org-export-as 'test nil nil nil '(:with-timestamps t)) (should
"[2012-04-29 sun. 10:45]<2012-04-29 sun. 10:45>\n")) (equal
(should "[2012-04-29 sun. 10:45]<2012-04-29 sun. 10:45>\n"
(equal (org-export-as 'test nil nil nil '(:with-timestamps nil)) "")) (org-test-with-temp-text "[2012-04-29 sun. 10:45]<2012-04-29 sun. 10:45>"
(should (org-test-with-backend test
(equal (org-export-as 'test nil nil nil '(:with-timestamps active)) (org-export-as 'test nil nil nil '(:with-timestamps t))))))
"<2012-04-29 sun. 10:45>\n")) ;; nil value.
(should (should
(equal (org-export-as 'test nil nil nil '(:with-timestamps inactive)) (equal
"[2012-04-29 sun. 10:45]\n"))))) ""
(org-test-with-temp-text "[2012-04-29 sun. 10:45]<2012-04-29 sun. 10:45>"
(org-test-with-backend test
(org-export-as 'test nil nil nil '(:with-timestamps nil))))))
;; `active' value.
(should
(equal
"<2012-03-29 Thu>\n\nParagraph <2012-03-29 Thu>[2012-03-29 Thu]"
(org-test-with-temp-text
"<2012-03-29 Thu>[2012-03-29 Thu]
Paragraph <2012-03-29 Thu>[2012-03-29 Thu]"
(org-test-with-backend test
(org-trim
(org-export-as 'test nil nil nil '(:with-timestamps active)))))))
;; `inactive' value.
(should
(equal
"[2012-03-29 Thu]\n\nParagraph <2012-03-29 Thu>[2012-03-29 Thu]"
(org-test-with-temp-text
"<2012-03-29 Thu>[2012-03-29 Thu]
Paragraph <2012-03-29 Thu>[2012-03-29 Thu]"
(org-test-with-backend test
(org-trim
(org-export-as 'test nil nil nil '(:with-timestamps inactive))))))))
(ert-deftest test-org-export/comment-tree () (ert-deftest test-org-export/comment-tree ()
"Test if export process ignores commented trees." "Test if export process ignores commented trees."