emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
From: Noorul Islam K M <noorul@noorul.com>
To: paulusm <paulusm@bigpond.com>
Cc: emacs-orgmode@gnu.org
Subject: [PATCH] Re: Bug: habit: better error handling required [TAG=7.01g]
Date: Wed, 25 Aug 2010 14:42:27 +0530	[thread overview]
Message-ID: <87iq2zkqdg.fsf@noorul.maa.corp.collab.net> (raw)
In-Reply-To: <20100824115616.T1L77.22653.root@nskntwebs04p> (paulusm@bigpond.com's message of "Tue, 24 Aug 2010 11:56:16 +0000")

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

paulusm <paulusm@bigpond.com> 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


[-- Attachment #2: org-habit.txt --]
[-- Type: text/plain, Size: 1242 bytes --]

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)

[-- Attachment #3: Type: text/plain, Size: 201 bytes --]

_______________________________________________
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

  reply	other threads:[~2010-08-25  9:13 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-08-24 11:56 Bug: habit: better error handling required [TAG=7.01g] paulusm
2010-08-25  9:12 ` Noorul Islam K M [this message]
2010-08-25 10:17   ` [Accepted] " Carsten Dominik
2010-08-25 10:37     ` Noorul Islam K M

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=87iq2zkqdg.fsf@noorul.maa.corp.collab.net \
    --to=noorul@noorul.com \
    --cc=emacs-orgmode@gnu.org \
    --cc=paulusm@bigpond.com \
    /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).