emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
From: Ihor Radchenko <yantar92@posteo.net>
To: Tom Alexander <tom@fizz.buzz>
Cc: emacs-orgmode@gnu.org
Subject: Re: [PATCH] Clarify that REST is not supported on the start TIME in a time-range timestamp.
Date: Wed, 04 Oct 2023 09:02:25 +0000	[thread overview]
Message-ID: <87bkdeoj4u.fsf@localhost> (raw)
In-Reply-To: <e8a88c0b-79d3-4baa-ab12-642def56273d@app.fastmail.com>

"Tom Alexander" <tom@fizz.buzz> writes:

> Potentially related, org-mode is accepting this malformed timestamp from[1]:
> ```
> <2016-02-14 Sun ++y>
> ```
>
> The org-mode documentation[2] only includes REST with TIME, defining TIME as "H:MMREST". The above does not have any TIME but it accepts the timestamp anyway:
> ...
> Perhaps that grammar is wrong and REST needs to be separated from TIME?

We have no internal consistency here, AFAIR.
The actual matching is done with

(defconst org-element--timestamp-regexp
  (concat org-ts-regexp-both
	  "\\|"
	  "\\(?:<[0-9]+-[0-9]+-[0-9]+[^>\n]+?\\+[0-9]+[dwmy]>\\)"
	  "\\|"
	  "\\(?:<%%\\(?:([^>\n]+)\\)>\\)")
  "Regexp matching any timestamp type object.")

with org-ts-regexp-both matching

(rx (seq
       (= 4 digit) "-" (= 2 digit) "-" (= 2 digit)
       (optional " " (*? nonl))))

(and also brackets)

Then, `org-element-timestamp-parser' looks for DATE/TIME/REPEATERS/etc
inside the above match, disregarding any order:

(string-match
		    "[012]?[0-9]:[0-5][0-9]\\(-\\([012]?[0-9]\\):\\([0-5][0-9]\\)\\)"
		    date-start)

(string-match "\\([.+]?\\+\\)\\([0-9]+\\)\\([hdwmy]\\)"
				 raw-value)                    

(string-match "\\(-\\)?-\\([0-9]+\\)\\([hdwmy]\\)" raw-value)

However, not all the Org code is using org-element parser yet. Certain
parts of Org are matching manually using a separate, more strict
regexps, like org-ts-regexp0, org-ts-regexp1, ...

So, we chose to use a more strict definition in org-syntax for the time
being, before we consolidate things together in more uniform ways.

As for the problem with REST you raised, I am inclined to remove it from
syntax doc for the time being - it only creates more confusion,
unfortunately.

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


  reply	other threads:[~2023-10-04  9:04 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-10-02 21:45 [PATCH] Clarify that REST is not supported on the start TIME in a time-range timestamp Tom Alexander
2023-10-02 23:43 ` Tom Alexander
2023-10-04  9:02   ` Ihor Radchenko [this message]
2023-10-07  1:20     ` Tom Alexander
2023-10-07  8:33       ` Ihor Radchenko

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.orgmode.org/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87bkdeoj4u.fsf@localhost \
    --to=yantar92@posteo.net \
    --cc=emacs-orgmode@gnu.org \
    --cc=tom@fizz.buzz \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).