Browse Source

Allow to exclude tasks from being exported

* doc/org.texi (Selective export): Document exclusion of any tasks from
export.
* lisp/org-exp.el (org-export-with-tasks): New option.
(org-export-plist-vars): Add :tasks property.
Carsten Dominik 14 years ago
parent
commit
b4e2ef4cb9
6 changed files with 44 additions and 15 deletions
  1. 8 2
      doc/org.texi
  2. 1 0
      lisp/org-ascii.el
  3. 1 0
      lisp/org-docbook.el
  4. 31 13
      lisp/org-exp.el
  5. 1 0
      lisp/org-html.el
  6. 2 0
      lisp/org-latex.el

+ 8 - 2
doc/org.texi

@@ -9311,6 +9311,7 @@ enabled (default in Emacs 23).
 
 @vindex org-export-select-tags
 @vindex org-export-exclude-tags
+@cindex org-export-with-tasks
 @cindex org-export-with-done-tasks
 You may use tags to select the parts of a document that should be exported,
 or to exclude parts from export.  This behavior is governed by two variables:
@@ -9332,8 +9333,10 @@ Finally, all subtrees that are marked by any of the @emph{exclude} tags will
 be removed from the export buffer.
 @end enumerate
 
-Also, if the variable @code{org-export-with-done-tasks} is @code{nil}, the
-entire subtree of entries starting with a DONE state keyword will be removed.
+If the variable @code{org-export-with-tasks} is nil, all TODO items will be
+removed for export along with the subtree belonging to the item.  If the
+variable @code{org-export-with-done-tasks} is @code{nil}, TODO items will
+still be exported, but items with a DONE state will not be exported.
 
 @node Export options, The export dispatcher, Selective export, Exporting
 @section Export options
@@ -9433,6 +9436,7 @@ toc:       @r{turn on/off table of contents, or set level limit (integer)}
 -:         @r{turn on/off conversion of special strings.}
 f:         @r{turn on/off footnotes like this[1].}
 todo:      @r{turn on/off inclusion of TODO keywords into exported text}
+tasks:     @r{turn on/off inclusion of tasks (TODO items)}
 donetasks: @r{turn on/off inclusion of DONE tasks}
 pri:       @r{turn on/off priority cookies}
 tags:      @r{turn on/off inclusion of tags, may also be @code{not-in-toc}}
@@ -10913,6 +10917,7 @@ respective variable for details.
 @vindex org-export-with-drawers
 @vindex org-export-with-tags
 @vindex org-export-with-todo-keywords
+@vindex org-export-with-tasks
 @vindex org-export-with-done-tasks
 @vindex org-export-with-priority
 @vindex org-export-with-TeX-macros
@@ -10962,6 +10967,7 @@ respective variable for details.
 @item @code{:drawers}               @tab @code{org-export-with-drawers}
 @item @code{:tags}                  @tab @code{org-export-with-tags}
 @item @code{:todo-keywords}         @tab @code{org-export-with-todo-keywords}
+@item @code{:tasks}                 @tab @code{org-export-with-tasks}
 @item @code{:done-tasks}            @tab @code{org-export-with-done-tasks}
 @item @code{:priority}              @tab @code{org-export-with-priority}
 @item @code{:TeX-macros}            @tab @code{org-export-with-TeX-macros}

+ 1 - 0
lisp/org-ascii.el

@@ -303,6 +303,7 @@ publishing directory."
 		  :footnotes (plist-get opt-plist :footnotes)
 		  :timestamps (plist-get opt-plist :timestamps)
 		  :todo-keywords (plist-get opt-plist :todo-keywords)
+		  :tasks (plist-get opt-plist :tasks)
 		  :done-tasks (plist-get opt-plist :done-tasks)
 		  :verbatim-multiline t
 		  :select-tags (plist-get opt-plist :select-tags)

+ 1 - 0
lisp/org-docbook.el

@@ -529,6 +529,7 @@ publishing directory."
 	    (plist-get opt-plist :skip-before-1st-heading)
 	    :drawers (plist-get opt-plist :drawers)
 	    :todo-keywords (plist-get opt-plist :todo-keywords)
+	    :tasks (plist-get opt-plist :tasks)
 	    :done-tasks (plist-get opt-plist :done-tasks)
 	    :tags (plist-get opt-plist :tags)
 	    :priority (plist-get opt-plist :priority)

+ 31 - 13
lisp/org-exp.el

@@ -296,6 +296,12 @@ When nil, remove all these keywords from the export."
   :group 'org-export-general
   :type 'boolean)
 
