Browse Source

org-export: Export `clock' and `planning' elements

* contrib/lisp/org-export.el (org-export-option-alist): Add new
  filters.
(org-export-with-clocks, org-export-with-planning,
org-export-filter-clock-functions,
org-export-filter-planning-functions): New variables.
(org-export--skip-p): Skip `clock' and `planning' types depending on
export options.
* contrib/lisp/org-e-ascii.el (org-e-ascii-clock,
  org-e-ascii-planning): New functions.
(org-e-ascii-time-stamp): Update function.  Use `org-translate-time'.
* contrib/lisp/org-e-html.el (org-e-html-clock, org-e-html-planning):
  New functions.
(org-e-html-time-stamp): Update function.
* contrib/lisp/org-e-latex.el (org-e-latex-clock,
  org-e-latex-planning): New functions.
(org-e-latex-time-stamp): Update function.  Use `org-translate-time'.
* contrib/lisp/org-e-odt.el (org-e-odt-clock, org-e-odt-planning): New
  functions.
(org-e-odt-time-stamp): Update function.  Use `org-translate-time'.
* testing/lisp/test-org-export.el: Add tests.
Nicolas Goaziou 13 years ago
parent
commit
941f90a649

+ 38 - 8
contrib/lisp/org-e-ascii.el

@@ -1018,6 +1018,22 @@ holding contextual information."
    contents (org-e-ascii--current-text-width center-block info) 'center))
 
 
+;;;; Clock
+
+(defun org-e-ascii-clock (clock contents info)
+  "Transcode a CLOCK object from Org to ASCII.
+CONTENTS is nil.  INFO is a plist holding contextual
+information."
+  (concat org-clock-string " "
+	  (org-translate-time (org-element-property :value clock))
+	  (let ((time (org-element-property :time clock)))
+	    (and time
+		 (concat " => "
+			 (apply 'format
+				"%2s:%02s"
+				(org-split-string time ":")))))))
+
+
 ;;;; Code
 
 (defun org-e-ascii-code (code contents info)
@@ -1460,15 +1476,30 @@ INFO is a plist used as a communication channel."
       (replace-regexp-in-string "---" "—" text)))))
 
 
-;;;; Property Drawer
+;;;; Planning
 
-(defun org-e-ascii-property-drawer (property-drawer contents info)
-  "Transcode a PROPERTY-DRAWER element from Org to ASCII.
+(defun org-e-ascii-planning (planning contents info)
+  "Transcode a PLANNING element from Org to ASCII.
 CONTENTS is nil.  INFO is a plist used as a communication
 channel."
-  ;; The property drawer isn't exported but we want separating blank
-  ;; lines nonetheless.
-  "")
+  (mapconcat
+   'identity
+   (delq nil
+	 (list (let ((closed (org-element-property :closed planning)))
+		 (when closed (concat org-closed-string " "
+				      (org-translate-time closed))))
+	       (let ((deadline (org-element-property :deadline planning)))
+		 (when deadline (concat org-deadline-string " "
+					(org-translate-time deadline))))
+	       (let ((scheduled (org-element-property :scheduled planning)))
+		 (when scheduled (concat org-scheduled-string " "
+					 (org-translate-time scheduled))))))
+   " "))
+
+
+;;;; Property Drawer
+;;
+;; Property drawers are ignored.
 
 
 ;;;; Quote Block
@@ -1727,8 +1758,7 @@ a communication channel."
 (defun org-e-ascii-time-stamp (time-stamp contents info)
   "Transcode a TIME-STAMP object from Org to ASCII.
 CONTENTS is nil.  INFO is a plist holding contextual information."
-  ;; Return time-stamps as-is.
-  (org-element-time-stamp-interpreter time-stamp contents))
+  (org-translate-time (org-element-property :value time-stamp)))
 
 
 ;;;; Underline

+ 48 - 12
contrib/lisp/org-e-html.el

@@ -1852,6 +1852,23 @@ holding contextual information."
    (format "<div style=\"text-align: center\">\n%s</div>" contents)))
 
 
+;;;; Clock
+
+(defun org-e-html-clock (clock contents info)
+  "Transcode a CLOCK element from Org to HTML.
+CONTENTS is nil.  INFO is a plist used as a communication
+channel."
+  (format "<p>
+<span class=\"timestamp-wrapper\">
+<span class=\"timestamp-kwd\">%s</span> <span class=\"timestamp\">%s</span>%s
+</span>
+</p>"
+	  org-clock-string
+	  (org-translate-time (org-element-property :value clock))
+	  (let ((time (org-element-property :time clock)))
+	    (and time (format " <span class=\"timestamp\">(%s)</span>" time)))))
+
+
 ;;;; Code
 
 (defun org-e-html-code (code contents info)
@@ -2634,6 +2651,34 @@ contextual information."
   text)
 
 
+;; Planning
+
+(defun org-e-html-planning (planning contents info)
+  "Transcode a PLANNING element from Org to HTML.
+CONTENTS is nil.  INFO is a plist used as a communication
+channel."
+  (let ((span-fmt "<span class=\"timestamp-kwd\">%s</span> <span class=\"timestamp\">%s</span>"))
+    (format
+     "<p><span class=\"timestamp-wrapper\">%s</span></p>"
+     (mapconcat
+      'identity
+      (delq nil
+	    (list
+	     (let ((closed (org-element-property :closed planning)))
+	       (when closed
+		 (format span-fmt org-closed-string
+			 (org-translate-time closed))))
+	     (let ((deadline (org-element-property :deadline planning)))
+	       (when deadline
+		 (format span-fmt org-deadline-string
+			 (org-translate-time deadline))))
+	     (let ((scheduled (org-element-property :scheduled planning)))
+	       (when scheduled
+		 (format span-fmt org-scheduled-string
+			 (org-translate-time scheduled))))))
+      " "))))
+
+
 ;;;; Property Drawer
 
 (defun org-e-html-property-drawer (property-drawer contents info)
@@ -2939,18 +2984,9 @@ information."
   "Transcode a TIME-STAMP object from Org to HTML.
 CONTENTS is nil.  INFO is a plist holding contextual
 information."
-  (let ((value (org-element-property :value time-stamp))
-        (type (org-element-property :type time-stamp))
-        (appt-type (org-element-property :appt-type time-stamp)))
-    (setq value (org-translate-time (org-export-secondary-string value info)))
-    (setq appt-type (case appt-type
-		      (scheduled org-scheduled-string)
-		      (deadline org-deadline-string)
-		      (closed org-closed-string)))
-    (format "<span class=\"timestamp-wrapper\">%s%s</span>"
-	    (if (not appt-type) ""
-		(format "<span class=\"timestamp-kwd\">%s</span> " appt-type))
-	    (format "<span class=\"timestamp\">%s</span>" value))))
+  (let ((value (org-translate-time (org-element-property :value time-stamp))))
+    (format "<span class=\"timestamp-wrapper\"><span class=\"timestamp\">%s</span></span>"
+	    value)))
 
 
 ;;;; Underline

+ 69 - 27
contrib/lisp/org-e-latex.el

@@ -19,9 +19,9 @@
 ;; along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
 ;;; Commentary:
-
+;;
 ;; This library implements a LaTeX back-end for Org generic exporter.
-
+;;
 ;; To test it, run
 ;;
 ;;   M-: (org-export-to-buffer 'e-latex "*Test e-LaTeX*") RET
@@ -29,7 +29,7 @@
 ;; in an org-mode buffer then switch to the buffer to see the LaTeX
 ;; export.  See contrib/lisp/org-export.el for more details on how
 ;; this exporter works.
-
+;;
 ;; It introduces three new buffer keywords: "LATEX_CLASS",
 ;; "LATEX_CLASS_OPTIONS" and "LATEX_HEADER".
 
@@ -941,6 +941,11 @@ holding export options."
 
 ;;; Transcode Functions
 
+;;;; Babel Call
+;;
+;; Babel Calls are ignored.
+
+
 ;;;; Bold
 
 (defun org-e-latex-bold (bold contents info)
@@ -961,6 +966,22 @@ holding contextual information."
    (format "\\begin{center}\n%s\\end{center}" contents)))
 
 
+;;;; Clock
+
+(defun org-e-latex-clock (clock contents info)
+  "Transcode a CLOCK element from Org to LaTeX.
+CONTENTS is nil.  INFO is a plist holding contextual
+information."
+  (concat
+   "\\noindent"
+   (format "\\textbf{%s} " org-clock-string)
+   (format org-e-latex-inactive-timestamp-format
+	   (concat (org-translate-time (org-element-property :value clock))
+		   (let ((time (org-element-property :time clock)))
+		     (and time (format " (%s)" time)))))
+   "\\\\"))
+
+
 ;;;; Code
 
 (defun org-e-latex-code (code contents info)
@@ -971,12 +992,12 @@ channel."
 
 
 ;;;; Comment
-
+;;
 ;; Comments are ignored.
 
 
 ;;;; Comment Block
-
+;;
 ;; Comment Blocks are ignored.
 
 
@@ -1059,7 +1080,7 @@ CONTENTS is nil.  INFO is a plist holding contextual information."
 
 
 ;;;; Footnote Definition
-
+;;
 ;; Footnote Definitions are ignored.
 
 
@@ -1228,7 +1249,7 @@ CONTENTS is nil.  INFO is a plist holding contextual information."
 
 
 ;;;; Inline Babel Call
-
+;;
 ;; Inline Babel Calls are ignored.
 
 
@@ -1571,11 +1592,6 @@ INFO is a plist holding contextual information.  See
      (t (format "\\texttt{%s}" desc)))))
 
 
-;;;; Babel Call
-
-;; Babel Calls are ignored.
-
-
 ;;;; Macro
 
 (defun org-e-latex-macro (macro contents info)
@@ -1669,6 +1685,40 @@ contextual information."
   text)
 
 
+;;;; Planning
+
+(defun org-e-latex-planning (planning contents info)
+  "Transcode a PLANNING element from Org to LaTeX.
+CONTENTS is nil.  INFO is a plist holding contextual
+information."
+  (concat
+   "\\noindent"
+   (mapconcat
+    'identity
+    (delq nil
+	  (list
+	   (let ((closed (org-element-property :closed planning)))
+	     (when closed
+	       (concat
+		(format "\\textbf{%s} " org-closed-string)
+		(format org-e-latex-inactive-timestamp-format
+			(org-translate-time closed)))))
+	   (let ((deadline (org-element-property :deadline planning)))
+	     (when deadline
+	       (concat
+		(format "\\textbf{%s} " org-deadline-string)
+		(format org-e-latex-active-timestamp-format
+			(org-translate-time deadline)))))
+	   (let ((scheduled (org-element-property :scheduled planning)))
+	     (when scheduled
+	       (concat
+		(format "\\textbf{%s} " org-scheduled-string)
+		(format org-e-latex-active-timestamp-format
+			(org-translate-time scheduled)))))))
+    " ")
+   "\\\\"))
+
+
 ;;;; Property Drawer
 
 (defun org-e-latex-property-drawer (property-drawer contents info)
@@ -2113,21 +2163,13 @@ information."
   "Transcode a TIME-STAMP object from Org to LaTeX.
 CONTENTS is nil.  INFO is a plist holding contextual
 information."
-  (let ((value (org-element-property :value time-stamp))
-	(type (org-element-property :type time-stamp))
-	(appt-type (org-element-property :appt-type time-stamp)))
-    (concat (cond ((eq appt-type 'scheduled)
-		   (format "\\textbf{\\textsc{%s}} " org-scheduled-string))
-		  ((eq appt-type 'deadline)
-		   (format "\\textbf{\\textsc{%s}} " org-deadline-string))
-		  ((eq appt-type 'closed)
-		   (format "\\textbf{\\textsc{%s}} " org-closed-string)))
-	    (cond ((memq type '(active active-range))
-		   (format org-e-latex-active-timestamp-format value))
-		  ((memq type '(inactive inactive-range))
-		   (format org-e-latex-inactive-timestamp-format value))
-		  (t
-		   (format org-e-latex-diary-timestamp-format value))))))
+  (let ((value (org-translate-time (org-element-property :value time-stamp)))
+	(type (org-element-property :type time-stamp)))
+    (cond ((memq type '(active active-range))
+	   (format org-e-latex-active-timestamp-format value))
+	  ((memq type '(inactive inactive-range))
+	   (format org-e-latex-inactive-timestamp-format value))
+	  (t (format org-e-latex-diary-timestamp-format value)))))
 
 
 ;;;; Underline

+ 49 - 30
contrib/lisp/org-e-odt.el

@@ -2947,6 +2947,22 @@ holding contextual information."
   (org-e-odt--wrap-label center-block contents))
 
 
+;;;; Clock
+
+(defun org-e-odt-clock (clock contents info)
+  "Transcode a CLOCK element from Org to HTML.
+CONTENTS is nil.  INFO is a plist used as a communication
+channel."
+  (org-e-odt-format-fontify
+   (concat (org-e-odt-format-fontify org-clock-string "timestamp-kwd")
+	   (org-e-odt-format-fontify
+	    (concat (org-translate-time (org-element-property :value clock))
+		    (let ((time (org-element-property :time clock)))
+		      (and time (format " (%s)" time))))
+	    "timestamp"))
+   "timestamp-wrapper"))
+
+
 ;;;; Code
 
 (defun org-e-odt-code (code contents info)
@@ -3759,6 +3775,32 @@ contextual information."
   text)
 
 
+;;;; Planning
+
+(defun org-e-odt-planning (planning contents info)
+  "Transcode a PLANNING element from Org to HTML.
+CONTENTS is nil.  INFO is a plist used as a communication
+channel."
+  (org-e-odt-format-fontify
+   (concat
+    (let ((closed (org-element-property :closed planning)))
+      (when closed
+	(concat (org-e-odt-format-fontify org-closed-string "timestamp-kwd")
+		(org-e-odt-format-fontify (org-translate-time closed)
+					  "timestamp"))))
+    (let ((deadline (org-element-property :deadline planning)))
+      (when deadline
+	(concat (org-e-odt-format-fontify org-deadline-string "timestamp-kwd")
+		(org-e-odt-format-fontify (org-translate-time deadline)
+					  "timestamp"))))
+    (let ((scheduled (org-element-property :scheduled planning)))
+      (when scheduled
+	(concat (org-e-odt-format-fontify org-scheduled-string "timestamp-kwd")
+		(org-e-odt-format-fontify (org-translate-time scheduled)
+					  "timestamp")))))
+   "timestamp-wrapper"))
+
+
 ;;;; Property Drawer
 
 (defun org-e-odt-property-drawer (property-drawer contents info)
@@ -4108,36 +4150,13 @@ information."
 
 (defun org-e-odt-time-stamp (time-stamp contents info)
   "Transcode a TIME-STAMP object from Org to HTML.
-CONTENTS is nil.  INFO is a plist holding contextual
-information."
-  ;; (let ((value (org-element-property :value time-stamp))
-  ;; 	(type (org-element-property :type time-stamp))
-  ;; 	(appt-type (org-element-property :appt-type time-stamp)))
-  ;;   (concat (cond ((eq appt-type 'scheduled)
-  ;; 		   (format "\\textbf{\\textsc{%s}} " org-scheduled-string))
-  ;; 		  ((eq appt-type 'deadline)
-  ;; 		   (format "\\textbf{\\textsc{%s}} " org-deadline-string))
-  ;; 		  ((eq appt-type 'closed)
-  ;; 		   (format "\\textbf{\\textsc{%s}} " org-closed-string)))
-  ;; 	    (cond ((memq type '(active active-range))
-  ;; 		   (format org-e-odt-active-timestamp-format value))
-  ;; 		  ((memq type '(inactive inactive-range))
-  ;; 		   (format org-e-odt-inactive-timestamp-format value))
-  ;; 		  (t
-  ;; 		   (format org-e-odt-diary-timestamp-format value)))))
-  (let ((value (org-element-property :value time-stamp))
-        (type (org-element-property :type time-stamp))
-        (appt-type (org-element-property :appt-type time-stamp)))
-    (setq value (org-export-secondary-string value info))
-    (org-e-odt-format-fontify
-     (concat
-      (org-e-odt-format-fontify
-       (cond ((eq appt-type 'scheduled) org-scheduled-string)
-	     ((eq appt-type 'deadline) org-deadline-string)
-	     ((eq appt-type 'closed) org-closed-string)) "timestamp-kwd")
-      ;; FIXME: (org-translate-time value)
-      (org-e-odt-format-fontify value "timestamp"))
-     "timestamp-wrapper")))
+CONTENTS is nil.  INFO is a plist used as a communication
+channel."
+  (org-e-odt-format-fontify
+   (org-e-odt-format-fontify
+    (org-translate-time (org-element-property :value time-stamp))
+    "timestamp")
+   "timestamp-wrapper"))
 
 
 ;;;; Underline

+ 144 - 106
contrib/lisp/org-export.el

@@ -19,33 +19,33 @@
 ;; along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
 ;;; Commentary:
-
+;;
 ;; This library implements a generic export engine for Org, built on
 ;; its syntactical parser: Org Elements.
-
+;;
 ;; Besides that parser, the generic exporter is made of three distinct
 ;; parts:
-
+;;
 ;; - The communication channel consists in a property list, which is
 ;;   created and updated during the process.  Its use is to offer
 ;;   every piece of information, would it be about initial environment
 ;;   or contextual data, all in a single place.  The exhaustive list
 ;;   of properties is given in "The Communication Channel" section of
 ;;   this file.
-
+;;
 ;; - The transcoder walks the parse tree, ignores or treat as plain
 ;;   text elements and objects according to export options, and
 ;;   eventually calls back-end specific functions to do the real
 ;;   transcoding, concatenating their return value along the way.
-
+;;
 ;; - The filter system is activated at the very beginning and the very
 ;;   end of the export process, and each time an element or an object
 ;;   has been converted.  It is the entry point to fine-tune standard
 ;;   output from back-end transcoders.
-
+;;
 ;; The core function is `org-export-as'.  It returns the transcoded
 ;; buffer as a string.
