mirror of
https://git.savannah.gnu.org/git/emacs/org-mode.git
synced 2024-09-29 22:07:49 +00:00
org-element: Fix interpreter for timestamp with delay
* lisp/org-element.el (org-element-timestamp-interpreter): Correctly interpret timestamps with delays. * testing/lisp/test-org-element.el: Add test.
This commit is contained in:
parent
11514badc1
commit
92c2ccb1fb
|
@ -3660,12 +3660,12 @@ CONTENTS is nil."
|
||||||
(hour "h") (day "d") (week "w") (month "m") (year "y"))))
|
(hour "h") (day "d") (week "w") (month "m") (year "y"))))
|
||||||
(warning-string
|
(warning-string
|
||||||
(concat
|
(concat
|
||||||
(and (eq (org-element-property :warninger-type timestamp) 'first)
|
(case (org-element-property :warning-type timestamp)
|
||||||
"-")
|
(first "--")
|
||||||
"-"
|
(all "-"))
|
||||||
(let ((val (org-element-property :warninger-value timestamp)))
|
(let ((val (org-element-property :warning-value timestamp)))
|
||||||
(and val (number-to-string val)))
|
(and val (number-to-string val)))
|
||||||
(case (org-element-property :warninger-unit timestamp)
|
(case (org-element-property :warning-unit timestamp)
|
||||||
(hour "h") (day "d") (week "w") (month "m") (year "y"))))
|
(hour "h") (day "d") (week "w") (month "m") (year "y"))))
|
||||||
(build-ts-string
|
(build-ts-string
|
||||||
;; Build an Org timestamp string from TIME. ACTIVEP is
|
;; Build an Org timestamp string from TIME. ACTIVEP is
|
||||||
|
@ -3685,11 +3685,12 @@ CONTENTS is nil."
|
||||||
(format "\\&-%02d:%02d" hour-end minute-end)
|
(format "\\&-%02d:%02d" hour-end minute-end)
|
||||||
nil nil ts)))
|
nil nil ts)))
|
||||||
(unless activep (setq ts (format "[%s]" (substring ts 1 -1))))
|
(unless activep (setq ts (format "[%s]" (substring ts 1 -1))))
|
||||||
(when (org-string-nw-p repeat-string)
|
(dolist (s (list repeat-string warning-string))
|
||||||
|
(when (org-string-nw-p s)
|
||||||
(setq ts (concat (substring ts 0 -1)
|
(setq ts (concat (substring ts 0 -1)
|
||||||
" "
|
" "
|
||||||
repeat-string
|
s
|
||||||
(substring ts -1))))
|
(substring ts -1)))))
|
||||||
;; Return value.
|
;; Return value.
|
||||||
ts)))
|
ts)))
|
||||||
(type (org-element-property :type timestamp)))
|
(type (org-element-property :type timestamp)))
|
||||||
|
|
|
@ -2456,7 +2456,7 @@ DEADLINE: <2012-01-01> SCHEDULED: <2012-01-01> CLOSED: [2012-01-01]\n"))))
|
||||||
;; Diary.
|
;; Diary.
|
||||||
(should (equal (org-test-parse-and-interpret "<%%diary-float t 4 2>")
|
(should (equal (org-test-parse-and-interpret "<%%diary-float t 4 2>")
|
||||||
"<%%diary-float t 4 2>\n"))
|
"<%%diary-float t 4 2>\n"))
|
||||||
;; Timestamp with repeater interval.
|
;; Timestamp with repeater interval, with delay, with both.
|
||||||
(should (equal (org-test-parse-and-interpret "<2012-03-29 thu. +1y>")
|
(should (equal (org-test-parse-and-interpret "<2012-03-29 thu. +1y>")
|
||||||
"<2012-03-29 thu. +1y>\n"))
|
"<2012-03-29 thu. +1y>\n"))
|
||||||
(should
|
(should
|
||||||
|
@ -2467,6 +2467,23 @@ DEADLINE: <2012-01-01> SCHEDULED: <2012-01-01> CLOSED: [2012-01-01]\n"))))
|
||||||
(:type active :year-start 2012 :month-start 3 :day-start 29
|
(:type active :year-start 2012 :month-start 3 :day-start 29
|
||||||
:repeater-type cumulate :repeater-value 1 :repeater-unit year))
|
:repeater-type cumulate :repeater-value 1 :repeater-unit year))
|
||||||
nil)))
|
nil)))
|
||||||
|
(should
|
||||||
|
(string-match
|
||||||
|
"<2012-03-29 .* -1y>"
|
||||||
|
(org-element-timestamp-interpreter
|
||||||
|
'(timestamp
|
||||||
|
(:type active :year-start 2012 :month-start 3 :day-start 29
|
||||||
|
:warning-type all :warning-value 1 :warning-unit year))
|
||||||
|
nil)))
|
||||||
|
(should
|
||||||
|
(string-match
|
||||||
|
"<2012-03-29 .* \\+1y -1y>"
|
||||||
|
(org-element-timestamp-interpreter
|
||||||
|
'(timestamp
|
||||||
|
(:type active :year-start 2012 :month-start 3 :day-start 29
|
||||||
|
:warning-type all :warning-value 1 :warning-unit year
|
||||||
|
:repeater-type cumulate :repeater-value 1 :repeater-unit year))
|
||||||
|
nil)))
|
||||||
;; Timestamp range with repeater interval
|
;; Timestamp range with repeater interval
|
||||||
(should (equal (org-test-parse-and-interpret
|
(should (equal (org-test-parse-and-interpret
|
||||||
"<2012-03-29 Thu +1y>--<2012-03-30 Thu +1y>")
|
"<2012-03-29 Thu +1y>--<2012-03-30 Thu +1y>")
|
||||||
|
|
Loading…
Reference in a new issue