emacs-elpa-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[elpa] externals-release/org fd8ddf2874 4/4: org-clock-sum: Gracefully s


From: ELPA Syncer
Subject: [elpa] externals-release/org fd8ddf2874 4/4: org-clock-sum: Gracefully skip invalid CLOCK lines
Date: Fri, 14 Jun 2024 09:58:42 -0400 (EDT)

branch: externals-release/org
commit fd8ddf2874ca00505aa096c6172ea750cd5e9eaa
Author: Ihor Radchenko <yantar92@posteo.net>
Commit: Ihor Radchenko <yantar92@posteo.net>

    org-clock-sum: Gracefully skip invalid CLOCK lines
    
    * lisp/org-clock.el (org-clock-sum): Skip invalid CLOCK
    lines (malformed or with times missing).  Display a warning.
    
    This brings back the old behavior with such CLOCK lines being silently
    skipped.  Now, we also display a warning.
    
    Reported-by: Robert Nyman <RKNyman@NymanTechnology.com>
    Link: 
https://list.orgmode.org/orgmode/0e2ed754-bc71-4558-9c46-f17d73981fe5@NymanTechnology.com/
---
 lisp/org-clock.el | 47 +++++++++++++++++++++++++----------------------
 1 file changed, 25 insertions(+), 22 deletions(-)

diff --git a/lisp/org-clock.el b/lisp/org-clock.el
index 5555bb1bc3..c6fd507b08 100644
--- a/lisp/org-clock.el
+++ b/lisp/org-clock.el
@@ -2048,28 +2048,31 @@ PROPNAME lets you set a custom text property instead of 
:org-clock-minutes."
            (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)))))
+              (condition-case nil
+                 (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))))
+                (error
+                 (org-display-warning (format "org-clock-sum: Ignoring invalid 
%s" (org-current-line-string))))))
             ((match-end 4)
              ;; A naked time.
              (setq t1 (+ t1 (string-to-number (match-string 5))



reply via email to

[Prev in Thread] Current Thread [Next in Thread]