From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp1.migadu.com ([2001:41d0:403:4876::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms13.migadu.com with LMTPS id KAdELXZjeWYDdQEA62LTzQ:P1 (envelope-from ) for ; Mon, 24 Jun 2024 12:15:50 +0000 Received: from aspmx1.migadu.com ([2001:41d0:403:4876::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp1.migadu.com with LMTPS id KAdELXZjeWYDdQEA62LTzQ (envelope-from ) for ; Mon, 24 Jun 2024 14:15:50 +0200 X-Envelope-To: larch@yhetil.org Authentication-Results: aspmx1.migadu.com; dkim=pass header.d=outlook.com header.s=selector1 header.b=tn1PUNsx; 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=1719231350; 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=WjKDUlgSHupZLfeBdCvKmL1J1ztmUnESVaWWW5Xavb4=; b=nP7NYRVGztdaYh5+tJtkNLBcxFq3PL4DSptaqeOIit3xZK6NAVcnjaSFatmKwSwsnaYgQd HmnyqSNPog7VbuqWZzSOLjJ1TXXMhpQGIcxKApxBCudH2wCgXOdzJQfw/3JMxSUrbOWp5c YovUKr1Vh+tHKMZEp7B42gjLtbwUKYtG6jIAQPlswL7x1aYTOxxU8MauxVLmVm74QNqxjL Ii/vnvMAkuBHFOm2BwG8QSbNkP3llPnGm2VIOwNVeLlWzuR4WE0/Cri0h3iMdqcpD825Zu LQxtf1jVJQINqoUt99ld8oIDsl84jmkg7ecu8B4R6uUpG3b+Ta+y8gsaoZSIUg== ARC-Authentication-Results: i=2; aspmx1.migadu.com; dkim=pass header.d=outlook.com header.s=selector1 header.b=tn1PUNsx; 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-Seal: i=2; s=key1; d=yhetil.org; t=1719231350; a=rsa-sha256; cv=pass; b=tqyoWs9ZP4IHKdYwDU9JGZrAXVfraZ5nne5yU4iVqOC3XWwVeh3cNLdhAzRV3F6R5uyq8b HRecsa33I+x92ZOSnfweqMiwzUpmpMZmgnfJqqw4E0mNJGYGBlfumc3qy44g98o/+bMwMS Ql/90cT58Khe2gLFWj0zpUxIs44H4Me3QOQQsQpalUe5oe/zq9lTvDSi9JAoWXIvpArIp7 RHdTsi2qQPF9DlF/C0BWhHVSaZuT+rxL/6T1w6KQQd1AIE6f4iFGc4yPiyX4rcZXD0m6h0 oDptzj7FUAKCmDZ1rL2CvncNDHasgqKtG67phjuJm4+/yt8xlLS5Wz47C3PjPA== 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 6609D73CB2 for ; Mon, 24 Jun 2024 14:15:50 +0200 (CEST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sLibC-0005ff-MZ; Mon, 24 Jun 2024 08:15:06 -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 1sLibA-0005cU-Dc for emacs-orgmode@gnu.org; Mon, 24 Jun 2024 08:15:04 -0400 Received: from mail-bn8nam11olkn2080d.outbound.protection.outlook.com ([2a01:111:f403:2c14::80d] helo=NAM11-BN8-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 1sLib7-0000G9-DE for emacs-orgmode@gnu.org; Mon, 24 Jun 2024 08:15:04 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=BUr1Fws6FHWMsQkJHbaw3yiDYSPETE3DUHeE9O4xUeS9d/j+/iQXr5frH3+0OepEy9NAR51uD+XkKzjvhaJyc89asH5HYz31kt8kd1VMC84mWSPzAj0hJi0aPXjAWkjBDP9ArwKkZeyHvaLejtkAAr9zMUzKp/hijCdKnssi0+lA2PsNRTgXhmhxQZFpfM/cnckt2hETACsZDzm89mMseDIgXdIzWjN3BuQkv6ZBLHJ4qVWUV0z2UsniP4WF9T42GEwwrc6O/+WU+jzPEA1JVdl6+ctaFhQ8XTBBByZ+Wffsyi2jn2iEToQj4vke9EuoLQPvj3PHmIrTDYIKK14JlQ== 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=WjKDUlgSHupZLfeBdCvKmL1J1ztmUnESVaWWW5Xavb4=; b=AbFfZMCEKGnSxr9+JH3+ouMFzAgJPkgfSEawoeId6yJPVWkyv89LJGLfmjPwYC1RFCoBZR93IOpP8roMkIXrc2k938H8bUuJ3jpOOwjhyi5OqZn9fOtGx5lew8jWVUKoAaRVXrQ2YESsP+sWCWfuY1U/agqC6Ep9sTEkRdAvA3nlz2/XkBr++rKrIyf1AeFh/zlWEx3kOqV+4ywWwQ174+vM6os2WFamjmGiBeP7eNqcTSLaurrnEW1H0PzVb29Pe65T3yiz0Bo9+TrhngBGR+FMjqM6hz8ZYgHtEhbGdXn2P5uTj0IaIzuTBPI99qUJXKxAfjz6p54oldxIDk/s2w== 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=WjKDUlgSHupZLfeBdCvKmL1J1ztmUnESVaWWW5Xavb4=; b=tn1PUNsxE9arr8oSQliHxyQ80Q0iEYIWzyh127rO4kpoSUBgcm93HHfE5We3CMa4rrHf0wywYlOST6NzY8vpcu7Wiytmzv7Wzah2bAYs9mxsVl3NgX8ZWe8s5P2TjMXRJtMGRJnYnRioM8VSSNFEI0BQX21GqsAnRseTsGsXV6HD4bMHYnVDYjWhHQl7R1GUBezg7KKVec9thj5LdXX2nlyfVYZv/asn27mykqYd8sfc4+M+i5jZ9CikO8eugZZtdSScMpTbirm3VxL2cKdZf6JxX/w1SuzRJWikVQIqDD3qUI7idsBWSZQx0c1jcuO+g2925UX21XgNJxVt38cqsQ== Received: from CH3PR84MB3424.NAMPRD84.PROD.OUTLOOK.COM (2603:10b6:610:1c4::17) by PH7PR84MB1485.NAMPRD84.PROD.OUTLOOK.COM (2603:10b6:510:150::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7698.29; Mon, 24 Jun 2024 12:09:57 +0000 Received: from CH3PR84MB3424.NAMPRD84.PROD.OUTLOOK.COM ([fe80::5c77:7a58:48ed:9aef]) by CH3PR84MB3424.NAMPRD84.PROD.OUTLOOK.COM ([fe80::5c77:7a58:48ed:9aef%3]) with mapi id 15.20.7698.025; Mon, 24 Jun 2024 12:09:57 +0000 From: Morgan Smith To: Ihor Radchenko Cc: emacs-orgmode@gnu.org, Sanel Zukan Subject: Parse malformed clocklines (was: Re: [PATCH] lisp/org-clock.el (org-clock-sum): Rewrite regex using rx) In-Reply-To: <87h6do7zj6.fsf@localhost> (Ihor Radchenko's message of "Thu, 20 Jun 2024 09:07:41 +0000") References: <87r0f9b9n2.fsf@localhost> <87frvpyzrf.fsf@localhost> <875xu6aee8.fsf@localhost> <87bk3x9bpv.fsf@localhost> <87h6do7zj6.fsf@localhost> X-Hashcash: 1:20:240624:emacs-orgmode@gnu.org::4aFfMuwwjODXNTsX:mXm X-Hashcash: 1:20:240624:yantar92@posteo.net::7ENpgOY5Qso0Zot0:5bsn X-Hashcash: 1:20:240624:sanelz@gmail.com::Tz5xfsclhZrhdlTH:Ll54 Date: Mon, 24 Jun 2024 08:09:44 -0400 Message-ID: User-Agent: Gnus/5.13 (Gnus v5.13) Content-Type: multipart/mixed; boundary="=-=-=" X-TMN: [ZSzdk7/v76ENmuLZCUcjlnQq2iVFHRWV] X-ClientProxiedBy: YT1PR01CA0064.CANPRD01.PROD.OUTLOOK.COM (2603:10b6:b01:2e::33) To CH3PR84MB3424.NAMPRD84.PROD.OUTLOOK.COM (2603:10b6:610:1c4::17) X-Microsoft-Original-Message-ID: <87h6diee47.fsf_-_@outlook.com> MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CH3PR84MB3424:EE_|PH7PR84MB1485:EE_ X-MS-Office365-Filtering-Correlation-Id: adc4d436-ef54-4d69-3e48-08dc94469015 X-Microsoft-Antispam: BCL:0; ARA:14566002|6092099009|461199025|440099025|3412199022; X-Microsoft-Antispam-Message-Info: TBWASkgTQ21escEvOYvNwiaVNmjMA3peXg7LP6K0x0fpM3jyDj80uue/wiDpb3bOIxpnkcUEe32ahIfF0lVV8JfuGgplZlliyTGuey1jv8wc0UZ3PUok4CTQwQB94yRwPHRHM8mU4FrXD3sYh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69mwBYBecgdmEcpcf9NnF2L8bj3KkIK3T?= =?us-ascii?Q?zcNFwhkfqgjq0xV07EmJrv4JgzDSazkjaeO5+rIGQ3eJDVrGE0YHL3U3kckX?= =?us-ascii?Q?mmkM/DeKwiNk5llCEIk1Y0rZls4Mj1DGfQ7i2OPpmcLkKAyodCsgmATHnIL5?= =?us-ascii?Q?pfRRTznTUpYuk4QWHsTaaxLTCo4B2bcJg72tKltCfpXHr2leIw22d4OXpmFO?= =?us-ascii?Q?89mufgYNegN57BwETPPTIlFsUuSRfvbcal9svz85AVHljf1iz+78kqT4HOIF?= =?us-ascii?Q?a5jMfTzAj1NEhZ3Ow4kOJ8bSVzqGjFkuB9PumwNN7vcpLLGtzD8OUIkgqhya?= =?us-ascii?Q?pKaN8yMau3CUcssOVp2uJwU/NEmFrabpsr1QgQASEMwwR6oudu/qMAyGM14O?= =?us-ascii?Q?N4wefyJfjybIgtdOtCPXzmN1tynRzAp1EkyZ5MYDsVuCeDfn7h6fHD2DEUFc?= =?us-ascii?Q?69Bf1sfkdSsFlkoP6iPjnLiuCQEVOriWOannY5HzKrgQAMd9BTkyYsh7xnBW?= =?us-ascii?Q?ARkR1ASdca1Slgwfy90gaIGYeN30COZnBQHJhm7H64QXfsPiz0OrpIQ1dxl+?= =?us-ascii?Q?Jvd6RpF6GDSugrmccfPWUUk5GumjX/NzckDwRFtCzgCBGpOPYICuOyXcBnPf?= =?us-ascii?Q?UkRSjO4U8pbUclTQiFeVZpCnw/uwFxzBab/kjMV3T8ymUNVaFrW3KAu6u0go?= =?us-ascii?Q?AarlNy7h0PB3BCEhB550eooih9XYji+/qdZMRK96UUqvYVJrVVGOGZBPQLlJ?= =?us-ascii?Q?0YhMJHZFqTyQWeiRhGWmsR3Wk1uONs26NqDx50URZU/d4S8q/crU4Vv2AnGL?= =?us-ascii?Q?heGBrzU900jgrlLO6hJEIFrmgSf/iNKy6+ldANow0bsFidu1i64uZczaZVee?= =?us-ascii?Q?2owMxia0s3fDnEo4dQBq?= X-OriginatorOrg: outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: adc4d436-ef54-4d69-3e48-08dc94469015 X-MS-Exchange-CrossTenant-AuthSource: CH3PR84MB3424.NAMPRD84.PROD.OUTLOOK.COM X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 24 Jun 2024 12:09:56.9200 (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: PH7PR84MB1485 Received-SPF: pass client-ip=2a01:111:f403:2c14::80d; envelope-from=morgan.j.smith@outlook.com; helo=NAM11-BN8-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-Country: US X-Migadu-Flow: FLOW_IN X-Spam-Score: -10.91 X-Migadu-Queue-Id: 6609D73CB2 X-Migadu-Scanner: mx10.migadu.com X-Migadu-Spam-Score: -10.91 X-TUID: ZDkTFRixT2iX --=-=-= Content-Type: text/plain Ihor Radchenko writes: > Morgan Smith writes: > >>> That's expected. >>> We have the following _syntax_ description for clock lines: >>> >>> https://orgmode.org/worg/org-syntax.html#Clocks...>> clock: INACTIVE-TIMESTAMP-RANGE DURATION >> ... >> My specific issue is that the ":*-end" stuff can be set when the >> "*-start" stuff is not. >> ... >> CLOCK: [2023-11-15 Wed 15rr:26]--[2023-11-15 Wed 16:12] => 0:46 >> calculated time: 58320.0 >> ... >> What this shows is that an invalid end will cause the entry to be >> ignored, but an invalid start will not. > > Yup. Everything makes sense, but only within syntax spec. Actual code > that handles such clock lines is another story. > > Warning is important because a number of people use clock functionality > for billing - miscalculating clock sums can literally affect people's > income :) > > I think that the best course of action when a problematic timestamp > without opening/closing time is encountered is: > > 1. Warn user > 2. Still calculate the duration, assuming 0s in time (simply because > previous versions of Org mode did it) > > (2) is kind of debatable, but I can imagine some users might make use of > > such feature by putting clocks by hand: > CLOCK: [2023-11-15 Wed]--[2023-11-16 Thu] => 24:00 > > These users may then simply suppress the warning. I'm very tempted to just make it hard rule that clocklines need to be fully specified. If you take a look at the attached patch, it shows one way we could do this. First, I modify the timestamp parser so the ":*-end" variables don't always inherit the ":*-start" variables. They can be nil independent of the start. Then in the clockline parser I ensure that every single field is set. If it isn't, then I set the timestamp to nil so it won't be used. This preserves the flexibility you want in timestamp parsing while also catching many malformed clocklines. Let me know what you think of this approach. Also a couple questions about this approach: 1. Will changing the timestamp parser have far-reaching implications? Is this something I should avoid? 2. Is there a way to give user errors in the parser code? I'm using `org-element--cache-warn' in my patch but I'm not sure that's the right thing to do. (if it is the right thing then we need to define it earlier in the file) --=-=-= Content-Type: text/x-patch Content-Disposition: attachment; filename=0001-Warn-about-invalid-clock-lines.patch >From 82231fb4b11b780488c66b4e5f0ee6fcf6643f1d Mon Sep 17 00:00:00 2001 From: Morgan Smith Date: Wed, 19 Jun 2024 13:41:50 -0400 Subject: [PATCH] Warn about invalid clock lines --- lisp/org-element.el | 32 +++++++++++++++++++++++++------- 1 file changed, 25 insertions(+), 7 deletions(-) diff --git a/lisp/org-element.el b/lisp/org-element.el index d6ad9824a..113cd6059 100644 --- a/lisp/org-element.el +++ b/lisp/org-element.el @@ -2312,6 +2312,25 @@ Return a new syntax node of `clock' type containing `:status', (unless (bolp) (skip-chars-forward " \t")) (count-lines before-blank (point)))) (end (point))) + (when (and value ;; Clock lines don't need timestamps + (or + (not + (and (org-element-property :year-start value) + (org-element-property :month-start value) + (org-element-property :day-start value) + (org-element-property :hour-start value) + (org-element-property :minute-start value))) + (and (eq status 'closed) + (not (and (org-element-property :year-end value) + (org-element-property :month-end value) + (org-element-property :day-end value) + (org-element-property :hour-end value) + (org-element-property :minute-end value)))))) + (setq value nil) + (org-element--cache-warn "Invalid clock element at %s:%d: \"%s\"" + (buffer-name) + (line-number-at-pos begin t) + (buffer-substring-no-properties begin end))) (org-element-create 'clock (list :status status @@ -4393,15 +4412,14 @@ Assume point is at the beginning of the timestamp." hour-start (nth 2 date) minute-start (nth 1 date)))) ;; Compute date-end. It can be provided directly in timestamp, - ;; or extracted from time range. Otherwise, it defaults to the - ;; same values as date-start. + ;; or extracted from time range. (unless diaryp (let ((date (and date-end (org-parse-time-string date-end t)))) - (setq year-end (or (nth 5 date) year-start) - month-end (or (nth 4 date) month-start) - day-end (or (nth 3 date) day-start) - hour-end (or (nth 2 date) (car time-range) hour-start) - minute-end (or (nth 1 date) (cdr time-range) minute-start)))) + (setq year-end (or (nth 5 date) (and time-range year-start)) + month-end (or (nth 4 date) (and time-range month-start)) + day-end (or (nth 3 date) (and time-range day-start)) + hour-end (or (nth 2 date) (car time-range)) + minute-end (or (nth 1 date) (cdr time-range))))) ;; Diary timestamp with time. (when (and diaryp (string-match "\\([012]?[0-9]\\):\\([0-5][0-9]\\)\\(-\\([012]?[0-9]\\):\\([0-5][0-9]\\)\\)?" date-start)) -- 2.45.1 --=-=-=--