all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* Bug: org-deadline drops warning periods from TIME [9.4.6 (9.4.6-10-gee652a-elpaplus @ /home/fap/.emacs.d/elpa/org-plus-contrib-20210712/)]
@ 2021-07-21 15:09 erimius
  2021-08-31 15:55 ` Timothy
  2021-12-20 14:29 ` [PATCH] " Ihor Radchenko
  0 siblings, 2 replies; 4+ messages in thread
From: erimius @ 2021-07-21 15:09 UTC (permalink / raw)
  To: emacs-orgmode

* Reproduction

Call ~org-deadline~ with a warning period like so:


(org-deadline nil "<2021-07-20 Tue -1d>")
   ;; => DEADLINE: <2021-07-20 Tue>

* Expected

Deadline gets added with the warning period provided.

* Actual

Deadline gets added without the provided warning period.

* Discussion

I've opened a Emacs Stackexchange question regarding this:
https://emacs.stackexchange.com/questions/66765/how-to-insert-an-org-deadline-from-lisp-with-a-warning-period/

And got told the following by Nick D:

#+begin_quote
I think this is a bug: the function ~org--deadline-or-schedule~ saves a
repeater (e.g ~+2d~ ) and adds it back at the end, but the regexp does
not match a warning period (e.g. ~-2d~) so it drops it. You should
probably report it with ~M-x org-submit-bug-report~.
#+end_quote

* Version info

Emacs  : GNU Emacs 27.1 (build 1, x86_64-pc-linux-gnu, GTK+ Version
3.24.20, cairo version 1.16.0)
 of 2020-09-19
Package: Org mode version 9.4.6 (9.4.6-10-gee652a-elpaplus @
/home/fap/.emacs.d/elpa/org-plus-contrib-20210712/)



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

* Re: Bug: org-deadline drops warning periods from TIME [9.4.6 (9.4.6-10-gee652a-elpaplus @ /home/fap/.emacs.d/elpa/org-plus-contrib-20210712/)]
  2021-07-21 15:09 Bug: org-deadline drops warning periods from TIME [9.4.6 (9.4.6-10-gee652a-elpaplus @ /home/fap/.emacs.d/elpa/org-plus-contrib-20210712/)] erimius
@ 2021-08-31 15:55 ` Timothy
  2021-12-20 14:29 ` [PATCH] " Ihor Radchenko
  1 sibling, 0 replies; 4+ messages in thread
From: Timothy @ 2021-08-31 15:55 UTC (permalink / raw)
  To: erimius; +Cc: emacs-orgmode

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

Bug confirmed and added to updates.orgmode.org.

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

* [PATCH] Re: Bug: org-deadline drops warning periods from TIME [9.4.6 (9.4.6-10-gee652a-elpaplus @ /home/fap/.emacs.d/elpa/org-plus-contrib-20210712/)]
  2021-07-21 15:09 Bug: org-deadline drops warning periods from TIME [9.4.6 (9.4.6-10-gee652a-elpaplus @ /home/fap/.emacs.d/elpa/org-plus-contrib-20210712/)] erimius
  2021-08-31 15:55 ` Timothy
@ 2021-12-20 14:29 ` Ihor Radchenko
  2022-05-15  6:51   ` Ihor Radchenko
  1 sibling, 1 reply; 4+ messages in thread
From: Ihor Radchenko @ 2021-12-20 14:29 UTC (permalink / raw)
  To: erimius; +Cc: emacs-orgmode

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

erimius@web.de writes:

> * Reproduction
>
> Call ~org-deadline~ with a warning period like so:
>
>
> (org-deadline nil "<2021-07-20 Tue -1d>")
>    ;; => DEADLINE: <2021-07-20 Tue>
>
> * Expected
>
> Deadline gets added with the warning period provided.

Can you try the attached patch?

Also, note that warning period is still not supported when reading
deadline interactively. Not sure if we need it though.

Best,
Ihor


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 0001-org-deadline-or-schedule-Allow-warning-period-in-TIM.patch --]
[-- Type: text/x-diff, Size: 1505 bytes --]

From 5ea33ca79c1c9fa60e960fcc4508fbfc5358b95f Mon Sep 17 00:00:00 2001
Message-Id: <5ea33ca79c1c9fa60e960fcc4508fbfc5358b95f.1640010497.git.yantar92@gmail.com>
From: Ihor Radchenko <yantar92@gmail.com>
Date: Mon, 20 Dec 2021 22:26:56 +0800
Subject: [PATCH] org--deadline-or-schedule: Allow warning period in TIME
 argument

* lisp/org.el (org--deadline-or-schedule): Match warning period if
provided in TIME arg.

Fixes https://orgmode.org/list/83b84e24-bf18-8b2c-0e8e-84abbd2915c8@web.de
---
 lisp/org.el | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/lisp/org.el b/lisp/org.el
index ce4e08eab..29e1d4d0e 100644
--- a/lisp/org.el
+++ b/lisp/org.el
@@ -10652,7 +10652,13 @@ (defun org--deadline-or-schedule (arg type time)
 			    ;; We use `org-repeat-re' because we need
 			    ;; to tell the difference between a real
 			    ;; repeater and a time delta, e.g. "+2d".
-			    (string-match org-repeat-re time)
+			    (or (string-match org-repeat-re time)
+                                ;; `org-repeat-re' is not sufficient
+                                ;; to match warning periods.
+                                (and (string-match-p org-ts-regexp-both time)
+                                     (string-match "\\([.+-]+[0-9]+[hdwmy]\
+\\(?:[/ ][-+]?[0-9]+[hdwmy]\\)?\\)"
+                                                   time)))
 			    (match-string 1 time))
 		       (and (org-string-nw-p old-date)
 			    (string-match "\\([.+-]+[0-9]+[hdwmy]\
-- 
2.32.0


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

* Re: [PATCH] Re: Bug: org-deadline drops warning periods from TIME [9.4.6 (9.4.6-10-gee652a-elpaplus @ /home/fap/.emacs.d/elpa/org-plus-contrib-20210712/)]
  2021-12-20 14:29 ` [PATCH] " Ihor Radchenko
@ 2022-05-15  6:51   ` Ihor Radchenko
  0 siblings, 0 replies; 4+ messages in thread
From: Ihor Radchenko @ 2022-05-15  6:51 UTC (permalink / raw)
  To: erimius; +Cc: emacs-orgmode

Ihor Radchenko <yantar92@gmail.com> writes:

> erimius@web.de writes:
>
>> * Reproduction
>>
>> Call ~org-deadline~ with a warning period like so:
>>
>>
>> (org-deadline nil "<2021-07-20 Tue -1d>")
>>    ;; => DEADLINE: <2021-07-20 Tue>
>>
>> * Expected
>>
>> Deadline gets added with the warning period provided.
>
> Can you try the attached patch?
>
> Also, note that warning period is still not supported when reading
> deadline interactively. Not sure if we need it though.

Applied onto main via cdbb1c963.

I changed the patch adding support for timestamps with repeaters _and_
warning. Also, added the relevant tests.

Best,
Ihor


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

end of thread, other threads:[~2022-05-15  6:52 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2021-07-21 15:09 Bug: org-deadline drops warning periods from TIME [9.4.6 (9.4.6-10-gee652a-elpaplus @ /home/fap/.emacs.d/elpa/org-plus-contrib-20210712/)] erimius
2021-08-31 15:55 ` Timothy
2021-12-20 14:29 ` [PATCH] " Ihor Radchenko
2022-05-15  6:51   ` 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.