Просмотр исходного кода

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
Ihor Radchenko 2 лет назад
Родитель
Сommit
cdbb1c9633
2 измененных файлов с 25 добавлено и 4 удалено
  1. 8 4
      lisp/org.el
  2. 17 0
      testing/lisp/test-org.el

+ 8 - 4
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]\

+ 17 - 0
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>"