branch: externals/org
commit dc2f270ac4bd74e454dd56bc0e91f74f10568a1c
Author: Ihor Radchenko <[email protected]>
Commit: Ihor Radchenko <[email protected]>
org-agenda: Fix multi-day ranges with non-nil
`org-agenda-default-appointment-duration'
* lisp/org-agenda.el (org-agenda-get-blocks): Force
`org-agenda-default-appointment-duration' to be nil for time blocks -
they already have begin/end time, even if during different days.
* testing/examples/agenda-file2.org (five):
* testing/lisp/test-org-agenda.el (test-org-agenda/time-grid): New
test.
Reported-by: hrdl <[email protected]>
Link: https://orgmode.org/list/[email protected]
---
lisp/org-agenda.el | 45 ++++++++++++++++++++++-----------------
testing/examples/agenda-file2.org | 2 ++
testing/lisp/test-org-agenda.el | 8 +++++++
3 files changed, 36 insertions(+), 19 deletions(-)
diff --git a/lisp/org-agenda.el b/lisp/org-agenda.el
index f807c00309..78b1c2abdf 100644
--- a/lisp/org-agenda.el
+++ b/lisp/org-agenda.el
@@ -6858,25 +6858,32 @@ scheduled items with an hour specification like
[h]h:mm."
"--"
"<" (regexp-quote end-time) ".*?>")
nil)))
- (setq txt (org-agenda-format-item
- (concat
- (when inactive? org-agenda-inactive-leader)
- (format
- (nth (if (= start-day end-day) 0 1)
- org-agenda-timerange-leaders)
- (1+ (- agenda-today start-day)) (1+ (- end-day
start-day))))
- (org-add-props head nil
- 'effort effort
- 'effort-minutes effort-minutes)
- level category tags
- (cond
- ((and (= start-day agenda-today) (= end-day
agenda-today))
- (concat "<" start-time ">--<" end-time ">"))
- ((= start-day agenda-today)
- (concat "<" start-time ">"))
- ((= end-day agenda-today)
- (concat "<" end-time ">")))
- remove-re))))
+ ;; `org-agenda-format-item' automatically creates a
+ ;; time range when
+ ;; `org-agenda-default-appointment-duration' is
+ ;; non-nil and only start/end time is given.
+ ;; We do not want it here, when the range spans
+ ;; multiple days.
+ (let ((org-agenda-default-appointment-duration nil))
+ (setq txt (org-agenda-format-item
+ (concat
+ (when inactive? org-agenda-inactive-leader)
+ (format
+ (nth (if (= start-day end-day) 0 1)
+ org-agenda-timerange-leaders)
+ (1+ (- agenda-today start-day)) (1+ (- end-day
start-day))))
+ (org-add-props head nil
+ 'effort effort
+ 'effort-minutes effort-minutes)
+ level category tags
+ (cond
+ ((and (= start-day agenda-today) (= end-day
agenda-today))
+ (concat "<" start-time ">--<" end-time ">"))
+ ((= start-day agenda-today)
+ (concat "<" start-time ">"))
+ ((= end-day agenda-today)
+ (concat "<" end-time ">")))
+ remove-re)))))
(org-add-props txt props
'face face
'org-marker marker 'org-hd-marker hdmarker
diff --git a/testing/examples/agenda-file2.org
b/testing/examples/agenda-file2.org
index ec413e71e9..258c77607d 100644
--- a/testing/examples/agenda-file2.org
+++ b/testing/examples/agenda-file2.org
@@ -6,3 +6,5 @@ SCHEDULED: <2024-01-17 Wed 10:00-12:30>
SCHEDULED: <2024-01-17 Wed 13:00-15:00>
* TODO four
SCHEDULED: <2024-01-17 Wed 19:00>
+* TODO five
+<2024-01-17 Wed 19:00>--<2024-01-18 Thu 18:00>
diff --git a/testing/lisp/test-org-agenda.el b/testing/lisp/test-org-agenda.el
index 72a005e714..778f91e8ec 100644
--- a/testing/lisp/test-org-agenda.el
+++ b/testing/lisp/test-org-agenda.el
@@ -168,6 +168,14 @@
(save-excursion
(goto-char (point-min))
(should (search-forward "agenda-file2:19:00-20:00 Scheduled: TODO
four")))
+ ;; `org-agenda-default-appointment-duration'
+ ;; should not affect date range in timestamps.
+ (save-excursion
+ (goto-char (point-min))
+ (should-not (re-search-forward "agenda-file2:19:00-20:00.+TODO five"
nil t)))
+ (save-excursion
+ (goto-char (point-min))
+ (should (search-forward "agenda-file2:19:00...... (1/2): TODO five")))
;; Bug
https://list.orgmode.org/orgmode/[email protected]/
(save-excursion
(goto-char (point-min))