From mboxrd@z Thu Jan  1 00:00:00 1970
Return-Path: <emacs-orgmode-bounces+larch=yhetil.org@gnu.org>
Received: from mp12.migadu.com ([2001:41d0:2:4a6f::])
	(using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits))
	by ms9.migadu.com with LMTPS
	id gNJ7GIg5oWTYkQAASxT56A
	(envelope-from <emacs-orgmode-bounces+larch=yhetil.org@gnu.org>)
	for <larch@yhetil.org>; Sun, 02 Jul 2023 10:47:04 +0200
Received: from aspmx1.migadu.com ([2001:41d0:2:4a6f::])
	(using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits))
	by mp12.migadu.com with LMTPS
	id EAYxGIg5oWSkYQEAauVa8A
	(envelope-from <emacs-orgmode-bounces+larch=yhetil.org@gnu.org>)
	for <larch@yhetil.org>; Sun, 02 Jul 2023 10:47: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 083AC3A589
	for <larch@yhetil.org>; Sun,  2 Jul 2023 10:47:03 +0200 (CEST)
Received: from localhost ([::1] helo=lists1p.gnu.org)
	by lists.gnu.org with esmtp (Exim 4.90_1)
	(envelope-from <emacs-orgmode-bounces@gnu.org>)
	id 1qFsin-0005FP-Oy; Sun, 02 Jul 2023 04:46:17 -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 <yantar92@posteo.net>)
 id 1qFsil-0005F8-J5
 for emacs-orgmode@gnu.org; Sun, 02 Jul 2023 04:46:15 -0400
Received: from mout02.posteo.de ([185.67.36.66])
 by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256)
 (Exim 4.90_1) (envelope-from <yantar92@posteo.net>)
 id 1qFsii-0005Jb-Ql
 for emacs-orgmode@gnu.org; Sun, 02 Jul 2023 04:46:15 -0400
Received: from submission (posteo.de [185.67.36.169]) 
 by mout02.posteo.de (Postfix) with ESMTPS id 07782240101
 for <emacs-orgmode@gnu.org>; Sun,  2 Jul 2023 10:46:10 +0200 (CEST)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=posteo.net; s=2017;
 t=1688287570; bh=AC5jppRAGvcipWGWvd+BkMN1C8/KMGQtqPgHgXJbHFg=;
 h=From:To:Cc:Subject:Date:Message-ID:MIME-Version:From;
 b=PH0xTVEXAF9xiPmyZ1xnwyCB71D1itdaaq/cr0I/etL0WwXLvEoY4ncPex4ycukp6
 6GKqYKLQNB+KnPq+E/Yofcev2tayoWnLeSInnUapemaZOI3O6HOpYdtP/ESwO/fW8g
 At6UXLX+6V8WZG05qoHUygUUBY2DBt9/2M106IbHRubT9P6T2mIe+TMgnbUf6+S13O
 3frtU+n10rdja4/5NgNOEJ3EfpF3nbT2GHAKJTylTa+idUmATNhcU5fWNlOBLVFX98
 E3OdnceRJ8/fVwQg5MATmlAw4pBUBakSDIq1DTC+RN9fSaIhMP01D2jH51bho4Lk9v
 mOCT8/xA+nl7g==
Received: from customer (localhost [127.0.0.1])
 by submission (posteo.de) with ESMTPSA id 4Qv2hd1nrYz6twW;
 Sun,  2 Jul 2023 10:46:09 +0200 (CEST)
From: Ihor Radchenko <yantar92@posteo.net>
To: Ilya Chernyshov <ichernyshovvv@gmail.com>
Cc: emacs-orgmode <emacs-orgmode@gnu.org>
Subject: Re: [PATCH] org-element-timestamp-interpreter: Return daterange
 anyway, if DATERANGE is non-nil
In-Reply-To: <CAGEwbGU9bmg=jAAX5OTrcrjV0q67Nd2yR3aVM4Z-yOUv1Pz1sQ@mail.gmail.com>
References: <87y1ot6dqz.fsf@gmail.com> <87wn4cegt4.fsf@localhost>
 <9E22693E-7D20-470A-B57B-EA17BBE9160F@gmail.com>
 <87a616c5do.fsf@localhost>
 <CAGEwbGU9bmg=jAAX5OTrcrjV0q67Nd2yR3aVM4Z-yOUv1Pz1sQ@mail.gmail.com>
Date: Sun, 02 Jul 2023 08:46:08 +0000
Message-ID: <87wmzi4s6n.fsf@localhost>
MIME-Version: 1.0
Content-Type: text/plain
Received-SPF: pass client-ip=185.67.36.66; envelope-from=yantar92@posteo.net;
 helo=mout02.posteo.de
