0
0
Fork 1
mirror of https://git.savannah.gnu.org/git/emacs/org-mode.git synced 2024-08-25 09:32:51 +00:00

Let blocking be turned-off on a per-file basis using local variables

Wes Hardaker writes:

> Attached is a patch that lets local variables define whether or not todo
> dependency blocking should be used (both for TODOs and for checkboxes).
> I have one file in particular that I'm using checkboxes to quickly
> indicate multi-selections from a list but for most of my files I want
> TODOs blocked by uncompleted checkboxes.
>
> Normally org uses hook methods for checking for TODO blocks and this
> patch just inserts a check at the top to test and see if the variable
> turning on the blocking type is still set.
This commit is contained in:
Carsten Dominik 2010-02-01 17:34:50 +01:00
parent b66858acbb
commit 16f73aff96
2 changed files with 76 additions and 68 deletions

View file

@ -1,5 +1,9 @@
2010-02-01 Carsten Dominik <carsten.dominik@gmail.com> 2010-02-01 Carsten Dominik <carsten.dominik@gmail.com>
* org.el (org-block-todo-from-children-or-siblings-or-parent)
(org-block-todo-from-checkboxes): Respect the local variable
value when deciding if blocking should be active.
* org-latex.el (org-export-latex-make-header): Define the align * org-latex.el (org-export-latex-make-header): Define the align
macro if it is not yet defined. macro if it is not yet defined.

View file

