bug-gnu-emacs
[Top][All Lists]
Advanced

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

bug#68653: Excorporate: generate better org timestamps


From: Thomas Fitzsimmons
Subject: bug#68653: Excorporate: generate better org timestamps
Date: Wed, 14 Feb 2024 22:38:44 -0500
User-agent: Gnus/5.13 (Gnus v5.13)

Hi Benjamin,

Thank you for the patch.  From my testing, when org-schedule is passed a
start and end date separated by "--", it only includes the start date in
the range.  Therefore, your patch as-is would be a regression because it
would omit the end date.

Unless I am missing something, an Org date range cannot express an end
timestamp on a different day.  I guess that is why I originally used the
<start>--<end> notation, and appended --<end> after the org-schedule
call.

Can you test the attached amended patch (whitespace-only changes
omitted) and confirm it works as you expect for same-day events, while
preserving the existing behaviour of end timestamps of multi-day events?

(A more ambitious plan would be to add support to Org for multi-day
ranges, then have Excorporate use that new format instead, but no users
have complained about --<end> so far, so I am fine continuing with that,
and adding the hour ranges as you suggest.)

Thank you,
Thomas

diff --git a/excorporate-org.el b/excorporate-org.el
index 74dbe9d111..f6bdc10fe3 100644
--- a/excorporate-org.el
+++ b/excorporate-org.el
@@ -251,11 +251,19 @@ defun exco-org-insert-meeting-headline
                      "TODO"
                    "DONE")))
     (insert (format "** %s %s\n" keyword subject))
+    ;; If the meeting times are on the same day use a time period
+    ;; otherwise use a range of days.
+    (if (= (time-to-day-in-year start-time) (time-to-day-in-year end-time))
+       (org-schedule
+        nil (format "<%s-%s>"
+                    (format-time-string "%Y-%m-%d %a %H:%M" start-time)
+                    (format-time-string "%H:%M" end-time)))
+      (progn
         (org-schedule nil (format-time-string "<%Y-%m-%d %a %H:%M>"
                                              start-time))
         (forward-line -1)
         (end-of-line)
-    (insert  "--" (format-time-string "<%Y-%m-%d %a %H:%M>" end-time))
+    (insert  "--" (format-time-string "<%Y-%m-%d %a %H:%M>" end-time))))
     (forward-line)
     (org-set-property "Identifier" (format "%S" item-identifier))
     (org-insert-time-stamp (current-time) t t "+ Retrieved " "\n")))





reply via email to

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