+(defcustom org-export-with-tasks t
+  "Non-nil means include TODO items for export.
+When nil, remove the entire subtrees belonging to tasks, independent of state."
+  :group 'org-export-general
+  :type 'boolean)
+
 (defcustom org-export-with-done-tasks t
   "Non-nil means include DONE items for export.
 When nil, remove the entire subtrees belonging to DONE tasks."
@@ -627,6 +633,7 @@ table.el tables."
     (:drawers		      "d"	  org-export-with-drawers)
     (:tags		      "tags"	  org-export-with-tags)
     (:todo-keywords	      "todo"	  org-export-with-todo-keywords)
+    (:tasks	              "tasks"     org-export-with-tasks)
     (:done-tasks	      "donetasks" org-export-with-done-tasks)
     (:priority		      "pri"	  org-export-with-priority)
     (:TeX-macros	      "TeX"	  org-export-with-TeX-macros)
@@ -1106,8 +1113,9 @@ on this string to produce the exported version."
       (run-hooks 'org-export-preprocess-after-tree-selection-hook)
 
       ;; Get rid of DONE tasks if that option is configured
-      (unless (plist-get parameters :done-tasks)
-	(org-export-remove-done-tasks))
+      (org-export-remove-tasks
+       (plist-get parameters :tasks)
+       (plist-get parameters :done-tasks))
 
       ;; Change lists ending. Other parts of export may insert blank
       ;; lines and lists' structure could be altered.
@@ -1499,19 +1507,29 @@ removed as well."
 		    (point-max)))
       (delete-region beg end))))
 
-(defun org-export-remove-done-tasks ()
-  "Remove all tasks that are done."
-  (let ((re (concat "^\\*+[ \t]+\\("
-		    (mapconcat 'regexp-quote org-done-keywords "\\|")
-		    "\\)\\($\\|[ \t]\\)"))
+(defun org-export-remove-tasks (tasks done-tasks)
+  "Remove tasks depending on configuration.
+When TASKS is nil, remove all tasks.
+When DONE-TASKS is nil remove the DONE tasks."
+  (unless (and tasks done-tasks)
+    (let ((re (concat "^\\*+[ \t]+\\("
+		      (mapconcat
+		       'regexp-quote
+		       (cond ((not tasks) org-todo-keywords-1)
+			     ((not done-tasks) org-done-keywords))
+		       "\\|")
+		      "\\)\\($\\|[ \t]\\)"))
 	(case-fold-search nil)
 	beg)
-    (goto-char (point-min))
-    (while (re-search-forward re nil t)
-      (org-if-unprotected
-       (setq beg (match-beginning 0))
-       (org-end-of-subtree t t)
-       (delete-region beg (point))))))
+      (goto-char (point-min))
+      (while (re-search-forward re nil t)
+	(org-if-unprotected
+	 (setq beg (match-beginning 0))
+	 (org-end-of-subtree t t)
+	 (if (looking-at "^\\*+[ \t]+END[ \t]*$")
+	     ;; Kill the END line of the inline task
+	     (goto-char (min (point-max) (1+ (match-end 0)))))
+	 (delete-region beg (point)))))))
 
 (defun org-export-remove-archived-trees (export-archived-trees)
   "Remove archived trees.

+ 1 - 0
lisp/org-html.el

@@ -1179,6 +1179,7 @@ PUB-DIR is set, use this as the publishing directory."
 	    (plist-get opt-plist :skip-before-1st-heading)
 	    :drawers (plist-get opt-plist :drawers)
 	    :todo-keywords (plist-get opt-plist :todo-keywords)
+	    :tasks (plist-get opt-plist :tasks)
 	    :done-tasks (plist-get opt-plist :done-tasks)
 	    :tags (plist-get opt-plist :tags)
 	    :priority (plist-get opt-plist :priority)

+ 2 - 0
lisp/org-latex.el

@@ -869,6 +869,7 @@ when PUB-DIR is set, use this as the publishing directory."
 		:drawers (plist-get opt-plist :drawers)
 		:timestamps (plist-get opt-plist :timestamps)
 		:todo-keywords (plist-get opt-plist :todo-keywords)
+		:tasks (plist-get opt-plist :tasks)
 		:done-tasks (plist-get opt-plist :done-tasks)
 		:add-text nil
 		:skip-before-1st-heading skip
@@ -887,6 +888,7 @@ when PUB-DIR is set, use this as the publishing directory."
 	   :drawers (plist-get opt-plist :drawers)
 	   :timestamps (plist-get opt-plist :timestamps)
 	   :todo-keywords (plist-get opt-plist :todo-keywords)
+	   :tasks (plist-get opt-plist :tasks)
 	   :done-tasks (plist-get opt-plist :done-tasks)
 	   :add-text (if (eq to-buffer 'string) nil text)
 	   :skip-before-1st-heading skip