emacs-orgmode
[Top][All Lists]
Advanced

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

[Orgmode] Supporting non-stuck projects view with minimal effort


From: Friedrich Delgado Friedrichs
Subject: [Orgmode] Supporting non-stuck projects view with minimal effort
Date: Tue, 22 Dec 2009 18:58:03 +0100
User-agent: Mutt/1.5.20 (2009-06-14)

Hi!

I've been thinking, the view of stuck projects is nice, but I'd need a
view of non-stuck projects to complement it.

I came up with this ugly mess:

(defun fdf/org-agenda-list-unstuck-projects (&rest ignore)
  "Create agenda view for projects that are NOT stuck.
Stuck projects are project that have no next actions.  For the
definitions
of what a project is and how to check if it stuck, customize the
variable
`org-stuck-projects'.
MATCH is being ignored."
  (interactive)
  (let* ((org-agenda-overriding-header
          (or org-agenda-overriding-header "List of unstuck projects:
          "))
         (matcher (nth 0 org-stuck-projects))
         (todo (nth 1 org-stuck-projects))
         (todo-wds (if (member "*" todo)
                       (progn
                         (org-prepare-agenda-buffers (org-agenda-files
                                                      nil 'ifmode))
                         (org-delete-all
                          org-done-keywords-for-agenda
                          (copy-sequence
                          org-todo-keywords-for-agenda)))
                     todo))
         (todo-re (concat "^\\*+[ \t]+\\("
                          (mapconcat 'identity todo-wds "\\|")
                          "\\)\\>"))
         (tags (nth 2 org-stuck-projects))
         (tags-re (if (member "*" tags)
                      (org-re "^\\*+ .*:[[:alnum:address@hidden:[ \t]*$")
                    (if tags
                        (concat "^\\*+ .*:\\("
                                (mapconcat 'identity tags "\\|")
                                (org-re "\\):[[:alnum:]_@:]*[
                                \t]*$")))))
         (gen-re (nth 3 org-stuck-projects))
         (re-list
          (delq nil
                (list
                 (if todo todo-re)
                 (if tags tags-re)
                 (and gen-re (stringp gen-re) (string-match "\\S-"
                 gen-re)
                      gen-re))))
         (skip-regexp
          (if re-list
              (mapconcat 'identity re-list "\\|")
            (error "No information how to identify unstuck
            projects"))))
    (org-tags-view nil matcher)
    (let ((org-agenda-skip-function
           (lambda ()
             (org-agenda-skip-if t 'notregexp skip-regexp))))
      (with-current-buffer org-agenda-buffer-name
        (setq org-agenda-redo-command
              '(org-agenda-list-stuck-projects
                (or current-prefix-arg org-last-arg)))))))

As you will notice, this is blatantly copied and pasted from
org-agenda-list-stuck-projects (which is why it's ugly), the only
difference is that it doesn't set org-agenda-skip-function but uses
org-agenda-skip-if.

I think this could be very easily integrated into
org-agenda-list-stuck-projects (with an optional parameter 'negate'),
but I somehow feel reluctant to patch org-core for some irrational
reason.

Kind regards
     Friedel
-- 
        Friedrich Delgado Friedrichs <address@hidden>
                             TauPan on Ircnet and Freenode ;)

Attachment: pgpSG4XNXIJbp.pgp
Description: PGP signature


reply via email to

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