-
+;;
 ;; In order to derive an exporter out of this generic implementation,
 ;; one can define a transcode function for each element or object.
 ;; Such function should return a string for the corresponding element,
@@ -54,21 +54,21 @@
 ;; 1. the element or object itself,
 ;; 2. its contents, or nil when it isn't recursive,
 ;; 3. the property list used as a communication channel.
-
+;;
 ;; If no such function is found, that element or object type will
 ;; simply be ignored, along with any separating blank line.  The same
 ;; will happen if the function returns the nil value.  If that
 ;; function returns the empty string, the type will be ignored, but
 ;; the blank lines will be kept.
-
+;;
 ;; Contents, when not nil, are stripped from any global indentation
 ;; (although the relative one is preserved).  They also always end
 ;; with a single newline character.
-
+;;
 ;; These functions must follow a strict naming convention:
 ;; `org-BACKEND-TYPE' where, obviously, BACKEND is the name of the
 ;; export back-end and TYPE the type of the element or object handled.
-
+;;
 ;; Moreover, two additional functions can be defined.  On the one
 ;; hand, `org-BACKEND-template' returns the final transcoded string,
 ;; and can be used to add a preamble and a postamble to document's
@@ -77,14 +77,14 @@
 ;; `org-BACKEND-plain-text', when defined, is to be called on every
 ;; text not recognized as an element or an object.  It must accept two
 ;; arguments: the text string and the information channel.
-
+;;
 ;; Any back-end can define its own variables.  Among them, those
 ;; customizables should belong to the `org-export-BACKEND' group.
 ;; Also, a special variable, `org-BACKEND-option-alist', allows to
 ;; define buffer keywords and "#+options:" items specific to that
 ;; back-end.  See `org-export-option-alist' for supported defaults and
 ;; syntax.
