Improve future detection when reading dates

PT writes:

> [Orgmode] org-read-date-prefer-future 'time doesn't always prefer future
>
> This is a very useful setting, because it allows the user to
> quickly schedule a task into the future by simply entering the
> time, but it doesn't always do the right thing.
>
> Suppose I scheduled a task to 1pm, but I didn't have time to deal
> with it during the day. It's 5pm now. If I want to reschedule the task to
> tomorrow 10am then I can write simply 10am to the time prompt and
> it puts the task correctly to tomorrow 10am. However, if I want
> to reschedule it to tomorrow 2pm then I can't write simply 2pm,
> because then it schedules the task at 2pm today (which is past
> already, since it's 5 pm).
>
> The problem is the feature uses the task's own scheduled time to
> determine if a time is in the past, instead of the current time.
>
>
> It's Org-mode version 6.33
This commit is contained in:
Carsten Dominik 2010-01-01 11:31:57 +01:00
parent 7050ea8d4a
commit 70d6341f2e
2 changed files with 16 additions and 13 deletions

View File

@ -7,6 +7,8 @@
variables on which image creation depends.
(org-create-formula-image): Add the header stuff from in-buffer
settings.
(org-read-date-analyze): Base the analysis for future preference
on NOW, not on the default date.
* org-inlinetask.el (org-inlinetask-export-handler): Add CSS class
for TODO keyword in inline tasks.

View File

@ -13342,9 +13342,10 @@ user."
(defun org-read-date-analyze (ans def defdecode)
"Analyse the combined answer of the date prompt."
;; FIXME: cleanup and comment
(let (delta deltan deltaw deltadef year month day
hour minute second wday pm h2 m2 tl wday1
iso-year iso-weekday iso-week iso-year iso-date futurep)
(let ((nowdecode (decode-time (current-time)))
delta deltan deltaw deltadef year month day
hour minute second wday pm h2 m2 tl wday1
iso-year iso-weekday iso-week iso-year iso-date futurep)
(setq org-read-date-analyze-futurep nil)
(when (string-match "\\`[ \t]*\\.[ \t]*\\'" ans)
(setq ans "+0"))
@ -13417,13 +13418,13 @@ user."
day (or (nth 3 tl) (nth 3 defdecode))
month (or (nth 4 tl)
(if (and org-read-date-prefer-future
(nth 3 tl) (< (nth 3 tl) (nth 3 defdecode)))
(prog1 (1+ (nth 4 defdecode)) (setq futurep t))
(nth 3 tl) (< (nth 3 tl) (nth 3 nowdecode)))
(prog1 (1+ (nth 4 nowdecode)) (setq futurep t))
(nth 4 defdecode)))
year (or (nth 5 tl)
(if (and org-read-date-prefer-future
(nth 4 tl) (< (nth 4 tl) (nth 4 defdecode)))
(prog1 (1+ (nth 5 defdecode)) (setq futurep t))
(nth 4 tl) (< (nth 4 tl) (nth 4 nowdecode)))
(prog1 (1+ (nth 5 nowdecode)) (setq futurep t))
(nth 5 defdecode)))
hour (or (nth 2 tl) (nth 2 defdecode))
minute (or (nth 1 tl) (nth 1 defdecode))
@ -13432,14 +13433,14 @@ user."
(when (and (eq org-read-date-prefer-future 'time)
(not (nth 3 tl)) (not (nth 4 tl)) (not (nth 5 tl))
(equal day (nth 3 defdecode))
(equal month (nth 4 defdecode))
(equal year (nth 5 defdecode))
(equal day (nth 3 nowdecode))
(equal month (nth 4 nowdecode))
(equal year (nth 5 nowdecode))
(nth 2 tl)
(or (< (nth 2 tl) (nth 2 defdecode))
(and (= (nth 2 tl) (nth 2 defdecode))
(or (< (nth 2 tl) (nth 2 nowdecode))
(and (= (nth 2 tl) (nth 2 nowdecode))
(nth 1 tl)
(< (nth 1 tl) (nth 1 defdecode)))))
(< (nth 1 tl) (nth 1 nowdecode)))))
(setq day (1+ day)
futurep t))