org-export: Add an option to toggle export of stat cookies

* contrib/lisp/org-export.el (org-export-with-statistics-cookies): New
  variable.
(org-export-options-alist): Use new variable.
(org-export--skip-p): Handle new option.
* testing/lisp/test-org-export.el: Add test.
This commit is contained in:
Nicolas Goaziou 2012-08-27 12:31:05 +02:00
parent 9f2824852c
commit caf2432c52
2 changed files with 35 additions and 25 deletions

View File

@ -142,6 +142,7 @@
(:with-plannings nil "p" org-export-with-planning) (:with-plannings nil "p" org-export-with-planning)
(:with-priority nil "pri" org-export-with-priority) (:with-priority nil "pri" org-export-with-priority)
(:with-special-strings nil "-" org-export-with-special-strings) (:with-special-strings nil "-" org-export-with-special-strings)
(:with-statistics-cookies nil "stat" org-export-with-statistics-cookies)
(:with-sub-superscript nil "^" org-export-with-sub-superscripts) (:with-sub-superscript nil "^" org-export-with-sub-superscripts)
(:with-toc nil "toc" org-export-with-toc) (:with-toc nil "toc" org-export-with-toc)
(:with-tables nil "|" org-export-with-tables) (:with-tables nil "|" org-export-with-tables)
@ -504,6 +505,13 @@ e.g. \"-:nil\"."
:group 'org-export-general :group 'org-export-general
:type 'boolean) :type 'boolean)
(defcustom org-export-with-statistics-cookies t
"Non-nil means include statistics cookies in export.
This option can also be set with the #+OPTIONS: line,
e.g. \"stat:nil\""
:group 'org-export-general
:type 'boolean)
(defcustom org-export-with-sub-superscripts t (defcustom org-export-with-sub-superscripts t
"Non-nil means interpret \"_\" and \"^\" for export. "Non-nil means interpret \"_\" and \"^\" for export.
@ -1796,7 +1804,12 @@ OPTIONS is the plist holding export options. SELECTED, when
non-nil, is a list of headlines belonging to a tree with a select non-nil, is a list of headlines belonging to a tree with a select
tag." tag."
(case (org-element-type blob) (case (org-element-type blob)
;; Check headline. (clock (not (plist-get options :with-clocks)))
(drawer
(or (not (plist-get options :with-drawers))
(and (consp (plist-get options :with-drawers))
(not (member (org-element-property :drawer-name blob)
(plist-get options :with-drawers))))))
(headline (headline
(let ((with-tasks (plist-get options :with-tasks)) (let ((with-tasks (plist-get options :with-tasks))
(todo (org-element-property :todo-keyword blob)) (todo (org-element-property :todo-keyword blob))
@ -1820,9 +1833,14 @@ tag."
(and (memq with-tasks '(todo done)) (and (memq with-tasks '(todo done))
(not (eq todo-type with-tasks))) (not (eq todo-type with-tasks)))
(and (consp with-tasks) (not (member todo with-tasks)))))))) (and (consp with-tasks) (not (member todo with-tasks))))))))
;; Check inlinetask.
(inlinetask (not (plist-get options :with-inlinetasks))) (inlinetask (not (plist-get options :with-inlinetasks)))
;; Check timestamp. (planning (not (plist-get options :with-plannings)))
(statistics-cookie (not (plist-get options :with-statistics-cookies)))
(table-cell
(and (org-export-table-has-special-column-p
(org-export-get-parent-table blob))
(not (org-export-get-previous-element blob options))))
(table-row (org-export-table-row-is-special-p blob options))
(timestamp (timestamp
(case (plist-get options :with-timestamps) (case (plist-get options :with-timestamps)
;; No timestamp allowed. ;; No timestamp allowed.
@ -1836,24 +1854,7 @@ tag."
;; inactive. ;; inactive.
(inactive (inactive
(not (memq (org-element-property :type blob) (not (memq (org-element-property :type blob)
'(inactive inactive-range)))))) '(inactive inactive-range))))))))
;; Check drawer.
(drawer
(or (not (plist-get options :with-drawers))
(and (consp (plist-get options :with-drawers))
(not (member (org-element-property :drawer-name blob)
(plist-get options :with-drawers))))))
;; Check table-row.
(table-row (org-export-table-row-is-special-p blob options))
;; Check table-cell.
(table-cell
(and (org-export-table-has-special-column-p
(org-export-get-parent-table blob))
(not (org-export-get-previous-element blob options))))
;; Check clock.
(clock (not (plist-get options :with-clocks)))
;; Check planning.
(planning (not (plist-get options :with-plannings)))))

View File

@ -65,14 +65,16 @@ already filled in `info'."
(equal (equal
(org-export--parse-option-keyword (org-export--parse-option-keyword
"H:1 num:t \\n:t timestamp:t arch:t author:t creator:t d:t email:t "H:1 num:t \\n:t timestamp:t arch:t author:t creator:t d:t email:t
*:t e:t ::t f:t pri:t -:t ^:t toc:t |:t tags:t tasks:t <:t todo:t inline:nil") *:t e:t ::t f:t pri:t -:t ^:t toc:t |:t tags:t tasks:t <:t todo:t inline:nil
stat:t")
'(:headline-levels '(:headline-levels
1 :preserve-breaks t :section-numbers t :time-stamp-file t 1 :preserve-breaks t :section-numbers t :time-stamp-file t
:with-archived-trees t :with-author t :with-creator t :with-drawers t :with-archived-trees t :with-author t :with-creator t :with-drawers t
:with-email t :with-emphasize t :with-entities t :with-fixed-width t :with-email t :with-emphasize t :with-entities t :with-fixed-width t
:with-footnotes t :with-inlinetasks nil :with-priority t :with-footnotes t :with-inlinetasks nil :with-priority t
:with-special-strings t :with-sub-superscript t :with-toc t :with-tables t :with-special-strings t :with-statistics-cookies t :with-sub-superscript t
:with-tags t :with-tasks t :with-timestamps t :with-todo-keywords t))) :with-toc t :with-tables t :with-tags t :with-tasks t :with-timestamps t
:with-todo-keywords t)))
;; Test some special values. ;; Test some special values.
(should (should
(equal (equal
@ -282,7 +284,14 @@ Paragraph"
"*************** Task\nContents\n*************** END" "*************** Task\nContents\n*************** END"
(org-test-with-backend test (org-test-with-backend test
(org-export-as 'test nil nil nil '(:with-inlinetasks nil))))) (org-export-as 'test nil nil nil '(:with-inlinetasks nil)))))
"")))) "")))
;; Statistics cookies.
(should
(equal ""
(org-test-with-temp-text "[0/0]"
(org-test-with-backend test
(org-export-as
'test nil nil nil '(:with-statistics-cookies nil)))))))
(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."