From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp10.migadu.com ([2001:41d0:306:2d92::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms9.migadu.com with LMTPS id eNdSEhBMrGQ7tgAASxT56A (envelope-from ) for ; Mon, 10 Jul 2023 20:21:04 +0200 Received: from aspmx1.migadu.com ([2001:41d0:306:2d92::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp10.migadu.com with LMTPS id 8BxfERBMrGQV8wAAG6o9tA (envelope-from ) for ; Mon, 10 Jul 2023 20:21:04 +0200 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by aspmx1.migadu.com (Postfix) with ESMTPS id CAA4E32ADC for ; Mon, 10 Jul 2023 20:21:03 +0200 (CEST) Authentication-Results: aspmx1.migadu.com; dkim=pass header.d=gmail.com header.s=20221208 header.b=FrCNNRnS; spf=pass (aspmx1.migadu.com: domain of "emacs-orgmode-bounces+larch=yhetil.org@gnu.org" designates 209.51.188.17 as permitted sender) smtp.mailfrom="emacs-orgmode-bounces+larch=yhetil.org@gnu.org"; dmarc=pass (policy=none) header.from=gmail.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=yhetil.org; s=key1; t=1689013264; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type:in-reply-to:in-reply-to: references:references:list-id:list-help:list-unsubscribe: list-subscribe:list-post:dkim-signature; bh=SWFNYaUmUrDQpnKSPSLKKkEJ+SH9r4CmlVuWebOzzvw=; b=ruZ3H1gEP3fh+aiWrX38EYBgYBMig/6DJfrtBL4gM1shx0oNKEV2PLsAPeRs3OL4T2I2XC Muk55sysg/aXqaltXUvp58iam/+tdfllIj6Ybb+IQcmrRA7c9tL45l8Y/CiLEfjN7LJCEo AoVv8+FDmcWt3uI0bFkpABufTClCaJJupK6C27iJGH6L5ZA9/dXq5g4wXMA9Dp7XVNf00V eOilvJxrTZbRS5jPMMfu/I7tNs3hQRCa/dXlQFjlu1v4/+W+/rxHo0S5x3+cgQgz4wZ0tl /Ass/MWRB4LN4VF95B5yIiHS6/IwNPmDnFoIOOfjz1p/XpzkxMEV1H4gSQYSbw== ARC-Seal: i=1; s=key1; d=yhetil.org; t=1689013264; a=rsa-sha256; cv=none; b=n6aQfE0aRo62FYB3TAwh8S6xD0lTOE5iK/nL3CQ3C6eUapA2kNZTM8NeR/Akf5U7N+jLk0 GWHyjNeFS862jZG0amMAaiSRlWsc8Q3fk6EgVlYP1SzjfhM+PG0W6yqY+46ljLSkBDgNJ/ 58HY91fV7fMkvUraSqzrQZ4EOE63RQFEY5FBvJtdiRmhGfEgTab4bvABzJ1PE0I5dlA3fF moSBkPD3ZaZk4CdTWIZ/3Z2EFeAGARRqkHArNbn2pdlq6GzDqOQ330c3yqnsFJCsHoQJRq CZDKr9GL4BHmyPiX5BQQjU1nqAiNge6bm5rrqSGlEQ69TlqhcGNMvUGo0Z+snA== ARC-Authentication-Results: i=1; aspmx1.migadu.com; dkim=pass header.d=gmail.com header.s=20221208 header.b=FrCNNRnS; spf=pass (aspmx1.migadu.com: domain of "emacs-orgmode-bounces+larch=yhetil.org@gnu.org" designates 209.51.188.17 as permitted sender) smtp.mailfrom="emacs-orgmode-bounces+larch=yhetil.org@gnu.org"; dmarc=pass (policy=none) header.from=gmail.com Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qIvUK-0007ok-E5; Mon, 10 Jul 2023 14:19:56 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qIvUI-0007mr-8O for emacs-orgmode@gnu.org; Mon, 10 Jul 2023 14:19:54 -0400 Received: from mail-lj1-x22d.google.com ([2a00:1450:4864:20::22d]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qIvUF-0001W2-8O for emacs-orgmode@gnu.org; Mon, 10 Jul 2023 14:19:53 -0400 Received: by mail-lj1-x22d.google.com with SMTP id 38308e7fff4ca-2b703c900e3so74010621fa.1 for ; Mon, 10 Jul 2023 11:19:50 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1689013189; x=1691605189; h=mime-version:message-id:date:references:in-reply-to:subject:cc:to :from:from:to:cc:subject:date:message-id:reply-to; bh=SWFNYaUmUrDQpnKSPSLKKkEJ+SH9r4CmlVuWebOzzvw=; b=FrCNNRnS72+4iUB4SUdKNzmRVwZeTGomwtEmuimIfzhu1j/e6QVtLak8UUWoD9InV5 02yaGkgAnmxKmzsTLsKNB1uHJpicOVcz0+qDRzl34NRewNmSdlL4ZBvB6IC9r9dncYDr cEOc1DWmTOe4nN4BQYn5LeDcr8G6OIz1ALptWxcfI/lpEUEs7g+/snmnv0Nu/GY+rwt5 I/FeOpCQEea8NoDI3aSai1vlDnyoXfthoAsArzObJBcyCcp+X3vW3sTfb8ww3IjZTu07 wjwDh9kLwaFzXUKJEDYwn6wqbqWQUyh5UeTNw62WEMEozTzrOszUVIRMW7nnndXAeBWb 5Z2g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1689013189; x=1691605189; h=mime-version:message-id:date:references:in-reply-to:subject:cc:to :from:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=SWFNYaUmUrDQpnKSPSLKKkEJ+SH9r4CmlVuWebOzzvw=; b=g4fchtbqIyxF7Os5zrmf3jmqX0cIPM9Kw6M2RQS2tUaxBndfaEQ+8q2Tca0dBqwGlh fwF+XZOhAV2r7fWB+TUATACycWcbUVMuwq/+9QRUIu/GVpRrbUO43taUshvgrqMBwNTN RvjLxFbTqJqH0rcDGlfgI+6OkaDWDGGX4TmdYELxiX8Z8tMPWZXrXYODpGOZksH1nPnc E9A88/aa5qURHtSxD89zZ3uBo8SLzUQ7D4tF9RVyjeuvIFmhT8KEBQLdJ/8ZOBEXgPID qEAaQgZKfgFyaZZrxeZUm0fumgFNjTtRv0DoVusNh2yZvhlikCDVYWupAz1JOtmMTuM+ LCcg== X-Gm-Message-State: ABy/qLZDl2Ucqw9UxStV5i0B03xXH5zcJZ4KIY1N4nm8IRoo+gqqkjBZ YYg45UK2XGtOnYi96pR62dsCQ9dxVI4= X-Google-Smtp-Source: APBJJlFtfhmOMFqeeXL1buM6Lqy77Fe+ckurMmx04GO9/TQN0WujiKRiC9XDsSgpH70KAxNzZFGsBw== X-Received: by 2002:a2e:8eca:0:b0:2b6:fa92:479e with SMTP id e10-20020a2e8eca000000b002b6fa92479emr11711226ljl.42.1689013188606; Mon, 10 Jul 2023 11:19:48 -0700 (PDT) Received: from sonyvaio ([92.127.245.54]) by smtp.gmail.com with ESMTPSA id a11-20020a2e88cb000000b002b6e77e87fcsm81394ljk.68.2023.07.10.11.19.47 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 10 Jul 2023 11:19:48 -0700 (PDT) From: Ilya Chernyshov To: Ihor Radchenko Cc: emacs-orgmode Subject: Re: [PATCH] org-element-timestamp-interpreter: Return daterange anyway, if DATERANGE is non-nil In-Reply-To: <87ttueajih.fsf@localhost> References: <87y1ot6dqz.fsf@gmail.com> <87wn4cegt4.fsf@localhost> <9E22693E-7D20-470A-B57B-EA17BBE9160F@gmail.com> <87a616c5do.fsf@localhost> <87wmzi4s6n.fsf@localhost> <87edlkyyit.fsf@gmail.com> <87ttueajih.fsf@localhost> Date: Tue, 11 Jul 2023 01:19:42 +0700 Message-ID: <87edlfljcx.fsf@gmail.com> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" Received-SPF: pass client-ip=2a00:1450:4864:20::22d; envelope-from=ichernyshovvv@gmail.com; helo=mail-lj1-x22d.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: emacs-orgmode@gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-orgmode-bounces+larch=yhetil.org@gnu.org Sender: emacs-orgmode-bounces+larch=yhetil.org@gnu.org X-Migadu-Country: US X-Migadu-Flow: FLOW_IN X-Migadu-Spam-Score: -4.97 X-Spam-Score: -4.97 X-Migadu-Queue-Id: CAA4E32ADC X-Migadu-Scanner: mx2.migadu.com X-TUID: /EW6vX5zl2gF --=-=-= Content-Type: text/plain Hi. Preserved old behavior for `org-element-timestamp-interpreter' function for :range-type set to `nil'. The new function The new function takes into account :range-type value when interpreting ranges and throws error when :range-type set for `active'/`inactive' types. --=-=-= Content-Type: text/x-patch Content-Disposition: attachment; filename=0001-lisp-org-element.el-Add-new-timestamp-property-range.patch >From aa21a84fa38324f455cb17ac32e656e1242c2135 Mon Sep 17 00:00:00 2001 From: Ilya Chernyshov Date: Sat, 18 Feb 2023 14:55:39 +0700 Subject: [PATCH] lisp/org-element.el: Add new timestamp property :range-type * lisp/org-element (org-element-timestamp-interpreter): Preserve old behavior when :range-type is `nil'. Take into account :range-type value when interpreting ranges. When :range-type is `timerange', return a timerange (). If :range-type is `daterange' return a daterange (<...>--<...>). When :range-type is nil, return a daterange (as it was before). When :range-type is `daterange' or `timerange' and :type is `active'/`inactive', throw an error. (org-element-timestamp-parser): Add :range-type property. * testing/lisp/test-org-element (test-org-element/timestamp-interpreter): Add new tests. (test-org-element/timestamp-parser): Add tests for :range-type property. * etc/ORG-NEWS (Major changes and additions to Org API): Add news about this property. --- etc/ORG-NEWS | 7 + lisp/org-element.el | 171 +++++++++++-------------- testing/lisp/test-org-element.el | 211 ++++++++++++++++++++++++++++++- 3 files changed, 290 insertions(+), 99 deletions(-) diff --git a/etc/ORG-NEWS b/etc/ORG-NEWS index d04e92275..d8d2275d9 100644 --- a/etc/ORG-NEWS +++ b/etc/ORG-NEWS @@ -200,6 +200,13 @@ a newly created one. Previously, one had to use : (apply #'org-element-create 'section nil (org-element-contents node)) +**** New property ~:range-type~ for org-element timestamp object + +~org-element-timestamp-parser~ now adds =:range-type= property to each +timestamp object. Possible values: ~timerange~, ~daterange~, ~nil~. + +~org-element-timestamp-interpreter~ takes into account this property +and returns approptiate timestamp string. *** ~org-priority=show~ command no longer adjusts for scheduled/deadline diff --git a/lisp/org-element.el b/lisp/org-element.el index bfb1d206e..5cbc57aab 100644 --- a/lisp/org-element.el +++ b/lisp/org-element.el @@ -4043,7 +4043,7 @@ Assume point is at the target." "Parse time stamp at point, if any. When at a time stamp, return a new syntax node of `timestamp' type -containing `:type', `:raw-value', `:year-start', `:month-start', +containing `:type', `:range-type', `:raw-value', `:year-start', `:month-start', `:day-start', `:hour-start', `:minute-start', `:year-end', `:month-end', `:day-end', `:hour-end', `:minute-end', `:repeater-type', `:repeater-value', `:repeater-unit', @@ -4077,6 +4077,10 @@ Assume point is at the beginning of the timestamp." (activep 'active) ((or date-end time-range) 'inactive-range) (t 'inactive))) + (range-type (cond + (date-end 'daterange) + (time-range 'timerange) + (t nil))) (repeater-props (and (not diaryp) (string-match "\\([.+]?\\+\\)\\([0-9]+\\)\\([hdwmy]\\)" @@ -4123,6 +4127,7 @@ Assume point is at the beginning of the timestamp." (org-element-create 'timestamp (nconc (list :type type + :range-type range-type :raw-value raw-value :year-start year-start :month-start month-start @@ -4142,99 +4147,77 @@ Assume point is at the beginning of the timestamp." (defun org-element-timestamp-interpreter (timestamp _) "Interpret TIMESTAMP object as Org syntax." - (let* ((repeat-string - (concat - (pcase (org-element-property :repeater-type timestamp) - (`cumulate "+") (`catch-up "++") (`restart ".+")) - (let ((val (org-element-property :repeater-value timestamp))) - (and val (number-to-string val))) - (pcase (org-element-property :repeater-unit timestamp) - (`hour "h") (`day "d") (`week "w") (`month "m") (`year "y")))) - (warning-string - (concat - (pcase (org-element-property :warning-type timestamp) - (`first "--") (`all "-")) - (let ((val (org-element-property :warning-value timestamp))) - (and val (number-to-string val))) - (pcase (org-element-property :warning-unit timestamp) - (`hour "h") (`day "d") (`week "w") (`month "m") (`year "y")))) - (build-ts-string - ;; Build an Org timestamp string from TIME. ACTIVEP is - ;; non-nil when time stamp is active. If WITH-TIME-P is - ;; non-nil, add a time part. HOUR-END and MINUTE-END - ;; specify a time range in the timestamp. REPEAT-STRING is - ;; the repeater string, if any. - (lambda (time activep &optional with-time-p hour-end minute-end) - (let ((ts (format-time-string - (org-time-stamp-format with-time-p) - time))) - (when (and hour-end minute-end) - (string-match "[012]?[0-9]:[0-5][0-9]" ts) - (setq ts - (replace-match - (format "\\&-%02d:%02d" hour-end minute-end) - nil nil ts))) - (unless activep (setq ts (format "[%s]" (substring ts 1 -1)))) - (dolist (s (list repeat-string warning-string)) - (when (org-string-nw-p s) - (setq ts (concat (substring ts 0 -1) - " " - s - (substring ts -1))))) - ;; Return value. - ts))) - (type (org-element-property :type timestamp))) - (pcase type - ((or `active `inactive) - (let* ((minute-start (org-element-property :minute-start timestamp)) - (minute-end (org-element-property :minute-end timestamp)) - (hour-start (org-element-property :hour-start timestamp)) - (hour-end (org-element-property :hour-end timestamp)) - (time-range-p (and hour-start hour-end minute-start minute-end - (or (/= hour-start hour-end) - (/= minute-start minute-end))))) - (funcall - build-ts-string - (org-encode-time 0 - (or minute-start 0) - (or hour-start 0) - (org-element-property :day-start timestamp) - (org-element-property :month-start timestamp) - (org-element-property :year-start timestamp)) - (eq type 'active) - (and hour-start minute-start) - (and time-range-p hour-end) - (and time-range-p minute-end)))) - ((or `active-range `inactive-range) - (let ((minute-start (org-element-property :minute-start timestamp)) - (minute-end (org-element-property :minute-end timestamp)) - (hour-start (org-element-property :hour-start timestamp)) - (hour-end (org-element-property :hour-end timestamp))) - (concat - (funcall - build-ts-string (org-encode-time - 0 - (or minute-start 0) - (or hour-start 0) - (org-element-property :day-start timestamp) - (org-element-property :month-start timestamp) - (org-element-property :year-start timestamp)) - (eq type 'active-range) - (and hour-start minute-start)) - "--" - (funcall build-ts-string - (org-encode-time - 0 - (or minute-end 0) - (or hour-end 0) - (org-element-property :day-end timestamp) - (org-element-property :month-end timestamp) - (org-element-property :year-end timestamp)) - (eq type 'active-range) - (and hour-end minute-end))))) - (_ (org-element-property :raw-value timestamp))))) - - + (let((type (org-element-property :type timestamp))) + (if (member type '(active inactive inactive-range active-range)) + (let ((day-start (org-element-property :day-start timestamp)) + (month-start (org-element-property :month-start timestamp)) + (year-start (org-element-property :year-start timestamp))) + (when (and day-start month-start year-start) + (let* ((repeat-string + (concat + (pcase (org-element-property :repeater-type timestamp) + (`cumulate "+") (`catch-up "++") (`restart ".+")) + (let ((val (org-element-property :repeater-value timestamp))) + (and val (number-to-string val))) + (pcase (org-element-property :repeater-unit timestamp) + (`hour "h") (`day "d") (`week "w") (`month "m") (`year "y")))) + (range-type (org-element-property :range-type timestamp)) + (warning-string + (concat + (pcase (org-element-property :warning-type timestamp) + (`first "--") (`all "-")) + (let ((val (org-element-property :warning-value timestamp))) + (and val (number-to-string val))) + (pcase (org-element-property :warning-unit timestamp) + (`hour "h") (`day "d") (`week "w") (`month "m") (`year "y")))) + (hour-start (org-element-property :hour-start timestamp)) + (minute-start (org-element-property :minute-start timestamp)) + (brackets + (if (member + type + '(inactive inactive-range)) + (cons "[" "]") + (cons "<" ">"))) + (timestamp-end + (concat + (and (org-string-nw-p repeat-string) (concat " " repeat-string)) + (and (org-string-nw-p warning-string) (concat " " warning-string)) + (cdr brackets)))) + (concat + (car brackets) + (format-time-string + (org-time-stamp-format (when (and minute-start hour-start) t) 'no-brackets) + (org-encode-time + 0 (or minute-start 0) (or hour-start 0) + day-start month-start year-start)) + (let((hour-end (org-element-property :hour-end timestamp)) + (minute-end (org-element-property :minute-end timestamp))) + (pcase type + ((or `active `inactive) + (pcase range-type + (`nil + (when (and hour-start hour-end minute-start minute-end + (or (/= hour-start hour-end) + (/= minute-start minute-end))) + (format "-%02d:%02d" hour-end minute-end))) + ((or `timerange `daterange) + (error "`:range-type' must be `nil' for `active'/`inactive' type")))) + ((or `active-range `inactive-range) + (pcase range-type + (`timerange (format "-%02d:%02d" (or hour-end hour-start) (or minute-end minute-start))) + ((or `nil `daterange) + (concat + timestamp-end + "--" (car brackets) + (format-time-string + (org-time-stamp-format (when (and minute-end hour-end) t) 'no-brackets) + (org-encode-time + 0 (or minute-end 0) (or hour-end 0) + (or (org-element-property :day-end timestamp) day-start) + (or (org-element-property :month-end timestamp) month-start) + (or (org-element-property :year-end timestamp) year-start))))))))) + timestamp-end)))) + (org-element-property :raw-value timestamp)))) ;;;; Underline (defun org-element-underline-parser () diff --git a/testing/lisp/test-org-element.el b/testing/lisp/test-org-element.el index 283ade10f..1a1f7aa75 100644 --- a/testing/lisp/test-org-element.el +++ b/testing/lisp/test-org-element.el @@ -3138,8 +3138,73 @@ Outside list" (org-test-with-temp-text "<2012-03-29 Thu +1y -1y>" (let ((ts (org-element-context))) (list (org-element-property :repeater-type ts) - (org-element-property :warning-type ts))))))) - + (org-element-property :warning-type ts)))))) + ;; :range-type property + (should + (eq + (org-test-with-temp-text "<2023-07-02 Sun>" + (org-element-property :range-type (org-element-timestamp-parser))) + nil)) + (should + (eq + (org-test-with-temp-text "<2023-07-02 Sun 12:00>" + (org-element-property :range-type (org-element-timestamp-parser))) + nil)) + (should + (eq + (org-test-with-temp-text "<2023-07-02 Sun 12:00-13:00>" + (org-element-property :range-type (org-element-timestamp-parser))) + 'timerange)) + (should + (eq + (org-test-with-temp-text "<2023-07-02 Sun 12:00-12:00>" + (org-element-property :range-type (org-element-timestamp-parser))) + 'timerange)) + (should + (eq + (org-test-with-temp-text "<2023-07-02 Sun>--<2023-07-02 Sun>" + (org-element-property :range-type (org-element-timestamp-parser))) + 'daterange)) + (should + (eq + (org-test-with-temp-text "<2023-07-02 Sun>--<2023-07-03 Mon>" + (org-element-property :range-type (org-element-timestamp-parser))) + 'daterange)) + (should + (eq + (org-test-with-temp-text "<2023-07-02 Sun 12:00>--<2023-07-02 Sun 12:00>" + (org-element-property :range-type (org-element-timestamp-parser))) + 'daterange)) + (should + (eq + (org-test-with-temp-text "<2023-07-02 Sun 12:00>--<2023-07-03 Mon 13:00>" + (org-element-property :range-type (org-element-timestamp-parser))) + 'daterange)) + (should + (eq + (org-test-with-temp-text "<2023-07-02 Sun 12:00>--<2023-07-02 Sun>" + (org-element-property :range-type (org-element-timestamp-parser))) + 'daterange)) + (should + (eq + (org-test-with-temp-text "<2023-07-02 Sun 12:00>--<2023-07-03 Mon>" + (org-element-property :range-type (org-element-timestamp-parser))) + 'daterange)) + (should + (eq + (org-test-with-temp-text "<2023-07-02 Sun 12:00>--<2023-07-02 Sun 13:00>" + (org-element-property :range-type (org-element-timestamp-parser))) + 'daterange)) + (should + (eq + (org-test-with-temp-text "<2023-07-02 Sun 12:00>--<2023-07-02 Sun>" + (org-element-property :range-type (org-element-timestamp-parser))) + 'daterange)) + (should + (eq + (org-test-with-temp-text "<2023-07-02 Sun 12:00 +5d>--<2023-07-02 Sun 13:00>" + (org-element-property :range-type (org-element-timestamp-parser))) + 'daterange))) ;;;; Underline @@ -3685,6 +3750,14 @@ DEADLINE: <2012-03-29 thu.> SCHEDULED: <2012-03-29 thu.> CLOSED: [2012-03-29 thu '(timestamp (:type active :year-start 2012 :month-start 3 :day-start 29 :hour-start 16 :minute-start 40)) nil))) + (should + (string-match + "<2012-03-29 .* 16:40>" + (org-element-timestamp-interpreter + '(timestamp + (:type active :year-start 2012 :month-start 3 :day-start 29 + :hour-start 16 :minute-start 40 :year-end 2012 :month-end 3 + :day-end 29 :hour-end 16 :minute-end 40)) nil))) ;; Inactive. (should (string-match "\\[2012-03-29 .* 16:40\\]" @@ -3696,11 +3769,35 @@ DEADLINE: <2012-03-29 thu.> SCHEDULED: <2012-03-29 thu.> CLOSED: [2012-03-29 thu '(timestamp (:type inactive :year-start 2012 :month-start 3 :day-start 29 :hour-start 16 :minute-start 40)) nil))) - ;; Active range. + ;; Active daterange. (should (string-match "<2012-03-29 .* 16:40>--<2012-03-29 .* 16:41>" (org-test-parse-and-interpret "<2012-03-29 thu. 16:40>--<2012-03-29 thu. 16:41>"))) + ;;; No end time, dates are not equal + (should + (string-match + "<2012-03-29 .* 16:40>--<2012-03-30 .*>" + (org-element-timestamp-interpreter + '(timestamp + (:type active-range :year-start 2012 :month-start 3 :day-start 29 + :hour-start 16 :minute-start 40 :year-end 2012 :month-end 3 + :day-end 30)) nil))) + (should + (string-match + "<2012-03-29 .* 16:40>--<2012-03-29 .* 16:40>" + (org-element-timestamp-interpreter + '(timestamp + (:type active-range :year-start 2012 :month-start 3 :day-start 29 + :hour-start 16 :minute-start 40 :year-end 2012 :month-end 3 + :day-end 29 :hour-end 16 :minute-end 40)) nil))) + (should + (string-match + "<2012-03-29 .* 16:40>--<2012-03-29 .*>" + (org-element-timestamp-interpreter + '(timestamp + (:type active-range :year-start 2012 :month-start 3 :day-start 29 + :hour-start 16 :minute-start 40)) nil))) (should (string-match "<2012-03-29 .* 16:40>--<2012-03-29 .* 16:41>" @@ -3709,7 +3806,7 @@ DEADLINE: <2012-03-29 thu.> SCHEDULED: <2012-03-29 thu.> CLOSED: [2012-03-29 thu (:type active-range :year-start 2012 :month-start 3 :day-start 29 :hour-start 16 :minute-start 40 :year-end 2012 :month-end 3 :day-end 29 :hour-end 16 :minute-end 41)) nil))) - ;; Inactive range. + ;; Inactive daterange. (should (string-match "\\[2012-03-29 .* 16:40\\]--\\[2012-03-29 .* 16:41\\]" (org-test-parse-and-interpret @@ -3722,6 +3819,11 @@ DEADLINE: <2012-03-29 thu.> SCHEDULED: <2012-03-29 thu.> CLOSED: [2012-03-29 thu (:type inactive-range :year-start 2012 :month-start 3 :day-start 29 :hour-start 16 :minute-start 40 :year-end 2012 :month-end 3 :day-end 29 :hour-end 16 :minute-end 41)) nil))) + ;; Active timerange + (should + (string-match "<2012-03-29 .* 16:40-16:41>" + (org-test-parse-and-interpret + "<2012-03-29 thu. 16:40-16:41>"))) ;; Diary. (should (equal (org-test-parse-and-interpret "<%%diary-float t 4 2>") "<%%diary-float t 4 2>\n")) @@ -3767,7 +3869,106 @@ DEADLINE: <2012-03-29 thu.> SCHEDULED: <2012-03-29 thu.> CLOSED: [2012-03-29 thu (:type active-range :year-start 2012 :month-start 3 :day-start 29 :year-end 2012 :month-end 3 :day-end 30 :repeater-type cumulate :repeater-value 1 :repeater-unit year)) - nil)))) + nil))) + ;; Tests for :range-type property + ;;; Errors + (should-error + (org-element-timestamp-interpreter + '(timestamp + (:range-type timerange + :type active + :year-start 2023 :month-start 7 :day-start 10 + :year-end 2023 :month-end 7 :day-end 10 + :hour-start 17 :minute-start 30 + :hour-end 17 :minute-end 30)) + nil)) + (should-error + (org-element-timestamp-interpreter + '(timestamp + (:range-type daterange + :type active :year-start 2023 :month-start 7 :day-start 10 + :hour-start 17 :minute-start 30)) nil)) + (should-error + (org-element-timestamp-interpreter + '(timestamp + (:range-type timerange + :type inactive + :year-start 2023 :month-start 7 :day-start 10 + :year-end 2023 :month-end 7 :day-end 10 + :hour-start 17 :minute-start 30 + :hour-end 17 :minute-end 30)) + nil)) + (should-error + (org-element-timestamp-interpreter + '(timestamp + (:range-type daterange + :type inactive :year-start 2023 :month-start 7 :day-start 10 + :hour-start 17 :minute-start 30)) nil)) + + ;;; End part is nil + (should + (string-match "<2023-07-10 .*>--<2023-07-10 .*>" + (org-element-timestamp-interpreter + '(timestamp + (:range-type daterange + :type active-range :year-start 2023 :month-start 7 :day-start 10)) nil))) + (should + (string-match "<2023-07-10 .* 17:30-17:30>" + (org-element-timestamp-interpreter + '(timestamp + (:range-type timerange + :type active-range :year-start 2023 :month-start 7 :day-start 10 + :hour-start 17 :minute-start 30)) nil))) + (should + (string-match "<2023-07-10 .* 17:30>--<2023-07-10 .*>" + (org-element-timestamp-interpreter + '(timestamp + (:range-type daterange + :type active-range :year-start 2023 :month-start 7 :day-start 10 + :hour-start 17 :minute-start 30)) nil))) + ;;; End is equal to start + (should + (string-match "<2023-07-10 .* 17:30-17:30>" + (org-element-timestamp-interpreter + '(timestamp + (:range-type timerange + :type active-range + :year-start 2023 :month-start 7 :day-start 10 + :year-end 2023 :month-end 7 :day-end 10 + :hour-start 17 :minute-start 30 + :hour-end 17 :minute-end 30)) nil))) + (should + (string-match "<2023-07-10 .* 17:30>--<2023-07-10 .* 17:30>" + (org-element-timestamp-interpreter + '(timestamp + (:range-type daterange + :type active-range + :year-start 2023 :month-start 7 :day-start 10 + :year-end 2023 :month-end 7 :day-end 10 + :hour-start 17 :minute-start 30 + :hour-end 17 :minute-end 30)) nil))) + ;;;; End date is not equal to start date, but interpret the object as a timerange (:range-type 'timerange) + (should + (string-match "<2023-07-10 .* 17:30-18:30>" + (org-element-timestamp-interpreter + '(timestamp + (:range-type timerange + :type active-range + :year-start 2023 :month-start 7 :day-start 10 + :year-end 2023 :month-end 8 :day-end 10 + :hour-start 17 :minute-start 30 + :hour-end 18 :minute-end 30)) nil))) + ;;;; End date is not equal to start date, interpret the object as a daterange (:range-type 'daterange) + (should + (string-match "<2023-07-10 .* 17:30>--<2023-08-10 .* 18:30>" + (org-element-timestamp-interpreter + '(timestamp + (:range-type daterange + :type active-range + :year-start 2023 :month-start 7 :day-start 10 + :year-end 2023 :month-end 8 :day-end 10 + :hour-start 17 :minute-start 30 + :hour-end 18 :minute-end 30)) nil)))) (ert-deftest test-org-element/verse-block-interpreter () "Test verse block interpretation." -- 2.40.1 --=-=-=--