From mboxrd@z Thu Jan 1 00:00:00 1970 From: Bastien Subject: New feature: cancel a repeater to allow marking repeating tasks as DONE Date: Mon, 11 Nov 2013 18:17:49 +0100 Message-ID: <87li0ug8n6.fsf@bzg.ath.cx> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:47328) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Vfv87-00059q-VC for emacs-orgmode@gnu.org; Mon, 11 Nov 2013 12:18:34 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Vfv81-0006CT-QF for emacs-orgmode@gnu.org; Mon, 11 Nov 2013 12:18:27 -0500 Received: from plane.gmane.org ([80.91.229.3]:35118) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Vfv81-0006CM-Cl for emacs-orgmode@gnu.org; Mon, 11 Nov 2013 12:18:21 -0500 Received: from list by plane.gmane.org with local (Exim 4.69) (envelope-from ) id 1Vfv7s-000494-Te for emacs-orgmode@gnu.org; Mon, 11 Nov 2013 18:18:12 +0100 Received: from mar75-2-81-56-68-112.fbx.proxad.net ([81.56.68.112]) by main.gmane.org with esmtp (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Mon, 11 Nov 2013 18:18:12 +0100 Received: from bzg by mar75-2-81-56-68-112.fbx.proxad.net with local (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Mon, 11 Nov 2013 18:18:12 +0100 List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org Sender: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org To: emacs-orgmode@gnu.org --=-=-= Content-Type: text/plain Sometimes it's useful to cancel a repeater: for example, when you want to mark a task as definitely DONE. The attached patch does this by allowing the user to use -1 as the numeric prefix argument for `org-todo'. (It does not delete the repeater, instead it sets it to 0 so that planning information structure is preserved: for example, you can have a repeater and a 'start warning in X days' cookie.) Tests and feedback welcome! --=-=-= Content-Type: text/x-diff Content-Disposition: attachment; filename=0001-org.el-org-cancel-repeater-New-function.patch >From 5b8cc031f11a9989a2a72bb1358b2eafc72d6b8b Mon Sep 17 00:00:00 2001 From: Bastien Guerry Date: Mon, 11 Nov 2013 18:12:06 +0100 Subject: [PATCH 1/2] org.el (org-cancel-repeater): New function * 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. --- lisp/org.el | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/lisp/org.el b/lisp/org.el index 63a27f4..1d65b11 100644 --- a/lisp/org.el +++ b/lisp/org.el @@ -12124,6 +12124,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 it 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, @@ -12163,6 +12178,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) @@ -12828,7 +12844,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)) -- 1.8.4.2 --=-=-= Content-Type: text/plain -- Bastien --=-=-=--