summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCarsten Dominik <carsten.dominik@gmail.com>2011-03-30 00:48:29 +0200
committerCarsten Dominik <carsten.dominik@gmail.com>2011-03-30 00:48:29 +0200
commitb4e2ef4cb9b33909356286ab59b858158cf0c260 (patch)
tree29b249b81f8cffbeaddbd8064ef6375088a02854
parent6d40eb3809d6d293faff6c2bb7a304af0386de9a (diff)
downloadorg-mode-b4e2ef4cb9b33909356286ab59b858158cf0c260.tar.gz
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.
-rw-r--r--doc/org.texi10
-rw-r--r--lisp/org-ascii.el1
-rw-r--r--lisp/org-docbook.el1
-rw-r--r--lisp/org-exp.el44
-rw-r--r--lisp/org-html.el1
-rw-r--r--lisp/org-latex.el2
6 files changed, 44 insertions, 15 deletions
diff --git a/doc/org.texi b/doc/org.texi
index 1c1dc67..4cf90a8 100644
--- a/doc/org.texi
+++ b/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}
diff --git a/lisp/org-ascii.el b/lisp/org-ascii.el
index 47cf31c..de094cc 100644
--- a/lisp/org-ascii.el
+++ b/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)
diff --git a/lisp/org-docbook.el b/lisp/org-docbook.el
index f188c7c..ef7372f 100644
--- a/lisp/org-docbook.el
+++ b/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)
diff --git a/lisp/org-exp.el b/lisp/org-exp.el
index 3e6daa7..5d7d11f 100644
--- a/lisp/org-exp.el
+++ b/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.
diff --git a/lisp/org-html.el b/lisp/org-html.el
index 3564a83..84eaaa1 100644
--- a/lisp/org-html.el
+++ b/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)
diff --git a/lisp/org-latex.el b/lisp/org-latex.el
index ba9d8d1..0b56a99 100644
--- a/lisp/org-latex.el
+++ b/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