From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp0.migadu.com ([2001:41d0:403:4876::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms1.migadu.com with LMTPS id gLD+ERYKF2aDCQEAqHPOHw:P1 (envelope-from ) for ; Wed, 10 Apr 2024 23:52:22 +0200 Received: from aspmx1.migadu.com ([2001:41d0:403:4876::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp0.migadu.com with LMTPS id gLD+ERYKF2aDCQEAqHPOHw (envelope-from ) for ; Wed, 10 Apr 2024 23:52:22 +0200 X-Envelope-To: larch@yhetil.org Authentication-Results: aspmx1.migadu.com; dkim=pass header.d=outlook.com header.s=selector1 header.b=t8MgH0Aq; arc=pass ("microsoft.com:s=arcselector9901:i=1"); dmarc=pass (policy=none) header.from=outlook.com; 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-Seal: i=2; s=key1; d=yhetil.org; t=1712785942; a=rsa-sha256; cv=pass; b=QDVXPolPs1LIBh+RIzfrTDLS18ceH4NfyAbGj+FdROioj4U+KOe4ksSYYtpTfF0202gPK3 zw/Mfp+6tX9tYVQbddU6lOXIOwb8EMh1WCN2QbBREUh2psadcVw88Zouu46lImaZGEk4o1 st4yVBSQpgwz9FwGIR2yH+uzYRxxzNx+ddRpgJUnBCotve2ofS1VLGQcKIQbd07eVdXGwV kNimEyJfyuf/tazGXg6Tv/ByXuuGYwxNI5s1MLiRb5SaeZDH7ycYY82ItvEbN0iNe33a/t pIv2Ns7EEQ7YxdlLsh+ZFrJavidWcLHnCUYKwJwKBt8Neknvd9v7MPNaMlAQRQ== ARC-Authentication-Results: i=2; aspmx1.migadu.com; dkim=pass header.d=outlook.com header.s=selector1 header.b=t8MgH0Aq; arc=pass ("microsoft.com:s=arcselector9901:i=1"); dmarc=pass (policy=none) header.from=outlook.com; 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=2; a=rsa-sha256; c=relaxed/relaxed; d=yhetil.org; s=key1; t=1712785942; 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=IQ8rsLmzz3/mG55ACMEEHr8p5rCunVr3Ohbx7m/NMXc=; b=qyumCFyzvqK3+EX4b5VCRUVlXM06GklTEXQHOg23u5IPj+pZnOHDDEFaQBDpg/7dwGFCBz eEWLjEq0s8TFG7qpiBkeCNY2JAjgisgQ2Kw09hw2nVZfFrY64Uz5WjPxJBp5X5TEZ6yG6q PBSNN/BLhmyAMGTZMUgM678cZgo4U85XdT/Y37KhgXwHwwg/9kMxCA2UtTxQFTYaPbLeaV J1VLr6XFOupS0rqgwkWaXFuao+uXG5HodmtjG5BFU6JKlrGSnaA7qbk3OhBl9o8CGIsqCS qLybzmJW76QXOXpBsqMlfJpD66oOrLzd68dkoFvg4lmUH+lKn1W+7jJXGsMUcg== 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 B71BE6E58A for ; Wed, 10 Apr 2024 23:52:21 +0200 (CEST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rufqk-0008O7-BD; Wed, 10 Apr 2024 17:51:22 -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 1rufqi-0008No-II for emacs-orgmode@gnu.org; Wed, 10 Apr 2024 17:51:20 -0400 Received: from mail-dm6nam12olkn20801.outbound.protection.outlook.com ([2a01:111:f403:2c17::801] helo=NAM12-DM6-obe.outbound.protection.outlook.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rufqf-0008D9-Eb for emacs-orgmode@gnu.org; Wed, 10 Apr 2024 17:51:20 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=QeuJ9rjXrd6mZUcYUTI9z8r1gfYHtW8+aYvQqmJF0PDv0fV/8eGM08yx7JBL9ElJONQboCe1Se8LRvZYGZuWfrcnq4KlZ+9SOGKfiC+WXswFoChGkRjyOb3cBOHQpcvvReuFU3VT262cqEDwRkyP2SMEw6W/8B0szRDpId6KcgNyc4O83Y2+ql0otg/OKALbpeMMALxbV5lag1KVGuh8dOc5WiaNKSEwKecBnn1RNSw7Y16/g7r/+b86iKASrRLkuA1F1cQhOI9tv1yxOxoKa2GjJC4i4a4q+EDVkkLof75Hy00zT/nfdIfvEV21ERonWST1dvhJmw23y9V7Hs+8hg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=IQ8rsLmzz3/mG55ACMEEHr8p5rCunVr3Ohbx7m/NMXc=; b=MH0I4t4S3E4eOXQ5+i3H8x3KtRzjSowaYqg4d3FmAeZb9WGWH8iybQhcUXtlfJ90P4ZMZXVO33HPGvyQXdRPGKvokVXsvEJznCl4BP3M2Ew3Ppx8bNudNNIeAc1JPmhtTjZsktsRpK3DVvo0WEJ3btdTjOzSPy4k+0GOaERTZ9tO2UumbM28VB2cvWg81SzgHlJWJWtSJtDwvIsuCbT5/Hy+CbbFBWThyfAmIkLdN125VluyFytDd/HDsaO5ZTxyZiVQjById68au9J1fvsrIFxVac08ft1OLy6H6JYFVdJo3ODt9/Z8iO88P0Wm6g8cFeCYneSzrvXI5qIgRS1V3g== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=none; dmarc=none; dkim=none; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=outlook.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=IQ8rsLmzz3/mG55ACMEEHr8p5rCunVr3Ohbx7m/NMXc=; b=t8MgH0AqGq1rVWW72hAcFA136kKdOwH6hc0wuiQCKbqOeEQjY0RMpLHTltCHu1GTBBnqFIz7srSsb7QvN5DVWCf6SEnGXwYeY29cai5fhhfyaXN2NGI1QxyifTu/kSHoIzvgviXZAc23CiPAI1TBlb80D7Wf7ytXy+KG5exsqT/AnHs6sKpIE7ZMiqsHXnsuMOeRkdPaeN02u9kbmytRKaYFToQZRQII8Z9zU3z2EqBnAvyGPIOcpG/tNC9o4+ggmINURmWtLENi5rnWJ/wjZwAAq4c+jHfaXbQXSOynrhqM8VFwrnRciIc+wFaARJHXzdRZBmKEMGH3q8loBORPiw== Received: from CH3PR84MB3424.NAMPRD84.PROD.OUTLOOK.COM (2603:10b6:610:1c4::17) by DM4PR84MB1736.NAMPRD84.PROD.OUTLOOK.COM (2603:10b6:8:4b::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7452.26; Wed, 10 Apr 2024 21:46:11 +0000 Received: from CH3PR84MB3424.NAMPRD84.PROD.OUTLOOK.COM ([fe80::178d:1518:8a49:2a45]) by CH3PR84MB3424.NAMPRD84.PROD.OUTLOOK.COM ([fe80::178d:1518:8a49:2a45%6]) with mapi id 15.20.7452.019; Wed, 10 Apr 2024 21:46:11 +0000 From: Morgan Smith To: Ihor Radchenko Cc: emacs-orgmode@gnu.org Subject: Re: [PATCH] lisp/org-element.el: Add repeater-deadline support to org-element In-Reply-To: <87sezxo194.fsf@localhost> (Ihor Radchenko's message of "Sun, 07 Apr 2024 11:33:59 +0000") References: <87ttkht6jc.fsf@localhost> <87sezxo194.fsf@localhost> X-Hashcash: 1:20:240410:yantar92@posteo.net::z4cKSCbfSA0EV+kB:BEM X-Hashcash: 1:20:240410:emacs-orgmode@gnu.org::2sh+L+3lN5rjA8Ac:5mr3 Date: Wed, 10 Apr 2024 17:46:07 -0400 Message-ID: User-Agent: Gnus/5.13 (Gnus v5.13) Content-Type: multipart/mixed; boundary="=-=-=" X-TMN: [exuNTh/G7pSpg0H0hLhz3qtMSYDyH4nU] X-ClientProxiedBy: YQBPR0101CA0054.CANPRD01.PROD.OUTLOOK.COM (2603:10b6:c00:1::31) To CH3PR84MB3424.NAMPRD84.PROD.OUTLOOK.COM (2603:10b6:610:1c4::17) X-Microsoft-Original-Message-ID: <877ch4nb6o.fsf@outlook.com> MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CH3PR84MB3424:EE_|DM4PR84MB1736:EE_ X-MS-Office365-Filtering-Correlation-Id: 784bdb2d-94e7-4812-2e20-08dc59a7a31c X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: EAZUIiI6OtpAQCaVbXFQ8GdTji02xT77CB1k2uStM9+JxQTheLwub1hGIYar8TC98FIzg9piFMlyVpVefSvQPXI3T8dPLBxaQOva5V3G/FreUSKa4BUoq19IItiQn/EI9tBszW0FVTKwHYd7pkPCLZaOe45GcW+WOb1xbfXzsfD4o9/U5cWVnt/UD17kZjuFfdV65mDAfsivzbh0Xx4pkeb5iTBzZ/VbmW2jIbqdezDlyP7/Q1bNN55TztBu5+jESPl8zcr8fdQEcQRN9LFwIFRyyMb7bJE1qjAXF5snxx2hfb27lGjzac53WrUmMlnSwFsEA8YcXyeY5HXDqTbG2ox+GBKu0Yx4fm/g3YZFX0OU2Nz4NxWK+dmzJ6isI/ArQUgBhxtKJh135/K+IS1SHZmoFt9R0QoySVblB74qCmqcW8mA86i/ONGd89aYPqm2tw4Ks1XEPK7gRSDpwGB/X2v2AunZSKq53RSOrDiWbH38Jystsc7ij7/+/t6mMVIIUzWwIZfDUdKlW/o0gCgKaP0M5/QdUniq1vHsnCs1ox69GQcxCIZSY4AsF5hUqeNarp/eJOuXD340E01msZea25LRVsnxmxFuVPUcDiOd2j8CYGq8wI24Yc1zOS+hZZ/+ X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?us-ascii?Q?Jnr0mu1HuOotHenvZRttUb0CSIhqISOZWfgg+LkOehWvlVvoStlX6BjVC5sg?= =?us-ascii?Q?fW/fwA/4gCC7B3SUKnffsXzn/0CaDD8dTkAjtTaYo2YFpB1dXgQk8r4tUUil?= =?us-ascii?Q?c651eyXcPl/P8RGmrUXDisZ9f0ZzFK6eqvMULLN444NKJ/wfWU2+YHbDozaG?= =?us-ascii?Q?ov8KIMJ83ygS/jJVMPLa7MIGGzYE7o82rktFUPkGlbdyRkDdrGC10f7x0JqJ?= =?us-ascii?Q?4qvaRNgEV+mlgY6gpsZaPhC0IQGe0gr4CVIR2OU+KAstORVtMffcX77XZInO?= =?us-ascii?Q?SO7jf9ub+kMrPQIAKVVsDWdogDF2IG7UlP3COeJFW1bbmu3TEkYMvtWiz3aG?= =?us-ascii?Q?Vji6E8Is+n6px7lrKXVAr44sX1tMh/rYaU9BHIUCOppZFSwM/IzTruOGP1Gp?= =?us-ascii?Q?xk+7QODJkyGOJAqrTXLZyGaogLx6rd3ds2Yd37qK1ZMxSs2y9iPfpUe7jV2d?= =?us-ascii?Q?WqbZnzs5yIUr+hG8uIuZ9GPwkisp0lG0EtnDdeQvy/f18nZsCY8b2jx9x7o2?= =?us-ascii?Q?dP+/TzIQ8mzutOvp9kj5TpL58vAAYBU9+yQ2t6Ep8uJ+cfxayWFVuwfJnOZt?= =?us-ascii?Q?u9l4zoi2uoSglLe6z/XAeRlnMYw/l1xI91JRclErJovQins6ARqNJbj/0Q6+?= =?us-ascii?Q?DsNtqdPivBv0CUZJ/GSu6xhZa2WMW31Bq2b9GTXPUZZ/xQsCVGIc7u1+kooG?= =?us-ascii?Q?Gqp6M0z1XyrrZlWstjb40dRxsg1hd2JjYnuSKPND27AxRad9AQ5LirRhY98g?= =?us-ascii?Q?FuXLRb8neUpOdXuqT0LOHE9sXEx9bXVbkQ6/u9Sd6rOAQGMF9ihnQrk4LLam?= =?us-ascii?Q?C1qPFMTKnLhhmVcSkWq7fCcwsNf2vZt5jxA2FnvBDVEeAayoXak+NbU9a8xS?= =?us-ascii?Q?evHuTsR4jz6AWUvXZM5kXK5Ty/mNz47LnVd2LskLLlhTcp0cOQJm6cNJOE5p?= =?us-ascii?Q?gdONxYpVei7oF8qDD80WGGW2Zg1+1f+XBSEAQtE/yLjfc+5XMYzA0xjKc0pt?= =?us-ascii?Q?aBLJloEDiW1rkmQUcwRtCba9Pgc7SZcn/qVwkjePpsePeYMHluOeqZNyEr8O?= =?us-ascii?Q?Fxkmaow6i7RTOtNgZz74Xm62tPvF/FZ9LUTTp5+NJTHgoNN61CD5U1tT31nr?= =?us-ascii?Q?llQPFHZfHpTN8KoOrW63jDqBgl5wLnhfLKxAIIyc3R31KZopWFw+PCuRPVcY?= =?us-ascii?Q?RE0DJZryQfcusGjncYM2LV74D3flRxihLs5MV9aTn959UZTECF2S9dq48KUz?= =?us-ascii?Q?wGcrBMJa6VstYDxC+IIG?= X-OriginatorOrg: outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: 784bdb2d-94e7-4812-2e20-08dc59a7a31c X-MS-Exchange-CrossTenant-AuthSource: CH3PR84MB3424.NAMPRD84.PROD.OUTLOOK.COM X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 10 Apr 2024 21:46:11.3730 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 84df9e7f-e9f6-40af-b435-aaaaaaaaaaaa X-MS-Exchange-CrossTenant-RMS-PersistedConsumerOrg: 00000000-0000-0000-0000-000000000000 X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM4PR84MB1736 Received-SPF: pass client-ip=2a01:111:f403:2c17::801; envelope-from=morgan.j.smith@outlook.com; helo=NAM12-DM6-obe.outbound.protection.outlook.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, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 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-Flow: FLOW_IN X-Migadu-Country: US X-Spam-Score: -9.72 X-Migadu-Queue-Id: B71BE6E58A X-Migadu-Spam-Score: -9.72 X-Migadu-Scanner: mx10.migadu.com X-TUID: SwSHlgxgqw9/ --=-=-= Content-Type: text/plain Apologies for the delay. I had lots of social events surrounding the solar eclipse. The eclipse was really cool, I do recommend. See two patches attached again. All tests pass on my computer. I decided to add an extra `let' statement to my changes to `org-element-timestamp-parser'. I think it adds a touch of clarity and maybe performance. Ihor Radchenko writes: >> My change in org-syntax.org now implies that a repeater >> must come before a delay. I don't know what syntax to use that doesn't >> make that implication. Although I don't see the harm in telling people >> to put the repeater first. > > We can simply leave the previous REPEATER-OR-DELAY, but expand on it > that REPEATER-OR-DELAY is an instance of REPEATER or an instance of > DELAY. Does it make sense? Done. >> Done. It's my first time using rx though. I don't know if I should be >> compiling it or something for performance? > > `rx' is a macro. It will be expanded during compilation. Thank you for the piece of mind. I'll have to use `rx' more often :). Thanks for the reviews! I'll start switching org-habit over to the element API soon. I've already played with that a bit --=-=-= Content-Type: text/x-patch Content-Disposition: attachment; filename=0001-lisp-org-element.el-Add-repeater-deadline-support-to.patch >From 582d4e7372c005f098f213b496de6f85c0c11d2f Mon Sep 17 00:00:00 2001 From: Morgan Smith Date: Wed, 3 Apr 2024 16:30:42 -0400 Subject: [PATCH] lisp/org-element.el: Add repeater-deadline support to org-element * lisp/org-element.el (org-element-timestamp-parser, org-element-timestamp-interpreter): Add support for repeater deadlines. Adds two new properties: ':repeater-deadline-value' and ':repeater-deadline-unit'. * testing/lisp/test-org-element.el (test-org-element/timestamp-parser, test-org-element/timestamp-interpreter): Test support for repeater deadlines. * etc/ORG-NEWS: Add relevant news. --- etc/ORG-NEWS | 14 +++++++ lisp/org-element.el | 70 +++++++++++++++++++++++--------- testing/lisp/test-org-element.el | 38 ++++++++++++++++- 3 files changed, 100 insertions(+), 22 deletions(-) diff --git a/etc/ORG-NEWS b/etc/ORG-NEWS index aeb7ffd4b..2b418cd3c 100644 --- a/etc/ORG-NEWS +++ b/etc/ORG-NEWS @@ -512,6 +512,20 @@ timestamp object. Possible values: ~timerange~, ~daterange~, ~nil~. ~org-element-timestamp-interpreter~ takes into account this property and returns an appropriate timestamp string. +**** New properties =:repeater-deadline-value= and =:repeater-deadline-unit= for org-element timestamp object + +~org-element-timestamp-parser~ now adds =:repeater-deadline-value= and +=:repeater-deadline-unit= properties to each timestamp object that has +a repeater deadline. + +Possible values for =:repeater-deadline-value=: ~positive integer~, ~nil~. + +Possible values for =:repeater-deadline-unit=: ~hour~, ~day~, ~week~, +~month~, ~year~. + +~org-element-timestamp-interpreter~ takes into account these properties +and returns an appropriate timestamp string. + **** =org-link= store functions are passed an ~interactive?~ argument The ~:store:~ functions set for link types using diff --git a/lisp/org-element.el b/lisp/org-element.el index 8e5416d8b..49a312694 100644 --- a/lisp/org-element.el +++ b/lisp/org-element.el @@ -4288,12 +4288,13 @@ 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', `:range-type', `:raw-value', `:year-start', `:month-start', -`:day-start', `:hour-start', `:minute-start', `:year-end', -`:month-end', `:day-end', `:hour-end', `:minute-end', +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', -`:warning-type', `:warning-value', `:warning-unit', `:begin', `:end' -and `:post-blank' properties. Otherwise, return nil. +`:repeater-deadline-value', `:repeater-deadline-unit', `:warning-type', +`:warning-value', `:warning-unit', `:begin', `:end' and `:post-blank' +properties. Otherwise, return nil. Assume point is at the beginning of the timestamp." (when (looking-at-p org-element--timestamp-regexp) @@ -4326,20 +4327,38 @@ Assume point is at the beginning of the timestamp." (date-end 'daterange) (time-range 'timerange) (t nil))) - (repeater-props - (and (not diaryp) - (string-match "\\([.+]?\\+\\)\\([0-9]+\\)\\([hdwmy]\\)" - raw-value) - (list - :repeater-type - (let ((type (match-string 1 raw-value))) - (cond ((equal "++" type) 'catch-up) - ((equal ".+" type) 'restart) - (t 'cumulate))) - :repeater-value (string-to-number (match-string 2 raw-value)) - :repeater-unit - (pcase (string-to-char (match-string 3 raw-value)) - (?h 'hour) (?d 'day) (?w 'week) (?m 'month) (_ 'year))))) + (repeater-props + (and (not diaryp) + (string-match + (rx + (group (or "+" "++" ".+")) + (group (+ digit)) + (group (or "h" "d" "w" "m" "y")) + (\? + "/" + (group (+ digit)) + (group (or "h" "d" "w" "m" "y")))) + raw-value) + (nconc + (list + :repeater-type + (let ((type (match-string 1 raw-value))) + (cond ((equal "++" type) 'catch-up) + ((equal ".+" type) 'restart) + (t 'cumulate))) + :repeater-value (string-to-number (match-string 2 raw-value)) + :repeater-unit + (pcase (string-to-char (match-string 3 raw-value)) + (?h 'hour) (?d 'day) (?w 'week) (?m 'month) (_ 'year))) + + (let ((repeater-deadline-value (match-string 4 raw-value)) + (repeater-deadline-unit (match-string 5 raw-value))) + (when (and repeater-deadline-value repeater-deadline-unit) + (list + :repeater-deadline-value (string-to-number repeater-deadline-value) + :repeater-deadline-unit + (pcase (string-to-char repeater-deadline-unit) + (?h 'hour) (?d 'day) (?w 'week) (?m 'month) (_ 'year)))))))) (warning-props (and (not diaryp) (string-match "\\(-\\)?-\\([0-9]+\\)\\([hdwmy]\\)" raw-value) @@ -4407,7 +4426,18 @@ Assume point is at the beginning of the timestamp." (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")))) + (`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"))) + "")))) (range-type (org-element-property :range-type timestamp)) (warning-string (concat diff --git a/testing/lisp/test-org-element.el b/testing/lisp/test-org-element.el index c49dc80d1..ddd601690 100644 --- a/testing/lisp/test-org-element.el +++ b/testing/lisp/test-org-element.el @@ -3208,11 +3208,18 @@ Outside list" (let ((timestamp (org-element-context))) (or (org-element-property :hour-end timestamp) (org-element-property :minute-end timestamp))))) - ;; With repeater, warning delay and both. + ;; With repeater, repeater deadline, warning delay and combinations. (should (eq 'catch-up (org-test-with-temp-text "<2012-03-29 Thu ++1y>" (org-element-property :repeater-type (org-element-context))))) + (should + (equal '(catch-up 2 year) + (org-test-with-temp-text "<2012-03-29 Thu ++1y/2y>" + (let ((ts (org-element-context))) + (list (org-element-property :repeater-type ts) + (org-element-property :repeater-deadline-value ts) + (org-element-property :repeater-deadline-unit ts)))))) (should (eq 'first (org-test-with-temp-text "<2012-03-29 Thu --1y>" @@ -3223,6 +3230,14 @@ Outside list" (let ((ts (org-element-context))) (list (org-element-property :repeater-type ts) (org-element-property :warning-type ts)))))) + (should + (equal '(cumulate all 2 year) + (org-test-with-temp-text "<2012-03-29 Thu +1y/2y -1y>" + (let ((ts (org-element-context))) + (list (org-element-property :repeater-type ts) + (org-element-property :warning-type ts) + (org-element-property :repeater-deadline-value ts) + (org-element-property :repeater-deadline-unit ts)))))) ;; :range-type property (should (eq @@ -3963,7 +3978,7 @@ DEADLINE: <2012-03-29 thu.> SCHEDULED: <2012-03-29 thu.> CLOSED: [2012-03-29 thu ;; Diary. (should (equal (org-test-parse-and-interpret "<%%diary-float t 4 2>") "<%%diary-float t 4 2>\n")) - ;; Timestamp with repeater interval, with delay, with both. + ;; Timestamp with repeater interval, repeater deadline, with delay, with combinations. (should (string-match "<2012-03-29 .* \\+1y>" (org-test-parse-and-interpret "<2012-03-29 thu. +1y>"))) @@ -3975,6 +3990,15 @@ DEADLINE: <2012-03-29 thu.> SCHEDULED: <2012-03-29 thu.> CLOSED: [2012-03-29 thu (:type active :year-start 2012 :month-start 3 :day-start 29 :repeater-type cumulate :repeater-value 1 :repeater-unit year)) nil))) + (should + (string-match + "<2012-03-29 .* \\+1y/2y>" + (org-element-timestamp-interpreter + '(timestamp + (:type active :year-start 2012 :month-start 3 :day-start 29 + :repeater-type cumulate :repeater-value 1 :repeater-unit year + :repeater-deadline-value 2 :repeater-deadline-unit year)) + nil))) (should (string-match "<2012-03-29 .* -1y>" @@ -3992,6 +4016,16 @@ DEADLINE: <2012-03-29 thu.> SCHEDULED: <2012-03-29 thu.> CLOSED: [2012-03-29 thu :warning-type all :warning-value 1 :warning-unit year :repeater-type cumulate :repeater-value 1 :repeater-unit year)) nil))) + (should + (string-match + "<2012-03-29 .* \\+1y/2y -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 + :repeater-deadline-value 2 :repeater-deadline-unit year)) + nil))) ;; Timestamp range with repeater interval (should (string-match "<2012-03-29 .* \\+1y>--<2012-03-30 .* \\+1y>" -- 2.41.0 --=-=-= Content-Type: text/x-patch Content-Disposition: attachment; filename=0001-Document-repeater-deadline-syntax-and-element-api.patch >From db69967bed986d96a6d246cd66d6d53b0a63f922 Mon Sep 17 00:00:00 2001 From: Morgan Smith Date: Thu, 4 Apr 2024 16:49:31 -0400 Subject: [PATCH] Document repeater deadline syntax and element api * dev/org-element-api.org (Timestamp): Add ':repeater-deadline-unit' and ':repeater-deadline-value'. * org-syntax.org (Timestamps): Separate definition of repeater and delay. Add repeater deadline to repeater definition. --- dev/org-element-api.org | 5 +++++ org-syntax.org | 20 ++++++++++++++------ 2 files changed, 19 insertions(+), 6 deletions(-) diff --git a/dev/org-element-api.org b/dev/org-element-api.org index ffcda274..9d57238b 100644 --- a/dev/org-element-api.org +++ b/dev/org-element-api.org @@ -706,6 +706,11 @@ ** Timestamp (symbol: ~year~, ~month~, ~week~, ~day~, ~hour~ or ~nil~). - ~:repeater-value~ :: Value of shift, if a repeater is defined (integer or ~nil~). +- ~:repeater-deadline-unit~ :: Unit of shift, if a repeater deadline + is defined (symbol: ~year~, ~month~, ~week~, ~day~, ~hour~ or + ~nil~). +- ~:repeater-deadline-value~ :: Value of shift, if a repeater deadline + is defined (integer or ~nil~). - ~:type~ :: Type of timestamp (symbol: ~active~, ~active-range~, ~diary~, ~inactive~, ~inactive-range~). - ~:range-type~ :: Type of range (symbol: ~daterange~, ~timerange~ or diff --git a/org-syntax.org b/org-syntax.org index bdd372d1..0967ae98 100644 --- a/org-syntax.org +++ b/org-syntax.org @@ -1763,20 +1763,28 @@ ** 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 the following pattern: ++ 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 +MARK VALUE UNIT/VALUE UNIT #+end_example Where MARK, VALUE and UNIT are not separated by whitespace characters. - MARK :: Either the string =+= (cumulative type), =++= (catch-up type), - or =.+= (restart type) when forming a repeater, and either =-= (all - type) or =--= (first type) when forming a warning delay. + or =.+= (restart type). + - VALUE :: A number + - UNIT :: Either the character =h= (hour), =d= (day), =w= (week), =m= + (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 - UNIT :: Either the character =h= (hour), =d= (day), =w= (week), =m= (month), or =y= (year) - -There can be two instances of =REPEATER-OR-DELAY= in the timestamp: one -as a repeater and one as a warning delay. *Examples* -- 2.41.0 --=-=-=--