From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp10.migadu.com ([2001:41d0:306:2d92::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms9.migadu.com with LMTPS id FysuCxJZuGShTwAASxT56A (envelope-from ) for ; Wed, 19 Jul 2023 23:43:46 +0200 Received: from aspmx1.migadu.com ([2001:41d0:306:2d92::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp10.migadu.com with LMTPS id 0J6WCRJZuGQdOAEAG6o9tA (envelope-from ) for ; Wed, 19 Jul 2023 23:43:46 +0200 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 BD46A33F9B for ; Wed, 19 Jul 2023 23:43:44 +0200 (CEST) Authentication-Results: aspmx1.migadu.com; dkim=pass header.d=outlook.com header.s=selector1 header.b=QPwcv6gN; 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=1689803025; 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: content-transfer-encoding:content-transfer-encoding:list-id:list-help: list-unsubscribe:list-subscribe:list-post:dkim-signature; bh=czLs/ak5CA/AF3LMvjwQuOpK0Oul3oOt4z2hSPP9ELs=; b=RfrUt5D+yHgijJFUTtUUcJXbAwogCt+xfolh/MWPfSJhwmhp7g76cGG/mbB9Z6clgJQ9wW i+WgkAqTTSmE58Kdl8p7dOxAgCRcYQWUGMjxHP7f9aA3VMyecw+M5wD7l9S8VvliACUCwm /wyvbfuKzpDOZ8IczUPvHbKusLsPsOT+QLsT0xmES4kcg0LkA2yIiSffGi/FpdbJZJfDVf VwMgbeQaQd31axX1DWGPRjLQ2iWk6WkYuKwNvAa06AK7TruIRzTz2jcdCKxJkHAvyM4HHn z0oD95DRm7dfm03qUxd/Dk7oTIXteddT+u02LIfQyPMRXdlUHoNBhi9ezRE01A== ARC-Seal: i=2; s=key1; d=yhetil.org; t=1689803025; a=rsa-sha256; cv=pass; b=jPPDZWl7k9XwKHqHf6u85cDSUSUtvRNNE2fqohE3hk+QEfNMW8v29VBy+Bn7W12BjJK6Ul JpYn8FZp9Td7iSXksCbq1hFXSVRVmeKa/yO5xJr5Cv3xZ6p3O3YXrs0XqosjbRZ9h7AQj4 WlYTwvkd1R7RiR2VOhKIwR3rxLj7mHhyG/UQOFa4S5/TovpDPgTTh7ZUWNArtWqVBJzuaJ WZR2CuCzvezyA/To57m1N1YKY8gM75iMNLbnKchd5CuA7hbdukoM1GIeXC5wnH9l1K8khI lfwEiY46/1guvDe3RBAXzBGlWt/UFirICJ1EvZ0RMewscHqBB5hN9siVAr92kg== ARC-Authentication-Results: i=2; aspmx1.migadu.com; dkim=pass header.d=outlook.com header.s=selector1 header.b=QPwcv6gN; 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 localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qMEwd-0002He-6b; Wed, 19 Jul 2023 17:42:51 -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 1qMEwb-0002HT-K3 for emacs-orgmode@gnu.org; Wed, 19 Jul 2023 17:42:49 -0400 Received: from mail-dm6nam10olkn2081f.outbound.protection.outlook.com ([2a01:111:f400:7e88::81f] helo=NAM10-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 1qMEwZ-0008EA-HK for emacs-orgmode@gnu.org; Wed, 19 Jul 2023 17:42:49 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=bTgiA3msPq/YMhad6AfB/0BaDbfuSM4kx6X/Yb83qZGs3rk7yY614xkRAONfNvxmNMT1buLnx2PNsHLzAlCi1fGlFFTcbZCmjbrAtTbNhlWCh+bglZzEfWrKSnikeTzVM3/Iqc0Zp4Ytru5wXDX4Nx/GnszT7X1PsfezQzX+On50wmu9ZvNZE7yj/mFFZjKb/Ea71LGqWu4ndxiKby7p417JcpGxZ4bSPL/lHNoSzZ8r+ZwDjGlSq5EbONIioNABbhA4Ks8UxfJyUHT/PbWIF8Pg2LlovOMjC7B39AjqR3ZBkZqx4oSLJH06WoEfH4XQvV0HstdbCYIDP1acQsEECA== 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=czLs/ak5CA/AF3LMvjwQuOpK0Oul3oOt4z2hSPP9ELs=; b=IRy2YTAGKD5vZBHEgBaZ3sAAsw8KSNdUsISVbHiAOVwW/l3kSBbn/mwZaEwrZWukjmyTggtTCUgXxp7QZk5QbL/124Lf0h9rs7HLIb91HutkbDGLnY53AGLGUzH+jFQhcv2WTktX64LBltA07ZpFOzYzZzhp9ITeM/ZdsFlVNMUEYgudOWDgTYPPEo87OlDPDF32qolCZwodYiXKSA5UPpQZRvPUFY5x9Qpi3O1cR26FlJ1kOXBGAPRFMtWx0eFwab9ZQtgsIsShSLAU+elN7OkLsAgAP4CZ1i+obOdjmVY7xf38hP1hnKshXmiEtimqz1yxl7E1d/Xg6X5dORak5Q== 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=czLs/ak5CA/AF3LMvjwQuOpK0Oul3oOt4z2hSPP9ELs=; b=QPwcv6gNCPAtBiT2m2Y287RC8MnPG6vmFFvoVLOU4kZ9NMf1EJyTBpydji24kGJDCsGSVUS/4EMGZfWzLDc0r549gNGVSPf7rHzBg8itX1GC8ZTE0axF2PdX7gmXJ9da4Q7PoMh5dARgx8+38IjROxOBjDQU0WctNLe5Nq6qi76k4Opi6zeOFMujpTPLM+S6otzGz0kgqYVZDmIU0CKxyyztDnaZgYvot2OLmAhgmwGb8J3cbKW8OICXSZ5aMp3MbzbAi5iKajGzE9twE/Qj9gwS3Fm+D6DbM3p2hbE7aXRnJMi8+G4N3/UJ+Kx7XEl9dGk+KLjyeB/LegKOcRMZoA== Received: from DM5PR03MB3163.namprd03.prod.outlook.com (2603:10b6:4:40::24) by BL1PR03MB6166.namprd03.prod.outlook.com (2603:10b6:208:31e::9) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6609.23; Wed, 19 Jul 2023 21:37:41 +0000 Received: from DM5PR03MB3163.namprd03.prod.outlook.com ([fe80::b2fc:59fe:bb07:4d95]) by DM5PR03MB3163.namprd03.prod.outlook.com ([fe80::b2fc:59fe:bb07:4d95%4]) with mapi id 15.20.6609.024; Wed, 19 Jul 2023 21:37:41 +0000 From: Morgan Smith To: emacs-orgmode@gnu.org Subject: [PATCH] org-clock-sum: Rewrite function to improve performance Date: Wed, 19 Jul 2023 17:35:40 -0400 Message-ID: X-Mailer: git-send-email 2.41.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain X-TMN: [tPT2yu6414aKg0+fze0Xk4E/e036+CpG] X-ClientProxiedBy: YT4PR01CA0094.CANPRD01.PROD.OUTLOOK.COM (2603:10b6:b01:ff::8) To DM5PR03MB3163.namprd03.prod.outlook.com (2603:10b6:4:40::24) X-Microsoft-Original-Message-ID: <20230719213539.20414-2-Morgan.J.Smith@outlook.com> MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DM5PR03MB3163:EE_|BL1PR03MB6166:EE_ X-MS-Office365-Filtering-Correlation-Id: 75a15621-34d2-43ed-f229-08db88a0617a X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: g5fhhkwhQ28qmLM8+l23BAZ/zkwL6zjF7ar5Kfa4GDSzrIkUX7mj1Sq0DWPa4EGlNwSzsrJhFq+lXN4Dw072qK/OLHwKQRQpMv7tQXnw6xv2ena3r7925PZVlL+xXnCFssVo+96KpJchO0I1WxDGyKeG5NaIQIPZpFJL1eoPtqUsx9SUgP0cBB/s1JF2s7UB32IUjUiwKCI+o2tlUbCE8tULRUJlISbqQ4C2aU7r/xgkQRfKlv8ZQDub2osbc1sMukrh48HYter1RxX/aR3QQEHJKIgJ6S8d5LxJQcVvvbF+efpQw6plHzF2Qyx5W/pfrXGI83ttOPsSSTU587bIEptIERcCiX7TDREtstTgNoOdCdy8q80gNWS7chh784jFMDn6oNulwIxyicsj8wtjkBGkvxLtKyAFxMVuq/QFCB5wpp4/X1DfloRsvCtcVtw8eVogrbJXyAe1RTLKzHyazM/L4r3bKEvjaH4CEV/QTz1YFXbnfeUPSHwHF2yQxAFwuH3ZAM3iuE5nVV0JtK/zVF64dEg+xEz/gVI6GWrSAmr1959q6SM59CxVnGZaexon X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?us-ascii?Q?jSU91NseYMlT6X5ok+xAiRwdyAzsoePVyid9Ci1Tx0fbTqf7vV9J4GAWD7JO?= =?us-ascii?Q?2JEMUrTTsZjRK/n6o/Hfje0df3Snq5sUtwFjIJsC+t6lcNCznC+JhYPy0kCi?= =?us-ascii?Q?gw/O2PpmYeeGn5gW4lI/eEmRRp/FUCaQEh32Hn4cc/BfmvkfJGgsRez9XsrD?= =?us-ascii?Q?CvgTGzMjF1GyD+hgf7FR8AUEvNQtrTlzGnHpdePqalNIIw6xZl/CSe1KlX8d?= =?us-ascii?Q?KgDInIjnLO47wkWyLOdVRjmTJ2EazprSvn4Jcku1hP/a5OO0bW48PWpogJXG?= =?us-ascii?Q?ECUnzwdEJYAhavhwf50jAUch5UwzQutrNHQKRd+GZlDDv6NyMO0GjHpMQeRy?= =?us-ascii?Q?Nx35Yl2p3HyL5pkHch+04yL5qPoDnDzplebvbDc3Y1QrU6CCM+qMlhwFHXXf?= =?us-ascii?Q?XbLU/0AQu4MJ2Uqy0kxQYSjgQrlR0tyOU65rPbjpBseGEFGmjwBa+Zu+WUS4?= =?us-ascii?Q?WBka1whqr58GBL2X2zJFiTAK5x+jZPb/NeC8w8is/KriZMWEnNljVpJ+qysq?= =?us-ascii?Q?YLe0FG2q3lU66Ia9MxreC+RVV200OF3fWOD/lKWo9yyWtISgAxCWn3boIlC5?= =?us-ascii?Q?tLeeLPvkxDXHbagq38Hredaz5bHIaoqBbkenZIbGxvq4YD5jjP3oOGDL4r1f?= =?us-ascii?Q?HmtJLE/DgNJtaeT6OVGfdLBfLHVbkGeaJmUVs6VjtgOO3qcwuXQG3AVbLq9o?= =?us-ascii?Q?QF1Xc4A6y/Fb20R6FT1Sb7gkIW4ftvKrlnm1c0f77NKUJVW7ShfFfdiVIwYU?= =?us-ascii?Q?aa4PEym55GMNGMwFjbdNWtN6oiC9jY0tbav+GS9FqxQOTbXEQCjRKtcNCeZi?= =?us-ascii?Q?ITyvay9ZZ/sw2kQbJPHNnRYUQHPVRbqR0wpN9Tcac41O71uYCeNM63IrC878?= =?us-ascii?Q?Tqf/XL1q2oJ5IbQaT0NUnvZIyazHsHT6rEAxUKZxL9+fHSIjTrBhBqTC4HrK?= =?us-ascii?Q?GV5kY9Ck7zzwfKveOnYLyPKQ5l3nmnOemX5098C3ORQfbJhsfq9mFOvF+jpL?= =?us-ascii?Q?L673RDxDS6G3Ts/zn59/P+L0e9VnUXxc0JFYbprKBO7b6ClM21zu4TtoM9rS?= =?us-ascii?Q?sZHNrA9IcNA9Ov/ziWjHa11JgAUNfoWEEYlqo0AaW6lc8KlignQU/neIqR7V?= =?us-ascii?Q?GKLzekoUKlzjXHrFVeBYOnEZ+y3VG1d4IkQg0nSEjhC0DfGYOpSeptllYoRF?= =?us-ascii?Q?KdVvROHmp6+Bps7Ri3lP9wIVa8uXCND61gc3PkNcMgnYVXoFNRrDFf69/PY?= =?us-ascii?Q?=3D?= X-OriginatorOrg: outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: 75a15621-34d2-43ed-f229-08db88a0617a X-MS-Exchange-CrossTenant-AuthSource: DM5PR03MB3163.namprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 19 Jul 2023 21:37:41.8991 (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: BL1PR03MB6166 Received-SPF: pass client-ip=2a01:111:f400:7e88::81f; envelope-from=Morgan.J.Smith@outlook.com; helo=NAM10-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, T_SCC_BODY_TEXT_LINE=-0.01 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-Scanner: mx2.migadu.com X-Migadu-Spam-Score: -8.48 X-Spam-Score: -8.48 X-Migadu-Queue-Id: BD46A33F9B X-TUID: q2bIhAuxEuqA * lisp/org-clock.el(org-clock-sum): Rewrite function using 'org-element-map' to traverse the file instead of searching. --- Hello! I have a very big file with lots of clock entries and refreshing my clocktable has become slow. Using '(benchmark-elapse (org-ctrl-c-ctrl-c))' I saw that it took 5.660532903 seconds to refresh it! After this rewrite it only takes 3.384914703 seconds. Not great, but better. Thanks, Morgan lisp/org-clock.el | 148 +++++++++++++++++----------------------------- 1 file changed, 54 insertions(+), 94 deletions(-) diff --git a/lisp/org-clock.el b/lisp/org-clock.el index 264774032..148af864b 100644 --- a/lisp/org-clock.el +++ b/lisp/org-clock.el @@ -33,15 +33,10 @@ (require 'cl-lib) (require 'org) +(require 'org-element) (declare-function calendar-iso-to-absolute "cal-iso" (date)) (declare-function notifications-notify "notifications" (&rest params)) -(declare-function org-element-property "org-element-ast" (property node)) -(declare-function org-element-contents-end "org-element" (node)) -(declare-function org-element-end "org-element" (node)) -(declare-function org-element-type "org-element-ast" (node &optional anonymous)) -(declare-function org-element-type-p "org-element-ast" (node types)) -(defvar org-element-use-cache) (declare-function org-inlinetask-at-task-p "org-inlinetask" ()) (declare-function org-inlinetask-goto-beginning "org-inlinetask" ()) (declare-function org-inlinetask-goto-end "org-inlinetask" ()) @@ -1948,100 +1943,65 @@ 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]+\\)\\)")) - (lmax 30) - (ltimes (make-vector lmax 0)) - (level 0) - (tstart (cond ((stringp tstart) (org-time-string-to-seconds tstart)) + (let* ((tstart (cond ((stringp tstart) (org-time-string-to-seconds tstart)) ((consp tstart) (float-time tstart)) (t tstart))) (tend (cond ((stringp tend) (org-time-string-to-seconds tend)) ((consp tend) (float-time tend)) (t tend))) - (t1 0) - time) + (file-total 0)) (remove-text-properties (point-min) (point-max) - `(,(or propname :org-clock-minutes) t - :org-clock-force-headline-inclusion t)) - (save-excursion - (goto-char (point-max)) - (while (re-search-backward re nil t) - (let* ((element (save-match-data (org-element-at-point))) - (element-type (org-element-type element))) - (cond - ((and (eq element-type 'clock) (match-end 2)) - ;; Two time stamps. - (let* ((timestamp (org-element-property :value element)) - (ts (float-time - (org-encode-time - (list 0 - (org-element-property :minute-start timestamp) - (org-element-property :hour-start timestamp) - (org-element-property :day-start timestamp) - (org-element-property :month-start timestamp) - (org-element-property :year-start timestamp) - nil -1 nil)))) - (te (float-time - (org-encode-time - (list 0 - (org-element-property :minute-end timestamp) - (org-element-property :hour-end timestamp) - (org-element-property :day-end timestamp) - (org-element-property :month-end timestamp) - (org-element-property :year-end timestamp) - nil -1 nil)))) - (dt (- (if tend (min te tend) te) - (if tstart (max ts tstart) ts)))) - (when (> dt 0) (cl-incf t1 (floor dt 60))))) - ((match-end 4) - ;; A naked time. - (setq t1 (+ t1 (string-to-number (match-string 5)) - (* 60 (string-to-number (match-string 4)))))) - ((memq element-type '(headline inlinetask)) ;A headline - ;; Add the currently clocking item time to the total. - (when (and org-clock-report-include-clocking-task - (eq (org-clocking-buffer) (current-buffer)) - (eq (marker-position org-clock-hd-marker) (point)) - tstart - tend - (>= (float-time org-clock-start-time) tstart) - (<= (float-time org-clock-start-time) tend)) - (let ((time (floor (org-time-convert-to-integer - (time-since org-clock-start-time)) - 60))) - (setq t1 (+ t1 time)))) - (let* ((headline-forced - (get-text-property (point) - :org-clock-force-headline-inclusion)) - (headline-included - (or (null headline-filter) - (save-excursion - (save-match-data (funcall headline-filter)))))) - (setq level (- (match-end 1) (match-beginning 1))) - (when (>= level lmax) - (setq ltimes (vconcat ltimes (make-vector lmax 0)) lmax (* 2 lmax))) - (when (or (> t1 0) (> (aref ltimes level) 0)) - (when (or headline-included headline-forced) - (if headline-included - (cl-loop for l from 0 to level do - (aset ltimes l (+ (aref ltimes l) t1)))) - (setq time (aref ltimes level)) - (goto-char (match-beginning 0)) - (put-text-property (point) (line-end-position) - (or propname :org-clock-minutes) time) - (when headline-filter - (save-excursion - (save-match-data - (while (org-up-heading-safe) - (put-text-property - (point) (line-end-position) - :org-clock-force-headline-inclusion t)))))) - (setq t1 0) - (cl-loop for l from level to (1- lmax) do - (aset ltimes l 0)))))))) - (setq org-clock-file-total-minutes (aref ltimes 0)))))) + `(,(or propname :org-clock-minutes) t)) + (org-element-map (org-element-parse-buffer 'element nil t) '(headline inlinetask) + (lambda (headline) + (when headline-filter + (unless + (save-excursion + (org-element-map headline '(headline inlinetask) + (lambda (child) + (goto-char (org-element-begin child)) + (funcall headline-filter)))) + (throw :org-element-skip nil))) + (let ((headline-total 0)) + (org-element-map (org-element-contents headline) 'clock + (lambda (el) + (let (duration) + (if + (eq 'running (org-element-property :status el)) + (progn + (when (and org-clock-report-include-clocking-task + (eq (org-clocking-buffer) (current-buffer)) + (eq (marker-position org-clock-hd-marker) + (org-element-begin headline)) + tstart + tend + (>= (float-time org-clock-start-time) tstart) + (<= (float-time org-clock-start-time) tend)) + (let ((time (floor (org-time-convert-to-integer + (time-since org-clock-start-time)) + 60))) + (setq duration time)))) + (let* ((timestamp (org-element-property :value el)) + (ts (float-time (org-timestamp-to-time timestamp))) + (te (float-time (org-timestamp-to-time timestamp t))) + (dt (- (if tend (min te tend) te) + (if tstart (max ts tstart) ts)))) + (setq duration (floor dt 60)))) + (when (> duration 0) + (setq headline-total (+ headline-total duration))))) + nil nil 'headline) + (put-text-property (org-element-begin headline) (1- (org-element-contents-begin headline)) + (or propname :org-clock-minutes) headline-total) + (org-element-lineage-map headline + (lambda (parent) + (put-text-property (org-element-begin parent) (1- (org-element-contents-begin parent)) + (or propname :org-clock-minutes) + (+ headline-total + (get-text-property (org-element-begin parent) + (or propname :org-clock-minutes))))) + 'headline) + (setq file-total (+ file-total headline-total))))) + (setq org-clock-file-total-minutes file-total)))) (defun org-clock-sum-current-item (&optional tstart) "Return time, clocked on current item in total." -- 2.41.0