Browse Source

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.
Nicolas Goaziou 12 years ago
parent
commit
caf2432c52
2 changed files with 35 additions and 25 deletions
  1. 22 21
      contrib/lisp/org-export.el
  2. 13 4
      testing/lisp/test-org-export.el

+ 22 - 21
contrib/lisp/org-export.el

@@ -142,6 +142,7 @@
     (:with-plannings nil "p" org-export-with-planning)
     (:with-priority nil "pri" org-export-with-priority)
     (: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-toc nil "toc" org-export-with-toc)
     (:with-tables nil "|" org-export-with-tables)
@@ -504,6 +505,13 @@ e.g. \"-:nil\"."
   :group 'org-export-general
   :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
   "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
 tag."
   (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
      (let ((with-tasks (plist-get options :with-tasks))
 	   (todo (org-element-property :todo-keyword blob))
@@ -1820,9 +1833,14 @@ tag."
 		 (and (memq with-tasks '(todo done))
 		      (not (eq todo-type with-tasks)))
 		 (and (consp with-tasks) (not (member todo with-tasks))))))))
-    ;; Check inlinetask.
     (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
      (case (plist-get options :with-timestamps)
        ;; No timestamp allowed.
@@ -1836,24 +1854,7 @@ tag."
        ;; inactive.
        (inactive
 	(not (memq (org-element-property :type blob)
-		   '(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)))))
+		   '(inactive inactive-range))))))))
 
 
 

+ 13 - 4
testing/lisp/test-org-export.el

@@ -65,14 +65,16 @@ already filled in `info'."
    (equal
     (org-export--parse-option-keyword
      "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
       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-email t :with-emphasize t :with-entities t :with-fixed-width 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-tags t :with-tasks t :with-timestamps t :with-todo-keywords t)))
+      :with-special-strings t :with-statistics-cookies t :with-sub-superscript t
+      :with-toc t :with-tables t :with-tags t :with-tasks t :with-timestamps t
+      :with-todo-keywords t)))
   ;; Test some special values.
   (should
    (equal
@@ -282,7 +284,14 @@ Paragraph"
 	    "*************** Task\nContents\n*************** END"
 	  (org-test-with-backend test
 	    (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 ()
   "Test if export process ignores commented trees."