Morgan Smith <morgan.j.sm...@outlook.com> writes: > See two patches attached again. All tests pass on my computer.
Thanks! Applied, onto main, with amendments (see the attached diffs). https://git.savannah.gnu.org/cgit/emacs/org-mode.git/commit/?id=66e307b41 https://git.sr.ht/~bzg/worg/commit/f1486f42
diff --git a/etc/ORG-NEWS b/etc/ORG-NEWS index 2b418cd3c..e61bd6988 100644 --- a/etc/ORG-NEWS +++ b/etc/ORG-NEWS @@ -516,7 +516,9 @@ and returns an appropriate timestamp string. ~org-element-timestamp-parser~ now adds =:repeater-deadline-value= and =:repeater-deadline-unit= properties to each timestamp object that has -a repeater deadline. +a repeater deadline. For example, in =<2012-03-29 Thu ++1y/2y>=, =2y= +is the repeater deadline with a value of =2= and unit of =y=. See +"5.3.3 Tracking your habits" section in the manual. Possible values for =:repeater-deadline-value=: ~positive integer~, ~nil~. diff --git a/lisp/org-element.el b/lisp/org-element.el index 49a312694..e7561f16f 100644 --- a/lisp/org-element.el +++ b/lisp/org-element.el @@ -4331,13 +4331,13 @@ (defun org-element-timestamp-parser () (and (not diaryp) (string-match (rx - (group (or "+" "++" ".+")) - (group (+ digit)) - (group (or "h" "d" "w" "m" "y")) - (\? + (group-n 1 (or "+" "++" ".+")) + (group-n 2 (+ digit)) + (group-n 3 (any "hdwmy")) + (optional "/" - (group (+ digit)) - (group (or "h" "d" "w" "m" "y")))) + (group-n 4 (+ digit)) + (group-n 5 (any "hdwmy")))) raw-value) (nconc (list @@ -4427,17 +4427,15 @@ (defun org-element-timestamp-interpreter (timestamp _) (and val (number-to-string val))) (pcase (org-element-property :repeater-unit timestamp) (`hour "h") (`day "d") (`week "w") (`month "m") (`year "y")) - (let ((repeater-deadline-value - (org-element-property :repeater-deadline-value timestamp)) - (repeater-deadline-unit - (org-element-property :repeater-deadline-unit timestamp))) - (if (and repeater-deadline-value repeater-deadline-unit) - (concat - "/" - (number-to-string repeater-deadline-value) - (pcase repeater-deadline-unit - (`hour "h") (`day "d") (`week "w") (`month "m") (`year "y"))) - "")))) + (when-let ((repeater-deadline-value + (org-element-property :repeater-deadline-value timestamp)) + (repeater-deadline-unit + (org-element-property :repeater-deadline-unit timestamp))) + (concat + "/" + (number-to-string repeater-deadline-value) + (pcase repeater-deadline-unit + (`hour "h") (`day "d") (`week "w") (`month "m") (`year "y")))))) (range-type (org-element-property :range-type timestamp)) (warning-string (concat
diff --git a/org-syntax.org b/org-syntax.org index c8eb7f77..70a46dcf 100644 --- a/org-syntax.org +++ b/org-syntax.org @@ -1776,8 +1776,8 @@ ** Timestamps + TIME (optional) :: An instance of the pattern =H:MM= where =H= represents a one to two digit number (and can start with =0=), and =M= represents a single digit. -+ REPEATER-OR-DELAY (optional) :: An instance of a single REPEATER and/or an - instance of a single DELAY in any order. ++ REPEATER-OR-DELAY (optional) :: An instance of a single =REPEATER= and/or an + instance of a single =DELAY= in any order. + REPEATER (optional) :: An instance of the following pattern: #+begin_example MARK VALUE UNIT @@ -1786,18 +1786,18 @@ ** Timestamps Where MARK, VALUE and UNIT are not separated by whitespace characters. - MARK :: Either the string =+= (cumulative type), =++= (catch-up type), or =.+= (restart type). - - VALUE :: A number + - VALUE :: A number. - UNIT :: Either the character =h= (hour), =d= (day), =w= (week), =m= - (month), or =y= (year) + (month), or =y= (year). + DELAY (optional) :: An instance of the following pattern: #+begin_example MARK VALUE UNIT #+end_example Where MARK, VALUE and UNIT are not separated by whitespace characters. - MARK :: Either =-= (all type) or =--= (first type). - - VALUE :: A number + - VALUE :: A number. - UNIT :: Either the character =h= (hour), =d= (day), =w= (week), =m= - (month), or =y= (year) + (month), or =y= (year). *Examples* @@ -1807,6 +1807,7 @@ ** Timestamps [2004-08-24 Tue]--[2004-08-26 Thu] <2012-02-08 Wed 20:00 ++1d> <2030-10-05 Sat +1m -3d> +<2012-03-29 Thu ++1y/2y> #+end_example ** Text Markup
-- Ihor Radchenko // yantar92, Org mode contributor, Learn more about Org mode at <https://orgmode.org/>. Support Org development at <https://liberapay.com/org-mode>, or support my work at <https://liberapay.com/yantar92>