Gary Oberbrunner <[email protected]> writes:

> In my org files, apparently I have an empty agenda item somewhere. This
> causes org-agenda-to-appt to fail with this backtrace:
>
> Debugger entered--Lisp error: (args-out-of-range 1 1)
>   get-text-property(1 txt "")
>   #f(compiled-function (x) #<bytecode -0x17bb48bdbfe28efb>)("")
>   org-agenda-to-appt()
>
> I'm not sure where the empty-string item comes from, but this simple
> patch to remove empty-string entries fixes it:

I'm struggling to recreate the error.  If you could find where it comes
from that would be very helpful.  I've created the attached test suite
but it does not error.

>From 6020e5ee7691d5c534cf9ab46b28f617bbb14695 Mon Sep 17 00:00:00 2001
From: Morgan Smith <[email protected]>
Date: Thu, 9 Oct 2025 13:12:22 -0400
Subject: [PATCH] test-org/org-agenda-to-appt: New test

testing/lisp/test-org-agenda.el (test-org/org-agenda-to-appt): New
test.
---
 testing/lisp/test-org-agenda.el | 43 +++++++++++++++++++++++++++++++++
 1 file changed, 43 insertions(+)

diff --git a/testing/lisp/test-org-agenda.el b/testing/lisp/test-org-agenda.el
index e59461bdb..c49c643bd 100644
--- a/testing/lisp/test-org-agenda.el
+++ b/testing/lisp/test-org-agenda.el
@@ -957,6 +957,49 @@ test-org-agenda/bulk-custom-arg-func
       (should (= arg-f-call-cnt 1))
       (should (equal f-called-args '(1 2 3))))))
 
+;; Agenda integrations
+
+(defvar appt-time-msg-list)
+(ert-deftest test-org/org-agenda-to-appt ()
+  "Test `org-agenda-to-appt'."
+  (org-test-at-time "2024-01-17"
+    (cl-macrolet
+        ((org-test-agenda-to-appt (agenda-string
+                                   &rest body)
+           `(let (appt-time-msg-list)
+              (org-test-agenda-with-agenda ,agenda-string
+                (org-agenda-to-appt)
+                ,@body))))
+
+      (org-test-agenda-to-appt
+       "* TODO a\nSCHEDULED: <2024-01-17 16:00>"
+       (should (string-equal
+                (nth 1 (car appt-time-msg-list))
+                "16:00 TODO a")))
+      (org-test-agenda-to-appt
+       "* TODO a\nDEADLINE: <2024-01-17 16:00>"
+       (should (string-equal
+                (nth 1 (car appt-time-msg-list))
+                "16:00 TODO a")))
+      (org-test-agenda-to-appt
+       "* TODO\nSCHEDULED: <2024-01-17 16:00>"
+       (should (string-equal
+                (nth 1 (car appt-time-msg-list))
+                "16:00 TODO")))
+      ;; TODO: This doesn't seem right...
+      (org-test-agenda-to-appt
+       "*   :tag:\nSCHEDULED: <2024-01-17 16:00>"
+       (should (string-equal
+                (nth 1 (car appt-time-msg-list))
+                "16:00 :tag:                                       :tag:")))
+      (org-test-agenda-to-appt
+       "*\nSCHEDULED: <2024-01-17 16:00>"
+       (should (null appt-time-msg-list)))
+      (org-test-agenda-to-appt
+       "* \nSCHEDULED: <2024-01-17 16:00>"
+       (should (string-equal
+                (nth 1 (car appt-time-msg-list))
+                "16:00 "))))))
 
 
 (provide 'test-org-agenda)
-- 
2.51.0

Reply via email to