From mboxrd@z Thu Jan 1 00:00:00 1970 From: Noorul Islam K M Subject: [PATCH] Re: Bug: habit: better error handling required [TAG=7.01g] Date: Wed, 25 Aug 2010 14:42:27 +0530 Message-ID: <87iq2zkqdg.fsf@noorul.maa.corp.collab.net> References: <20100824115616.T1L77.22653.root@nskntwebs04p> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" Return-path: Received: from [140.186.70.92] (port=34176 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1OoC3R-00013Y-Ma for emacs-orgmode@gnu.org; Wed, 25 Aug 2010 05:13:58 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.69) (envelope-from ) id 1OoC3Q-0005c4-9S for emacs-orgmode@gnu.org; Wed, 25 Aug 2010 05:13:57 -0400 Received: from mail-pw0-f41.google.com ([209.85.160.41]:60129) by eggs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1OoC3Q-0005bl-4x for emacs-orgmode@gnu.org; Wed, 25 Aug 2010 05:13:56 -0400 Received: by pwi3 with SMTP id 3so385666pwi.0 for ; Wed, 25 Aug 2010 02:13:54 -0700 (PDT) In-Reply-To: <20100824115616.T1L77.22653.root@nskntwebs04p> (paulusm@bigpond.com's message of "Tue, 24 Aug 2010 11:56:16 +0000") List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org Errors-To: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org To: paulusm Cc: emacs-orgmode@gnu.org --=-=-= paulusm writes: > Hi org-mode people, > > Whilst playing with the "shaving" example from > http://orgmode.org/manual/Tracking-your-habits.html I accidentally put a > bad character in the SCHEDULED timestamp. > > Instead of: "SCHEDULED: <2010-08-26 Thu .+2d/4d>" > I had: "SCHEDULED: <2010-08-26 Thu .+2nd/4d>" > > When trying to view my agenda, I was presented with a blank agenda and Emacs > very quietly reported: > "org-habit-duration-to-days: Wrong type argument: stringp, nil" > which is not really helpful. > > Removing the bad character fixes the issue, and I can duplicate the error > condition as described above. > > Perhaps some better error trapping could be done? > > Attached is the patch which catch this error and throws meaningful message. lisp/org-habit.el : (org-habit-parse-todo) - Find sr-days only if scheduled-repeat is non nil - Used 4th element of the list returned by (org-heading-components) as habit-entry - Modified the error message to be more meaningful. Thanks and Regards Noorul --=-=-= Content-Disposition: attachment; filename=org-habit.txt diff --git a/lisp/org-habit.el b/lisp/org-habit.el index 2fa352f..9071e2f 100644 --- a/lisp/org-habit.el +++ b/lisp/org-habit.el @@ -149,15 +149,15 @@ This list represents a \"habit\" for the rest of this module." (assert (org-is-habit-p (point))) (let* ((scheduled (org-get-scheduled-time (point))) (scheduled-repeat (org-get-repeat org-scheduled-string)) - (sr-days (org-habit-duration-to-days scheduled-repeat)) (end (org-entry-end-position)) - (habit-entry (org-no-properties (nth 5 (org-heading-components)))) - closed-dates deadline dr-days) + (habit-entry (org-no-properties (nth 4 (org-heading-components)))) + closed-dates deadline dr-days sr-days) (if scheduled (setq scheduled (time-to-days scheduled)) (error "Habit %s has no scheduled date" habit-entry)) (unless scheduled-repeat - (error "Habit %s has no scheduled repeat period" habit-entry)) + (error "Habit '%s' has no scheduled repeat period or has an incorrect one" habit-entry)) + (setq sr-days (org-habit-duration-to-days scheduled-repeat)) (unless (> sr-days 0) (error "Habit %s scheduled repeat period is less than 1d" habit-entry)) (when (string-match "/\\([0-9]+[dwmy]\\)" scheduled-repeat) --=-=-= Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: inline _______________________________________________ Emacs-orgmode mailing list Please use `Reply All' to send replies to the list. Emacs-orgmode@gnu.org http://lists.gnu.org/mailman/listinfo/emacs-orgmode --=-=-=--