emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
From: Kyle Meyer <kyle@kyleam.com>
To: Org-mode <emacs-orgmode@gnu.org>
Subject: [PATCH] org-closest-date: Don't accept canceled repeater
Date: Fri, 10 Jul 2015 22:58:46 -0400	[thread overview]
Message-ID: <87380viemx.fsf@kmlap.domain.org> (raw)

[-- Attachment #1: Type: text/plain, Size: 159 bytes --]

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


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 0001-org-closest-date-Don-t-accept-canceled-repeater.patch --]
[-- Type: text/x-diff, Size: 1797 bytes --]

From 61cba7d42e19479ad3137f0f1ee01dc116d853e2 Mon Sep 17 00:00:00 2001
From: Kyle Meyer <kyle@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..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


             reply	other threads:[~2015-07-11  2:59 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-07-11  2:58 Kyle Meyer [this message]
2015-07-13 10:07 ` [PATCH] org-closest-date: Don't accept canceled repeater Rasmus
2015-07-13 15:06   ` Kyle Meyer
2015-07-15 17:17     ` Rasmus
2015-07-16  1:50       ` Kyle Meyer
2015-07-16  9:44         ` Rasmus

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.orgmode.org/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87380viemx.fsf@kmlap.domain.org \
    --to=kyle@kyleam.com \
    --cc=emacs-orgmode@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).