diff options
author | Carsten Dominik <carsten.dominik@gmail.com> | 2011-03-29 17:29:24 +0200 |
---|---|---|
committer | Carsten Dominik <carsten.dominik@gmail.com> | 2011-03-29 17:29:24 +0200 |
commit | 6d40eb3809d6d293faff6c2bb7a304af0386de9a (patch) | |
tree | 06fc5119e3f53fe63ccc02567dbe9e14817c5aa0 | |
parent | 35a2ef34003f7eb4e39e45a36221d45ba2f4b464 (diff) | |
download | org-mode-6d40eb3809d6d293faff6c2bb7a304af0386de9a.tar.gz |
Implement export without DONE tasks
* doc/org.texi (Selective export): Document how to exclude DONE tasks
from export.
(Publishing options): Document the properties to be used to turn off
export of DONE tasks.
* lisp/org-ascii.el (org-export-as-ascii):
* lisp/org-docbook.el (org-export-as-docbook):
* lisp/org-html.el (org-export-as-html):
* lisp/org-latex.el (org-export-as-latex): Pass the :done-tasks property
to the export preprocessor.
* lisp/org-exp.el (org-export-with-done-tasks): New option.
(org-export-plist-vars): Add entry for :done-tasks.
(org-export-preprocess-string): Call `org-export-remove-done-tasks'.
(org-export-remove-done-tasks): New function.
-rw-r--r-- | doc/org.texi | 24 | ||||
-rw-r--r-- | lisp/org-ascii.el | 1 | ||||
-rw-r--r-- | lisp/org-docbook.el | 1 | ||||
-rw-r--r-- | lisp/org-exp.el | 25 | ||||
-rw-r--r-- | lisp/org-html.el | 1 | ||||
-rw-r--r-- | lisp/org-latex.el | 2 |
6 files changed, 47 insertions, 7 deletions
diff --git a/doc/org.texi b/doc/org.texi index 6fc848b..1c1dc67 100644 --- a/doc/org.texi +++ b/doc/org.texi @@ -9307,26 +9307,33 @@ enabled (default in Emacs 23). @node Selective export, Export options, Exporting, Exporting @section Selective export -@cindex export, selective by tags +@cindex export, selective by tags or TODO keyword @vindex org-export-select-tags @vindex org-export-exclude-tags +@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: @code{org-export-select-tags} and @code{org-export-exclude-tags}. -Org first checks if any of the @emph{select} tags is present in the buffer. -If yes, all trees that do not carry one of these tags will be excluded. If a -selected tree is a subtree, the heading hierarchy above it will also be -selected for export, but not the text below those headings. +@enumerate +@item +Org first checks if any of the @emph{select} tags is present in the +buffer. If yes, all trees that do not carry one of these tags will be +excluded. If a selected tree is a subtree, the heading hierarchy above it +will also be selected for export, but not the text below those headings. -@noindent +@item If none of the select tags is found, the whole buffer will be selected for export. -@noindent +@item 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. @node Export options, The export dispatcher, Selective export, Exporting @section Export options @@ -9426,6 +9433,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} +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}} <: @r{turn on/off inclusion of any time/date stamps like DEADLINES} @@ -10905,6 +10913,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-done-tasks @vindex org-export-with-priority @vindex org-export-with-TeX-macros @vindex org-export-with-LaTeX-fragments @@ -10953,6 +10962,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{: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} @item @code{:LaTeX-fragments} @tab @code{org-export-with-LaTeX-fragments} diff --git a/lisp/org-ascii.el b/lisp/org-ascii.el index 5727f04..47cf31c 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) + :done-tasks (plist-get opt-plist :done-tasks) :verbatim-multiline t :select-tags (plist-get opt-plist :select-tags) :exclude-tags (plist-get opt-plist :exclude-tags) diff --git a/lisp/org-docbook.el b/lisp/org-docbook.el index 02704c4..f188c7c 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) + :done-tasks (plist-get opt-plist :done-tasks) :tags (plist-get opt-plist :tags) :priority (plist-get opt-plist :priority) :footnotes (plist-get opt-plist :footnotes) diff --git a/lisp/org-exp.el b/lisp/org-exp.el index 3e84314..3e6daa7 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-done-tasks t + "Non-nil means include DONE items for export. +When nil, remove the entire subtrees belonging to DONE tasks." + :group 'org-export-general + :type 'boolean) + (defcustom org-export-with-priority nil "Non-nil means include priority cookies in export. When nil, remove priority cookies for export." @@ -621,6 +627,7 @@ table.el tables." (:drawers "d" org-export-with-drawers) (:tags "tags" org-export-with-tags) (:todo-keywords "todo" org-export-with-todo-keywords) + (:done-tasks "donetasks" org-export-with-done-tasks) (:priority "pri" org-export-with-priority) (:TeX-macros "TeX" org-export-with-TeX-macros) (:LaTeX-fragments "LaTeX" org-export-with-LaTeX-fragments) @@ -1098,6 +1105,10 @@ on this string to produce the exported version." (plist-get parameters :exclude-tags)) (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)) + ;; Change lists ending. Other parts of export may insert blank ;; lines and lists' structure could be altered. (org-export-mark-list-end) @@ -1488,6 +1499,20 @@ 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]\\)")) + (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)))))) + (defun org-export-remove-archived-trees (export-archived-trees) "Remove archived trees. When EXPORT-ARCHIVED-TREES is `headline;, only the headline will be exported. diff --git a/lisp/org-html.el b/lisp/org-html.el index 62fce1b..3564a83 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) + :done-tasks (plist-get opt-plist :done-tasks) :tags (plist-get opt-plist :tags) :priority (plist-get opt-plist :priority) :footnotes (plist-get opt-plist :footnotes) diff --git a/lisp/org-latex.el b/lisp/org-latex.el index ed1f416..ba9d8d1 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) + :done-tasks (plist-get opt-plist :done-tasks) :add-text nil :skip-before-1st-heading skip :select-tags nil @@ -886,6 +887,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) + :done-tasks (plist-get opt-plist :done-tasks) :add-text (if (eq to-buffer 'string) nil text) :skip-before-1st-heading skip :select-tags (plist-get opt-plist :select-tags) |