-
+;;
 ;; Tools for common tasks across back-ends are implemented in the
 ;; penultimate part of this file.  A dispatcher for standard back-ends
 ;; is provided in the last one.
@@ -102,7 +102,7 @@
 
 
 ;;; Internal Variables
-
+;;
 ;; Among internal variables, the most important is
 ;; `org-export-option-alist'.  This variable define the global export
 ;; options, shared between every exporter, and how they are acquired.
@@ -127,6 +127,7 @@
     (: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)
     (:with-creator nil "creator" org-export-with-creator)
     (:with-drawers nil "d" org-export-with-drawers)
     (:with-email nil "email" org-export-with-email)
@@ -134,6 +135,7 @@
     (:with-entities nil "e" org-export-with-entities)
     (:with-fixed-width nil ":" org-export-with-fixed-width)
     (:with-footnotes nil "f" org-export-with-footnotes)
+    (: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-sub-superscript nil "^" org-export-with-sub-superscripts)
@@ -180,6 +182,7 @@ way they are handled must be hard-coded into
   '((:filter-bold . org-export-filter-bold-functions)
     (:filter-babel-call . org-export-filter-babel-call-functions)
     (:filter-center-block . org-export-filter-center-block-functions)
+    (:filter-clock . org-export-filter-clock-functions)
     (:filter-code . org-export-filter-code-functions)
     (:filter-comment . org-export-filter-comment-functions)
     (:filter-comment-block . org-export-filter-comment-block-functions)
@@ -210,6 +213,7 @@ way they are handled must be hard-coded into
     (:filter-parse-tree . org-export-filter-parse-tree-functions)
     (:filter-plain-list . org-export-filter-plain-list-functions)
     (:filter-plain-text . org-export-filter-plain-text-functions)
+    (:filter-planning . org-export-filter-planning-functions)
     (:filter-property-drawer . org-export-filter-property-drawer-functions)
     (:filter-quote-block . org-export-filter-quote-block-functions)
     (:filter-quote-section . org-export-filter-quote-section-functions)
@@ -259,9 +263,9 @@ rules.")
 
 
 ;;; User-configurable Variables
-
+;;
 ;; Configuration for the masses.
-
+;;
 ;; They should never be accessed directly, as their value is to be
 ;; stored in a property list (cf. `org-export-option-alist').
 ;; Back-ends will read their value from there instead.
