Re: [BUG] Date prompt suggests yesterday when changing timestamp with org-extend-today-until set [9.6]

2023-03-11 Thread Ihor Radchenko
Tim Ruffing  writes:

> Sorry for the late reply. The patch solves the problem for me, thanks!
> Would be great to have this fixed.

Thanks for confirming!
Fixed, on main now.
https://git.savannah.gnu.org/cgit/emacs/org-mode.git/commit/?id=d6e75d0ee

> Unless you see a bug that I'm not seeing, the behavior looks correct to
> me (with the patch applied):

Good no know. I wanted to hear from an actual user of the
org-extend-today-until feature.

-- 
Ihor Radchenko // yantar92,
Org mode contributor,
Learn more about Org mode at .
Support Org development at ,
or support my work at 



Re: [BUG] Date prompt suggests yesterday when changing timestamp with org-extend-today-until set [9.6]

2023-03-09 Thread Tim Ruffing
Sorry for the late reply. The patch solves the problem for me, thanks!
Would be great to have this fixed.

On Sun, 2023-01-22 at 11:44 +, Ihor Radchenko wrote:
> * This is test
> SCHEDULED: <2023-01-28 Sat>
> 
> Then, M-: (setq org-extend-today-until 20)
> Then, C-c C-s on the heading above
> 
> What will happen if one tries to do "." or +1 or ++1. I find the
> current
> behavior rather disorienting. Could someone check what we promise in
> the
> Org manual, `org-read-date' docstring, `org-extend-today-until'
> docstring, and what actually happens in practice?
> 

Unless you see a bug that I'm not seeing, the behavior looks correct to
me (with the patch applied): The default date (when the user hasn't
entered anything) is the existing timestamp.  Then "." selects today
explicitly, "+" is relative to today, and "++" is relative to the
default date. That's exactly what's promised
in https://orgmode.org/manual/The-date_002ftime-prompt.html and also in
the `org-read-date` doctring. (And I think it makes sense.)

Best,
Tim



Re: [BUG] Date prompt suggests yesterday when changing timestamp with org-extend-today-until set [9.6]

2023-01-22 Thread Ihor Radchenko
Tim Ruffing  writes:

> Assume org-extend-today-until is set to an integer greater 0, say 3.
> When I change a timestamp without date such as <2023-01-20> (e.g, when
> rescheduling), the prompt defaults to a day earlier, i.e., to "2023-01-
> 19" in this case. The same happens with <2023-01-20 01:00> which is
> still before 3am. 

Thanks for reporting!
May you try the attached patch?

I am, however, still concerned about how `org-read-date' is handling
`org-extend-today-until'.

If we have something like

* This is test
SCHEDULED: <2023-01-28 Sat>

Then, M-: (setq org-extend-today-until 20)
Then, C-c C-s on the heading above

What will happen if one tries to do "." or +1 or ++1. I find the current
behavior rather disorienting. Could someone check what we promise in the
Org manual, `org-read-date' docstring, `org-extend-today-until'
docstring, and what actually happens in practice?

>From 998f2f9b93f5727942fa0e53567288ebcf544764 Mon Sep 17 00:00:00 2001
Message-Id: <998f2f9b93f5727942fa0e53567288ebcf544764.1674387603.git.yanta...@posteo.net>
From: Ihor Radchenko 
Date: Sun, 22 Jan 2023 14:37:47 +0300
Subject: [PATCH] org-read-date: Do not consider `org-extend-today-until' with
 default time

* lisp/org.el (org-read-date): When DEFAULT-TIME time provided, prefer
it even when `org-extend-today-until' dictates -1 day shift.  We
should only consider `org-extend-today-until' for actual today times,
not for future dates, where is becomes confusing.

Reported-by: Tim Ruffing 
Link: https://orgmode.org/list/3489c1917ad4be0625ea5f0b2c1b0f2b72ea39e9.ca...@timruffing.de
---
 lisp/org.el | 6 +-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/lisp/org.el b/lisp/org.el
index 0e6a3da0a..f4cc7b4be 100644
--- a/lisp/org.el
+++ b/lisp/org.el
@@ -13695,7 +13695,11 @@ (defun org-read-date ( with-time to-time from-string prompt
 	 (calendar-view-holidays-initially-flag nil)
 	 ans (org-ans0 "") org-ans1 org-ans2 final cal-frame)
 ;; Rationalize `org-def' and `org-defdecode', if required.
-(when (< (nth 2 org-defdecode) org-extend-today-until)
+;; Only consider `org-extend-today-until' when explicit reference
+;; time is not given.
+(when (and (not default-time)
+   (not org-overriding-default-time)
+   (< (nth 2 org-defdecode) org-extend-today-until))
   (setf (nth 2 org-defdecode) -1)
   (setf (nth 1 org-defdecode) 59)
   (setq org-def (org-encode-time org-defdecode))
-- 
2.39.1


-- 
Ihor Radchenko // yantar92,
Org mode contributor,
Learn more about Org mode at .
Support Org development at ,
or support my work at 


[BUG] Date prompt suggests yesterday when changing timestamp with org-extend-today-until set [9.6]

2023-01-21 Thread Tim Ruffing
Hi,

Assume org-extend-today-until is set to an integer greater 0, say 3.
When I change a timestamp without date such as <2023-01-20> (e.g, when
rescheduling), the prompt defaults to a day earlier, i.e., to "2023-01-
19" in this case. The same happens with <2023-01-20 01:00> which is
still before 3am. 
 
That's very confusing, in particular in the case when the old timestamp
only has a date but no time. But even when the old timestamp has has a
time, org should never suggest yesterday. I think a good rule of thumb
here is that if the user just presses Enter without having typed
anything at the prompt, the timestamp shouldn't change at all.

The bug happens because org-read-date tries to take into account the
value of org-extend-today-until but it should probably do this when the
default time suggested to the user is taken from the current wallclock
time, not when it's taken from an existing timestamp. 

A similar issue when capturing has been reported and fixed here:
https://lists.gnu.org/archive/html/emacs-orgmode/2019-06/msg00056.html

(Please include me in CC for now, I haven't subscribed to mailing
list.) 

Best,
Tim


PS: Thanks for org-mode. It has my changed my life.