emacs-orgmode
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Orgmode] Tip: Interleaving notes and todos


From: John Wiegley
Subject: [Orgmode] Tip: Interleaving notes and todos
Date: Sun, 07 Oct 2007 05:59:00 -0400
User-agent: Gnus/5.11 (Gnus v5.11) Emacs/22.1 (darwin)

I've recently found it very happen to start adding non-task "notes" into the
flow of my todos.

What I do is make notes look like completed todos.  They get entered into the
regular flow, which prompts me either to a) generate a task from them, or b)
simply file them into their related category.  Since they are implicit in a
"complete" state, I have org-mode automatically archive them into my todo
archive after a certain number of days.

I set apart the coloring of notes from todo by using the "NOTE" todo state,
and the following face values (note, these assume a white background):

 (setq org-todo-keyword-faces
       (quote (("TODO" :foreground "medium blue" :weight bold)
               ("APPT" :foreground "medium blue" :weight bold)
               ("NOTE" :foreground "dark violet" :weight bold)
               ("STARTED" :foreground "dark orange" :weight bold)
               ("WAITING" :foreground "red" :weight bold)
               ("DELEGATED" :foreground "red" :weight bold))))

This is paired with the following at the top of my org-mode file:

  MY TASKS  -*- mode: org; fill-column: 78; after-save-hook: 
(archive-done-tasks) -*-

  #+SEQ_TODO: TODO STARTED WAITING DELEGATED APPT | DONE DEFERRED CANCELLED NOTE
  #+ARCHIVE: archive.txt::

If you're looking for the code behind `archive-done-tasks', just add the
code following this post to your .emacs file.

John

(defvar org-my-archive-expiry-days 7
  "The number of days after which a completed task should be auto-archived.
This can be 0 for immediate, or a floating point value.")

(defun org-my-archive-done-tasks ()
  (interactive)
  (save-excursion
    (goto-char (point-min))
    (let ((done-regexp
           (concat "\\* \\(" (regexp-opt org-done-keywords) "\\) "))
          (state-regexp
           (concat "- State \"\\(" (regexp-opt org-done-keywords)
                   "\\)\"\\s-*\\[\\([^]\n]+\\)\\]")))
      (while (re-search-forward done-regexp nil t)
        (let ((end (save-excursion
                     (outline-next-heading)
                     (point)))
              begin)
          (goto-char (line-beginning-position))
          (setq begin (point))
          (if (re-search-forward state-regexp end t)
              (let* ((time-string (match-string 2))
                     (when-closed (org-parse-time-string time-string)))
                (if (>= (time-to-number-of-days
                         (time-subtract (current-time)
                                        (apply #'encode-time when-closed)))
                        org-my-archive-expiry-days)
                    (org-archive-subtree)))
            (goto-char end)))))
    (save-buffer)))

(setq safe-local-variable-values (quote ((after-save-hook archive-done-tasks))))

(defalias 'archive-done-tasks 'org-my-archive-done-tasks)




reply via email to

[Prev in Thread] Current Thread [Next in Thread]