X-Spam_score_int: -43
X-Spam_score: -4.4
X-Spam_bar: ----
X-Spam_report: (-4.4 / 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,
 RCVD_IN_DNSWL_MED=-2.3, RCVD_IN_MSPIKE_H5=0.001, RCVD_IN_MSPIKE_WL=0.001,
 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." <emacs-orgmode.gnu.org>
List-Unsubscribe: <https://lists.gnu.org/mailman/options/emacs-orgmode>,
 <mailto:emacs-orgmode-request@gnu.org?subject=unsubscribe>
List-Archive: <https://lists.gnu.org/archive/html/emacs-orgmode>
List-Post: <mailto:emacs-orgmode@gnu.org>
List-Help: <mailto:emacs-orgmode-request@gnu.org?subject=help>
List-Subscribe: <https://lists.gnu.org/mailman/listinfo/emacs-orgmode>,
 <mailto:emacs-orgmode-request@gnu.org?subject=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
ARC-Seal: i=1; s=key1; d=yhetil.org; t=1688287624; a=rsa-sha256; cv=none;
	b=H1hlhZ7g7vGErUZSkVgD7uRjZPCgTSIV9ex3wE6XQps+FBNST6oNs61dNVZ7xXtX/zVNAv
	f1VswZosniUe1jyz4nrKFmQr6JABeQ4HJiPSA0n2IuQ497V3TxvlHNf72wkAbKsEnCTBnC
	Z08DGj5sr3cdTiqRfkILlduZG39PgQQ4bQ8RLmq4Q/45hQH9T0n09cQeP+O/SXFBj5uTPb
	zmBaqrS8LOPn8IkdPsoHNG1nqUcjUN+TS1patBoQHJQDjDnl7+o6Q6/1/khSPVCaSfQv0J
	J0QNVzwpkGT1QL0cWZin75xqhBFqaXfK2daNKhRUsUqcbJMAxMu8EztKRH6H/A==
ARC-Authentication-Results: i=1;
	aspmx1.migadu.com;
	dkim=pass header.d=posteo.net header.s=2017 header.b=PH0xTVEX;
	dmarc=pass (policy=none) header.from=posteo.net;
	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"
ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=yhetil.org;
	s=key1; t=1688287624;
	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=CIOYLCGGNilfLttkBhdZkG2TIdkISwGvXNVwkUj/wIo=;
	b=SYL4l0PvOrY11+LywaUBDF72LvUub3yBx5F6RUTg5wpt++2ECnDpBLLfhkIoO7CmEr3nDa
	JiOOreJ6doFKPrs5FIFA2am5aq1szh8lduok+BMXFk+ArLwX+IYMLuxEhZmcMiFKsEM7hl
	CK5djYaM989pv7E66ez78cfACC9PHr+VpKyiDBP5GjGl+B/6IoJLQJI8rRhruzGWN1muSm
	HZrdWOtdbe3PBA6eeidNdU1nPcq7hBoljAOmwz3DzwWoHNZlRRV6vUKgc5whOcQE987PdS
	AMSjpz9dw73xR7cnqyyo6gWD70j63VoAjGN7ZPwj3LftIMiqpAtl93Roxw9kSw==
Authentication-Results: aspmx1.migadu.com;
	dkim=pass header.d=posteo.net header.s=2017 header.b=PH0xTVEX;
	dmarc=pass (policy=none) header.from=posteo.net;
	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"
X-Migadu-Scanner: scn0.migadu.com
X-Migadu-Spam-Score: -8.23
X-Spam-Score: -8.23
X-Migadu-Queue-Id: 083AC3A589
X-TUID: Qo58xEbcitTn

Ilya Chernyshov <ichernyshovvv@gmail.com> writes:

> In the new patch I added :range-type timestamp property, adjusted
> interpreter,
> parser functions, added tests for the property.

Thanks!

Some general stylistic comments:

1. You left some whitespace-only blank lines and spaces at the end of
   lines. Please, clean them up.
2. Please, use double space between sentences in the commit message and
   link to this thread. See
   https://orgmode.org/worg/org-contribute.html#commit-messages
3. I noticed some (let((...) forms. Please put spaces between sexps like
   (let ((...)
       ^ space here

> * lisp/org-element (org-element-timestamp-parser): Add :range-type property

Dot is missing at the end of the sentence here.

>  (defun org-element-timestamp-interpreter (timestamp _)
>    "Interpret TIMESTAMP object as Org syntax."
> ...
> +	         (concat
> +                  "<" start-date (and start-time (concat " " start-time))
> +                  (if date-range-p
> +                      (concat ">--<" end-date (and end-time (concat " " end-time)))
> +                    (if time-range-p (concat "-" end-time)))
> +                  ">")))

Here, you are manually constructing time part of the timestamp,
bypassing `org-time-stamp-format' and `org-timestamp-formats'. Please,
use `org-time-stamp-format' for times as well.
If necessary, feed free to extend `org-time-stamp-format' and the value
of `org-timestamp-formats' constant.

> +	    (dolist (s (list repeat-string warning-string))
> +	      (when (org-string-nw-p s)
> +	        (setq ts (string-replace ">" (concat " " s ">") ts))))
> +	    (pcase (org-element-property :type timestamp)
> +              ((or `active `active-range)
> +               ts)
> +              ((or `inactive `inactive-range)
> +               (string-replace
> +                "<" "["
> +                (string-replace ">" "]" ts)))))))

`string-replace' is fragile here. If we ever need to put "<" or ">"
inside timestamp, random breakages may happen. Please, rewrite.



>    (should
>     (string-match
> -    "\\[2012-03-29 .* 16:40\\]--\\[2012-03-29 .* 16:41\\]"
> +    "\\[2012-03-29 .* 16:40-16:41\\]"
>      (org-element-timestamp-interpreter
>       '(timestamp
>         (: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)))
> +  
>    ;; Diary.
>    (should (equal (org-test-parse-and-interpret "<%%diary-float t 4 2>")
>  		 "<%%diary-float t 4 2>\n"))
> -- 
> 2.40.1

> * lisp/org-element (org-element-timestamp-interpreter): For ranges:
> When :range-type is nil or `timerange', return timerange (<YYYY-mm-DD
> HH:MM-HH:MM>) if date-start and date-end are equal; return
> daterange(<...>--<...>) otherwise. When :range-type is `daterange',
> return daterange anyway. Refactor the code.

Interpreting timestamps with :time-range nil and
:day-end/:year-end/:month-end non-nil as timerange is a breaking change.
Let's avoid it.

With the new version of the parser, the test example will never happen,
but the tested AST structure might happen in the wild - we do not want
to break anything when it is not necessary.

-- 
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>