Inline tasks: New module org-inlinetask.el

This module implements inline tasks in Org-mode.  Inline tasks are
tasks that have all the properties of normal outline nodes, including
the ability to store meta data like scheduling dates, TODO state, tags
and properties.  However, these nodes are treated specially by the
visibility cycling and export commands.
This commit is contained in:
Carsten Dominik 2009-03-30 13:15:36 +02:00
parent e341a34297
commit cd6907beb9
3 changed files with 89 additions and 30 deletions

View File

@ -1,5 +1,10 @@
2009-03-30 Carsten Dominik <carsten.dominik@gmail.com>
* org.el (org-modules): Add org-inlinetasks.el
(org-cycle): Implement limiting level on cycling.
* org-inlinetask.el: New file.
* org.el (org-emphasis-regexp-components): Allow braces in
emphasis pre and post match.

View File

@ -1,10 +1,10 @@
;;; org-inlinetask.el --- Tasks outside the outline hierarchy
;; Copyright (C) 2008 Free Software Foundation, Inc.
;;; org-inlinetask.el --- Tasks independent of outline hierarchy
;; Copyright (C) 2009 Free Software Foundation, Inc.
;;
;; Author: Carsten Dominik <carsten at orgmode dot org>
;; Keywords: outlines, hypermedia, calendar, wp
;; Homepage: http://orgmode.org
;; Version: 0.01
;; Version: 6.24trans
;;
;; This file is not yet part of GNU Emacs.
;;
@ -26,39 +26,81 @@
;;
;;; Commentary:
;;
This module implements inline tasks in Org-mode. Inline tasks are
tasks that have all the properties of normal outline nodes, including
the ability to store meta data like scheduling dates, TODO state, tags
and properties. However, these nodes are treated specially by the
visibility cycling commands and by the export commands.
Visibility cycling exempts these nodes from cycling, so whenever their
parent is opened, so are these tasks.
Export commands do not treat the tasks as part of the sectioning
structure, but as a spe
;; This module implements inline tasks in Org-mode. Inline tasks are
;; tasks that have all the properties of normal outline nodes, including
;; the ability to store meta data like scheduling dates, TODO state, tags
;; and properties. However, these nodes are treated specially by the
;; visibility cycling and export commands.
;;
;; Visibility cycling exempts these nodes from cycling. So whenever their
;; parent is opened, so are these tasks. This will only work with
;; `org-cycle', so if you are also using orther commands to show/hide
;; entries, you will occasionally find these tasks to behave like
;; all other outline nodes, seemingly splitting the text of the parent
;; into children.
;;
;; Export commands do not treat these nodes as part of the sectioning
;; structure, but as a special inline text that is either removed, or
;; formatted in some special way.
;;
;; Special fontification of inline tasks, so that they can be immediately
;; recognized. From the stars of the headline, only the first and the
;; last two will be visible, the others will be hidden using the
;; `org-hide' face.
;;
;; An inline task is identified solely by a minimum outline level, given
;; by the variable `org-inlinetask-min-level', default 15.
;;
;; Inline tasks are normally assumed to contain at most a time planning
;; line (DEADLINE etc) after it, and then any number of drawers, for
;; example LOGBOOK of PROPERTIES. No empty lines are allowed.
;; If you need to have normal text as part of an inline task, you
;; can do so by adding an "END" headline with the same number of stars,
;; for example
;;
;; **************** TODO some small task
;; DEADLINE: <2009-03-30 Mon>
;; :PROPERTIES:
;; :SOMETHING: or other
;; :END:
;; And here is some extra text
;; **************** END
;;; Code
(defgroup org-inlinetask nil
"Options concerning inline tasks in Org mode."
:tag "Org Inline Tasks"
:group 'org-structure)
(defcustom org-inlinetask-min-level 15
"Minimum level a headline must have before it is treated as an inline task.
It is strongly recommended that you set `org-cycle-max-level' not at all,
or to a number smaller than this one. In fact, when `org-cycle-max-level' is
not set, it will be assumed to be one less than the value of smaller than
the value of this variable."
:group 'org-inlinetask
:type 'boolean)
(defcustom org-inlinetask-export 'arrow+content
"What should be done with inlinetasks upon export?
Possible values:
nil Remove entirely
arrow Insert arrow and headline
arrow+content Insert arrow and headline, add content like example
example Turn headline and content into example"
arrow Insert heading in bold, preceeded by an arrow
arrow+content Insert arrow and headline, add content below in an
#+begin_example box (ugly, but works for now)"
:group 'org-inlinetask
:group 'org-export-general
:type 'boolean)
(defun org-inlinetask-export-handler ()
"Handle headlines with level larger than `org-cycle-max-level'.
"Handle headlines with level larger or equal to `org-inlinetask-min-level'.
Either remove headline and meta data, or do special formatting."
(goto-char (point-min))
(let* ((nstars (if org-odd-levels-only
(1- (* 2 (or org-cycle-max-level 1000)))
(or org-cycle-max-level 1000)))
(1- (* 2 (or org-inlinetask-min-level 200)))
(or org-inlinetask-min-level 200)))
(re1 (format "^\\(\\*\\{%d,\\}\\) .*\n" nstars))
(re2 (concat "^[ \t]*" org-keyword-time-regexp))
headline beg end stars content)
@ -83,20 +125,20 @@ Either remove headline and meta data, or do special formatting."
(when (and org-inlinetask-export
(string-match org-complex-heading-regexp headline))
(when (memq org-inlinetask-export '(arrow+content arrow))
(insert "\n\n\\Rightarrow *"
(insert "\n\n\\Rightarrow\\Rightarrow\\Rightarrow *"
(if (match-end 2) (concat (match-string 2 headline) " ") "")
(match-string 4 headline) "*\n"))
(when (eq org-inlinetask-export 'arrow+content)
(when (and content (eq org-inlinetask-export 'arrow+content))
(insert "#+BEGIN_EXAMPLE\n" content "\n#+END_EXAMPLE\n"))
(insert "\n")))))
(defun org-inlinetask-fontify (limit)
"Fontify the inline tasks."
(let* ((nstars (if org-odd-levels-only
(1- (* 2 (or org-cycle-max-level 1000)))
(or org-cycle-max-level 1000)))
(1- (* 2 (or org-inlinetask-min-level 200)))
(or org-inlinetask-min-level 200)))
(re (concat "^\\(\\*\\)\\(\\*\\{"
(format "%d" (- nstars 2))
(format "%d" (- nstars 3))
",\\}\\)\\(\\*\\* .*\\)")))
(while (re-search-forward re limit t)
(add-text-properties (match-beginning 1) (match-end 1)

View File

@ -167,6 +167,7 @@ to add the symbol `xyz', and the package must have a call to
(const :tag " id: Global IDs for identifying entries" org-id)
(const :tag " info: Links to Info nodes" org-info)
(const :tag " jsinfo: Set up Sebastian Rose's JavaScript org-info.js" org-jsinfo)
(const :tag " inlinetask: Tasks independent of outline hierarchy" org-inlinetask)
(const :tag " irc: Links to IRC/ERC chat sessions" org-irc)
(const :tag " mac-message: Links to messages in Apple Mail" org-mac-message)
(const :tag " mew Links to Mew folders/messages" org-mew)
@ -553,7 +554,11 @@ new-frame Make a new frame each time. Note that in this case
Levels higher than this will, for cycling, be treated as text, not a headline.
When `org-odd-levels-only' is set, a value of N in this variable actually
means 2N-1 stars as the limiting headline.
When nil, cycle all levels."
When nil, cycle all levels.
Note that the limiting level of cycling is also influenced by
`org-inlinetask-min-level'. When `org-cycle-max-level' is not set but
`org-inlinetask-min-level' is, cycling will be limited to levels one less
than its value."
:group 'org-cycle
:type '(choice
(const :tag "No limit" nil)
@ -4482,6 +4487,7 @@ If KWD is a number, get the corresponding match group."
;;;###autoload
(defvar org-inlinetask-min-level)
(defun org-cycle (&optional arg)
"Visibility cycling for Org-mode.
@ -4517,9 +4523,15 @@ If KWD is a number, get the corresponding match group."
But only if also the variable `org-cycle-global-at-bob' is t."
(interactive "P")
(org-load-modules-maybe)
(let* ((nstars (if org-odd-levels-only
(and org-cycle-max-level (1- (* org-cycle-max-level 2)))
org-cycle-max-level))
(let* ((limit-level
(or org-cycle-max-level
(and (boundp 'org-inlinetask-min-level)
org-inlinetask-min-level
(1- org-inlinetask-min-level))))
(nstars (and limit-level
(if org-odd-levels-only
(and limit-level (1- (* limit 2)))
limit-level)))
(outline-regexp
(cond
((not (org-mode-p)) outline-regexp)