Merge branch 'maint'

This commit is contained in:
Nicolas Goaziou 2015-08-06 18:01:04 +02:00
commit 00ba78c78d
3 changed files with 84 additions and 47 deletions

View File

@ -3857,35 +3857,35 @@ dimming them."
(interactive "P") (interactive "P")
(when (org-called-interactively-p 'interactive) (when (org-called-interactively-p 'interactive)
(message "Dim or hide blocked tasks...")) (message "Dim or hide blocked tasks..."))
(mapc (lambda (o) (if (eq (overlay-get o 'org-type) 'org-blocked-todo) (dolist (o (overlays-in (point-min) (point-max)))
(delete-overlay o))) (when (eq (overlay-get o 'org-type) 'org-blocked-todo)
(overlays-in (point-min) (point-max))) (delete-overlay o)))
(save-excursion (save-excursion
(let ((inhibit-read-only t) (let ((inhibit-read-only t)
(org-depend-tag-blocked nil) (org-depend-tag-blocked nil)
(invis (or (not (null invisible)) org-blocked-by-checkboxes)
(eq org-agenda-dim-blocked-tasks 'invisible)))
org-blocked-by-checkboxes
invis1 b e p ov h l)
(goto-char (point-min)) (goto-char (point-min))
(while (let ((pos (next-single-property-change (point) 'todo-state))) (while (let ((pos (text-property-not-all
(and pos (goto-char (1+ pos)))) (point) (point-max) 'todo-state nil)))
(setq org-blocked-by-checkboxes nil invis1 invis) (when pos (goto-char (1+ pos))))
(setq org-blocked-by-checkboxes nil)
(let ((marker (org-get-at-bol 'org-hd-marker))) (let ((marker (org-get-at-bol 'org-hd-marker)))
(when (and marker (when (and (markerp marker)
(with-current-buffer (marker-buffer marker) (with-current-buffer (marker-buffer marker)
(save-excursion (goto-char marker) (save-excursion (goto-char marker)
(org-entry-blocked-p)))) (org-entry-blocked-p))))
(if org-blocked-by-checkboxes (setq invis1 nil)) ;; Entries blocked by checkboxes cannot be made invisible.
(setq b (if invis1 ;; See `org-agenda-dim-blocked-tasks' for details.
(max (point-min) (1- (point-at-bol))) (let* ((really-invisible
(point-at-bol)) (and (not org-blocked-by-checkboxes)
e (point-at-eol) (or invisible (eq org-agenda-dim-blocked-tasks
ov (make-overlay b e)) 'invisible))))
(if invis1 (ov (make-overlay (if really-invisible (line-end-position 0)
(overlay-put ov 'invisible t) (line-beginning-position))
(overlay-put ov 'face 'org-agenda-dimmed-todo-face)) (line-end-position))))
(overlay-put ov 'org-type 'org-blocked-todo)))))) (if really-invisible (overlay-put ov 'invisible t)
(overlay-put ov 'face 'org-agenda-dimmed-todo-face))
(overlay-put ov 'org-type 'org-blocked-todo)))))))
(when (org-called-interactively-p 'interactive) (when (org-called-interactively-p 'interactive)
(message "Dim or hide blocked tasks...done"))) (message "Dim or hide blocked tasks...done")))

View File

@ -12840,16 +12840,15 @@ changes because there are unchecked boxes in this entry."
t))) ; do not block t))) ; do not block
(defun org-entry-blocked-p () (defun org-entry-blocked-p ()
"Is the current entry blocked?" "Non-nil if entry at point is blocked."
(org-with-silent-modifications (and (not (org-entry-get nil "NOBLOCKING"))
(if (org-entry-get nil "NOBLOCKING") (member (org-entry-get nil "TODO") org-not-done-keywords)
nil ;; Never block this entry (not (run-hook-with-args-until-failure
(not (run-hook-with-args-until-failure 'org-blocker-hook
'org-blocker-hook (list :type 'todo-state-change
(list :type 'todo-state-change :position (point)
:position (point) :from 'todo
:from 'todo :to 'done)))))
:to 'done))))))
(defun org-update-statistics-cookies (all) (defun org-update-statistics-cookies (all)
"Update the statistics cookie, either from TODO or from checkboxes. "Update the statistics cookie, either from TODO or from checkboxes.

View File

@ -1242,6 +1242,49 @@
(goto-char (point-max)) (goto-char (point-max))
(org-in-commented-heading-p t)))) (org-in-commented-heading-p t))))
(ert-deftest test-org/entry-blocked-p ()
;; Check other dependencies.
(should
(org-test-with-temp-text "* TODO Blocked\n** DONE one\n** TODO two"
(let ((org-enforce-todo-dependencies t)
(org-blocker-hook
'(org-block-todo-from-children-or-siblings-or-parent)))
(org-entry-blocked-p))))
(should-not
(org-test-with-temp-text "* TODO Blocked\n** DONE one\n** DONE two"
(let ((org-enforce-todo-dependencies t)
(org-blocker-hook
'(org-block-todo-from-children-or-siblings-or-parent)))
(org-entry-blocked-p))))
;; Entry without a TODO keyword or with a DONE keyword cannot be
;; blocked.
(should-not
(org-test-with-temp-text "* Blocked\n** TODO one"
(let ((org-enforce-todo-dependencies t)
(org-blocker-hook
'(org-block-todo-from-children-or-siblings-or-parent)))
(org-entry-blocked-p))))
(should-not
(org-test-with-temp-text "* DONE Blocked\n** TODO one"
(let ((org-enforce-todo-dependencies t)
(org-blocker-hook
'(org-block-todo-from-children-or-siblings-or-parent)))
(org-entry-blocked-p))))
;; Follow :ORDERED: specifications.
(should
(org-test-with-temp-text
"* H\n:PROPERTIES:\n:ORDERED: t\n:END:\n** TODO one\n** <point>TODO two"
(let ((org-enforce-todo-dependencies t)
(org-blocker-hook
'(org-block-todo-from-children-or-siblings-or-parent)))
(org-entry-blocked-p))))
(should-not
(org-test-with-temp-text
"* H\n:PROPERTIES:\n:ORDERED: t\n:END:\n** <point>TODO one\n** DONE two"
(let ((org-enforce-todo-dependencies t)
(org-blocker-hook
'(org-block-todo-from-children-or-siblings-or-parent)))
(org-entry-blocked-p)))))
;;; Keywords ;;; Keywords
@ -3340,22 +3383,17 @@ Paragraph<point>"
;; Get "BLOCKED" property. ;; Get "BLOCKED" property.
(should (should
(equal "t" (equal "t"
(org-test-with-temp-text "* Blocked\n** DONE one\n** TODO two" (org-test-with-temp-text "* TODO Blocked\n** DONE one\n** TODO two"
(let ((org-enforce-todo-dependencies t) (let ((org-enforce-todo-dependencies t)
(org-blocker-hook (org-blocker-hook
'(org-block-todo-from-children-or-siblings-or-parent))) '(org-block-todo-from-children-or-siblings-or-parent)))
(cdr (assoc "BLOCKED" (org-entry-properties nil "BLOCKED"))))))) (cdr (assoc "BLOCKED" (org-entry-properties nil "BLOCKED")))))))
(should (should
(equal "t" (equal ""
(org-test-with-temp-text "* Blocked\n** DONE one\n** TODO two" (org-test-with-temp-text "* TODO Blocked\n** DONE one\n** DONE two"
(let ((org-enforce-todo-dependencies t) (let ((org-enforce-todo-dependencies t)
(org-blocker-hook (org-blocker-hook
'(org-block-todo-from-children-or-siblings-or-parent))) '(org-block-todo-from-children-or-siblings-or-parent)))
(cdr (assoc "BLOCKED" (org-entry-properties)))))))
(should
(equal ""
(org-test-with-temp-text "* Blocked\n** DONE one\n** DONE two"
(let ((org-enforce-todo-dependencies t))
(cdr (assoc "BLOCKED" (org-entry-properties nil "BLOCKED"))))))) (cdr (assoc "BLOCKED" (org-entry-properties nil "BLOCKED")))))))
;; Get "CLOSED", "DEADLINE" and "SCHEDULED" properties. ;; Get "CLOSED", "DEADLINE" and "SCHEDULED" properties.
(should (should
@ -3420,20 +3458,20 @@ Paragraph<point>"
;; Get "TIMESTAMP" and "TIMESTAMP_IA" properties. ;; Get "TIMESTAMP" and "TIMESTAMP_IA" properties.
(should (should
(equal "<2012-03-29 thu.>" (equal "<2012-03-29 thu.>"
(org-test-with-temp-text "* Entry\n<2012-03-29 thu.>" (org-test-with-temp-text "* Entry\n<2012-03-29 thu.>"
(cdr (assoc "TIMESTAMP" (org-entry-properties)))))) (cdr (assoc "TIMESTAMP" (org-entry-properties))))))
(should (should
(equal "[2012-03-29 thu.]" (equal "[2012-03-29 thu.]"
(org-test-with-temp-text "* Entry\n[2012-03-29 thu.]" (org-test-with-temp-text "* Entry\n[2012-03-29 thu.]"
(cdr (assoc "TIMESTAMP_IA" (org-entry-properties)))))) (cdr (assoc "TIMESTAMP_IA" (org-entry-properties))))))
(should (should
(equal "<2012-03-29 thu.>" (equal "<2012-03-29 thu.>"
(org-test-with-temp-text "* Entry\n[2014-03-04 tue.]<2012-03-29 thu.>" (org-test-with-temp-text "* Entry\n[2014-03-04 tue.]<2012-03-29 thu.>"
(cdr (assoc "TIMESTAMP" (org-entry-properties nil "TIMESTAMP")))))) (cdr (assoc "TIMESTAMP" (org-entry-properties nil "TIMESTAMP"))))))
(should (should
(equal "[2014-03-04 tue.]" (equal "[2014-03-04 tue.]"
(org-test-with-temp-text "* Entry\n<2012-03-29 thu.>[2014-03-04 tue.]" (org-test-with-temp-text "* Entry\n<2012-03-29 thu.>[2014-03-04 tue.]"
(cdr (assoc "TIMESTAMP_IA" (org-entry-properties nil "TIMESTAMP_IA")))))) (cdr (assoc "TIMESTAMP_IA" (org-entry-properties nil "TIMESTAMP_IA"))))))
;; Get standard properties. ;; Get standard properties.
(should (should
(equal "1" (equal "1"