From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp1.migadu.com ([2001:41d0:1008:1e59::1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms1.migadu.com with LMTPS id oMTwDqhNV2b0DAEAA41jLg (envelope-from ) for ; Wed, 29 May 2024 17:45:44 +0200 Received: from aspmx1.migadu.com ([2001:41d0:303:e16b::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp1.migadu.com with LMTPS id qG6/BqhNV2YlbQEA62LTzQ (envelope-from ) for ; Wed, 29 May 2024 17:45:44 +0200 X-Envelope-To: larch@yhetil.org Authentication-Results: aspmx1.migadu.com; dkim=pass header.d=hrdl.eu header.s=mail header.b=DMJmtuYJ; 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=reject) header.from=hrdl.eu ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=yhetil.org; s=key1; t=1716997544; 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:list-id:list-help:list-unsubscribe: list-subscribe:list-post:dkim-signature; bh=73A0wRV4O+Apr1KtdAhvMzK+ZGEBUt19jd9daUVoxZM=; b=ixgnpV/qBl/ElutfYz/fYABLzs3dEzW/XhI3a1ru/c9CY/PSeuL444t3KOUHoMIkt5gvBC HOdBD+aIAsSMu6VqTB0wcfWeDPYXuOAGKRFN9oy/OEl5KyuYOU8AO2Y4VzQHQpv8cbURe0 4daoui8J8jXdNNeclwXwUj5nAHF3uB8LTAeqFkO6XFBxsRfg10rB8N/wnqIPaZnLSpum78 PfwYppX+9KvxAn2bT3G9L0eCa1rnanIThJcdwoY0074J4Wb6coyerACp6bOuDCHg5NvJea 0yhJ/B4fotdka04ICQZlabLf0N3o1kYa3l/TIPPuwLpAAdqDm7pa8ntTBBZ1sw== ARC-Authentication-Results: i=1; aspmx1.migadu.com; dkim=pass header.d=hrdl.eu header.s=mail header.b=DMJmtuYJ; 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=reject) header.from=hrdl.eu ARC-Seal: i=1; s=key1; d=yhetil.org; t=1716997544; a=rsa-sha256; cv=none; b=s0/isUkP+ASbAkItJLqjSdrG8WecI0ysHHHk0r2/ltB7DS4Q+603l5ZHmnwy/GIem4iSyM VZibTFteMZ+XdNHqEfe8WtabjMRwxxFEMaXcfkYy5Eh0jPzFKewKJx+x7Qcvt4ZvRHe8P4 uANVxjMw3HKacIoIp7HoQSeiMKEZGZitLlRcteQ1rH6AaKFG/MDfRz7dS9AaUS0VpnreXt +BIBR58jl11EdScRtLXOqXv0n9Ty06AzEBdiIzIsa/XbgcPQioQ4V/qHIDKko1NvfK4rPh O9GXqA1x1ANUnmFHub08TTr0ouIVLjGLk07SYlqr115IMti1aByLarZaR4UTlg== 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 ACBAF56FA4 for ; Wed, 29 May 2024 17:45:43 +0200 (CEST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sCLTu-0007GA-38; Wed, 29 May 2024 11:44: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 1sCLTm-0006vs-O8 for emacs-orgmode@gnu.org; Wed, 29 May 2024 11:44:42 -0400 Received: from mail.hrdl.eu ([2a0a:4cc0:1:1b9::1]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1sCLTk-00071J-Q9 for emacs-orgmode@gnu.org; Wed, 29 May 2024 11:44:42 -0400 Date: Wed, 29 May 2024 17:44:33 +0200 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=hrdl.eu; s=mail; t=1716997475; bh=73A0wRV4O+Apr1KtdAhvMzK+ZGEBUt19jd9daUVoxZM=; h=Date:From:To:Subject; b=DMJmtuYJbisblMrFo+1Q/hQxrxZzyJuK1LIo2b5kONbU9LFiRSK1EGmd66JZpVvft gpQQ6suDI1byWYP1NcKheAfUs+kbTm2/GYE77vDe4O9mX2xhliPKqydepPEZCkRl/g nc0aXUNhlxKwrY+RKJBqmH8UGEEWuWtlTETaMks0= From: hrdl To: emacs-orgmode@gnu.org Subject: [BUG] org-agenda: incorrect display of multi-day date ranges [9.6.15 (release_9.6.15 @ /usr/share/emacs/29.3/lisp/org/)] Message-ID: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Received-SPF: pass client-ip=2a0a:4cc0:1:1b9::1; envelope-from=git@hrdl.eu; helo=mail.hrdl.eu 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, SPF_HELO_NONE=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-Spam-Score: -7.55 X-Spam-Score: -7.55 X-Migadu-Queue-Id: ACBAF56FA4 X-Migadu-Scanner: mx13.migadu.com X-TUID: hPD0pC8TotJr Parts of org-agenda do not handle time ranges spanning multiple days correctly. This is exarcabated when setting org-agenda-default-appointment-duration , which adds an incorrect end time to the entries corresponding to the start and end date. To reproduce: (prog (find-file "test.org") (insert "* Entry\n<2024-05-30 Thu 14:00>--<2024-05-31 Fri 16:00>") (save-buffer) (setq org-agenda-default-appointment-duration 30) ;; optional (org-agenda-file-to-front) (org-agenda-list) ;; Or, for ease of debugging (with-current-buffer "test.org" (setq date '(5 30 2024)) ;; Or 31 (org-agenda-get-blocks)) ) At the moment I use the following workaround, which would benefit from some feedback. >From 48192b14d3d5739467df7c41ac4e1e9c94f81ee4 Mon Sep 17 00:00:00 2001 From: hrdl Date: Wed, 29 May 2024 17:43:53 +0200 Subject: [PATCH] org-agenda: handle multi-day time ranges * lisp/org-agenda.el: (org-agenda-format-item, org-agenda-get-blocks): Handle start and end dates of multi-day time ranges --- lisp/org-agenda.el | 24 +++++++++++++++--------- 1 file changed, 15 insertions(+), 9 deletions(-) diff --git a/lisp/org-agenda.el b/lisp/org-agenda.el index 10f25be8a..2e4c01e50 100644 --- a/lisp/org-agenda.el +++ b/lisp/org-agenda.el @@ -6871,9 +6871,9 @@ scheduled items with an hour specification like [h]h:mm." ((and (= d1 d0) (= d2 d0)) (concat "<" start-time ">--<" end-time ">")) ((= d1 d0) - (concat "<" start-time ">")) + (concat "<" start-time ">--")) ((= d2 d0) - (concat "<" end-time ">"))) + (concat "--<" end-time ">"))) remove-re)))) (org-add-props txt props 'face face @@ -7013,21 +7013,24 @@ Any match of REMOVE-RE will be removed from TXT." ;; Normalize the time(s) to 24 hour. (when s1 (setq s1 (org-get-time-of-day s1 t))) (when s2 (setq s2 (org-get-time-of-day s2 t))) + ;; Possibly swap time(s) if this is an end timestamp of a multi-date time span + (when (and s1 (not s2) (string-prefix-p "--" dotime)) + (cl-rotatef s1 s2)) ;; Try to set s2 if s1 and ;; `org-agenda-default-appointment-duration' are set - (when (and s1 (not s2) org-agenda-default-appointment-duration) + (when (and s1 (not s2) (not (string-suffix-p "--" dotime)) org-agenda-default-appointment-duration) (setq s2 (org-duration-from-minutes (+ (org-duration-to-minutes s1 t) org-agenda-default-appointment-duration) nil t))) ;; Compute the duration - (when s2 + (when (and s1 s2) (setq duration (- (org-duration-to-minutes s2) (org-duration-to-minutes s1)))) ;; Format S1 and S2 for display. (when s1 (setq s1 (format "%5s" (org-get-time-of-day s1 'overtime)))) - (when s2 (setq s2 (org-get-time-of-day s2 'overtime)))) + (when s2 (setq s2 (format "%5s" (org-get-time-of-day s2 'overtime))))) (when (string-match org-tag-group-re txt) ;; Tags are in the string (if (or (eq org-agenda-remove-tags t) @@ -7065,14 +7068,17 @@ Any match of REMOVE-RE will be removed from TXT." ""))) (if (equal "" s) "" (concat s org-agenda-breadcrumbs-separator)))))) (setq time (cond (s2 (concat - (org-agenda-time-of-day-to-ampm-maybe s1) + (if s1 (org-agenda-time-of-day-to-ampm-maybe s1) + (make-string (if org-agenda-timegrid-use-ampm 7 5) ? )) "-" (org-agenda-time-of-day-to-ampm-maybe s2) (when org-agenda-timegrid-use-ampm " "))) (s1 (concat (org-agenda-time-of-day-to-ampm-maybe s1) - (if org-agenda-timegrid-use-ampm - (concat time-grid-trailing-characters " ") - time-grid-trailing-characters))) + (if (string-suffix-p "--" dotime) + (concat "-" (make-string (if org-agenda-timegrid-use-ampm 7 5) ? )) + (if org-agenda-timegrid-use-ampm + (concat time-grid-trailing-characters " ") + time-grid-trailing-characters)))) (t "")) category (if (symbolp category) (symbol-name category) category) level (or with-level "")) -- 2.45.1 Emacs : GNU Emacs 29.3 (build 1, x86_64-pc-linux-gnu, GTK+ Version 3.24.41, cairo version 1.18.0) Package: Org mode version 9.6.15 (release_9.6.15 @ /usr/share/emacs/29.3/lisp/org/)