From mboxrd@z Thu Jan 1 00:00:00 1970 From: Kyle Meyer Subject: [PATCH] org-closest-date: Don't accept canceled repeater Date: Fri, 10 Jul 2015 22:58:46 -0400 Message-ID: <87380viemx.fsf@kmlap.domain.org> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:33576) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZDl0G-0007Jo-Gm for emacs-orgmode@gnu.org; Fri, 10 Jul 2015 22:59:04 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZDl0C-0000at-Kc for emacs-orgmode@gnu.org; Fri, 10 Jul 2015 22:59:00 -0400 Received: from mail-qg0-f43.google.com ([209.85.192.43]:33207) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZDl0C-0000aZ-GW for emacs-orgmode@gnu.org; Fri, 10 Jul 2015 22:58:56 -0400 Received: by qgef3 with SMTP id f3so87643218qge.0 for ; Fri, 10 Jul 2015 19:58:54 -0700 (PDT) Received: from localhost ([2601:18a:c201:560f:9e4e:36ff:fe3d:ae9c]) by smtp.gmail.com with ESMTPSA id 25sm6719152qkw.13.2015.07.10.19.58.53 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 10 Jul 2015 19:58:53 -0700 (PDT) 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: Org-mode --=-=-= Content-Type: text/plain Hello, The attached patch fixes an arithmetic error that occurs when calling org-agenda on a file that contains a heading with a canceled repeater. -- Kyle --=-=-= Content-Type: text/x-diff Content-Disposition: attachment; filename=0001-org-closest-date-Don-t-accept-canceled-repeater.patch >From 61cba7d42e19479ad3137f0f1ee01dc116d853e2 Mon Sep 17 00:00:00 2001 From: Kyle Meyer 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..e1edeb1 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 (not (string-match "\\+0[hdwmy]" s)) + (string-match "\\+[0-9]+[hdwmy]" s)) (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 (wholenump dn) (user-error "Invalid change specifier: %s" change)) (if (eq dw 'week) (setq dw 'day dn (* 7 dn))) (cond -- 2.4.5 --=-=-=--