Rasmus <ras...@gmx.us> wrote: > Kyle Meyer <k...@kyleam.com> writes: >> ** TODO h >> DEADLINE: <2015-07-13 Mon +3w> >> >> and I run org-todo with a numeric prefix of -1, the repeater is canceled >> by changing it to +0w: > > I see. Shouldn't org-todo rather remove the repeater?
That seems fine to me. I wonder if there was a particular reason the original code set it to 0 instead. >> (+ daynr 1000))) >> - ((and daynr (string-match "\\+[0-9]+[hdwmy]" s)) >> + ((and daynr (not (string-match "\\+0[hdwmy]" s)) >> + (string-match "\\+[0-9]+[hdwmy]" s)) > > for no particular reason I prefer: > > (and daynr (string-match "\\+\\([0-9]+\\)[hdwmy]" s) > (> (string-to-number (match-string 1)) 0)) I do too (though I think s should be added to the match-string call). >> - (setq dn (string-to-number (match-string 1 change)) >> - dw (cdr (assoc (match-string 2 change) a1))) >> + (when (string-match "\\(\\+[0-9]+\\)\\([hdwmy]\\)" change) >> + (setq dn (string-to-number (match-string 1 change)) >> + dw (cdr (assoc (match-string 2 change) a1)))) >> + (unless (wholenump dn) > > Shouldn'it it also test that dn > 0? Doh, it should. I've attached an updated patch. Thanks for your comments.
>From 06e6f0bf1e1a23c4d9426191c321a971cdfeafae Mon Sep 17 00:00:00 2001 From: Kyle Meyer <k...@kyleam.com> Date: Fri, 10 Jul 2015 22:34:24 -0400 Subject: [PATCH] org-closest-date: Don't accept canceled repeater * lisp/org.el (org-time-string-to-absolute): Don't pass a canceled repeater to org-closest-date. (org-closest-date): Raise an error when passed a canceled repeater. Prevent arith-error from occurring when a canceled repeater is passed to org-closest-date. --- lisp/org.el | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/lisp/org.el b/lisp/org.el index 085b763..31e7674 100755 --- a/lisp/org.el +++ b/lisp/org.el @@ -17564,7 +17564,8 @@ (defun org-time-string-to-absolute (s &optional daynr prefer show-all buffer pos (if (org-diary-sexp-entry (match-string 1 s) "" date) daynr (+ daynr 1000))) - ((and daynr (string-match "\\+[0-9]+[hdwmy]" s)) + ((and daynr (string-match "\\+\\([0-9]+\\)[hdwmy]" s) + (> (string-to-number (match-string 1 s)) 0)) (org-closest-date s (if (and (boundp 'daynr) (integerp daynr)) daynr (time-to-days (current-time))) (match-string 0 s) prefer show-all)) @@ -17680,9 +17681,10 @@ (defun org-closest-date (start current change prefer show-all) (if (<= cday sday) (throw 'exit sday)) - (if (string-match "\\(\\+[0-9]+\\)\\([hdwmy]\\)" change) - (setq dn (string-to-number (match-string 1 change)) - dw (cdr (assoc (match-string 2 change) a1))) + (when (string-match "\\(\\+[0-9]+\\)\\([hdwmy]\\)" change) + (setq dn (string-to-number (match-string 1 change)) + dw (cdr (assoc (match-string 2 change) a1)))) + (unless (and dn (> dn 0)) (user-error "Invalid change specifier: %s" change)) (if (eq dw 'week) (setq dw 'day dn (* 7 dn))) (cond -- 2.4.5
-- Kyle