]> code.delx.au - gnu-emacs/commitdiff
2009-01-28 Carsten Dominik <carsten.dominik@gmail.com>
authorCarsten Dominik <dominik@science.uva.nl>
Wed, 28 Jan 2009 14:33:23 +0000 (14:33 +0000)
committerCarsten Dominik <dominik@science.uva.nl>
Wed, 28 Jan 2009 14:33:23 +0000 (14:33 +0000)
* org-agenda.el (org-agenda-get-todos): Start search from correct
position.

* org.el (org-fast-todo-selection): Make sure TODO selection does
not change buffer position.

* org-list.el (org-toggle-checkbox): Implement adding or removing
checkboxes from line or region when called with a prefix
argument.

* org-rmail.el (org-rmail-store-link): Protect the call to
`rmail-narrow-to-non-pruned-header'.

* org-clock.el (org-clock-special-range): Fix week display in
clock tables.

* org-exp.el (org-get-current-options): Fix bug when in indirect
buffer.

* org-agenda.el (org-agenda-dim-blocked-tasks): New option.
(org-finalize-agenda): Call `org-agenda-dim-blocked-tasks'.
(org-agenda-dim-blocked-tasks): New function.

* org.el (org-enforce-todo-dependencies): New option.
(org-block-todo-from-children-or-siblings): New function.

* org-faces.el (org-agenda-dimmed-todo-face): New face.

35 files changed:
doc/misc/ChangeLog
lisp/org/ChangeLog
lisp/org/org-agenda.el
lisp/org/org-archive.el
lisp/org/org-attach.el
lisp/org/org-bbdb.el
lisp/org/org-bibtex.el
lisp/org/org-clock.el
lisp/org/org-colview.el
lisp/org/org-compat.el
lisp/org/org-exp.el
lisp/org/org-export-latex.el
lisp/org/org-faces.el
lisp/org/org-footnote.el
lisp/org/org-gnus.el
lisp/org/org-id.el
lisp/org/org-info.el
lisp/org/org-irc.el
lisp/org/org-jsinfo.el
lisp/org/org-list.el
lisp/org/org-mac-message.el
lisp/org/org-macs.el
lisp/org/org-mew.el
lisp/org/org-mhe.el
lisp/org/org-mouse.el
lisp/org/org-plot.el
lisp/org/org-publish.el
lisp/org/org-remember.el
lisp/org/org-rmail.el
lisp/org/org-table.el
lisp/org/org-timer.el
lisp/org/org-vm.el
lisp/org/org-w3m.el
lisp/org/org-wl.el
lisp/org/org.el

index 81bd01e76642427f2484defcc2278acd7d33e044..0155df5acd2b6cf4cb3b498ee3f27a76293065f9 100644 (file)
@@ -1,3 +1,7 @@
+2009-01-28  Carsten Dominik  <dominik@science.uva.nl>
+
+       * org.texi (TODO dependencies): New section.
+
 2009-01-27  Carsten Dominik  <dominik@science.uva.nl>
 
        * org.texi (Plain lists, TODO basics, Priorities)
index f73d81b68013843e207c142a87cf6dd59d62463d..d52c5a204b71034f90cc0fc3d8d2e888c587aa1f 100644 (file)
@@ -1,3 +1,33 @@
+2009-01-28  Carsten Dominik  <carsten.dominik@gmail.com>
+
+       * org-agenda.el (org-agenda-get-todos): Start search from correct
+       position.
+
+       * org.el (org-fast-todo-selection): Make sure TODO selection does
+       not change buffer position.
+
+       * org-list.el (org-toggle-checkbox): Implement adding or removing
+       checkboxes from line or region when called with a prefix
+       argument.
+
+       * org-rmail.el (org-rmail-store-link): Protect the call to
+       `rmail-narrow-to-non-pruned-header'.
+
+       * org-clock.el (org-clock-special-range): Fix week display in
+       clock tables.
+
+       * org-exp.el (org-get-current-options): Fix bug when in indirect
+       buffer.
+
+       * org-agenda.el (org-agenda-dim-blocked-tasks): New option.
+       (org-finalize-agenda): Call `org-agenda-dim-blocked-tasks'.
+       (org-agenda-dim-blocked-tasks): New function.
+
+       * org.el (org-enforce-todo-dependencies): New option.
+       (org-block-todo-from-children-or-siblings): New function.
+
+       * org-faces.el (org-agenda-dimmed-todo-face): New face.
+
 2009-01-27  Carsten Dominik  <carsten.dominik@gmail.com>
 
        * org.el (org-todo): Return correct state type even if the blocker
index 97d68d5aa9fb7bcfbd666d31eda8a26ce2d221e5..091366ebaaba2606e5fb72e5be2e86e3faad5b77 100644 (file)
@@ -6,7 +6,7 @@
 ;; Author: Carsten Dominik <carsten at orgmode dot org>
 ;; Keywords: outlines, hypermedia, calendar, wp
 ;; Homepage: http://orgmode.org
-;; Version: 6.19e
+;; Version: 6.20c
 ;;
 ;; This file is part of GNU Emacs.
 ;;