@@ -299,6 +303,13 @@ e.g. \"author:nil\"."
   :group 'org-export-general
   :type 'boolean)
 
+(defcustom org-export-with-clocks nil
+  "Non-nil means export CLOCK keywords.
+This option can also be set with the #+OPTIONS line,
+e.g. \"c:t\"."
+  :group 'org-export-general
+  :type 'boolean)
+
 (defcustom org-export-with-creator 'comment
   "Non-nil means the postamble should contain a creator sentence.
 
@@ -430,6 +441,13 @@ e.g. \"e:nil\"."
   :group 'org-export-general
   :type 'boolean)
 
+(defcustom org-export-with-planning nil
+  "Non-nil means include planning info in export.
+This option can also be set with the #+OPTIONS: line,
+e.g. \"p:t\"."
+  :group 'org-export-general
+  :type 'boolean)
+
 (defcustom org-export-with-priority nil
   "Non-nil means include priority cookies in export.
 
@@ -658,10 +676,10 @@ standard mode."
 
 
 ;;; The Communication Channel
-
+;;
 ;; During export process, every function has access to a number of
 ;; properties.  They are of three types:
-
+;;
 ;; 1. Environment options are collected once at the very beginning of
 ;;    the process, out of the original buffer and configuration.
 ;;    Collecting them is handled by `org-export-get-environment'
@@ -676,40 +694,40 @@ standard mode."
 ;; 3. Local options are updated during parsing, and their value
 ;;    depends on the level of recursion.  For now, only `:ignore-list'
 ;;    belongs to that category.
-
+;;
 ;; Here is the full list of properties available during transcode
 ;; process, with their category (option, tree or local) and their
 ;; value type.
-
+;;
 ;; + `:author' :: Author's name.
 ;;   - category :: option
 ;;   - type :: string
-
+;;
 ;; + `:back-end' :: Current back-end used for transcoding.
 ;;   - category :: tree
 ;;   - type :: symbol
-
+;;
 ;; + `:creator' :: String to write as creation information.
 ;;   - category :: option
 ;;   - type :: string
-
+;;
 ;; + `:date' :: String to use as date.
 ;;   - category :: option
 ;;   - type :: string
-
+;;
 ;; + `:description' :: Description text for the current data.
 ;;   - category :: option
 ;;   - type :: string
-
+;;
 ;; + `:email' :: Author's email.
 ;;   - category :: option
 ;;   - type :: string
-
+;;
 ;; + `:exclude-tags' :: Tags for exclusion of subtrees from export
 ;;      process.
 ;;   - category :: option
 ;;   - type :: list of strings
-
+;;
 ;; + `:footnote-definition-alist' :: Alist between footnote labels and
 ;;     their definition, as parsed data.  Only non-inlined footnotes
 ;;     are represented in this alist.  Also, every definition isn't
@@ -721,152 +739,156 @@ standard mode."
 ;;     `org-export-get-footnote-definition' instead.
 ;;   - category :: option
 ;;   - type :: alist (STRING . LIST)
-
+;;
 ;; + `:headline-levels' :: Maximum level being exported as an
 ;;      headline.  Comparison is done with the relative level of
 ;;      headlines in the parse tree, not necessarily with their
 ;;      actual level.
 ;;   - category :: option
 ;;   - type :: integer
-
+;;
 ;; + `:headline-offset' :: Difference between relative and real level
 ;;      of headlines in the parse tree.  For example, a value of -1
 ;;      means a level 2 headline should be considered as level
 ;;      1 (cf. `org-export-get-relative-level').
 ;;   - category :: tree
 ;;   - type :: integer
-
+;;
 ;; + `:headline-numbering' :: Alist between headlines and their
 ;;      numbering, as a list of numbers
 ;;      (cf. `org-export-get-headline-number').
 ;;   - category :: tree
 ;;   - type :: alist (INTEGER . LIST)
-
+;;
 ;; + `:ignore-list' :: List of elements and objects that should be
 ;;      ignored during export.
 ;;   - category :: local
 ;;   - type :: list of elements and objects
-
+;;
 ;; + `:input-file' :: Full path to input file, if any.
 ;;   - category :: option
 ;;   - type :: string or nil
-
+;;
 ;; + `:keywords' :: List of keywords attached to data.
 ;;   - category :: option
 ;;   - type :: string
-
+;;
 ;; + `:language' :: Default language used for translations.
 ;;   - category :: option
 ;;   - type :: string
-
-;; + `:macro-input-file' :: Macro returning file name of input file,
-;;   or nil.
-;;   - category :: option
-;;   - type :: string or nil
-
+;;
 ;; + `:parse-tree' :: Whole parse tree, available at any time during
 ;;                   transcoding.
 ;;   - category :: global
 ;;   - type :: list (as returned by `org-element-parse-buffer')
-
+;;
 ;; + `:preserve-breaks' :: Non-nil means transcoding should preserve
 ;;      all line breaks.
 ;;   - category :: option
 ;;   - type :: symbol (nil, t)
-
+;;
 ;; + `:section-numbers' :: Non-nil means transcoding should add
 ;;      section numbers to headlines.
 ;;   - category :: option
 ;;   - type :: symbol (nil, t)
-
+;;
 ;; + `:select-tags' :: List of tags enforcing inclusion of sub-trees
 ;;                    in transcoding.  When such a tag is present,
 ;;                    subtrees without it are de facto excluded from
 ;;                    the process.  See `use-select-tags'.
 ;;   - category :: option
 ;;   - type :: list of strings
-
+;;
 ;; + `:target-list' :: List of targets encountered in the parse tree.
 ;;                    This is used to partly resolve "fuzzy" links
 ;;                    (cf. `org-export-resolve-fuzzy-link').
 ;;   - category :: tree
 ;;   - type :: list of strings
-
+;;
 ;; + `:time-stamp-file' :: Non-nil means transcoding should insert
 ;;      a time stamp in the output.
 ;;   - category :: option
 ;;   - type :: symbol (nil, t)
-
+;;
 ;; + `:with-archived-trees' :: Non-nil when archived subtrees should
 ;;      also be transcoded.  If it is set to the `headline' symbol,
 ;;      only the archived headline's name is retained.
 ;;   - category :: option
 ;;   - type :: symbol (nil, t, `headline')
-
+;;
 ;; + `:with-author' :: Non-nil means author's name should be included
 ;;                    in the output.
 ;;   - category :: option
 ;;   - type :: symbol (nil, t)
-
+;;
+;; + `:with-clocks' :: Non-nild means clock keywords should be exported.
+;;   - category :: option
+;;   - type :: symbol (nil, t)
+;;
 ;; + `:with-creator' :: Non-nild means a creation sentence should be
 ;;      inserted at the end of the transcoded string.  If the value
 ;;      is `comment', it should be commented.
 ;;   - category :: option
 ;;   - type :: symbol (`comment', nil, t)
-
+;;
 ;; + `:with-drawers' :: Non-nil means drawers should be exported.  If
 ;;      its value is a list of names, only drawers with such names
 ;;      will be transcoded.
 ;;   - category :: option
 ;;   - type :: symbol (nil, t) or list of strings
-
+;;
 ;; + `:with-email' :: Non-nil means output should contain author's
 ;;                   email.
 ;;   - category :: option
 ;;   - type :: symbol (nil, t)
-
+;;
 ;; + `:with-emphasize' :: Non-nil means emphasized text should be
 ;;      interpreted.
 ;;   - category :: option
 ;;   - type :: symbol (nil, t)
-
+;;
 ;; + `:with-fixed-width' :: Non-nil if transcoder should interpret
 ;;      strings starting with a colon as a fixed-with (verbatim) area.
 ;;   - category :: option
 ;;   - type :: symbol (nil, t)
-
+;;
 ;; + `:with-footnotes' :: Non-nil if transcoder should interpret
 ;;      footnotes.
 ;;   - category :: option
 ;;   - type :: symbol (nil, t)
-
+;;
+;; + `:with-plannings' :: Non-nil means transcoding should include
+;;      planning info.
+;;   - category :: option
+;;   - type :: symbol (nil, t)
+;;
 ;; + `:with-priority' :: Non-nil means transcoding should include
 ;;      priority cookies.
 ;;   - category :: option
 ;;   - type :: symbol (nil, t)
-
+;;
 ;; + `:with-special-strings' :: Non-nil means transcoding should
 ;;      interpret special strings in plain text.
 ;;   - category :: option
 ;;   - type :: symbol (nil, t)
-
+;;
 ;; + `:with-sub-superscript' :: Non-nil means transcoding should
 ;;      interpret subscript and superscript.  With a value of "{}",
 ;;      only interpret those using curly brackets.
 ;;   - category :: option
 ;;   - type :: symbol (nil, {}, t)
-
+;;
 ;; + `:with-tables' :: Non-nil means transcoding should interpret
 ;;                    tables.
 ;;   - category :: option
 ;;   - type :: symbol (nil, t)
-
+;;
 ;; + `:with-tags' :: Non-nil means transcoding should keep tags in
 ;;                  headlines.  A `not-in-toc' value will remove them
 ;;                  from the table of contents, if any, nonetheless.
 ;;   - category :: option
 ;;   - type :: symbol (nil, t, `not-in-toc')
-
+;;
 ;; + `:with-tasks' :: Non-nil means transcoding should include
 ;;                   headlines with a TODO keyword.  A `todo' value
 ;;                   will only include headlines with a todo type
@@ -876,19 +898,19 @@ standard mode."
 ;;                   be kept.
 ;;   - category :: option
 ;;   - type :: symbol (t, todo, done, nil) or list of strings
-
+;;
 ;; + `:with-timestamps' :: Non-nil means transcoding should include
 ;;      time stamps and associated keywords.  Otherwise, completely
 ;;      remove them.
 ;;   - category :: option
 ;;   - type :: symbol: (t, nil)
-
+;;
 ;; + `:with-toc' :: Non-nil means that a table of contents has to be
 ;;                 added to the output.  An integer value limits its
 ;;                 depth.
 ;;   - category :: option
 ;;   - type :: symbol (nil, t or integer)
-
+;;
 ;; + `:with-todo-keywords' :: Non-nil means transcoding should
 ;;      include TODO keywords.
 ;;   - category :: option
@@ -896,7 +918,7 @@ standard mode."
 
 
 ;;;; Environment Options
-
+;;
 ;; Environment options encompass all parameters defined outside the
 ;; scope of the parsed data.  They come from five sources, in
 ;; increasing precedence order:
@@ -906,19 +928,19 @@ standard mode."
 ;; - Options keyword symbols,
 ;; - Buffer keywords,
 ;; - Subtree properties.
-
+;;
 ;; The central internal function with regards to environment options
 ;; is `org-export-get-environment'.  It updates global variables with
 ;; "#+BIND:" keywords, then retrieve and prioritize properties from
 ;; the different sources.
-
+;;
 ;;  The internal functions doing the retrieval are:
 ;;  `org-export-get-global-options',
 ;;  `org-export-get-buffer-attributes',
 ;;  `org-export-parse-option-keyword',
 ;;  `org-export-get-subtree-options' and
 ;;  `org-export-get-inbuffer-options'
-
+;;
 ;; Also, `org-export-confirm-letbind' and `org-export-install-letbind'
 ;; take care of the part relative to "#+BIND:" keywords.
 
@@ -1254,11 +1276,11 @@ retrieved."
 
 
 ;;;; Tree Properties
-
+;;
 ;; Tree properties are infromation extracted from parse tree.  They
 ;; are initialized at the beginning of the transcoding process by
 ;; `org-export-collect-tree-properties'.
-
+;;
 ;; Dedicated functions focus on computing the value of specific tree
 ;; properties during initialization.  Thus,
 ;; `org-export-populate-ignore-list' lists elements and objects that
@@ -1478,22 +1500,26 @@ OPTIONS is the plist holding export options."
     (table-cell
      (and (org-export-table-has-special-column-p
 	   (nth 1 (org-export-get-genealogy blob options)))
-	  (not (org-export-get-previous-element blob options))))))
+	  (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)))))
 
 
 
 ;;; The Transcoder
-
+;;
 ;; This function reads Org data (obtained with, i.e.
 ;; `org-element-parse-buffer') and transcodes it into a specified
 ;; back-end output.  It takes care of updating local properties,
 ;; filtering out elements or objects according to export options and
 ;; organizing the output blank lines and white space are preserved.
-
+;;
 ;; Though, this function is inapropriate for secondary strings, which
 ;; require a fresh copy of the plist passed as INFO argument.  Thus,
 ;; `org-export-secondary-string' is provided for that specific task.
-
+;;
 ;; Internally, three functions handle the filtering of objects and
 ;; elements during the export.  In particular,
 ;; `org-export-ignore-element' marks an element or object so future
@@ -1660,7 +1686,7 @@ Any element in `:ignore-list' will be skipped when using
 
 
 ;;; The Filter System
-
+;;
 ;; Filters allow end-users to tweak easily the transcoded output.
 ;; They are the functional counterpart of hooks, as every filter in
 ;; a set is applied to the return value of the previous one.
@@ -1737,6 +1763,12 @@ Each filter is called with three arguments: the transcoded data,
 as a string, the back-end, as a symbol, and the communication
 channel, as a plist.  It must return a string or nil.")
 
+(defvar org-export-filter-clock-functions nil
+  "List of functions applied to a transcoded clock.
+Each filter is called with three arguments: the transcoded data,
+as a string, the back-end, as a symbol, and the communication
+channel, as a plist.  It must return a string or nil.")
+
 (defvar org-export-filter-drawer-functions nil
   "List of functions applied to a transcoded drawer.
 Each filter is called with three arguments: the transcoded data,
@@ -1839,6 +1871,12 @@ Each filter is called with three arguments: the transcoded data,
 as a string, the back-end, as a symbol, and the communication
 channel, as a plist.  It must return a string or nil.")
 
+(defvar org-export-filter-planning-functions nil
+  "List of functions applied to a transcoded planning.
+Each filter is called with three arguments: the transcoded data,
+as a string, the back-end, as a symbol, and the communication
+channel, as a plist.  It must return a string or nil.")
+
 (defvar org-export-filter-property-drawer-functions nil
   "List of functions applied to a transcoded property-drawer.
 Each filter is called with three arguments: the transcoded data,
@@ -2070,21 +2108,21 @@ Return the updated communication channel."
 
 
 ;;; Core functions
-
+;;
 ;; This is the room for the main function, `org-export-as', along with
 ;; its derivatives, `org-export-to-buffer' and `org-export-to-file'.
 ;; They differ only by the way they output the resulting code.
-
+;;
 ;; `org-export-output-file-name' is an auxiliary function meant to be
 ;; used with `org-export-to-file'.  With a given extension, it tries
 ;; to provide a canonical file name to write export output to.
-
+;;
 ;; Note that `org-export-as' doesn't really parse the current buffer,
 ;; but a copy of it (with the same buffer-local variables and
 ;; visibility), where include keywords are expanded and Babel blocks
 ;; are executed, if appropriate.
 ;; `org-export-with-current-buffer-copy' macro prepares that copy.
-
+;;
 ;; File inclusion is taken care of by
 ;; `org-export-expand-include-keyword' and
 ;; `org-export-prepare-file-contents'.  Structure wise, including
@@ -2461,17 +2499,17 @@ file should have."
 
 
 ;;; Tools For Back-Ends
-
+;;
 ;; A whole set of tools is available to help build new exporters.  Any
 ;; function general enough to have its use across many back-ends
 ;; should be added here.
-
+;;
 ;; As of now, functions operating on footnotes, headlines, links,
 ;; macros, references, src-blocks, tables and tables of contents are
 ;; implemented.
 
 ;;;; For Export Snippets
-
+;;
 ;; Every export snippet is transmitted to the back-end.  Though, the
 ;; latter will only retain one type of export-snippet, ignoring
 ;; others, based on the former's target back-end.  The function
@@ -2489,16 +2527,16 @@ applied."
 
 
 ;;;; For Footnotes
-
+;;
 ;; `org-export-collect-footnote-definitions' is a tool to list
 ;; actually used footnotes definitions in the whole parse tree, or in
 ;; an headline, in order to add footnote listings throughout the
 ;; transcoded data.
-
+;;
 ;; `org-export-footnote-first-reference-p' is a predicate used by some
 ;; back-ends, when they need to attach the footnote definition only to
 ;; the first occurrence of the corresponding label.
-
+;;
 ;; `org-export-get-footnote-definition' and
 ;; `org-export-get-footnote-number' provide easier access to
 ;; additional information relative to a footnote reference.
@@ -2625,14 +2663,14 @@ INFO is the plist used as a communication channel."
 
 
 ;;;; For Headlines
-
+;;
 ;; `org-export-get-relative-level' is a shortcut to get headline
 ;; level, relatively to the lower headline level in the parsed tree.
-
+;;
 ;; `org-export-get-headline-number' returns the section number of an
 ;; headline, while `org-export-number-to-roman' allows to convert it
 ;; to roman numbers.
-
+;;
 ;; `org-export-low-level-p', `org-export-first-sibling-p' and
 ;; `org-export-last-sibling-p' are three useful predicates when it
 ;; comes to fulfill the `:headline-levels' property.
@@ -2699,24 +2737,24 @@ INFO is the plist used as a communication channel."
 
 
 ;;;; For Links
-
+;;
 ;; `org-export-solidify-link-text' turns a string into a safer version
 ;; for links, replacing most non-standard characters with hyphens.
-
+;;
 ;; `org-export-get-coderef-format' returns an appropriate format
 ;; string for coderefs.
-
+;;
 ;; `org-export-inline-image-p' returns a non-nil value when the link
 ;; provided should be considered as an inline image.
-
+;;
 ;; `org-export-resolve-fuzzy-link' searches destination of fuzzy links
 ;; (i.e. links with "fuzzy" as type) within the parsed tree, and
 ;; returns an appropriate unique identifier when found, or nil.
-
+;;
 ;; `org-export-resolve-id-link' returns the first headline with
 ;; specified id or custom-id in parse tree, or nil when none was
 ;; found.
-
+;;
 ;; `org-export-resolve-coderef' associates a reference to a line
 ;; number in the element it belongs, or returns the reference itself
 ;; when the element isn't numbered.
@@ -2874,7 +2912,7 @@ depending on src-block or example element's switches."
 
 
 ;;;; For Macros
-
+;;
 ;; `org-export-expand-macro' simply takes care of expanding macros.
 
 (defun org-export-expand-macro (macro info)
@@ -2904,7 +2942,7 @@ INFO is a plist holding export options."
 
 
 ;;;; For References
-
+;;
 ;; `org-export-get-ordinal' associates a sequence number to any object
 ;; or element.
 
@@ -2971,22 +3009,22 @@ objects of the same type."
 
 
 ;;;; For Src-Blocks
-
+;;
 ;; `org-export-get-loc' counts number of code lines accumulated in
 ;; src-block or example-block elements with a "+n" switch until
 ;; a given element, excluded.  Note: "-n" switches reset that count.
-
+;;
 ;; `org-export-unravel-code' extracts source code (along with a code
 ;; references alist) from an `element-block' or `src-block' type
 ;; element.
-
+;;
 ;; `org-export-format-code' applies a formatting function to each line
 ;; of code, providing relative line number and code reference when
 ;; appropriate.  Since it doesn't access the original element from
 ;; which the source code is coming, it expects from the code calling
 ;; it to know if lines should be numbered and if code references
 ;; should appear.
-
+;;
 ;; Eventually, `org-export-format-code-default' is a higher-level
 ;; function (it makes use of the two previous functions) which handles
 ;; line numbering and code references inclusion, and returns source
@@ -3150,15 +3188,15 @@ code."
 
 
 ;;;; For Tables
-
+;;
 ;; `org-export-table-has-special-column-p' and
 ;; `org-export-table-row-is-special-p' are predicates used to look for
 ;; meta-information about the table structure.
-
+;;
 ;; `org-export-table-cell-width', `org-export-table-cell-alignment'
 ;; and `org-export-table-cell-borders' extract information from
 ;; a table-cell element.
-
+;;
 ;; `org-export-table-dimensions' gives the number on rows and columns
 ;; in the table, ignoring horizontal rules and special columns.
 ;; `org-export-table-cell-address', given a table-cell object, returns
@@ -3577,11 +3615,11 @@ return nil."
 
 
 ;;;; For Tables Of Contents
-
+;;
 ;; `org-export-collect-headlines' builds a list of all exportable
 ;; headline elements, maybe limited to a certain depth.  One can then
 ;; easily parse it and transcode it.
-
+;;
 ;; Building lists of tables, figures or listings is quite similar.
 ;; Once the generic function `org-export-collect-elements' is defined,
 ;; `org-export-collect-tables', `org-export-collect-figures' and
@@ -3662,7 +3700,7 @@ affiliated keyword."
 
 
 ;;;; Topology
-
+;;
 ;; Here are various functions to retrieve information about the
 ;; neighbourhood of a given element or object.  Neighbours of interest
 ;; are direct parent (`org-export-get-parent'), parent headline
@@ -3670,7 +3708,7 @@ affiliated keyword."
 ;; (`org-export-get-parent-paragraph'), previous element or object
 ;; (`org-export-get-previous-element') and next element or object
 ;; (`org-export-get-next-element').
-
+;;
 ;; All of these functions are just a specific use of the more generic
 ;; `org-export-get-genealogy', which returns the genealogy relative to
 ;; the element or object.
@@ -3766,7 +3804,7 @@ Return next element or object, a string, or nil."
 
 
 ;;; The Dispatcher
-
+;;
 ;; `org-export-dispatch' is the standard interactive way to start an
 ;; export process.  It uses `org-export-dispatch-ui' as a subroutine
 ;; for its interface.  Most commons back-ends should have an entry in

+ 35 - 5
testing/lisp/test-org-export.el

@@ -207,12 +207,42 @@ already filled in `info'."
     (org-test-with-temp-text ":TEST:\ncontents\n:END:"
       (org-test-with-backend "test"
 	(should (equal (org-export-as 'test nil nil nil '(:with-drawers nil))
-		       "")))))
-  (let ((org-drawers '("TEST")))
-    (org-test-with-temp-text ":TEST:\ncontents\n:END:"
-      (org-test-with-backend "test"
+		       ""))
 	(should (equal (org-export-as 'test nil nil nil '(:with-drawers t))
-		       ":TEST:\ncontents\n:END:\n"))))))
+		       ":TEST:\ncontents\n:END:\n")))))
+  (let ((org-drawers '("FOO" "BAR")))
+    (org-test-with-temp-text ":FOO:\nkeep\n:END:\n:BAR:\nremove\n:END:"
+      (org-test-with-backend "test"
+	(should
+	 (equal (org-export-as 'test nil nil nil '(:with-drawers ("FOO")))
+		":FOO:\nkeep\n:END:\n")))))
+  ;; Timestamps.
+  (org-test-with-temp-text "[2012-04-29 sun. 10:45]"
+    (org-test-with-backend "test"
+      (should
+       (equal (org-export-as 'test nil nil nil '(:with-timestamps t))
+	      "[2012-04-29 sun. 10:45]\n"))
+      (should
+       (equal (org-export-as 'test nil nil nil '(:with-timestamps nil)) ""))))
+  ;; Clocks.
+  (let ((org-clock-string "CLOCK:"))
+    (org-test-with-temp-text "CLOCK: [2012-04-29 sun. 10:45]"
+      (org-test-with-backend "test"
+	(should
+	 (equal (org-export-as 'test nil nil nil '(:with-clocks t))
+		"CLOCK: [2012-04-29 sun. 10:45]\n"))
+	(should
+	 (equal (org-export-as 'test nil nil nil '(:with-clocks nil)) "")))))
+  ;; Plannings.
+  (let ((org-closed-string "CLOSED:"))
+    (org-test-with-temp-text "CLOSED: [2012-04-29 sun. 10:45]"
+      (org-test-with-backend "test"
+	(should
+	 (equal (org-export-as 'test nil nil nil '(:with-plannings t))
+		"CLOSED: [2012-04-29 sun. 10:45]\n"))
+	(should
+	 (equal (org-export-as 'test nil nil nil '(:with-plannings nil))
+		""))))))
 
 (ert-deftest test-org-export/comment-tree ()
   "Test if export process ignores commented trees."