diff options
author | Noorul Islam <noorul@noorul.com> | 2010-08-25 14:12:27 +0000 |
---|---|---|
committer | Carsten Dominik <carsten.dominik@gmail.com> | 2010-08-25 12:16:47 +0200 |
commit | 92e491e52c09fa2789ff89c8314d77199c5a87e5 (patch) | |
tree | f0f030c21452d9a593be883127676faaf3f43301 | |
parent | 550278c13550237711a66c89696b71c8b9d04632 (diff) | |
download | org-mode-92e491e52c09fa2789ff89c8314d77199c5a87e5.tar.gz |
org-habit.el: better error handling required
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. Use 4th element of the list returned
by (org-heading-components) as habit-entry. Modify the error
message to be more meaningful.
TINYCHANGE
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?
>
>
-rw-r--r-- | lisp/org-habit.el | 10 |
1 files changed, 6 insertions, 4 deletions
diff --git a/lisp/org-habit.el b/lisp/org-habit.el index 2fa352f..f44d0fa 100644 --- a/lisp/org-habit.el +++ b/lisp/org-habit.el @@ -149,15 +149,17 @@ 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) |