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.
* testing/lisp/test-org.el (test-org/deadline): Add relevant tests.

Fixes https://orgmode.org/list/87o85bl582.fsf@localhost
This commit is contained in:
Ihor Radchenko 2022-05-15 14:49:10 +08:00
parent 5c14a17344
commit cdbb1c9633
No known key found for this signature in database
GPG Key ID: 6470762A7DA11D8B
2 changed files with 25 additions and 4 deletions

View File

@ -9742,10 +9742,14 @@ TYPE is either `deadline' or `scheduled'. See `org-deadline' or
;; time stamp. We are going to insert it back at the end of
;; the process.
(repeater (or (and (org-string-nw-p 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)
;; We use `org-ts-regexp-both' because we
;; need to tell the difference between a
;; real repeater and a time delta, e.g.
;; "+2d".
(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]\

View File

@ -5439,6 +5439,23 @@ Paragraph<point>"
(org-deadline nil "<2012-03-29 Tue +2y>"))
(replace-regexp-in-string
"\\( [.A-Za-z]+\\) " "" (buffer-string) nil nil 1))))
;; Preserve warning period.
(should
(equal "* H\nDEADLINE: <2021-07-20 -1d>"
(org-test-with-temp-text "* H"
(let ((org-adapt-indentation nil)
(org-last-inserted-timestamp nil))
(org-deadline nil "<2021-07-20 Tue -1d>"))
(replace-regexp-in-string
"\\( [.A-Za-z]+\\) " "" (buffer-string) nil nil 1))))
(should
(equal "* H\nDEADLINE: <2021-07-20 +1m -3d>"
(org-test-with-temp-text "* H"
(let ((org-adapt-indentation nil)
(org-last-inserted-timestamp nil))
(org-deadline nil "<2021-07-20 Tue +1m -3d>"))
(replace-regexp-in-string
"\\( [.A-Za-z]+\\) " "" (buffer-string) nil nil 1))))
;; Remove CLOSED keyword, if any.
(should
(equal "* H\nDEADLINE: <2012-03-29>"