@@ -513,6 +513,21 @@ deadlines are always turned off when the item is DONE."
   :group 'org-agenda-daily/weekly
   :type 'boolean)
 
+(defcustom org-agenda-dim-blocked-tasks t
+  "Non-nil means, dim blocked tasks in the agenda display.
+This causes some overhead during agenda construction, but if you have turned
+on `org-enforce-todo-dependencies' or any other blocking mechanism, this
+will create useful feedback in the agenda.
+Instead ot t, this variable can also have the value `invisible'.  Then
+blocked tasks will be invisible and only become visible when they
+become unblocked."
+  :group 'org-agenda-daily/weekly
+  :group 'org-agenda-todo-list
+  :type '(choice
+         (const :tag "Do not dim" nil)
+         (const :tag "Dim to a grey face" t)
+         (const :tag "Make invisibe" invisible)))
+
 (defcustom org-timeline-show-empty-dates 3
   "Non-nil means, `org-timeline' also shows dates without an entry.
 When nil, only the days which actually have entries are shown.
@@ -2132,6 +2147,8 @@ VALUE defaults to t."
          (org-agenda-columns))
       (when org-agenda-fontify-priorities
        (org-fontify-priorities))
+      (when (and org-agenda-dim-blocked-tasks org-blocker-hook)
+       (org-agenda-dim-blocked-tasks))
       (run-hooks 'org-finalize-agenda-hook)
       (setq org-agenda-type (get-text-property (point) 'org-agenda-type))
       )))
@@ -2162,6 +2179,36 @@ VALUE defaults to t."
               ((equal p h) 'bold)))
        (org-overlay-put ov 'org-type 'org-priority)))))
 
