all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Thomas Fitzsimmons <fitzsim@fitzsim.org>
To: Benjamin Leis <benleis1@gmail.com>
Cc: 68653@debbugs.gnu.org
Subject: bug#68653: Excorporate: generate better org timestamps
Date: Wed, 14 Feb 2024 22:38:44 -0500	[thread overview]
Message-ID: <m3wmr6v1kr.fsf@fitzsim.org> (raw)
In-Reply-To: <CADP9qHt_EVQ0+B24=tzoD-17=rzo76EutuLxVArtrY-n_ipnxQ@mail.gmail.com> (Benjamin Leis's message of "Sun, 21 Jan 2024 11:52:09 -0800")

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	other threads:[~2024-02-15  3:38 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-01-21 19:52 bug#68653: Excorporate: generate better org timestamps Benjamin Leis
2024-02-15  3:38 ` Thomas Fitzsimmons [this message]
2024-02-19 11:25   ` Ihor Radchenko
2024-02-19 14:07     ` Thomas Fitzsimmons

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=m3wmr6v1kr.fsf@fitzsim.org \
    --to=fitzsim@fitzsim.org \
    --cc=68653@debbugs.gnu.org \
    --cc=benleis1@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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.