emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
From: Ihor Radchenko <yantar92@gmail.com>
To: erimius@web.de
Cc: emacs-orgmode@gnu.org
Subject: [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/)]
Date: Mon, 20 Dec 2021 22:29:33 +0800	[thread overview]
Message-ID: <87o85bl582.fsf@localhost> (raw)
In-Reply-To: <83b84e24-bf18-8b2c-0e8e-84abbd2915c8@web.de>

[-- 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


  parent reply	other threads:[~2021-12-20 18:07 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-07-21 15:09 erimius
2021-08-31 15:55 ` Timothy
2021-12-20 14:29 ` Ihor Radchenko [this message]
2022-05-15  6:51   ` [PATCH] " Ihor Radchenko

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.orgmode.org/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87o85bl582.fsf@localhost \
    --to=yantar92@gmail.com \
    --cc=emacs-orgmode@gnu.org \
    --cc=erimius@web.de \
    --subject='[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/)]' \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link

Code repositories for project(s) associated with this inbox:

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

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).