emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
* Bug: habit: better error handling required [TAG=7.01g]
@ 2010-08-24 11:56 paulusm
  2010-08-25  9:12 ` [PATCH] " Noorul Islam K M
  0 siblings, 1 reply; 4+ messages in thread
From: paulusm @ 2010-08-24 11:56 UTC (permalink / raw)
  To: emacs-orgmode

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?


Regards,
Paul.



Emacs  : GNU Emacs 23.2.1 (i486-pc-linux-gnu, GTK+ Version 2.20.0)
 of 2010-05-16 on raven, modified by Debian
Package: Org-mode version TAG=7.01g

current state:
==============
(setq
 org-log-done 'time
 org-export-latex-after-initial-vars-hook '(org-beamer-after-initial-vars)
 org-agenda-files '("~/emacs/GTD/birthdays.org" "~/emacs/GTD/gtd.org"
		    "~/emacs/GTD/various-org-mode-demos.org")
 org-agenda-include-diary t
 org-babel-load-languages '((python . t) (emacs-lisp . t))
 org-metaup-hook '(org-babel-load-in-session-maybe)
 org-after-todo-state-change-hook '(org-clock-out-if-current)
 org-babel-tangle-lang-exts '(("python" . "py") ("emacs-lisp" . "el"))
 org-export-blocks-postblock-hook '(org-exp-res/src-name-cleanup)
 org-export-latex-format-toc-function 'org-export-latex-format-toc-default
 org-export-preprocess-hook '(org-export-blocks-preprocess)
 org-agenda-diary-file "~/emacs/GTD/gtd.org"
 org-tab-first-hook '(org-hide-block-toggle-maybe
		      org-babel-hide-result-toggle-maybe)
 org-src-mode-hook '(org-src-mode-configure-edit-buffer)
 org-confirm-shell-link-function 'yes-or-no-p
 org-export-first-hook '(org-beamer-initialize-open-trackers)
 org-agenda-before-write-hook '(org-agenda-add-entry-text)
 org-default-notes-file "~/emacs/GTD/notes.org"
 org-directory "~/emacs/GTD/"
 org-cycle-hook '(org-cycle-hide-archived-subtrees org-cycle-hide-drawers
		  org-cycle-show-empty-lines
		  org-optimize-window-after-visibility-change)
 org-export-preprocess-before-normalizing-links-hook '(org-remove-file-link-modifiers)
 org-mode-hook '(#[nil "\300\301\302\303\304$\207"
		   [org-add-hook change-major-mode-hook org-show-block-all append
		    local]
		   5]
		 #[nil "\300\301\302\303\304$\207"
		   [org-add-hook change-major-mode-hook org-babel-show-result-all
		    append local]
		   5]
		 org-babel-result-hide-spec org-babel-hide-all-hashes)
 org-agenda-ndays 1
 org-refile-targets '(("gtd.org" :level . 1))
 org-ctrl-c-ctrl-c-hook '(org-babel-lob-execute-maybe org-babel-hash-at-point
			  org-babel-execute-src-block-maybe)
 org-confirm-elisp-link-function 'yes-or-no-p
 org-export-interblocks '((lob org-babel-exp-lob-one-liners)
			  (src org-babel-exp-inline-src-blocks))
 org-occur-hook '(org-first-headline-recenter)
 org-from-is-user-regexp "\\<Paul\\>"
 org-export-preprocess-before-selecting-backend-code-hook '(org-beamer-select-beamer-code)
 org-modules '(org-bbdb org-bibtex org-docview org-gnus org-info org-jsinfo
	       org-habit org-irc org-mew org-mhe org-protocol org-rmail org-vm
	       org-wl org-w3m)
 org-export-latex-final-hook '(org-beamer-amend-header org-beamer-fix-toc
			       org-beamer-auto-fragile-frames
			       org-beamer-place-default-actions-for-lists)
 org-metadown-hook '(org-babel-pop-to-session-maybe)
 org-export-blocks '((src org-babel-exp-src-blocks nil)
		     (comment org-export-blocks-format-comment t)
		     (ditaa org-export-blocks-format-ditaa nil)
		     (dot org-export-blocks-format-dot nil))
 )

^ permalink raw reply	[flat|nested] 4+ messages in thread

* [PATCH] Re: Bug: habit: better error handling required [TAG=7.01g]
  2010-08-24 11:56 Bug: habit: better error handling required [TAG=7.01g] paulusm
@ 2010-08-25  9:12 ` Noorul Islam K M
  2010-08-25 10:17   ` [Accepted] " Carsten Dominik
  0 siblings, 1 reply; 4+ messages in thread
From: Noorul Islam K M @ 2010-08-25  9:12 UTC (permalink / raw)
  To: paulusm; +Cc: emacs-orgmode

[-- 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

^ permalink raw reply related	[flat|nested] 4+ messages in thread

* [Accepted] Re: Bug: habit: better error handling required [TAG=7.01g]
  2010-08-25  9:12 ` [PATCH] " Noorul Islam K M
@ 2010-08-25 10:17   ` Carsten Dominik
  2010-08-25 10:37     ` Noorul Islam K M
  0 siblings, 1 reply; 4+ messages in thread
From: Carsten Dominik @ 2010-08-25 10:17 UTC (permalink / raw)
  To: emacs-orgmode

Patch 241 (http://patchwork.newartisans.com/patch/241/) is now "Accepted".

Maintainer comment: Hat to fix the commit message to contain propert ChangeLog.  Please take a look for next time

This relates to the following submission:

http://mid.gmane.org/%3C87iq2zkqdg.fsf%40noorul.maa.corp.collab.net%3E

Here is the original message containing the patch:

> Content-Type: text/plain; charset="utf-8"
> MIME-Version: 1.0
> Content-Transfer-Encoding: 7bit
> Subject: [Orgmode] Re: Bug: habit: better error handling required [TAG=7.01g]
> Date: Wed, 25 Aug 2010 14:12:27 -0000
> From: Noorul Islam <noorul@noorul.com>
> X-Patchwork-Id: 241
> Message-Id: <87iq2zkqdg.fsf@noorul.maa.corp.collab.net>
> To: paulusm <paulusm@bigpond.com>
> Cc: emacs-orgmode@gnu.org
> 
> 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
> 
> 
> 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)
> 

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: Bug: habit: better error handling required [TAG=7.01g]
  2010-08-25 10:17   ` [Accepted] " Carsten Dominik
@ 2010-08-25 10:37     ` Noorul Islam K M
  0 siblings, 0 replies; 4+ messages in thread
From: Noorul Islam K M @ 2010-08-25 10:37 UTC (permalink / raw)
  To: Carsten Dominik; +Cc: emacs-orgmode

Carsten Dominik <cdominik@newartisans.com> writes:

> Patch 241 (http://patchwork.newartisans.com/patch/241/) is now "Accepted".
>
> Maintainer comment: Hat to fix the commit message to contain propert ChangeLog.  Please take a look for next time
>

I looked at the modified log. I think now I know how it should be. I
will keep this in mind. Thank you for fixing the log.

Thanks and Regards
Noorul

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2010-08-25 10:39 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-08-24 11:56 Bug: habit: better error handling required [TAG=7.01g] paulusm
2010-08-25  9:12 ` [PATCH] " Noorul Islam K M
2010-08-25 10:17   ` [Accepted] " Carsten Dominik
2010-08-25 10:37     ` Noorul Islam K M

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).