From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp1.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 QFr5AmQdGGY9zAAA62LTzQ:P1 (envelope-from ) for ; Thu, 11 Apr 2024 19:27:00 +0200 Received: from aspmx1.migadu.com ([2001:41d0:303:e224::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp1.migadu.com with LMTPS id QFr5AmQdGGY9zAAA62LTzQ (envelope-from ) for ; Thu, 11 Apr 2024 19:27:00 +0200 X-Envelope-To: larch@yhetil.org Authentication-Results: aspmx1.migadu.com; dkim=pass header.d=outlook.com header.s=selector1 header.b=QnOWn3Id; 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=1712856419; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:mime-version:mime-version: content-type:content-type:list-id:list-help:list-unsubscribe: list-subscribe:list-post:dkim-signature; bh=8yiVNB0Mgm4WKACV3C1AsHLesEjB80Jkcrgr8gfaMGs=; b=H4Gjvne0nhq1Tg6zEbRny0LCxMX+3P/ntSxgaGa2a2s4VC7BCweRK92jk97FAbiTyZCC5J tQKPaGsx0L/54+Wlbe6KpVFHaZ41HGIn5gB8ayF5coA3fy4SWJt94SNT2HuiyFsXyfiqn8 ILLXOKOkjQKTHCXf5UkF+bkhwzSL1OhC3hh+f2eoqw82/JAYClEm2LvVvsquSWydpc1NH2 geiC/Xhyjrv8qheQN9or1O01QA4SMbUB8myGAGFgJgSdmiKoqfCKx11vUCeUfoPXoxr4tl dXQvOd8bGmPo/2diOlg9pvqKJKWwlYAFaGkMjd5y6vaaBhHkXYLb49mD4j6YZw== ARC-Seal: i=2; s=key1; d=yhetil.org; t=1712856419; a=rsa-sha256; cv=pass; b=U/dkFUIX2I/kaLmOujAzvsxWaKxUyX0y2GAOn/a0Oty9K5pASRASJjktPLlW5vYr5Je3cl JZvi54/xcABl8aaYmkj8hLrB63aT/5ssCi0gA8KXyBeREya09Inm4FbGtktjcyoMEcPDpR u1fk2lZs77SLeqHrXSK30rPcsLApi/AZZYs9LTEiakbs18OJKUvdIuZLm8jNzUP/GLa6XR fy9IJei6GMe1xj3+MgdbQH5P3hulalpH+CR0VRH1qRRp7Q0+Ky6ac5Z9IpSpWgI30HQpcJ EQYIbcgaHcvPD5MuAJYXES3Cy2XGb0P9Oq0NVxnR6fwqnGRgM2GzMH5g119sGA== ARC-Authentication-Results: i=2; aspmx1.migadu.com; dkim=pass header.d=outlook.com header.s=selector1 header.b=QnOWn3Id; 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 AD4276343D for ; Thu, 11 Apr 2024 19:26:59 +0200 (CEST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ruyBZ-0001Vh-6L; Thu, 11 Apr 2024 13:26:05 -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 1ruyBX-0001VW-GX for emacs-orgmode@gnu.org; Thu, 11 Apr 2024 13:26:03 -0400 Received: from mail-co1nam11olkn20800.outbound.protection.outlook.com ([2a01:111:f403:2c16::800] helo=NAM11-CO1-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 1ruyBU-0006Ty-75 for emacs-orgmode@gnu.org; Thu, 11 Apr 2024 13:26:02 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=i+Lnhn+W105O+CFoUg6jr9Gv4lCFzxijKdKVx4TDJPQEikggFj7UgBHIoTFrT/PeSQWZRgHxFNEOIBljU/w12dID6hnF6hfroqg8WWigei9pNAmR/WC8jtMYGLfpWF1HOGg2HdYuwPNmbcYGTlcJKH9Ykb4yHQ+KUMyEQtk9gZAfp3BZkbuWv7H04JM1c3WnII04h4Dp61qICRREyYtnfvNp81bPhX+SguR6WQ5I32A5D/maL/JGogPGGyo7I8+XvOTvN5CTZwKy/eZWZobFiEhOlhnkd5s94TdoEXVrMOUCVdjuUe0bAEgyZxQH2keRB8ReYnbU3wR+Nyq0VEnr9A== 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=8yiVNB0Mgm4WKACV3C1AsHLesEjB80Jkcrgr8gfaMGs=; b=PKDRloZyPPppQ+PMky/hDN2ZrL/MJmE9NXIx9piRP0QVAzhQ0NzBHzN/rc84eMGRmlDzsTOs3XD0ySNF+ylcrH8V6BLjFvCUkWQ+0LiTsHBdJ9Xm9M8IVf4T7oZCAAxP4JSu4mLaVI1yJd61UnV0+ZKx5UcG/qUxiWivw8ZX7JDCAkiG/x2Kym6+uy6EGsba8up9gZRGxbSqZMrWMKHmr0us9dp5hjLGUZm1iZCJ2l4EqJ7UT4w6FTqlabOLlbYgQJXJrwpDoYGhqmuuRrOUo7tuSM1MVfWjM+FDRyx2dY37qQjx8bGO5k75KuNIBs0nfuZi1/sXPBeBApWE/fYo0A== 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=8yiVNB0Mgm4WKACV3C1AsHLesEjB80Jkcrgr8gfaMGs=; b=QnOWn3IdvefxKYTpsBU6MKaDm6o/x/3QrEObsg01RwgLgK+Tc+Z15BX/mLTuTFVCZ0UpBh6745vM/aNXoc7/JXW93XawEOsHZdnYWwGZu1mBQDPVFyt/DEYSKgldhbwzSK9RDZ86tllxu6x3pV9fAlWiXHQrSxtgYWhVa7rDRuaX1a0by6lioF6CxqtXWoyUHm0pkmWdP43XUa0D278iIaV88TE/EDLuFF47M07hZEN2J90WYRKZ/XR3HMXjcUEVmGFSoI3GUMZrXBMTe+7Er9hshat9qeUh/PLqHXpsG/weaAy6A8kJLteyi/YGnAzoK/eoDL2/W8Rbgv2KYCOmJA== Received: from CH3PR84MB3424.NAMPRD84.PROD.OUTLOOK.COM (2603:10b6:610:1c4::17) by LV8PR84MB3966.NAMPRD84.PROD.OUTLOOK.COM (2603:10b6:408:227::10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7452.26; Thu, 11 Apr 2024 17:20:53 +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, 11 Apr 2024 17:20:52 +0000 From: Morgan Smith To: emacs-orgmode@gnu.org Subject: [PATCH] lisp/org-clock.el (org-clock-sum): Rewrite regex using rx X-Hashcash: 1:20:240411:emacs-orgmode@gnu.org::GOIVbDaFvwHQ0314:7+Jr Date: Thu, 11 Apr 2024 13:20:49 -0400 Message-ID: User-Agent: Gnus/5.13 (Gnus v5.13) Content-Type: multipart/mixed; boundary="=-=-=" X-TMN: [uzQu+K0MEmZIAL59jJ+OL/eMS4sMcIvS] X-ClientProxiedBy: YQXPR0101CA0043.CANPRD01.PROD.OUTLOOK.COM (2603:10b6:c00:14::20) To CH3PR84MB3424.NAMPRD84.PROD.OUTLOOK.COM (2603:10b6:610:1c4::17) X-Microsoft-Original-Message-ID: <8734rrn7da.fsf@outlook.com> MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CH3PR84MB3424:EE_|LV8PR84MB3966:EE_ X-MS-Office365-Filtering-Correlation-Id: 1dd3874e-95fb-4938-50f4-08dc5a4bbd49 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: oUjO/wUEY8bP6pSrL18o1FaU6PS3Q6m4bCSZ7LbS0tcSQJdZAs3daMHnILM0w7S3NgODOOSlnY9D0C0So+YHs9+O2RS4m7ETY9KhFsjMbZsuvhRdtBB/Hza/84rqa6QmCotYMDXAfACQPw3QXm6X1uabVKRKpALt4dCkT6OO9mvoiGWUtCbvpBKiWQIhDgaEWGgfkpmE/pN0blPEEtiMG+uB6EgHdUG9yrVfhNHH207AwxWaSHV6RcTR1nIJJeHcIqIwOi65W1jqHcPIi7mhrL9pwc7MaZH5ngR/0/I90qwNktmPuq2LVUB8RwRH55leoxJAlr2P5D0x5IGbFT5HxyV/OxcGQXwzPY6Hd3C9tX0UKqlvZtVSDKRUTr3ddpAuSC9qO5CIK6UdgWaNs3cjuacCHM/A4UGqhXOYVuLu/Rdq7q9o7T88LMzpbliNQxrZ75BTGyhHCmz+hqwy4mdt92QF9QbMi8u/XOvOt/HUa8yq9noHMuNu/JPTdL3PyUAG4NcwA01emryaW4Vbyy5vO5ZQOanpOMoY7dMnAld02Ju0k/jCrs3FiVew5TXO/GrYA28O3XTtsEiSs6qiTxaxs9xAF2gVTBo3YvjRZqoa4g9eIh8s1u5AjRucYS9QZ6pn X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?us-ascii?Q?LCYFcbRSU+91ljSroIx7h1r0ktq4z4dBjlQqI0KhkCC58f8oskboiuFIoOYa?= =?us-ascii?Q?ueVXrXuO5qq5jKRNnUylnBwwNFJMeUtTHIh4idPN7vWtaFTdtFF24PhnYKKi?= =?us-ascii?Q?S5By3D12zt6O+m0eWDQq6jRyARCnj2yirUEehlE0n8uaPooB/4UVUZLOB8vg?= =?us-ascii?Q?0ecEExaHDpb55LKxEiX1EVO/VKo0/VgRg4PE0hSFsTtkSyY6uwFk6VuMjfNy?= =?us-ascii?Q?vZarADLt2T2n8tGQxZdYH3FggD/Ie9F03H6GcrKARjRCIcT0G/f8Tn53abyd?= =?us-ascii?Q?rNNjL/CIUSRseiSd033qeEt1EE3bzWtHU2/11uL4NiYt6FVgK2QiiDkCGdjV?= =?us-ascii?Q?Ch9ukOyuavRj+nXnbDZNSd/QRSwDWkq0H+1lrt3KHsTeRZOAh9FNsSj9EBjO?= =?us-ascii?Q?LYg0yZBuTcvC4FrpJV0/Q59k+B0pyErzl44K7DvkHxz8VJYodJZH1GIJhYWf?= =?us-ascii?Q?v4uDyHm4lfsEdFFN6ALTql1qjgW/2FxIUNtctw7ENlV0HrE5hED1Q3dwUHgf?= =?us-ascii?Q?O3ts44sJG+phMWuu838abyGzICiKzKrP55dZHmrn/dmmwfyrvAflbl0bHvAH?= =?us-ascii?Q?i/Do/qtjAd2oYYTpTOXGFJnXxi55RWFu4fXDQaexuSVMnh4At0kXybz5bsG1?= =?us-ascii?Q?QU6ujKBqUVG8hOM21z6MWSzwskQfhXDp+ps20vkioGzNvTtQvkAl3qN0qOlW?= =?us-ascii?Q?U/by266R/XXf0NsdHSAZWTa7MfLSdZhNXxOlPK6IS9IhHFrl5Dr3geMKguL1?= =?us-ascii?Q?Vu0LiO123SDMod4DSvk3qhJ3LuOs9AsMYwnArFATrSQabT8qbH3N4PknYt2/?= =?us-ascii?Q?1ONqwOq1sSuyk6FVvVlFA1MUIdu8rk2OlBg7UPNi5jv/cJhl3zwADaPRXTuN?= =?us-ascii?Q?nsXm86xDsC+e+8OsTCwReNvyVMplydZcS3eu0xtDa5A1RhBSB3ZlcPweYVSn?= =?us-ascii?Q?AnT/1jVs2TxP4hFGddKJITR/7ZTzaE5OaA3pc5Q/iAXuwM5iOqOJwbSDybbi?= =?us-ascii?Q?uqU9QnmBIW2s9caja4laoGU0NwO4Aj9yDiFA6M+WLEMGEz0QDKx5PdfHwqXr?= =?us-ascii?Q?UfU56ynlsspT9bZk1rO+TQAE/Nii9CPZkXWTkYkdr4aC0UanGWYRgsoXLhMC?= =?us-ascii?Q?pUnQIDjmcMHZ/chm/2fATi/hDuPebjwdMxk1ywXgklTYuYKODcuCabYCEime?= =?us-ascii?Q?mVttGUsRRnSYn8S7UPObgicu0ND8Lvp4uN883yBX/o9ZItcws80YqYAVdAmE?= =?us-ascii?Q?9svki8Vvr77dlE49VS9K?= X-OriginatorOrg: outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: 1dd3874e-95fb-4938-50f4-08dc5a4bbd49 X-MS-Exchange-CrossTenant-AuthSource: CH3PR84MB3424.NAMPRD84.PROD.OUTLOOK.COM X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 11 Apr 2024 17:20:52.6660 (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: LV8PR84MB3966 Received-SPF: pass client-ip=2a01:111:f403:2c16::800; envelope-from=Morgan.J.Smith@outlook.com; helo=NAM11-CO1-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-Migadu-Spam-Score: -9.72 X-Spam-Score: -9.72 X-Migadu-Queue-Id: AD4276343D X-Migadu-Scanner: mx12.migadu.com X-TUID: AkGTtbSZWdIj --=-=-= Content-Type: text/plain Hello! See two attached patches. All tests pass on my computer. Every once in a while I feel obligated to go back to org-clock-sum to try and optimize it. I have a file with 8 clocktables in it and it takes forever to update. This time I decided instead of trying to optimize, I'm just going to try and understand. The regex has been altered slightly. 1. Instead of using "[ \t]", I decided to use [[:blank:]]. No real reason. I just think it's easier to read and maybe slightly more correct? 2. For the timestamps, instead of ".*?" (using a non-greedy ".*") I decided to use "[^]]*" (accept everything except "]"). I did this simply because I'm not used to using non-greedy regex's. Maybe this way performs better? I didn't test that. 3. I used the variable `org-outline-regexp' but that doesn't actually change the regex. --=-=-= Content-Type: text/x-patch Content-Disposition: attachment; filename=0001-lisp-org-clock.el-org-clock-sum-Rewrite-regex-using-.patch >From 3c3d7abed25cafb2be1096ca079a0e8be907c644 Mon Sep 17 00:00:00 2001 From: Morgan Smith Date: Thu, 11 Apr 2024 12:23:21 -0400 Subject: [PATCH 1/2] lisp/org-clock.el (org-clock-sum): Rewrite regex using rx --- lisp/org-clock.el | 20 +++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) diff --git a/lisp/org-clock.el b/lisp/org-clock.el index 65a54579a..5ef987ab8 100644 --- a/lisp/org-clock.el +++ b/lisp/org-clock.el @@ -2008,9 +2008,23 @@ each headline in the time range with point at the headline. Headlines for which HEADLINE-FILTER returns nil are excluded from the clock summation. PROPNAME lets you set a custom text property instead of :org-clock-minutes." (with-silent-modifications - (let* ((re (concat "^\\(\\*+\\)[ \t]\\|^[ \t]*" - org-clock-string - "[ \t]*\\(?:\\(\\[.*?\\]\\)-+\\(\\[.*?\\]\\)\\|=>[ \t]+\\([0-9]+\\):\\([0-9]+\\)\\)")) + (let* ((re (rx line-start + (or + (group (regexp org-outline-regexp)) + (seq (* blank) + (literal org-clock-string) + (* blank) + (or + (seq + (group "[" (* (not "]")) "]") + (+ "-") + (group "[" (* (not "]")) "]")) + (seq + "=>" + (+ blank) + (group (+ digit)) + ":" + (group (+ digit)))))))) (lmax 30) (ltimes (make-vector lmax 0)) (level 0) -- 2.41.0 --=-=-= Content-Type: text/x-patch Content-Disposition: attachment; filename=0002-Test-clock-times-without-timestamps.patch >From e5298920568e4c5a34589640f11edfa09a98d0d1 Mon Sep 17 00:00:00 2001 From: Morgan Smith Date: Thu, 11 Apr 2024 12:51:18 -0400 Subject: [PATCH 2/2] Test clock times without timestamps * testing/lisp/test-org-clock.el (test-org-clock/clocktable/insert): Add a clock time that does not include timestamps. --- testing/lisp/test-org-clock.el | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/testing/lisp/test-org-clock.el b/testing/lisp/test-org-clock.el index 44c62e7bc..be8acb529 100644 --- a/testing/lisp/test-org-clock.el +++ b/testing/lisp/test-org-clock.el @@ -345,13 +345,12 @@ CLOCK: [2022-11-03 %s 06:00]--[2022-11-03 %s 06:01] => 0:01 (equal "| Headline | Time | |--------------+--------| -| *Total time* | *1:00* | +| *Total time* | *2:00* | |--------------+--------| -| H1 | 1:00 |" +| H1 | 2:00 |" (org-test-with-temp-text "* H1\n" - (insert (org-test-clock-create-clock ". 1:00" ". 2:00")) - - (goto-line 2) + (insert (org-test-clock-create-clock ". 1:00" ". 2:00") + "CLOCK: => 1:00\n") (require 'org-clock) (org-dynamic-block-insert-dblock "clocktable") -- 2.41.0 --=-=-=--