On Sun, 19 May 2019 at 14:36, Neil Jerram <[email protected]> wrote:
> I have a capture template like this:
>
> '(org-capture-templates
> (quote
> (("a" "" entry
> (file "~/org/capture.org")
> "** TODO %?
> SCHEDULED: %^t"))))
>
> When I use that, the date prompt defaults to yesterday, whereas I'd expect
> it to default to today.
>
> I believe this is because I also have (setq org-extend-today-until 2).
> What happens is that (org-get-cursor-date) gets the right _date_, then
> converts that to a time at midnight, i.e. <date> 00:00. And then, I
> presume, some following code thinks that means <date>-1, because of my
> org-extend-today-until setting.
>
> Thoughts?
>
> Many thanks,
> Neil
>
Well I think it's a bug and propose the attached fix. Please let me know
what you think.
Neil
From d52c66f4e4f1fead135427d2c638890b5c7ab224 Mon Sep 17 00:00:00 2001
From: Neil Jerram <[email protected]>
Date: Tue, 28 May 2019 21:01:17 +0100
Subject: [PATCH] Make capture's idea of the current day more intuitive
---
lisp/org.el | 8 +++++---
1 file changed, 5 insertions(+), 3 deletions(-)
diff --git a/lisp/org.el b/lisp/org.el
index c6861dc9a..763eb1e45 100644
--- a/lisp/org.el
+++ b/lisp/org.el
@@ -18936,7 +18936,9 @@ Returns the number of empty lines passed."
This works in the calendar and in the agenda, anywhere else it just
returns the current time.
If WITH-TIME is non-nil, returns the time of the event at point (in
-the agenda) or the current time of the day."
+the agenda) or the current time of the day; otherwise returns 12pm
+on the cursor date. (Returning 12pm instead of 12am here avoids
+problems of interpretation with respect to `org-extend-today-until'.)"
(let (date day defd tp hod mod)
(when with-time
(setq tp (get-text-property (point) 'time))
@@ -18949,13 +18951,13 @@ the agenda) or the current time of the day."
(cond
((eq major-mode 'calendar-mode)
(setq date (calendar-cursor-to-date)
- defd (encode-time 0 (or mod 0) (or hod 0)
+ defd (encode-time 0 (or mod 0) (or hod 12)
(nth 1 date) (nth 0 date) (nth 2 date))))
((eq major-mode 'org-agenda-mode)
(setq day (get-text-property (point) 'day))
(when day
(setq date (calendar-gregorian-from-absolute day)
- defd (encode-time 0 (or mod 0) (or hod 0)
+ defd (encode-time 0 (or mod 0) (or hod 12)
(nth 1 date) (nth 0 date) (nth 2 date))))))
(or defd (current-time))))
--
2.17.1