summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCarsten Dominik <carsten.dominik@gmail.com>2011-10-04 14:12:11 +0200
committerCarsten Dominik <carsten.dominik@gmail.com>2011-10-04 14:12:11 +0200
commit620913e596be302f72ea35fbb6d80753dc438b1b (patch)
treefaf4f0afd447173409d187df4d6e847db809863a
parenta33fc1ce7d0a1e40072bbf303dc278b39fba7883 (diff)
downloadorg-mode-620913e596be302f72ea35fbb6d80753dc438b1b.tar.gz
Improve error reporting on bad time stamps during agenda construction
* lisp/org.el (org-time-string-to-time): (org-time-string-to-absolute): Add optional arguments BUFFER and POS for error reporting. * lisp/org-agenda.el (org-get-all-dates): (org-agenda-get-timestamps): (org-agenda-get-deadlines): (org-agenda-get-scheduled): (org-agenda-get-blocks): Call time stamp parsing functions with information on where the timestamp was taken from.
-rw-r--r--lisp/org-agenda.el25
-rw-r--r--lisp/org.el22
2 files changed, 34 insertions, 13 deletions
diff --git a/lisp/org-agenda.el b/lisp/org-agenda.el
index b1fa5f5..2b8e343 100644
--- a/lisp/org-agenda.el
+++ b/lisp/org-agenda.el
@@ -3431,22 +3431,26 @@ When EMPTY is non-nil, also include days without any entries."
(let ((re (concat
(if pre-re pre-re "")
(if inactive org-ts-regexp-both org-ts-regexp)))
- dates dates1 date day day1 day2 ts1 ts2)
+ dates dates1 date day day1 day2 ts1 ts2 pos)
(if force-today
(setq dates (list (org-today))))
(save-excursion
(goto-char beg)
(while (re-search-forward re end t)
(setq day (time-to-days (org-time-string-to-time
- (substring (match-string 1) 0 10))))
+ (substring (match-string 1) 0 10)
+ (current-buffer) (match-beginning 0))))
(or (memq day dates) (push day dates)))
(unless no-ranges
(goto-char beg)
(while (re-search-forward org-tr-regexp end t)
+ (setq pos (match-beginning 0))
(setq ts1 (substring (match-string 1) 0 10)
ts2 (substring (match-string 2) 0 10)
- day1 (time-to-days (org-time-string-to-time ts1))
- day2 (time-to-days (org-time-string-to-time ts2)))
+ day1 (time-to-days (org-time-string-to-time
+ ts1 (current-buffer) pos))
+ day2 (time-to-days (org-time-string-to-time
+ ts2 (current-buffer) pos)))
(while (< (setq day1 (1+ day1)) day2)
(or (memq day1 dates) (push day1 dates)))))
(setq dates (sort dates '<))
@@ -4739,7 +4743,8 @@ This function is invoked if `org-agenda-todo-ignore-deadlines',
(org-agenda-skip)
(if (and (match-end 1)
(not (= d1 (org-time-string-to-absolute
- (match-string 1) d1 nil show-all))))
+ (match-string 1) d1 nil show-all
+ (current-buffer) b0))))
(throw :skip nil))
(if (and e3
(not (org-diary-sexp-entry (buffer-substring b3 e3) "" date)))
@@ -5157,7 +5162,8 @@ See also the user option `org-agenda-clock-consistency-checks'."
(member todo-state
org-agenda-repeating-timestamp-show-all))
d2 (org-time-string-to-absolute
- (match-string 1) d1 'past show-all)
+ (match-string 1) d1 'past show-all
+ (current-buffer) pos)
diff (- d2 d1)
wdays (if suppress-prewarning
(let ((org-deadline-warning-days suppress-prewarning))
@@ -5263,7 +5269,8 @@ FRACTION is what fraction of the head-warning time has passed."
(member todo-state
org-agenda-repeating-timestamp-show-all))
d2 (org-time-string-to-absolute
- (match-string 1) d1 'past show-all)
+ (match-string 1) d1 'past show-all
+ (current-buffer) pos)
diff (- d2 d1))
(setq pastschedp (and todayp (< diff 0)))
;; When to show a scheduled item in the calendar:
@@ -5363,8 +5370,8 @@ FRACTION is what fraction of the head-warning time has passed."
(end-time (match-string 2)))
(setq s1 (match-string 1)
s2 (match-string 2)
- d1 (time-to-days (org-time-string-to-time s1))
- d2 (time-to-days (org-time-string-to-time s2)))
+ d1 (time-to-days (org-time-string-to-time s1 (current-buffer) pos))
+ d2 (time-to-days (org-time-string-to-time s2 (current-buffer) pos)))
(if (and (> (- d0 d1) -1) (> (- d2 d0) -1))
;; Only allow days between the limits, because the normal
;; date stamps will catch the limits.
diff --git a/lisp/org.el b/lisp/org.el
index f19fb2e..d1497b3 100644
--- a/lisp/org.el
+++ b/lisp/org.el
@@ -15403,12 +15403,19 @@ days in order to avoid rounding problems."
l (push m l)))
(apply 'format fmt (nreverse l))))
-(defun org-time-string-to-time (s)
- (apply 'encode-time (org-parse-time-string s)))
+(defun org-time-string-to-time (s &optional buffer pos)
+ (condition-case errdata
+ (apply 'encode-time (org-parse-time-string s))
+ (error (error "Bad timestamp `%s'%s\nError was: %s"
+ s (if (not (and buffer pos))
+ ""
+ (format " at %d in buffer `%s'" pos buffer))
+ (cdr errdata)))))
+
(defun org-time-string-to-seconds (s)
(org-float-time (org-time-string-to-time s)))
-(defun org-time-string-to-absolute (s &optional daynr prefer show-all)
+(defun org-time-string-to-absolute (s &optional daynr prefer show-all buffer pos)
"Convert a time stamp to an absolute day number.
If there is a specifier for a cyclic time stamp, get the closest date to
DAYNR.
@@ -15423,7 +15430,14 @@ The variable date is bound by the calendar when this is called."
(org-closest-date s (if (and (boundp 'daynr) (integerp daynr)) daynr
(time-to-days (current-time))) (match-string 0 s)
prefer show-all))
- (t (time-to-days (apply 'encode-time (org-parse-time-string s))))))
+ (t (time-to-days
+ (condition-case errdata
+ (apply 'encode-time (org-parse-time-string s))
+ (error (error "Bad timestamp `%s'%s\nError was: %s"
+ s (if (not (and buffer pos))
+ ""
+ (format " at %d in buffer `%s'" pos buffer))
+ (cdr errdata))))))))
(defun org-days-to-iso-week (days)
"Return the iso week number."