diff --git a/lisp/org.el b/lisp/org.el index 766e3f80f..dc0b21516 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 0cee31d4e..473933a6b 100644 --- a/testing/lisp/test-org.el +++ b/testing/lisp/test-org.el @@ -5439,6 +5439,23 @@ Paragraph" (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>"