summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCarsten Dominik <carsten.dominik@gmail.com>2011-03-25 07:53:20 +0100
committerCarsten Dominik <carsten.dominik@gmail.com>2011-03-30 09:06:59 +0200
commitb8fdddcd9cba913478a084bfaf1e6372a5e8670e (patch)
tree0880916623f25d8eb6512dd912057ec6b8e8c7bf
parentb71413947c9221ba7cf098362dc9b1d25f9c6b21 (diff)
downloadorg-mode-b8fdddcd9cba913478a084bfaf1e6372a5e8670e.tar.gz
Add tools for tracking meeting notes
* lisp/org.el (org-numbered-action-format): New option. (org-new-numbered-action): New command. (org-collect-todos-in-subtree): New command.
-rw-r--r--lisp/org.el56
1 files changed, 56 insertions, 0 deletions
diff --git a/lisp/org.el b/lisp/org.el
index 28025ea..e652ff1 100644
--- a/lisp/org.el
+++ b/lisp/org.el
@@ -1104,6 +1104,12 @@ breaking the list structure."
(const :tag "Always" t)
(const :tag "Auto" auto)))))
+(defcustom org-numbered-action-format "TODO Action #%d "
+ "Default structure of the headling of a new action.
+%d will become the number of the action."
+ :group 'org-edit-structure
+ :type 'string)
+
(defcustom org-insert-heading-hook nil
"Hook being run after inserting a new heading."
:group 'org-edit-structure
@@ -6924,6 +6930,29 @@ This is important for non-interactive uses of the command."
(hide-subtree)))
(run-hooks 'org-insert-heading-hook)))))
+(defun org-new-numbered-action (&optional inline)
+ "Insert a new numbered action, using `org-numbered-action-format'.
+With prefix argument, insert an inline task."
+ (interactive "P")
+ (let* ((num (let ((re "\\`#\\([0-9]+\\)\\'"))
+ (1+ (apply 'max 0
+ (mapcar
+ (lambda (e)
+ (if (string-match re (car e))
+ (string-to-number (match-string 1 (car e)))
+ 0))
+ (org-get-buffer-tags))))))
+ (tag (concat "#" (number-to-string num))))
+ (if inline
+ (org-inlinetask-insert-task)
+ (org-insert-heading nil 'force))
+ (unless (eql (char-before) ?\ ) (insert " "))
+ (insert (format org-numbered-action-format num))
+ (org-toggle-tag tag 'on)
+ (if (= (point-max) (point-at-bol))
+ (save-excursion (goto-char (point-at-eol)) (insert "\n")))
+ (unless (eql (char-before) ?\ ) (insert " "))))
+
(defun org-get-heading (&optional no-tags)
"Return the heading of the current entry, without the stars."
(save-excursion
@@ -7571,6 +7600,33 @@ If optional TXT is given, check this string instead of the current kill."
(throw 'exit nil)))
t))))
+(defun org-collect-todos-in-subtree ()
+ "Collect all TODO items in the current subtree into a flat list."
+ (interactive)
+ (let ((buf (get-buffer-create "Org TODO Collect"))
+ (cnt 0))
+ (with-current-buffer buf (erase-buffer) (org-mode))
+ (save-excursion
+ (save-restriction
+ (org-narrow-to-subtree)
+ (goto-char (point-min))
+ (while (re-search-forward org-complex-heading-regexp nil t)
+ (when (and (match-end 2)
+ (member (match-string 2) org-not-done-keywords))
+ (setq beg (match-beginning 0)
+ cnt (1+ cnt))
+ (org-end-of-subtree t t)
+ (setq end (point))
+ (copy-region-as-kill beg end)
+ (with-current-buffer buf
+ (org-paste-subtree 1)
+ (or (bolp) (insert "\n"))
+ (set-buffer-modified-p nil))))))
+ (with-current-buffer buf
+ (kill-region (point-min) (point-max)))
+ (kill-buffer buf)
+ (message "Collected %d TODO items as flat list into the kill buffer" cnt)))
+
(defvar org-markers-to-move nil
"Markers that should be moved with a cut-and-paste operation.
Those markers are stored together with their positions relative to