From 57c379bb2635f12dbc8db0febe0502c27621b828 Mon Sep 17 00:00:00 2001 From: Carsten Dominik Date: Wed, 30 Mar 2011 05:27:43 +0200 Subject: [PATCH] Clean up the new options to remove tasks on export --- doc/org.texi | 13 +++++------- lisp/org-ascii.el | 1 - lisp/org-docbook.el | 1 - lisp/org-exp.el | 48 ++++++++++++++++++++++++++------------------- lisp/org-html.el | 3 +-- lisp/org-latex.el | 2 -- 6 files changed, 34 insertions(+), 34 deletions(-) diff --git a/doc/org.texi b/doc/org.texi index 4cf90a828..b7cb93f5d 100644 --- a/doc/org.texi +++ b/doc/org.texi @@ -9312,7 +9312,6 @@ 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: @code{org-export-select-tags} and @code{org-export-exclude-tags}. @@ -9333,10 +9332,9 @@ Finally, all subtrees that are marked by any of the @emph{exclude} tags will be removed from the export buffer. @end enumerate -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. +The variable @code{org-export-with-tasks} can be configured to select which +kind of tasks should be included for export. See the docstring of the +variable for more information. @node Export options, The export dispatcher, Selective export, Exporting @section Export options @@ -9436,8 +9434,8 @@ 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} +tasks: @r{turn on/off inclusion of tasks (TODO items), can be nil to remove} + @r{all tasks, @code{todo} to remove DONE tasks, or list of kwds to keep} 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} @@ -10968,7 +10966,6 @@ respective variable for details. @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} @item @code{:LaTeX-fragments} @tab @code{org-export-with-LaTeX-fragments} diff --git a/lisp/org-ascii.el b/lisp/org-ascii.el index de094cc90..a2bbb0f66 100644 --- a/lisp/org-ascii.el +++ b/lisp/org-ascii.el @@ -304,7 +304,6 @@ publishing directory." :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) :exclude-tags (plist-get opt-plist :exclude-tags) diff --git a/lisp/org-docbook.el b/lisp/org-docbook.el index ef7372f72..dbb608dbf 100644 --- a/lisp/org-docbook.el +++ b/lisp/org-docbook.el @@ -530,7 +530,6 @@ publishing directory." :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) :footnotes (plist-get opt-plist :footnotes) diff --git a/lisp/org-exp.el b/lisp/org-exp.el index 5d7d11f23..91495351d 100644 --- a/lisp/org-exp.el +++ b/lisp/org-exp.el @@ -298,15 +298,20 @@ When nil, remove all these keywords from the export." (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." +This may have the following values: +t include tasks independent of state. +todo include only tasks that are not yet done. +done include only tasks that are already done. +nil remove all tasks before export +list of TODO kwds keep only tasks with these keywords" :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) + :type '(choice + (const :tag "All tasks" t) + (const :tag "No tasks" nil) + (const :tag "Not-done tasks" todo) + (const :tag "Only done tasks" done) + (repeat :tag "Specific TODO keywords" + (string :tag "Keyword")))) (defcustom org-export-with-priority nil "Non-nil means include priority cookies in export. @@ -634,7 +639,6 @@ table.el tables." (: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) (:LaTeX-fragments "LaTeX" org-export-with-LaTeX-fragments) @@ -855,7 +859,7 @@ security risks." (while (setq o (pop op)) (if (and (nth 1 o) (string-match (concat "\\<" (regexp-quote (nth 1 o)) - ":\\([^ \t\n\r;,.]*\\)") + ":\\(([^)\n]+)\\|[^ \t\n\r;,.]*\\)") options)) (setq p (plist-put p (car o) (car (read-from-string @@ -1112,10 +1116,8 @@ 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 - (org-export-remove-tasks - (plist-get parameters :tasks) - (plist-get parameters :done-tasks)) + ;; Get rid of tasks, depending on configuration + (org-export-remove-tasks (plist-get parameters :tasks)) ;; Change lists ending. Other parts of export may insert blank ;; lines and lists' structure could be altered. @@ -1507,16 +1509,22 @@ removed as well." (point-max))) (delete-region beg end)))) -(defun org-export-remove-tasks (tasks done-tasks) +(defun org-export-remove-tasks (keep) "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) +When KEEP is nil, remove all tasks. +When KEEP is `todo', remove the tasks that are DONE. +When KEEP is `done', remove the tasks that are not yet done. +When it is a list of strings, keep only tasks with these TODO keywords." + (when (or (listp keep) (memq keep '(todo done nil))) (let ((re (concat "^\\*+[ \t]+\\(" (mapconcat 'regexp-quote - (cond ((not tasks) org-todo-keywords-1) - ((not done-tasks) org-done-keywords)) + (cond ((not keep) org-todo-keywords-1) + ((eq keep 'todo) org-done-keywords) + ((eq keep 'done) org-not-done-keywords) + ((listp keep) + (org-delete-all keep (copy-sequence + org-todo-keywords-1)))) "\\|") "\\)\\($\\|[ \t]\\)")) (case-fold-search nil) diff --git a/lisp/org-html.el b/lisp/org-html.el index 84eaaa145..0e1bb88b2 100644 --- a/lisp/org-html.el +++ b/lisp/org-html.el @@ -1021,7 +1021,7 @@ OPT-PLIST is the export options list." ;;; org-export-as-html ;;;###autoload -(defun org-export-as-html (arg &optional hidden ext-plist +q(defun org-export-as-html (arg &optional hidden ext-plist to-buffer body-only pub-dir) "Export the outline as a pretty HTML file. If there is an active region, export only the region. The prefix @@ -1180,7 +1180,6 @@ PUB-DIR is set, use this as the publishing directory." :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) :footnotes (plist-get opt-plist :footnotes) diff --git a/lisp/org-latex.el b/lisp/org-latex.el index 0b56a99bb..e42b64d62 100644 --- a/lisp/org-latex.el +++ b/lisp/org-latex.el @@ -870,7 +870,6 @@ when PUB-DIR is set, use this as the publishing directory." :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 :select-tags nil @@ -889,7 +888,6 @@ when PUB-DIR is set, use this as the publishing directory." :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 :select-tags (plist-get opt-plist :select-tags)