@ -10161,54 +10161,56 @@ changes. Such blocking occurs when:
3. The parent of the task is blocked because it has siblings that should 3. The parent of the task is blocked because it has siblings that should
be done first, or is child of a block grandparent TODO entry." be done first, or is child of a block grandparent TODO entry."
(catch 'dont-block (if (not org-enforce-todo-dependencies)
;; If this is not a todo state change, or if this entry is already DONE, t ; if locally turned off don't block
;; do not block (catch 'dont-block
(when (or (not (eq (plist-get change-plist :type) 'todo-state-change)) ;; If this is not a todo state change, or if this entry is already DONE,
(member (plist-get change-plist :from) ;; do not block
(cons 'done org-done-keywords)) (when (or (not (eq (plist-get change-plist :type) 'todo-state-change))
(member (plist-get change-plist :to) (member (plist-get change-plist :from)
(cons 'todo org-not-done-keywords)) (cons 'done org-done-keywords))
(not (plist-get change-plist :to))) (member (plist-get change-plist :to)
(throw 'dont-block t)) (cons 'todo org-not-done-keywords))
;; If this task has children, and any are undone, it's blocked (not (plist-get change-plist :to)))
(save-excursion (throw 'dont-block t))
(org-back-to-heading t) ;; If this task has children, and any are undone, it's blocked
(let ((this-level (funcall outline-level))) (save-excursion
(outline-next-heading) (org-back-to-heading t)
(let ((child-level (funcall outline-level))) (let ((this-level (funcall outline-level)))
(while (and (not (eobp)) (outline-next-heading)
(> child-level this-level)) (let ((child-level (funcall outline-level)))
;; this todo has children, check whether they are all (while (and (not (eobp))
;; completed (> child-level this-level))
(if (and (not (org-entry-is-done-p)) ;; this todo has children, check whether they are all
(org-entry-is-todo-p)) ;; completed
(throw 'dont-block nil)) (if (and (not (org-entry-is-done-p))
(outline-next-heading) (org-entry-is-todo-p))
(setq child-level (funcall outline-level)))))) (throw 'dont-block nil))
;; Otherwise, if the task's parent has the :ORDERED: property, and (outline-next-heading)
;; any previous siblings are undone, it's blocked (setq child-level (funcall outline-level))))))
(save-excursion ;; Otherwise, if the task's parent has the :ORDERED: property, and
(org-back-to-heading t) ;; any previous siblings are undone, it's blocked
(let* ((pos (point)) (save-excursion
(parent-pos (and (org-up-heading-safe) (point)))) (org-back-to-heading t)
(if (not parent-pos) (throw 'dont-block t)) ; no parent (let* ((pos (point))
(when (and (org-entry-get (point) "ORDERED") (parent-pos (and (org-up-heading-safe) (point))))
(forward-line 1)
(re-search-forward org-not-done-heading-regexp pos t))
(throw 'dont-block nil)) ; block, there is an older sibling not done.
;; Search further up the hierarchy, to see if an anchestor is blocked
(while t
(goto-char parent-pos)
(if (not (looking-at org-not-done-heading-regexp))
(throw 'dont-block t)) ; do not block, parent is not a TODO
(setq pos (point))
(setq parent-pos (and (org-up-heading-safe) (point)))
(if (not parent-pos) (throw 'dont-block t)) ; no parent (if (not parent-pos) (throw 'dont-block t)) ; no parent
(when (and (org-entry-get (point) "ORDERED") (when (and (org-entry-get (point) "ORDERED")
(forward-line 1) (forward-line 1)
(re-search-forward org-not-done-heading-regexp pos t)) (re-search-forward org-not-done-heading-regexp pos t))
(throw 'dont-block nil))))))) ; block, older sibling not done. (throw 'dont-block nil)) ; block, there is an older sibling not done.
;; Search further up the hierarchy, to see if an anchestor is blocked
(while t
(goto-char parent-pos)
(if (not (looking-at org-not-done-heading-regexp))
(throw 'dont-block t)) ; do not block, parent is not a TODO
(setq pos (point))
(setq parent-pos (and (org-up-heading-safe) (point)))
(if (not parent-pos) (throw 'dont-block t)) ; no parent
(when (and (org-entry-get (point) "ORDERED")
(forward-line 1)
(re-search-forward org-not-done-heading-regexp pos t))
(throw 'dont-block nil)))))))) ; block, older sibling not done.
(defcustom org-track-ordered-property-with-tag nil (defcustom org-track-ordered-property-with-tag nil
"Should the ORDERED property also be shown as a tag? "Should the ORDERED property also be shown as a tag?
@ -10252,30 +10254,32 @@ See variable `org-track-ordered-property-with-tag'."
"Block turning an entry into a TODO, using checkboxes. "Block turning an entry into a TODO, using checkboxes.
This checks whether the current task should be blocked from state This checks whether the current task should be blocked from state
changes because there are unchecked boxes in this entry." changes because there are unchecked boxes in this entry."
(catch 'dont-block (if (not org-enforce-todo-checkbox-dependencies)
;; If this is not a todo state change, or if this entry is already DONE, t ; if locally turned off don't block
;; do not block (catch 'dont-block
(when (or (not (eq (plist-get change-plist :type) 'todo-state-change)) ;; If this is not a todo state change, or if this entry is already DONE,
(member (plist-get change-plist :from) ;; do not block
(cons 'done org-done-keywords)) (when (or (not (eq (plist-get change-plist :type) 'todo-state-change))
(member (plist-get change-plist :to) (member (plist-get change-plist :from)
(cons 'todo org-not-done-keywords)) (cons 'done org-done-keywords))
(not (plist-get change-plist :to))) (member (plist-get change-plist :to)
(throw 'dont-block t)) (cons 'todo org-not-done-keywords))
;; If this task has checkboxes that are not checked, it's blocked (not (plist-get change-plist :to)))
(save-excursion (throw 'dont-block t))
(org-back-to-heading t) ;; If this task has checkboxes that are not checked, it's blocked
(let ((beg (point)) end) (save-excursion
(outline-next-heading) (org-back-to-heading t)
(setq end (point)) (let ((beg (point)) end)
(goto-char beg) (outline-next-heading)
(if (re-search-forward "^[ \t]*\\([-+*]\\|[0-9]+[.)]\\)[ \t]+\\[[- ]\\]" (setq end (point))
end t) (goto-char beg)
(progn (if (re-search-forward "^[ \t]*\\([-+*]\\|[0-9]+[.)]\\)[ \t]+\\[[- ]\\]"
(if (boundp 'org-blocked-by-checkboxes) end t)
(setq org-blocked-by-checkboxes t)) (progn
(throw 'dont-block nil))))) (if (boundp 'org-blocked-by-checkboxes)
t)) ; do not block (setq org-blocked-by-checkboxes t))
(throw 'dont-block nil)))))
t))) ; do not block
(defun org-entry-blocked-p () (defun org-entry-blocked-p ()
"Is the current entry blocked?" "Is the current entry blocked?"