+(defun org-agenda-dim-blocked-tasks ()
+  "Dim currently blocked TODO's in the agenda display."
+  (mapc (lambda (o) (if (eq (org-overlay-get o 'org-type) 'org-blocked-todo)
+                       (org-delete-overlay o)))
+       (org-overlays-in (point-min) (point-max)))
+  (save-excursion
+    (let ((inhibit-read-only t)
+         (invis (eq org-agenda-dim-blocked-tasks 'invisible))
+         b e p ov h l)
+      (goto-char (point-min))
+      (while (let ((pos (next-single-property-change (point) 'todo-state)))
+              (and pos (goto-char (1+ pos))))
+       (let ((marker (get-text-property (point) 'org-hd-marker)))
+         (when (and marker
+                    (not (with-current-buffer (marker-buffer marker)
+                           (save-excursion
+                             (goto-char marker)
+                             (run-hook-with-args-until-failure
+                              'org-blocker-hook
+                              (list :type 'todo-state-change
+                                    :position marker
+                                    :from 'todo
+                                    :to 'done))))))
+           (setq b (if invis (max (point-min) (1- (point))) (point))
+                 e (point-at-eol)
+                 ov (org-make-overlay b e))
+           (if invis
+               (org-overlay-put ov 'invisible t)
+             (org-overlay-put ov 'face 'org-agenda-dimmed-todo-face))
+           (org-overlay-put ov 'org-type 'org-blocked-todo)))))))
 
 (defvar org-agenda-skip-function nil
   "Function to be called at each match during agenda construction.
@@ -3272,7 +3319,7 @@ the documentation of `org-diary'."
       (catch :skip
        (save-match-data
          (beginning-of-line)
-         (setq beg (point) end (progn (outline-next-heading) (point)))
+         (setq beg (point) end (save-excursion (outline-next-heading) (point)))
          (when (org-agenda-check-for-timestamp-as-reason-to-ignore-todo-item end)
            (goto-char (1+ beg))
            (or org-agenda-todo-list-sublevels (org-end-of-subtree 'invisible))
index 045a505e45fa099d865d32f845864453dcddb5d7..ff4c0f65e5d4cc297694e12ee3a316dad7580cc3 100644 (file)
@@ -6,7 +6,7 @@
 ;; Author: Carsten Dominik <carsten at orgmode dot org>
 ;; Keywords: outlines, hypermedia, calendar, wp
 ;; Homepage: http://orgmode.org
-;; Version: 6.19e
+;; Version: 6.20c
 ;;
 ;; This file is part of GNU Emacs.
 ;;
index d68fe410c9b58ce49ae6f0aa3c9035a3ea9df38c..3af6d645c5f3ef1828a0bb5447e85716f22539e9 100644 (file)
@@ -4,7 +4,7 @@
 
 ;; Author: John Wiegley <johnw@newartisans.com>
 ;; Keywords: org data task
-;; Version: 6.19e
+;; Version: 6.20c
 
 ;; This file is part of GNU Emacs.
 ;;
index 5656ba5f5e78a9ac5b1da44ee740822811c4bbf5..f2f6d9cadd4fa703f0c3762c056e609504981255 100644 (file)
@@ -7,7 +7,7 @@
 ;;         Thomas Baumann <thomas dot baumann at ch dot tum dot de>
 ;; Keywords: outlines, hypermedia, calendar, wp
 ;; Homepage: http://orgmode.org
-;; Version: 6.19e
+;; Version: 6.20c
 ;;
 ;; This file is part of GNU Emacs.
 ;;
index 968da0044a833cac33f11a2605a7c55d800ad0f8..d5026b9cca87b5ed8a2cbb9bab95377e715f0de9 100644 (file)
@@ -5,7 +5,7 @@
 ;; Author: Bastien Guerry <bzg at altern dot org>
 ;;         Carsten Dominik <carsten dot dominik at gmail dot com>
 ;; Keywords: org, wp, remember
-;; Version: 6.19e
+;; Version: 6.20c
 ;;
 ;; This file is part of GNU Emacs.
 ;;
index 44118471625440f7447cb7ee278bf7a1304c55bb..b800285153aec805884fa013635ea2927a03d819 100644 (file)
@@ -6,7 +6,7 @@
 ;; Author: Carsten Dominik <carsten at orgmode dot org>
 ;; Keywords: outlines, hypermedia, calendar, wp
 ;; Homepage: http://orgmode.org
-;; Version: 6.19e
+;; Version: 6.20c
 ;;
 ;; This file is part of GNU Emacs.
 ;;
@@ -724,6 +724,7 @@ the returned times will be formatted strings."
       (setq date (calendar-gregorian-from-absolute
                  (calendar-absolute-from-iso (list w 1 y))))
       (setq d (nth 1 date) month (car date) y (nth 2 date)
+           dow 1
            key 'week))
      ((string-match "^\\([0-9]+\\)-\\([0-9]\\{1,2\\}\\)-\\([0-9]\\{1,2\\}\\)$" skey)
       (setq y (string-to-number (match-string 1 skey))
index 3de6ec958449a480db744cd134e95e0873aa7848..64dcf2326ed4661d6e13a1353c8ca9949324de7c 100644 (file)
@@ -6,7 +6,7 @@
 ;; Author: Carsten Dominik <carsten at orgmode dot org>
 ;; Keywords: outlines, hypermedia, calendar, wp
 ;; Homepage: http://orgmode.org
-;; Version: 6.19e
+;; Version: 6.20c
 ;;
 ;; This file is part of GNU Emacs.
 ;;
index e9e750437b5357967d63772f56c45f0f1396cc9f..21445c835a20ff5f43dddd4a1e2e515d7fd640e8 100644 (file)
@@ -6,7 +6,7 @@
 ;; Author: Carsten Dominik <carsten at orgmode dot org>
 ;; Keywords: outlines, hypermedia, calendar, wp
 ;; Homepage: http://orgmode.org
-;; Version: 6.19e
+;; Version: 6.20c
 ;;
 ;; This file is part of GNU Emacs.
 ;;
index 89cbd95d61b03571ef03fb9423aa2bb5a6eb14f5..3b2fbbe45d1702315dd27211237c4ddd79300eb5 100644 (file)
@@ -6,7 +6,7 @@
 ;; Author: Carsten Dominik <carsten at orgmode dot org>
 ;; Keywords: outlines, hypermedia, calendar, wp
 ;; Homepage: http://orgmode.org
-;; Version: 6.19e
+;; Version: 6.20c
 ;;
 ;; This file is part of GNU Emacs.
 ;;
@@ -3031,7 +3031,10 @@ Does include HTML export options as well as TODO and CATEGORY stuff."
    (mapconcat 'identity org-export-exclude-tags " ")
    org-export-html-link-up
    org-export-html-link-home
-   (file-name-nondirectory buffer-file-name)
+   (or (ignore-errors
+        (file-name-sans-extension
+         (file-name-nondirectory (buffer-file-name (buffer-base-buffer)))))
+       "NOFILENAME")
    "TODO FEEDBACK VERIFY DONE"
    "Me Jason Marie DONE"
    org-highest-priority org-lowest-priority org-default-priority
index ce79337b4f68cb46b6290320e0f87a43dfd304dd..945dee0a5f37be8e6b5a499de57309b6d8ecf4a4 100644 (file)
@@ -4,7 +4,7 @@
 ;;
 ;; Emacs Lisp Archive Entry
 ;; Filename: org-export-latex.el
-;; Version: 6.19e
+;; Version: 6.20c
 ;; Author: Bastien Guerry <bzg AT altern DOT org>
 ;; Maintainer: Bastien Guerry <bzg AT altern DOT org>
 ;; Keywords: org, wp, tex
index 2ba13d2e965b727c1f06aec183a04bc851c52153..18b169bebf740b330fa48b09ada45db507001742 100644 (file)
@@ -6,7 +6,7 @@
 ;; Author: Carsten Dominik <carsten at orgmode dot org>
 ;; Keywords: outlines, hypermedia, calendar, wp
 ;; Homepage: http://orgmode.org
-;; Version: 6.19e
+;; Version: 6.20c
 ;;
 ;; This file is part of GNU Emacs.
 ;;
@@ -400,15 +400,15 @@ changes."
 (defface org-clock-overlay ;; copied from secondary-selection
   (org-compatible-face nil
     '((((class color) (min-colors 88) (background light))
-       :background "yellow1")
+       (:background "yellow1"))
       (((class color) (min-colors 88) (background dark))
-       :background "SkyBlue4")
+       (:background "SkyBlue4"))
       (((class color) (min-colors 16) (background light))
-       :background "yellow")
+       (:background "yellow"))
       (((class color) (min-colors 16) (background dark))
-       :background "SkyBlue4")
+       (:background "SkyBlue4"))
       (((class color) (min-colors 8))
-       :background "cyan" :foreground "black")
+       (:background "cyan" :foreground "black"))
       (t (:inverse-video t))))
     "Basic face for displaying the secondary selection."
     :group 'org-faces)
@@ -456,6 +456,11 @@ belong to the weekend.")
   "Face for items scheduled for a certain day."
   :group 'org-faces)
 
+(defface org-agenda-dimmed-todo-face
+  '((((background light)) (:foreground "grey50"))
+    (((background dark)) (:foreground "grey50")))
+  "Face used to dimm blocked tasks in the agenda."
+  :group 'org-faces)
 
 (defface org-scheduled-previously
   (org-compatible-face nil
index 4372411c06d757aca0757c7713a0466fd7793ad5..94112d0f4505124c0526397363373e78919044ff 100644 (file)
@@ -5,7 +5,7 @@
 ;; Author: Carsten Dominik <carsten at orgmode dot org>
 ;; Keywords: outlines, hypermedia, calendar, wp
 ;; Homepage: http://orgmode.org
-;; Version: 6.19e
+;; Version: 6.20c
 ;;
 ;; This file is part of GNU Emacs.
 ;;
index 393d47b25c9c3c677321e37bd4413e014e118ddf..ee5fcbcfb81cb5075a55b5e6a7b65865bed1c9c4 100644 (file)
@@ -7,7 +7,7 @@
 ;;         Tassilo Horn <tassilo at member dot fsf dot org>
 ;; Keywords: outlines, hypermedia, calendar, wp
 ;; Homepage: http://orgmode.org
-;; Version: 6.19e
+;; Version: 6.20c
 ;;
 ;; This file is part of GNU Emacs.
 ;;
index 659142b7191f07f3ec04808832581d71d1a30d84..b68241d7257751aa2130b400004d072afed924e9 100644 (file)
@@ -5,7 +5,7 @@
 ;; Author: Carsten Dominik <carsten at orgmode dot org>
 ;; Keywords: outlines, hypermedia, calendar, wp
 ;; Homepage: http://orgmode.org
-;; Version: 6.19e
+;; Version: 6.20c
 ;;
 ;; This file is part of GNU Emacs.
 ;;
index 388ae9d8212b2de83eeaf3b04eb3a554afa37054..223248f568ac4d925c0129144e4c2f604f499bd8 100644 (file)
@@ -6,7 +6,7 @@
 ;; Author: Carsten Dominik <carsten at orgmode dot org>
 ;; Keywords: outlines, hypermedia, calendar, wp
 ;; Homepage: http://orgmode.org
-;; Version: 6.19e
+;; Version: 6.20c
 ;;
 ;; This file is part of GNU Emacs.
 ;;
index ddf9e3bc6354ed0fa78ae0a7f674768960c54c7d..d9ecf6524ce1a4b895eb2a8e9bda3b1101a44b4f 100644 (file)
@@ -4,7 +4,7 @@
 ;;
 ;; Author: Philip Jackson <emacs@shellarchive.co.uk>
 ;; Keywords: erc, irc, link, org
-;; Version: 6.19e
+;; Version: 6.20c
 ;;
 ;; This file is part of GNU Emacs.
 ;;
index d2b49a007d4e9cb3ee454c22e3a2c684c93c91ca..b74122b9cf9dcbb1297c5558b66c92a9f51d7d6f 100644 (file)
@@ -6,7 +6,7 @@
 ;; Author: Carsten Dominik <carsten at orgmode dot org>
 ;; Keywords: outlines, hypermedia, calendar, wp
 ;; Homepage: http://orgmode.org
-;; Version: 6.19e
+;; Version: 6.20c
 ;;
 ;; This file is part of GNU Emacs.
 ;;
index 08140a348037996585e81547dd5ad4d90b52c26b..78f3552e9b3bde132337170003e921e3fff54206 100644 (file)
@@ -7,7 +7,7 @@
 ;;        Bastien Guerry <bzg AT altern DOT org>
 ;; Keywords: outlines, hypermedia, calendar, wp
 ;; Homepage: http://orgmode.org
-;; Version: 6.19e
+;; Version: 6.20c
 ;;
 ;; This file is part of GNU Emacs.
 ;;
@@ -248,11 +248,15 @@ Return t when things worked, nil when we are not in an item."
         (skip-chars-forward " \t")
         (looking-at "\\[[- X]\\]"))))
 
-(defun org-toggle-checkbox (&optional arg)
-  "Toggle the checkbox in the current line."
+(defun org-toggle-checkbox (&optional toggle-presence)
+  "Toggle the checkbox in the current line.
+With prefix arg TOGGLE-PRESENCE, add or remove checkboxes.
+When there is an active region, toggle status or presence of the checkbox
+in the first line, and make every item in the region have the same
+status or precence, respectively."
   (interactive "P")
   (catch 'exit
-    (let (beg end status (firstnew 'unknown))
+    (let (beg end status first-present first-status)
       (cond
        ((org-region-active-p)
        (setq beg (region-beginning) end (region-end)))
@@ -260,23 +264,46 @@ Return t when things worked, nil when we are not in an item."
        (setq beg (point) end (save-excursion (outline-next-heading) (point))))
        ((org-at-item-checkbox-p)
        (let ((pos (point)))
-         (replace-match
-          (cond (arg "[-]")
-                ((member (match-string 0) '("[ ]" "[-]")) "[X]")
-                (t "[ ]"))
-          t t)
+         (if toggle-presence
+             (progn
+               (replace-match "")
+               (goto-char (match-beginning 0))
+               (just-one-space))
+           (replace-match
+            (cond ((member (match-string 0) '("[ ]" "[-]")) "[X]")
+                  (t "[ ]"))
+            t t))
          (goto-char pos))
        (throw 'exit t))
+       ((org-at-item-p)
+       ;; add a checkbox
+       (save-excursion
+         (goto-char (match-end 0))
+         (insert "[ ] "))
+       (throw 'exit t))
        (t (error "Not at a checkbox or heading, and no active region")))
+      (setq end (move-marker (make-marker) end))
       (save-excursion
        (goto-char beg)
+       (setq first-present (org-at-item-checkbox-p)
+             first-status (and first-present (equal (match-string 0) "[X]")))
        (while (< (point) end)
-         (when (org-at-item-checkbox-p)
-           (setq status (equal (match-string 0) "[X]"))
-           (when (eq firstnew 'unknown)
-             (setq firstnew (not status)))
-           (replace-match
-            (if (if arg (not status) firstnew) "[X]" "[ ]") t t))
+         (if toggle-presence
+             (cond
+              ((and first-present (org-at-item-checkbox-p))
+               (save-excursion
+                 (replace-match "")
+                 (goto-char (match-beginning 0))
+                 (just-one-space)))
+              ((and (not first-present) (not (org-at-item-checkbox-p))
+                    (org-at-item-p))
+               (save-excursion
+                 (goto-char (match-end 0))
+                 (insert "[ ] "))))
+           (when (org-at-item-checkbox-p)
+             (setq status (equal (match-string 0) "[X]"))
+             (replace-match
+              (if first-status "[ ]" "[X]") t t)))
          (beginning-of-line 2)))))
   (org-update-checkbox-count-maybe))
 
index 3a94d2feafa2a3d2a7e742a54b5a29d82cf3e8e0..6d721261fecaa7212cb9792309d515c895364d6a 100644 (file)
@@ -3,7 +3,7 @@
 ;; Copyright (C) 2008, 2009 Free Software Foundation, Inc.
 
 ;; Author: John Wiegley <johnw@gnu.org>
-;; Version: 6.19e
+;; Version: 6.20c
 ;; Keywords: outlines, hypermedia, calendar, wp
 
 ;; This file is part of GNU Emacs.
index 70c9fc390a84a31fcf9c16d972c6e7a96917a0bf..5f8c5cf07c8ab76e4ac7956bba8b7315b797a0d2 100644 (file)
@@ -6,7 +6,7 @@
 ;; Author: Carsten Dominik <carsten at orgmode dot org>
 ;; Keywords: outlines, hypermedia, calendar, wp
 ;; Homepage: http://orgmode.org
-;; Version: 6.19e
+;; Version: 6.20c
 ;;
 ;; This file is part of GNU Emacs.
 ;;
index afbbe9a88f17dfa54b1ea1522c29f7358b343f48..99678a348ae19d95ca9473ff8609c1a325b048e2 100644 (file)
@@ -5,7 +5,7 @@
 ;; Author: Tokuya Kameshima <kames at fa2 dot so-net dot ne dot jp>
 ;; Keywords: outlines, hypermedia, calendar, wp
 ;; Homepage: http://orgmode.org
-;; Version: 6.19e
+;; Version: 6.20c
 
 ;; This file is part of GNU Emacs.
 
index d8276f09e5367904924471dcdef020ad673bd7e4..7333e146c7be4c8c375142e2f79572809291e7bd 100644 (file)
@@ -6,7 +6,7 @@
 ;; Author: Thomas Baumann <thomas dot baumann at ch dot tum dot de>
 ;; Keywords: outlines, hypermedia, calendar, wp
 ;; Homepage: http://orgmode.org
-;; Version: 6.19e
+;; Version: 6.20c
 ;;
 ;; This file is part of GNU Emacs.
 ;;
index a0597fec6ee4599d3adda982376e7d6824605285..2fef3c5aa895d89d4c72c1f1288d40582e2ffe09 100644 (file)
@@ -4,7 +4,7 @@
 ;;
 ;; Author: Piotr Zielinski <piotr dot zielinski at gmail dot com>
 ;; Maintainer: Carsten Dominik <carsten at orgmode dot org>
-;; Version: 6.19e
+;; Version: 6.20c
 ;;
 ;; This file is part of GNU Emacs.
 ;;
index fadd3541d0a62aa94a1730d0d9719f1b548bf589..9c0bb14e495a4d52b1df264d035f0c5e97266bd3 100644 (file)
@@ -5,7 +5,7 @@
 ;; Author: Eric Schulte <schulte dot eric at gmail dot com>
 ;; Keywords: tables, plotting
 ;; Homepage: http://orgmode.org
-;; Version: 6.19e
+;; Version: 6.20c
 ;;
 ;; This file is part of GNU Emacs.
 ;;
index 1ad5ae6820baa5d2ae6c55af56b8c3a24586ce99..d08a1ce5cc5ca457db4f12350d83378b4f12f8c6 100644 (file)
@@ -4,7 +4,7 @@
 ;; Author: David O'Toole <dto@gnu.org>
 ;; Maintainer: Bastien Guerry <bzg AT altern DOT org>
 ;; Keywords: hypermedia, outlines, wp
-;; Version: 6.19e
+;; Version: 6.20c
 
 ;; This file is part of GNU Emacs.
 ;;
index 74a7ada51db78e17aa1b052e6eb78345445e6153..a16d3bdea0aeb3d423422211a623a9511d9976e5 100644 (file)
@@ -6,7 +6,7 @@
 ;; Author: Carsten Dominik <carsten at orgmode dot org>
 ;; Keywords: outlines, hypermedia, calendar, wp
 ;; Homepage: http://orgmode.org
-;; Version: 6.19e
+;; Version: 6.20c
 ;;
 ;; This file is part of GNU Emacs.
 ;;
index 895da636deca1bdd7a33ca30ca982d0ffb2ef5e1..e24815c99e80644e65d747dac4a64d44f3d3a932 100644 (file)
@@ -6,7 +6,7 @@
 ;; Author: Carsten Dominik <carsten at orgmode dot org>
 ;; Keywords: outlines, hypermedia, calendar, wp
 ;; Homepage: http://orgmode.org
-;; Version: 6.19e
+;; Version: 6.20c
 ;;
 ;; This file is part of GNU Emacs.
 ;;
@@ -52,7 +52,8 @@
       (save-restriction
        (when (eq major-mode 'rmail-summary-mode)
          (rmail-show-message rmail-current-message))
-       (rmail-narrow-to-non-pruned-header)
+       (when (fboundp 'rmail-narrow-to-non-pruned-header)
+         (rmail-narrow-to-non-pruned-header))
        (let* ((folder buffer-file-name)
               (message-id (mail-fetch-field "message-id"))
               (from (mail-fetch-field "from"))
index 0c78685752c69a50878f79dc02ce8698ffbffd29..0b369a73adf8a69a3459aed08dae03f5e79b2d94 100644 (file)
@@ -6,7 +6,7 @@
 ;; Author: Carsten Dominik <carsten at orgmode dot org>
 ;; Keywords: outlines, hypermedia, calendar, wp
 ;; Homepage: http://orgmode.org
-;; Version: 6.19e
+;; Version: 6.20c
 ;;
 ;; This file is part of GNU Emacs.
 ;;
index 4c3584b4e7b2f2447785c9affc152f73434c1a50..632fe6d8fd00fa5ab79efde8ffe6197588d42c9f 100644 (file)
@@ -5,7 +5,7 @@
 ;; Author: Carsten Dominik <carsten at orgmode dot org>
 ;; Keywords: outlines, hypermedia, calendar, wp
 ;; Homepage: http://orgmode.org
-;; Version: 6.19e
+;; Version: 6.20c
 ;;
 ;; This file is part of GNU Emacs.
 ;;
index 2f12d6de07f35f37227e65356ec47c055eb5c0a0..cd625248a9550086f2b5c7f71ccdc674fe7cc111 100644 (file)
@@ -6,7 +6,7 @@
 ;; Author: Carsten Dominik <carsten at orgmode dot org>
 ;; Keywords: outlines, hypermedia, calendar, wp
 ;; Homepage: http://orgmode.org
-;; Version: 6.19e
+;; Version: 6.20c
 ;;
 ;; This file is part of GNU Emacs.
 ;;
index 808199e4bbae021c9da50f4cc7197488c6c64f28..f466fc34b322c3fe342a9f8b4dd9f64197a158d2 100644 (file)
@@ -5,7 +5,7 @@
 ;; Author: Andy Stewart <lazycat dot manatee at gmail dot com>
 ;; Keywords: outlines, hypermedia, calendar, wp
 ;; Homepage: http://orgmode.org
-;; Version: 6.19e
+;; Version: 6.20c
 ;;
 ;; This file is part of GNU Emacs.
 ;;
index 91d29ff0d9c2b2c9f688f8ce209a6bc96c9e2d82..ffbfee42e3d594cac1a1acb186a682249d3e86b2 100644 (file)
@@ -6,7 +6,7 @@
 ;; Author: Tokuya Kameshima <kames at fa2 dot so-net dot ne dot jp>
 ;; Keywords: outlines, hypermedia, calendar, wp
 ;; Homepage: http://orgmode.org
-;; Version: 6.19e
+;; Version: 6.20c
 ;;
 ;; This file is part of GNU Emacs.
 ;;
index 5508b814f9947e09af6133a32d6ad4d1d4b4b2a2..c99159c754f20230c03525e7025f10769038856b 100644 (file)
@@ -6,7 +6,7 @@
 ;; Author: Carsten Dominik <carsten at orgmode dot org>
 ;; Keywords: outlines, hypermedia, calendar, wp
 ;; Homepage: http://orgmode.org
-;; Version: 6.19e
+;; Version: 6.20c
 ;;
 ;; This file is part of GNU Emacs.
 ;;
@@ -94,7 +94,7 @@
 
 ;;; Version
 
-(defconst org-version "6.19e"
+(defconst org-version "6.20c"
   "The version number of the file org.el.")
 
 (defun org-version (&optional here)
@@ -1603,6 +1603,49 @@ Lisp variable `state'."
   :group 'org-todo
   :type 'hook)
 
+(defvar org-blocker-hook nil
+  "Hook for functions that are allowed to block a state change.
+
+Each function gets as its single argument a property list, see
+`org-trigger-hook' for more information about this list.
+
+If any of the functions in this hook returns nil, the state change
+is blocked.")
+
+(defvar org-trigger-hook nil
+  "Hook for functions that are triggered by a state change.
+
+Each function gets as its single argument a property list with at least
+the following elements:
+
+ (:type type-of-change :position pos-at-entry-start
+  :from old-state :to new-state)
+
+Depending on the type, more properties may be present.
+
+This mechanism is currently implemented for:
+
+TODO state changes
+------------------
+:type  todo-state-change
+:from  previous state (keyword as a string), or nil, or a symbol
+       'todo' or 'done', to indicate the general type of state.
+:to    new state, like in :from")
+
+(defcustom org-enforce-todo-dependencies nil
+  "Non-nil means, undone TODO entries will block switching the parent to DONE.
+Also, if a parent has an :ORDERED: property, switching an entry to DONE will
+be blocked if any prior sibling is not yet done.
+You need to set this variable through the customize interface, or to
+restart emacs after changing the value."
+  :set (lambda (var val)
+        (set var val)
+        (if val
+            (add-hook 'org-blocker-hook 'org-block-todo-from-children-or-siblings)
+          (remove-hook 'org-blocker-hook 'org-block-todo-from-children-or-siblings)))
+  :group 'org-todo
+  :type 'boolean)
+
 (defcustom org-todo-state-tags-triggers nil
   "Tag changes that should be triggered by TODO state changes.
 This is a list.  Each entry is
@@ -8272,34 +8315,6 @@ this is nil.")
              (push (nth 2 e) rtn)))
          rtn)))))
 
-(defvar org-blocker-hook nil
-  "Hook for functions that are allowed to block a state change.
-
-Each function gets as its single argument a property list, see
-`org-trigger-hook' for more information about this list.
-
-If any of the functions in this hook returns nil, the state change
-is blocked.")
-
-(defvar org-trigger-hook nil
-  "Hook for functions that are triggered by a state change.
-
-Each function gets as its single argument a property list with at least
-the following elements:
-
- (:type type-of-change :position pos-at-entry-start
-  :from old-state :to new-state)
-
-Depending on the type, more properties may be present.
-
-This mechanism is currently implemented for:
-
-TODO state changes
-------------------
-:type  todo-state-change
-:from  previous state (keyword as a string), or nil
-:to    new state (keyword as a string), or nil")
-
 (defvar org-agenda-headline-snapshot-before-repeat)
 (defun org-todo (&optional arg)
   "Change the TODO state of an item.
@@ -8492,6 +8507,60 @@ For calling through lisp, arg is also interpreted in the following way:
          (save-excursion
            (run-hook-with-args 'org-trigger-hook change-plist)))))))
 
+(defun org-block-todo-from-children-or-siblings (change-plist)
+  "Block turning an entry into a TODO, using the hierarchy.
+This checks whether the current task should be blocked from state
+changes.  Such blocking occurs when:
+
+  1. The task has children which are not all in a completed state.
+
+  2. A task has a parent with the property :ORDERED:, and there
+     are siblings prior to the current task with incomplete
+     status."
+  (catch 'dont-block
+    ;; If this is not a todo state change, or if this entry is already DONE,
+    ;; do not block
+    (when (or (not (eq (plist-get change-plist :type) 'todo-state-change))
+             (member (plist-get change-plist :from)
+                     (cons 'done org-done-keywords)))
+      (throw 'dont-block t))
+    ;; If this task has children, and any are undone, it's blocked
+    (save-excursion
+      (org-back-to-heading t)
+      (let ((this-level (funcall outline-level)))
+       (outline-next-heading)
+       (let ((child-level (funcall outline-level)))
+         (while (and (not (eobp))
+                     (> child-level this-level))
+           ;; this todo has children, check whether they are all
+           ;; completed
+           (if (and (not (org-entry-is-done-p))
+                    (org-entry-is-todo-p))
+               (throw 'dont-block nil))
+           (outline-next-heading)
+           (setq child-level (funcall outline-level))))))
+    ;; Otherwise, if the task's parent has the :ORDERED: property, and
+    ;; any previous siblings are undone, it's blocked
+    (save-excursion
+      (org-back-to-heading t)
+      (when (save-excursion
+             (ignore-errors
+               (outline-up-heading 1)
+               (org-entry-get (point) "ORDERED")))
+       (let* ((this-level (funcall outline-level))
+              (current-level this-level))
+         (while (and (not (bobp))
+                     (= current-level this-level))
+           (outline-previous-heading)
+           (setq current-level (funcall outline-level))
+           (if (= current-level this-level)
+               ;; this todo has children, check whether they are all
+               ;; completed
+               (if (and (not (org-entry-is-done-p))
+                        (org-entry-is-todo-p))
+                   (throw 'dont-block nil)))))))
+    t))                                        ; don't block
+
 (defun org-update-parent-todo-statistics ()
   "Update any statistics cookie in the parent of the current headline."
   (interactive)
@@ -8599,49 +8668,50 @@ Returns the new TODO keyword, or nil if no state change should occur."
         (ncol (/ (- (window-width) 4) fwidth))
         tg cnt e c tbl
         groups ingroup)
-    (save-window-excursion
-      (if expert
-         (set-buffer (get-buffer-create " *Org todo*"))
-       (org-switch-to-buffer-other-window (get-buffer-create " *Org todo*")))
-      (erase-buffer)
-      (org-set-local 'org-done-keywords done-keywords)
-      (setq tbl fulltable cnt 0)
-      (while (setq e (pop tbl))
+    (save-excursion
+      (save-window-excursion
+       (if expert
+           (set-buffer (get-buffer-create " *Org todo*"))
+         (org-switch-to-buffer-other-window (get-buffer-create " *Org todo*")))
+       (erase-buffer)
+       (org-set-local 'org-done-keywords done-keywords)
+       (setq tbl fulltable cnt 0)
+       (while (setq e (pop tbl))
+         (cond
+          ((equal e '(:startgroup))
+           (push '() groups) (setq ingroup t)
+           (when (not (= cnt 0))
+             (setq cnt 0)
+             (insert "\n"))
+           (insert "{ "))
+          ((equal e '(:endgroup))
+           (setq ingroup nil cnt 0)
+           (insert "}\n"))
+          (t
+           (setq tg (car e) c (cdr e))
+           (if ingroup (push tg (car groups)))
+           (setq tg (org-add-props tg nil 'face
+                                   (org-get-todo-face tg)))
+           (if (and (= cnt 0) (not ingroup)) (insert "  "))
+           (insert "[" c "] " tg (make-string
+                                  (- fwidth 4 (length tg)) ?\ ))
+           (when (= (setq cnt (1+ cnt)) ncol)
+             (insert "\n")
+             (if ingroup (insert "  "))
+             (setq cnt 0)))))
+       (insert "\n")
+       (goto-char (point-min))
+       (if (not expert) (org-fit-window-to-buffer))
+       (message "[a-z..]:Set [SPC]:clear")
+       (setq c (let ((inhibit-quit t)) (read-char-exclusive)))
        (cond
-        ((equal e '(:startgroup))
-         (push '() groups) (setq ingroup t)
-         (when (not (= cnt 0))
-           (setq cnt 0)
-           (insert "\n"))
-         (insert "{ "))
-        ((equal e '(:endgroup))
-         (setq ingroup nil cnt 0)
-         (insert "}\n"))
-        (t
-         (setq tg (car e) c (cdr e))
-         (if ingroup (push tg (car groups)))
-         (setq tg (org-add-props tg nil 'face
-                                 (org-get-todo-face tg)))
-         (if (and (= cnt 0) (not ingroup)) (insert "  "))
-         (insert "[" c "] " tg (make-string
-                                (- fwidth 4 (length tg)) ?\ ))
-         (when (= (setq cnt (1+ cnt)) ncol)
-           (insert "\n")
-           (if ingroup (insert "  "))
-           (setq cnt 0)))))
-      (insert "\n")
-      (goto-char (point-min))
-      (if (not expert) (org-fit-window-to-buffer))
-      (message "[a-z..]:Set [SPC]:clear")
-      (setq c (let ((inhibit-quit t)) (read-char-exclusive)))
-      (cond
-       ((or (= c ?\C-g)
-           (and (= c ?q) (not (rassoc c fulltable))))
-       (setq quit-flag t))
-       ((= c ?\ ) nil)
-       ((setq e (rassoc c fulltable) tg (car e))
-       tg)
-       (t (setq quit-flag t))))))
+        ((or (= c ?\C-g)
+             (and (= c ?q) (not (rassoc c fulltable))))
+         (setq quit-flag t))
+        ((= c ?\ ) nil)
+        ((setq e (rassoc c fulltable) tg (car e))
+         tg)
+        (t (setq quit-flag t)))))))
 
 (defun org-entry-is-todo-p ()
   (member (org-get-todo-state) org-not-done-keywords))