all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* [BUG] Date prompt suggests yesterday when changing timestamp with org-extend-today-until set [9.6]
@ 2023-01-20 11:55 Tim Ruffing
  2023-01-22 11:44 ` Ihor Radchenko
  0 siblings, 1 reply; 4+ messages in thread
From: Tim Ruffing @ 2023-01-20 11:55 UTC (permalink / raw)
  To: emacs-orgmode

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.



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

* Re: [BUG] Date prompt suggests yesterday when changing timestamp with org-extend-today-until set [9.6]
  2023-01-20 11:55 [BUG] Date prompt suggests yesterday when changing timestamp with org-extend-today-until set [9.6] Tim Ruffing
@ 2023-01-22 11:44 ` Ihor Radchenko
  2023-03-09 23:26   ` Tim Ruffing
  0 siblings, 1 reply; 4+ messages in thread
From: Ihor Radchenko @ 2023-01-22 11:44 UTC (permalink / raw)
  To: Tim Ruffing; +Cc: emacs-orgmode

[-- Attachment #1: Type: text/plain, Size: 944 bytes --]

Tim Ruffing <crypto@timruffing.de> 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?


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 0001-org-read-date-Do-not-consider-org-extend-today-until.patch --]
[-- Type: text/x-patch, Size: 1632 bytes --]

From 998f2f9b93f5727942fa0e53567288ebcf544764 Mon Sep 17 00:00:00 2001
Message-Id: <998f2f9b93f5727942fa0e53567288ebcf544764.1674387603.git.yantar92@posteo.net>
From: Ihor Radchenko <yantar92@posteo.net>
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 <crypto@timruffing.de>
Link: https://orgmode.org/list/3489c1917ad4be0625ea5f0b2c1b0f2b72ea39e9.camel@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 (&optional 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


[-- Attachment #3: Type: text/plain, Size: 224 bytes --]


-- 
Ihor Radchenko // yantar92,
Org mode contributor,
Learn more about Org mode at <https://orgmode.org/>.
Support Org development at <https://liberapay.com/org-mode>,
or support my work at <https://liberapay.com/yantar92>

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

* Re: [BUG] Date prompt suggests yesterday when changing timestamp with org-extend-today-until set [9.6]
  2023-01-22 11:44 ` Ihor Radchenko
@ 2023-03-09 23:26   ` Tim Ruffing
  2023-03-11  9:33     ` Ihor Radchenko
  0 siblings, 1 reply; 4+ messages in thread
From: Tim Ruffing @ 2023-03-09 23:26 UTC (permalink / raw)
  To: Ihor Radchenko; +Cc: emacs-orgmode

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 +0000, 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


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

* Re: [BUG] Date prompt suggests yesterday when changing timestamp with org-extend-today-until set [9.6]
  2023-03-09 23:26   ` Tim Ruffing
@ 2023-03-11  9:33     ` Ihor Radchenko
  0 siblings, 0 replies; 4+ messages in thread
From: Ihor Radchenko @ 2023-03-11  9:33 UTC (permalink / raw)
  To: Tim Ruffing; +Cc: emacs-orgmode

Tim Ruffing <crypto@timruffing.de> 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 <https://orgmode.org/>.
Support Org development at <https://liberapay.com/org-mode>,
or support my work at <https://liberapay.com/yantar92>


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

end of thread, other threads:[~2023-03-11  9:32 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-01-20 11:55 [BUG] Date prompt suggests yesterday when changing timestamp with org-extend-today-until set [9.6] Tim Ruffing
2023-01-22 11:44 ` Ihor Radchenko
2023-03-09 23:26   ` Tim Ruffing
2023-03-11  9:33     ` Ihor Radchenko

Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.