From 7e0ac9d9fd2d7f539e07d785e4c26aa520513195 Mon Sep 17 00:00:00 2001 From: Craig Jennings Date: Thu, 16 Jul 2026 14:35:56 -0500 Subject: fix(org-agenda): hoist cj/timeformat out of the defun it was buried in cj/timeformat was defvar'd inside cj/add-timestamp-to-org-entry, so the symbol wasn't special until the command had run once. Until then a let around the call bound it lexically and never reached the function. I moved it to top level with a docstring. It has no other callers. The nested defvar also poisons tests. ERT runs alphabetically, so an earlier test that calls the command makes the symbol special retroactively. A later special-variable-p check then passes on test ordering rather than on the code, reading green in a full-file run and red in isolation. The new guard snapshots special-variable-p into a defconst at load, before any test body runs. I filled in the missing coverage: point and the following line survive the insert, empty and unicode time strings, an empty buffer, and a read-only buffer signalling rather than dropping the stamp. The empty-string case pins a trailing space (current behavior, characterized rather than changed). --- modules/org-agenda-config.el | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'modules') diff --git a/modules/org-agenda-config.el b/modules/org-agenda-config.el index d4407b28..632184e5 100644 --- a/modules/org-agenda-config.el +++ b/modules/org-agenda-config.el @@ -383,11 +383,14 @@ The agenda is rebuilt from all sources before display, including: ;; ------------------------- Add Timestamp To Org Entry ------------------------ ;; simply adds a timestamp to put the org entry on an agenda +(defvar cj/timeformat "%Y-%m-%d %a" + "Date format for the stamp `cj/add-timestamp-to-org-entry' inserts. +Must stay an org-readable date so the stamped line reaches the agenda.") + (defun cj/add-timestamp-to-org-entry (s) "Add an event with time S to appear underneath the line-at-point. This allows a line to show in an agenda without being scheduled or a deadline." (interactive "sTime: ") - (defvar cj/timeformat "%Y-%m-%d %a") (org-end-of-line) (save-excursion (open-line 1) -- cgit v1.2.3