diff options
author | Bastien Guerry <bzg@altern.org> | 2013-11-13 13:56:12 +0100 |
---|---|---|
committer | Bastien Guerry <bzg@altern.org> | 2013-11-13 13:56:12 +0100 |
commit | 1eb03c8c87de9ccd0506ed90c4938240f5eb9fc2 (patch) | |
tree | d166d92e2991519e1ba979f77d2ddcce7a2cdc79 | |
parent | 7230133f8d5eb2727fea88f16c3f664d4d16a8c2 (diff) | |
download | org-mode-1eb03c8c87de9ccd0506ed90c4938240f5eb9fc2.tar.gz |
org.el: Allow C--1 C-c C-t to set repeated tasks to a done state
* org.el (org-cancel-repeater): New function.
(org-todo): Use the new function to cancel a repeater when
called with a numeric arg of -1.
Thanks to Kenneth Jacker for requesting a similar feature.
-rw-r--r-- | lisp/org.el | 19 |
1 files changed, 18 insertions, 1 deletions
diff --git a/lisp/org.el b/lisp/org.el index 3f677d6..689a362 100644 --- a/lisp/org.el +++ b/lisp/org.el @@ -12125,6 +12125,21 @@ nil or a string to be used for the todo mark." ) (defvar org-block-entry-blocking "" "First entry preventing the TODO state change.") +(defun org-cancel-repeater () + "Cancel a repeater by setting its numeric value to zero." + (interactive) + (save-excursion + (org-back-to-heading t) + (let ((bound1 (point)) + (bound0 (save-excursion (outline-next-heading) (point)))) + (when (re-search-forward + (concat "\\(" org-scheduled-time-regexp "\\)\\|\\(" + org-deadline-time-regexp "\\)\\|\\(" + org-ts-regexp "\\)") + bound0 t) + (if (re-search-backward "[ \t]+\\(?:[.+]\\)?\\+\\([0-9]+\\)[hdwmy]" bound1 t) + (replace-match "0" t nil nil 1)))))) + (defun org-todo (&optional arg) "Change the TODO state of an item. The state of an item is given by a keyword at the start of the heading, @@ -12145,6 +12160,7 @@ With a double \\[universal-argument] prefix, switch to the next set of TODO \ keywords (nextset). With a triple \\[universal-argument] prefix, circumvent any state blocking. With a numeric prefix arg of 0, inhibit note taking for the change. +With a numeric prefix arg of -1, cancel repeater to allow marking as DONE. When called through ELisp, arg is also interpreted in the following way: 'none -> empty state @@ -12164,6 +12180,7 @@ When called through ELisp, arg is also interpreted in the following way: org-loop-over-headlines-in-active-region cl (if (outline-invisible-p) (org-end-of-subtree nil t)))) (if (equal arg '(16)) (setq arg 'nextset)) + (when (equal arg -1) (org-cancel-repeater) (setq arg nil)) (let ((org-blocker-hook org-blocker-hook) commentp case-fold-search) @@ -12829,7 +12846,7 @@ This function is run automatically after each state change to a DONE state." (org-log-done nil) (org-todo-log-states nil) re type n what ts time to-state) - (when repeat + (when (and repeat (not (zerop (string-to-number repeat)))) (if (eq org-log-repeat t) (setq org-log-repeat 'state)) (setq to-state (or (org-entry-get nil "REPEAT_TO_STATE") org-todo-repeat-to-state)) |