I have some issues with the org-agenda log-mode. `org-agenda-log-mode-items' tells us what to display in a log-mode agenda. It can be a list containing any combination of clock, state, and closed.
- clock means include any clocking data - state means include any state change data - has a list item that looks like: - State "x" from "y" <timestamp> - closed means include any items with the "CLOSED:" keyword set The `state' and `closed' have no overlap since they are looking for different metadata. I'm ok with the behavior but it is not well documented and should be. The main issues I have is the behavior caused by `org-agenda-start-with-log-mode' (which is very connected to `org-agenda-show-log' and `org-agenda-show-log-scoped'). If `org-agenda-start-with-log-mode' is set to a list it completely overrides `org-agenda-log-mode-items' which is not documented anywhere. Furthermore, in this case it starts including "scheduled" and "deadline" items!! What!?!?! (see attached patch for a fix for that). The other value `org-agenda-start-with-log-mode' can have is one of 'only or 'clockcheck. 'only is documented as "Show only log items". In reality, 'only means enable log-mode and defer to `org-agenda-log-mode-items' for what to include. 'clockcheck is documented as "Show all possible log items". In reality, 'clockcheck means show only clock items and run `org-agenda-show-clocking-issues'. 'clockcheck is also the only customization that allows automatically running `org-agenda-show-clocking-issues'. We can show clocking issues just fine when other items are in the log-mode buffer. I'm quite puzzled as to why 'clockcheck overrides the value of `org-agenda-log-mode-items'. Changes I want to make: I'm going to say a series of sweeping changes here. Obviously if I where to implement them I'd make sure to follow proper deprecation procedure and try not the break user customizations. `org-agenda-start-with-log-mode' - better documentation - change 'only value to t (not sure why it's called only) - make `clockcheck' value not override `org-agenda-log-mode-items' - don't allow setting log-mode-items from here (why is this even a thing?) `org-agenda-log-mode-items' - better documentation
>From bfd36096af3d6d736c66ea7c7251d5ff3e121dd2 Mon Sep 17 00:00:00 2001 From: Morgan Smith <[email protected]> Date: Fri, 22 May 2026 15:12:44 -0400 Subject: [PATCH 1/2] org-agenda: Prevent some items from appearing in log-mode If `org-agenda-start-with-log-mode' was set to a list of log mode items (of the format of `org-agenda-log-mode-items') then scheduled and deadline items could start appearing in log-mode sections. This prevents that from happening. * lisp/org-agenda.el (org-agenda-list): Do not include entries that match `org-agenda-entry-types' when `org-agenda-show-log-scoped' is a list. --- lisp/org-agenda.el | 14 ++++---------- 1 file changed, 4 insertions(+), 10 deletions(-) diff --git a/lisp/org-agenda.el b/lisp/org-agenda.el index f3dec749d..1dca68196 100644 --- a/lisp/org-agenda.el +++ b/lisp/org-agenda.el @@ -4509,18 +4509,12 @@ org-agenda-list (unless org-agenda-include-deadlines (setq org-agenda-entry-types (delq :deadline* (delq :deadline org-agenda-entry-types)))) - (cond - ((memq org-agenda-show-log-scoped '(only clockcheck)) - (setq rtn (org-agenda-get-day-entries - file date :closed))) - (org-agenda-show-log-scoped + (if org-agenda-show-log-scoped + (setq rtn (org-agenda-get-day-entries + file date :closed)) (setq rtn (apply #'org-agenda-get-day-entries file date - (append '(:closed) org-agenda-entry-types)))) - (t - (setq rtn (apply #'org-agenda-get-day-entries - file date - org-agenda-entry-types))))) + org-agenda-entry-types)))) (setq rtnall (append rtnall rtn)))) ;; all entries (when org-agenda-include-diary (let ((org-agenda-search-headline-for-time t)) base-commit: 1f5bba867b25b212b4d6d081879110e696d31813 -- 2.54.0
>From 66a4c763eaa2c934d6cc0110f5c17089378a3ff7 Mon Sep 17 00:00:00 2001 From: Morgan Smith <[email protected]> Date: Fri, 22 May 2026 15:14:19 -0400 Subject: [PATCH 2/2] test-org-agenda/log-mode: New test * testing/lisp/test-org-agenda.el (test-org-agenda/log-mode): New test. --- testing/lisp/test-org-agenda.el | 117 ++++++++++++++++++++++++++++++++ 1 file changed, 117 insertions(+) diff --git a/testing/lisp/test-org-agenda.el b/testing/lisp/test-org-agenda.el index 9af012b7d..616ee9e97 100644 --- a/testing/lisp/test-org-agenda.el +++ b/testing/lisp/test-org-agenda.el @@ -1134,6 +1134,123 @@ test-org-agenda/bulk-custom-arg-func (should (= arg-f-call-cnt 1)) (should (equal f-called-args '(1 2 3)))))) +(ert-deftest test-org-agenda/log-mode () + "Test agenda in \"log mode\"." + (org-test-at-time "2026-05-20" + (org-test-agenda-with-agenda "* follow golden rule +DEADLINE: <2026-05-22> +CLOCK: [2026-05-21 Thu 10:00]--[2026-05-21 Thu 10:01] => 0:01 +* DONE write more tests +CLOSED: [2026-05-22 Fri 10:10] +:LOGBOOK: +CLOCK: [2026-05-22 Fri 10:10]--[2026-05-22 Fri 10:30] => 0:20 +- wrote test `test-org-agenda/log-mode' +CLOCK: [2026-05-20 Wed 10:37]--[2026-05-20 Wed 10:49] => 0:12 +:END: +* TODO do everyday +SCHEDULED: <2026-05-22 Fri +1d> +- State \"DONE\" from \"STRT\" [2026-05-21 Thu 09:00] +- State \"STRT\" from \"TODO\" [2026-05-21 Thu 08:00] +- State \"DONE\" from \"STRT\" [2026-05-20 Wed 15:57] +- State \"STRT\" from \"TODO\" [2026-05-20 Wed 12:57] +:LOGBOOK: +CLOCK: [2026-05-22 Fri 09:00]--[2026-05-22 Fri 10:00] => 1:00 +CLOCK: [2026-05-21 Thu 08:00]--[2026-05-21 Thu 09:00] => 1:00 +CLOCK: [2026-05-20 Wed 12:57]--[2026-05-20 Wed 15:57] => 3:00 +:END:" + (let ((org-agenda-custom-commands + '(("l" "log-mode" agenda "" + ((org-agenda-overriding-header "") + (org-agenda-use-time-grid nil) + (org-agenda-prefix-format "%?-12t% s") + (org-agenda-format-date "%F") + (org-agenda-show-all-dates nil))))) + ;; FIXME: Add tests for changing this variable + (org-agenda-log-mode-items '(closed clock state)) + ;; Every combination (ignoring order) + (log-mode-items-possible-values + '((closed) (clock) (state) + (closed clock) (closed state) (clock state) + (closed clock state)))) + (dolist (org-agenda-start-with-log-mode + (append '(only clockcheck) log-mode-items-possible-values)) + (should + (string-equal + (string-trim + (progn + (org-agenda nil "l") + (substring-no-properties (buffer-string)))) + (pcase-exhaustive org-agenda-start-with-log-mode + ((or 'only '(closed clock state)) + "2026-05-20 +10:37-10:49 Clocked: (0:12) DONE write more tests +12:57-15:57 Clocked: (3:00) TODO do everyday +15:57...... State: (DONE) TODO do everyday +2026-05-21 + 8:00-9:00 Clocked: (1:00) TODO do everyday + 9:00...... State: (DONE) TODO do everyday +10:00-10:01 Clocked: (0:01) follow golden rule +2026-05-22 + 9:00-10:00 Clocked: (1:00) TODO do everyday +10:10...... Closed: DONE write more tests +10:10-10:30 Clocked: (0:20) DONE write more tests - wrote test `test-org-agenda/log-mode'") + ('clockcheck + "2026-05-20 +10:37-10:49 Clocked: (0:12) DONE write more tests +12:57-15:57 Clocked: (3:00) TODO do everyday +2026-05-21 + 8:00-9:00 Clocked: (1:00) TODO do everyday +10:00-10:01 Clocked: (0:01) follow golden rule +2026-05-22 + 9:00-10:00 Clocked: (1:00) TODO do everyday +10:10-10:30 Clocked: (0:20) DONE write more tests - wrote test `test-org-agenda/log-mode'") + ('(closed) + "2026-05-22\n10:10...... Closed: DONE write more tests") + ('(clock) + "2026-05-20 +10:37-10:49 Clocked: (0:12) DONE write more tests +12:57-15:57 Clocked: (3:00) TODO do everyday +2026-05-21 + 8:00-9:00 Clocked: (1:00) TODO do everyday +10:00-10:01 Clocked: (0:01) follow golden rule +2026-05-22 + 9:00-10:00 Clocked: (1:00) TODO do everyday +10:10-10:30 Clocked: (0:20) DONE write more tests - wrote test `test-org-agenda/log-mode'") + ('(state) + "2026-05-20 +15:57...... State: (DONE) TODO do everyday +2026-05-21 + 9:00...... State: (DONE) TODO do everyday") + ('(closed clock) + "2026-05-20 +10:37-10:49 Clocked: (0:12) DONE write more tests +12:57-15:57 Clocked: (3:00) TODO do everyday +2026-05-21 + 8:00-9:00 Clocked: (1:00) TODO do everyday +10:00-10:01 Clocked: (0:01) follow golden rule +2026-05-22 + 9:00-10:00 Clocked: (1:00) TODO do everyday +10:10...... Closed: DONE write more tests +10:10-10:30 Clocked: (0:20) DONE write more tests - wrote test `test-org-agenda/log-mode'") + ('(closed state) + "2026-05-20 +15:57...... State: (DONE) TODO do everyday +2026-05-21 + 9:00...... State: (DONE) TODO do everyday +2026-05-22 +10:10...... Closed: DONE write more tests") + ('(clock state) + "2026-05-20 +10:37-10:49 Clocked: (0:12) DONE write more tests +12:57-15:57 Clocked: (3:00) TODO do everyday +15:57...... State: (DONE) TODO do everyday +2026-05-21 + 8:00-9:00 Clocked: (1:00) TODO do everyday + 9:00...... State: (DONE) TODO do everyday +10:00-10:01 Clocked: (0:01) follow golden rule +2026-05-22 + 9:00-10:00 Clocked: (1:00) TODO do everyday +10:10-10:30 Clocked: (0:20) DONE write more tests - wrote test `test-org-agenda/log-mode'"))))))))) (provide 'test-org-agenda) -- 2.54.0
