branch: externals/org commit cdbb1c9633fee07f15effe6704a7fb3d8a97825e Author: Ihor Radchenko <yanta...@gmail.com> Commit: Ihor Radchenko <yanta...@gmail.com>
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 --- lisp/org.el | 12 ++++++++---- testing/lisp/test-org.el | 17 +++++++++++++++++ 2 files changed, 25 insertions(+), 4 deletions(-) diff --git a/lisp/org.el b/lisp/org.el index 766e3f80ff..dc0b215165 100644 --- a/lisp/org.el +++ b/lisp/org.el @@ -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]\ diff --git a/testing/lisp/test-org.el b/testing/lisp/test-org.el index 0cee31d4e4..473933a6b4 100644 --- a/testing/lisp/test-org.el +++ b/testing/lisp/test-org.el @@ -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>"