all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* bug#68653: Excorporate: generate better org timestamps
@ 2024-01-21 19:52 Benjamin Leis
  2024-02-15  3:38 ` Thomas Fitzsimmons
  0 siblings, 1 reply; 4+ messages in thread
From: Benjamin Leis @ 2024-01-21 19:52 UTC (permalink / raw)
  To: 68653


[-- Attachment #1.1: Type: text/plain, Size: 1 bytes --]



[-- Attachment #1.2: Type: text/html, Size: 26 bytes --]

[-- Attachment #2: patch --]
[-- Type: application/octet-stream, Size: 1322 bytes --]

diff --git a/excorporate-org.el b/excorporate-org.el
index 74dbe9d..56863c4 100644
--- a/excorporate-org.el
+++ b/excorporate-org.el
@@ -1,4 +1,4 @@
-;;; excorporate-org.el --- Exchange Org Mode view     -*- lexical-binding: t -*-
+xs;;; excorporate-org.el --- Exchange Org Mode view     -*- lexical-binding: t -*-
 
 ;; Copyright (C) 2016-2020 Free Software Foundation, Inc.
 
@@ -251,11 +251,12 @@ identifier."
 		      "TODO"
 		    "DONE")))
     (insert (format "** %s %s\n" keyword subject))
-    (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))
+    ;; 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)))
+      (org-schedule nil (format "<%s>--<%s>" (format-time-string "%Y-%m-%d %a %H:%M" start-time)
+				(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")))

^ permalink raw reply related	[flat|nested] 4+ messages in thread

* bug#68653: Excorporate: generate better org timestamps
  2024-01-21 19:52 bug#68653: Excorporate: generate better org timestamps Benjamin Leis
@ 2024-02-15  3:38 ` Thomas Fitzsimmons
  2024-02-19 11:25   ` Ihor Radchenko
  0 siblings, 1 reply; 4+ messages in thread
From: Thomas Fitzsimmons @ 2024-02-15  3:38 UTC (permalink / raw)
  To: Benjamin Leis; +Cc: 68653

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")))





^ permalink raw reply related	[flat|nested] 4+ messages in thread

* bug#68653: Excorporate: generate better org timestamps
  2024-02-15  3:38 ` Thomas Fitzsimmons
@ 2024-02-19 11:25   ` Ihor Radchenko
  2024-02-19 14:07     ` Thomas Fitzsimmons
  0 siblings, 1 reply; 4+ messages in thread
From: Ihor Radchenko @ 2024-02-19 11:25 UTC (permalink / raw)
  To: Thomas Fitzsimmons; +Cc: Benjamin Leis, 68653

Thomas Fitzsimmons <fitzsim@fitzsim.org> writes:

> 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.

Note that Org mode schedule does not support date ranges.
It is recommended to use bare active timestamps for scheduling.
See "Important" note in https://orgmode.org/manual/Deadlines-and-Scheduling.html

> Unless I am missing something, an Org date range cannot express an end
> timestamp on a different day.

Org date range does allow multi-day ranges.
See https://orgmode.org/manual/Timestamps.html#index-timerange

-- 
Ihor Radchenko // yantar92,
Org mode contributor,
Learn more about Org mode at <https://orgmode.org/>.
Support Org development at <https://liberapay.com/org-mode>,
or support my work at <https://liberapay.com/yantar92>





^ permalink raw reply	[flat|nested] 4+ messages in thread

* bug#68653: Excorporate: generate better org timestamps
  2024-02-19 11:25   ` Ihor Radchenko
@ 2024-02-19 14:07     ` Thomas Fitzsimmons
  0 siblings, 0 replies; 4+ messages in thread
From: Thomas Fitzsimmons @ 2024-02-19 14:07 UTC (permalink / raw)
  To: Ihor Radchenko; +Cc: Benjamin Leis, 68653-done

Hi Ihor,

Ihor Radchenko <yantar92@posteo.net> writes:

> Thomas Fitzsimmons <fitzsim@fitzsim.org> writes:
>
>> 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.
>
> Note that Org mode schedule does not support date ranges.
> It is recommended to use bare active timestamps for scheduling.
> See "Important" note in https://orgmode.org/manual/Deadlines-and-Scheduling.html
>
>> Unless I am missing something, an Org date range cannot express an end
>> timestamp on a different day.
>
> Org date range does allow multi-day ranges.
> See https://orgmode.org/manual/Timestamps.html#index-timerange

OK, I was focusing on:

(org-schedule nil "<2024-08-23 Fri>--<2024-08-26 Mon>")
SCHEDULED: <2024-08-23 Fri>
"Scheduled to <2024-08-23 Fri>"

Thank you for clarifying this.  I think it is worth preserving the
multi-day behaviour in Excorporate, but Benjamin's patch is a nice
addition for same-day ranges.

I pushed the amended patch, and I am closing this bug report.

The change will go out with Excorporate 1.1.2 sometime today.

Thank you,
Thomas





^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2024-02-19 14:07 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-01-21 19:52 bug#68653: Excorporate: generate better org timestamps Benjamin Leis
2024-02-15  3:38 ` Thomas Fitzsimmons
2024-02-19 11:25   ` Ihor Radchenko
2024-02-19 14:07     ` Thomas Fitzsimmons

Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.