From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp0.migadu.com ([2001:41d0:303:e224::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms1.migadu.com with LMTPS id wJR6OjEXD2YEqQAAqHPOHw:P1 (envelope-from ) for ; Thu, 04 Apr 2024 23:10:10 +0200 Received: from aspmx1.migadu.com ([2001:41d0:303:e224::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp0.migadu.com with LMTPS id wJR6OjEXD2YEqQAAqHPOHw (envelope-from ) for ; Thu, 04 Apr 2024 23:10:10 +0200 X-Envelope-To: larch@yhetil.org Authentication-Results: aspmx1.migadu.com; dkim=pass header.d=outlook.com header.s=selector1 header.b=LKE2xc0z; 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=outlook.com; arc=pass ("microsoft.com:s=arcselector9901:i=1") ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=yhetil.org; s=key1; t=1712265009; 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=Y9aBE5B1D/EaXiEicZgsUikEvxFgd//oCQuGNsN7xDM=; b=cj7fbeiYq/x7j/W+8gnc3ifuX2a9/dhC0qjo2JUHgTTCiTGQ9ugCAlYlXcAnYiyNcpealv AHyO4ru5wr71V18LszWhw07vf8EMpuar78lRY6ZwgQAkHFwQLGXpK3wYsZCGFBVsijGOoc WY4M4ga89yr4dKqUy99TXWC0uR9jpBODyJC9XRXgjb99tY+sLAvF6XBYRVFNdqxhjItNh6 f/XpdcMY3v42QE2I1baSJkzF0UzWipe5c3JO/2Vmu29fLDsWqwVLuCCwBEEwUE12L4ztdi mK5E+f5OvwqwmYywLkQ6+Uxw8vS2tYle3SFDo9SXYiO6Ya3F9ENrGZ9YuOqX/w== ARC-Seal: i=2; s=key1; d=yhetil.org; t=1712265009; a=rsa-sha256; cv=pass; b=bAOCby2ExVwA2nufC037d0Yb3ApowMhVDxCuS0qSItqEiZbM4NkO1hUK8Ug/3XDhAeqpHW LNldJ+3ilgJy7KZYak04yRL/XP6mtxGSebhRrP5sYquUySrOTly/CpG8calx+AP15HWmEY v0HH+3rdUXmAy+u3beexpiGCc9rDUDNXI8TF/mxBN0lKrZ8C6vgaZNxrYwZFgb0JfnmmEZ 8HMrLgDRrNVwPfyqYB8opt9AVfksHoNzM64cYIhG7Exzr/KZr8roeX9ccZmYogXpLyR0r3 t54AqGwn9JQjQP6f7Vhf0sBHrOzgbZujCsy9Arhr1Hgvh/mijOSVyi1gfvewIA== ARC-Authentication-Results: i=2; aspmx1.migadu.com; dkim=pass header.d=outlook.com header.s=selector1 header.b=LKE2xc0z; 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=outlook.com; arc=pass ("microsoft.com:s=arcselector9901:i=1") 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 5B3A919D15 for ; Thu, 4 Apr 2024 23:10:09 +0200 (CEST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rsUKh-0004q1-Hq; Thu, 04 Apr 2024 17:09:15 -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 1rsUKe-0004pK-Kk for emacs-orgmode@gnu.org; Thu, 04 Apr 2024 17:09:13 -0400 Received: from mail-bn1nam02olkn2012.outbound.protection.outlook.com ([40.92.15.12] helo=NAM02-BN1-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 1rsUKY-0004IN-0B for emacs-orgmode@gnu.org; Thu, 04 Apr 2024 17:09:12 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=YQ1we9hHVRxSb6aXAVC4qGNwYvWY/u9G9+k2nOSL1VnMPgT4Ay+qnINmMzAtZq7MU1+mYxLLpH+DZngNpS4FpsOx5VENNZ/yTPMftWtQE4yPVA2InJpXfN7MssVd0xvr/yKOQZwLM668x/4EYcy8SJNqDii9v/+jJrjf6O8wt5Q748noU03krq/OL0v4IoHj5EiEJFzHQlCYbzMtLAmFRzvi1fKEr3GdjxujtmJ/hW6gVmclfcwzIvJBcMatod+B+W8ZSQ7wLrELBAJBK/JnhTnMTHQWuNP+K1VlJIxrX/tDgOh6XxgPu7hH9IvN0zNaVqpSVt5lEhqKILrYLrUn+w== 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=Y9aBE5B1D/EaXiEicZgsUikEvxFgd//oCQuGNsN7xDM=; b=egquIsEOE2O1Fm2z/iC3b8uQaQ1G2+H33sEfcjq0qxHvCdCboG+DkSZlPz/FA1UYTwu2c6iVZS4eXP6KqP6ifyYqDe1jO7bX7v8aAfdApa1B7i0zpW9Vi9t8i1xwQLYMmDa9P6PL+US97jMGhMHdny+swuTTDfl89qpFV4QmlbGADtNoOT3IQcy33Oh/vGojrkxRyBBYGDcrusltYGBCtn7wfcBNeALhC9jTypxXT5RJKEqtOkscMTiHpe1meWRMZEG2veJU/jye7oVC4xNfUKu9Y39XFtjuByuuXlX74YNLuU5hRnYhkSACXcLt79cIM/kGf5Uke8BwVWFT4QbNnw== 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=Y9aBE5B1D/EaXiEicZgsUikEvxFgd//oCQuGNsN7xDM=; b=LKE2xc0z1pYobAChWo8XTiHPvkBHtnLpS4aUWWeMb3eez4dq9itb8TjkUhrd3DJ9oCybk/cD9/E0W0os0pUf060yY57kFt6Z77A8+tuTDVY6/8130IEzpeWBbAW/ZdiX1yCyVY0PBnHQv8hYZfzJvgcgokVsleymCY9bpOl8gXG3taoUnRBliLPh40c3speiwBrLJfeFxKLKESRqgeMC2Y2s38sLJzmdd67M6PgPhMlGnWanJYnyQ61Zt0VRdWGZGAFBvf+HvGE8E7Bh1d1OgjxlibJKA4OLQ7JDPqmx5M4pLjvmEpXd9E88ZJXbod2wdv05srefYS3/BrKeo6KKew== Received: from CH3PR84MB3424.NAMPRD84.PROD.OUTLOOK.COM (2603:10b6:610:1c4::17) by PH7PR84MB2245.NAMPRD84.PROD.OUTLOOK.COM (2603:10b6:510:157::12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7452.26; Thu, 4 Apr 2024 21:08:59 +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; Thu, 4 Apr 2024 21:08:59 +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: <87ttkht6jc.fsf@localhost> (Ihor Radchenko's message of "Thu, 04 Apr 2024 16:51:51 +0000") References: <87ttkht6jc.fsf@localhost> X-Hashcash: 1:20:240404:yantar92@posteo.net::vjj8wBC0GLe46WP3:2UkG X-Hashcash: 1:20:240404:emacs-orgmode@gnu.org::A4iLghaDTUGP+TfZ:48bU Date: Thu, 04 Apr 2024 17:08:55 -0400 Message-ID: User-Agent: Gnus/5.13 (Gnus v5.13) Content-Type: multipart/mixed; boundary="=-=-=" X-TMN: [Q6jpHQB/HqW6rAKeZVhkLTTtWcSWlwNS] X-ClientProxiedBy: YT1PR01CA0099.CANPRD01.PROD.OUTLOOK.COM (2603:10b6:b01:2c::8) To CH3PR84MB3424.NAMPRD84.PROD.OUTLOOK.COM (2603:10b6:610:1c4::17) X-Microsoft-Original-Message-ID: <87bk6on8d4.fsf@outlook.com> MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CH3PR84MB3424:EE_|PH7PR84MB2245:EE_ X-MS-Office365-Filtering-Correlation-Id: 549183ad-2dd0-442a-51f3-08dc54eb7245 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 5F2bRMKGJCF0cWTd3GNBh6pE8732+0COrorZ4HmTaT8yjMdVgwXkcVp+TUoXizGv9rVOSZQ2UckoZaR6rsA9JkcY/AHLAQEe1cXcNgmxHDDYF/hoVILgqVgThqkF73hi89ktGhN3itbiqI6PyeahHKhqYnBOraAyxYllaPoKzX0gUUqap3SCyiMoxlBFTBs0O9AxyAc81BANfc/mH8I39MSo5pXl2exGCuZUdkTBnsGMRAzObcuva2XZHO6QrxWI7Rg4mw5JBCWwCTjs2Axi72QRCDTMjZMuVH1pWxy3vhzBKzZVQlu7JDvATSRZOlyRULqs9Mwk+gIEtHiGvzTuJGtq7fAGhkW0Ie2jRNNv47ia+N+6k69UyvdhSBhgFaS8gyibfqXRDx1LkvvvhVkmf2LXP3H4+s2V7ow6gFsS3CejU7vWd9eezYEkLJbLfPeauWm1HxBPHSYjAuMXs1F8ddtQ15uPIlGt+tjcj3h/FMh6qR4JaAjB6RzAN2HhNqAY+D0N1xHQDeSx6K6blRxGIni5SPYUE0as9rJkqT5Tihk6cALPuz+kxbZ7XTn96nmtSqPn10L5qKXJjZK1PLGF/wxWg723cr5DwimsNcO0DZ8Wbl1QBX/BEKV/EUPhVwSqg6a3o1T731bJFsho9sw9Jd76IUQKihDEemayK1fzkuB7fslAtbfab4F6HdFrCwfB X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?us-ascii?Q?pn/h/3ldS5hCKmjI8wQ1H4It1sq0sX/EmL1s1OFe1zEBtbIA1IrVw41pDF5U?= =?us-ascii?Q?LEM7Q/lgAKJlvCX3ckuX0Zks6uzK1GAOj4qRSDNrH/SVt221GWjeIbV6Cgci?= =?us-ascii?Q?iXNxUoxGA1ZPTJ+325hJZEZOMHNbdEWcWBPq5vLPYsszCfZtoA1u9VMkPMfu?= =?us-ascii?Q?lwdK+G6faF2Gkj9AdeiN155EqRIR2qnbtryF4j/jZr12O7b5svcjfdhkzWNF?= =?us-ascii?Q?7cOM9XuQn31YE5LdEZUNpx9aMadbNoTNatTXkhL78J1CTloBPAECXALu0sbN?= =?us-ascii?Q?dlPasQqhpmF13P6u3fUlngJqr2bTKPibNRQnXsknWOWX4gq455hqW8bkzv53?= =?us-ascii?Q?nhyXU/3iF9digRmKMyQRVBzMntJvWe+KH9gS635nn2zms1tkcft08z3mhx7W?= =?us-ascii?Q?atyl3OoBpq9p0ccDZ+i202cVXiLQ28BLkQ5bZWqFcVBgSH9/s3G9MO60QPIH?= =?us-ascii?Q?0DW8Lsi06aX08mkR2YrBKN2enHenexA3Gw5Yd58WtoyMUgwKsPgjZxmUi1Is?= =?us-ascii?Q?Ezo/1TvJo6dOUFQLhZt3qXI+NXaRHFVpPBpL/BumhPjhFCBpIy/2WQqjMpqS?= =?us-ascii?Q?rqhaDZ34k0JsXpmTXH54cr2OYvEVqXmVFQASkpO/U80YWrRoYhrUOUmTFC8o?= =?us-ascii?Q?Jvs1eHpnWf6PbPAW2gaZ4G4aNhoTWUyi0sBlqIoGdJdtD4Me751QuUwcBoyA?= =?us-ascii?Q?/pYOeBNowo6Nlu/tZSvgd0xt0YqOTUwSJP5dt4IAQaBsmEqUsTE0bZcJtO6I?= =?us-ascii?Q?8Z0h4K0EPo8clYnnFi4ZSQhmNyJ8omQGdhKadD8FDzRC27m2u+M61WQDQxxn?= =?us-ascii?Q?kataJ7RtGo7TQ+tyNz7rYHCDuN+MZ/LFAHwxtJODA2pAW3+qCsecDbWRJ7EB?= =?us-ascii?Q?yPAxeU53SXqDZF2v5tnuKCxJyJbnLouyEqvXxbWGBHVUtrBaSQZ6Dt32S3Ts?= =?us-ascii?Q?opdYaAsDzRhQPpmUehZLLpsxXJGqEZBwjGeQfUqocQd7jtrN9GpQTjDsEj30?= =?us-ascii?Q?Ss0OLN8Y0q3hSCWsxLL2fvstCU6e6HdeBvXnVUtSpmesygc+1x2GPv+GEqXB?= =?us-ascii?Q?gdpXZHaq1CNqYvopQSvuBG/F6V1Kss8/bvwRtWNd684XFr1QvGXKlcUeWLDe?= =?us-ascii?Q?7MH4VotyDWe08Y3UQ6PBqy7wqraLtYyPYFcigNCDSP/ZFOKwfAqIzYebrklY?= =?us-ascii?Q?K5s4f3UJ8vjkF2gtQmRK4rIHdezAojhwyy3oBx7jIwRnoO7N9+08XKNyAYz1?= =?us-ascii?Q?s4xEG5pCZOUOyA3thtNX?= X-OriginatorOrg: outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: 549183ad-2dd0-442a-51f3-08dc54eb7245 X-MS-Exchange-CrossTenant-AuthSource: CH3PR84MB3424.NAMPRD84.PROD.OUTLOOK.COM X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 04 Apr 2024 21:08:59.3122 (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: PH7PR84MB2245 Received-SPF: pass client-ip=40.92.15.12; envelope-from=Morgan.J.Smith@outlook.com; helo=NAM02-BN1-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, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=-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-Migadu-Spam-Score: -9.68 X-Spam-Score: -9.68 X-Migadu-Queue-Id: 5B3A919D15 X-Migadu-Scanner: mx12.migadu.com X-TUID: J0rR8P8VQsfk --=-=-= Content-Type: text/plain Hello, Thanks for the review! See two patches attached. One for org and one for worg. Tests still pass on my end. Ihor Radchenko writes: > Please also add etc/ORG-NEWS entry - it is org-element API change. Done > In addition to changes in Org git, you also need to update > https://orgmode.org/worg/org-syntax.html#Timestamps and > https://orgmode.org/worg/dev/org-element-api.html(the page source is at https://git.sr.ht/~bzg/worg) Done. Sort of. 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. > This will match timestamps like <2012-03-29 Thu +1y2y>. You may instead > use shy group \(?:...\)? around the whole /2y regexp match. (Or even > rewrite the regexp via rx for better readability, while we are on it). Done. It's my first time using rx though. I don't know if I should be compiling it or something for performance? > This is slightly confusing, because "deadline" has multiple meanings in > Org. repeater-deadline-value/unit would be more readable as the variable name. Done --=-=-= Content-Type: text/x-patch Content-Disposition: attachment; filename=0001-Document-repeater-deadline-syntax-and-element-api.patch >From b285023ca107f7c0fc8b89f7f636cf96bd217207 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 | 32 +++++++++++++++++++------------- 2 files changed, 24 insertions(+), 13 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..cf477655 100644 --- a/org-syntax.org +++ b/org-syntax.org @@ -1743,13 +1743,13 @@ ** Timestamps Timestamps are structured according to one of the seven following patterns: #+begin_example -<%%(SEXP)> (diary) - (active) -[DATE TIME REPEATER-OR-DELAY] (inactive) --- (active range) - (active range) -[DATE TIME REPEATER-OR-DELAY]--[DATE TIME REPEATER-OR-DELAY] (inactive range) -[DATE TIME-TIME REPEATER-OR-DELAY] (inactive range) +<%%(SEXP)> (diary) + (active) +[DATE TIME REPEATER DELAY] (inactive) +-- (active range) + (active range) +[DATE TIME REPEATER DELAY]--[DATE TIME REPEATER DELAY] (inactive range) +[DATE TIME-TIME REPEATER DELAY] (inactive range) #+end_example + SEXP :: A string consisting of any characters but =>= and =\n=. @@ -1763,20 +1763,26 @@ ** 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 (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 --=-=-= Content-Type: text/x-patch Content-Disposition: attachment; filename=0001-lisp-org-element.el-Add-repeater-deadline-support-to.patch >From 35af811225918d7bb19e54c1c0a6fb4858c8a33f 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 | 67 ++++++++++++++++++++++---------- testing/lisp/test-org-element.el | 38 +++++++++++++++++- 3 files changed, 97 insertions(+), 22 deletions(-) diff --git a/etc/ORG-NEWS b/etc/ORG-NEWS index fff4f47de..ef205c228 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..79eb5eb29 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,35 @@ 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))) + (when (and (match-string 4 raw-value) (match-string 5 raw-value)) + (list + :repeater-deadline-value (string-to-number (match-string 4 raw-value)) + :repeater-deadline-unit + (pcase (string-to-char (match-string 5 raw-value)) + (?h 'hour) (?d 'day) (?w 'week) (?m 'month) (_ 'year))))))) (warning-props (and (not diaryp) (string-match "\\(-\\)?-\\([0-9]+\\)\\([hdwmy]\\)" raw-value) @@ -4407,7 +4423,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 --=-=-=--