From a005c7636f30b710e27a6812ca989506d5df7531 Mon Sep 17 00:00:00 2001 From: Craig Jennings Date: Sat, 16 May 2026 03:45:29 -0500 Subject: refactor(org-workflow): four hygiene fixes from the module-by-module re-review - org-roam-config.el: extract `cj/--org-roam-should-copy-completed-task-p' and gate the `org-after-todo-state-change-hook' on it. Skips fileless buffers (org-capture, indirect, temp Org) where `buffer-file-name' is nil and the downstream copy used to crash. Same gcal.org skip preserved. Five existing tests updated to bind `buffer-file-name' inside `run-hooks' so the positive-case hook still fires. - org-webclipper.el: drop the redundant `org-protocol-protocol-alist' registration inside `cj/webclipper-ensure-initialized'. The `with-eval-after-load 'org-protocol' block at the bottom of the module is the single registration site now; comment in the initializer explains why. Split the matching test into two: one for template registration (the initializer's actual job) and one for protocol registration (which now fires from the after-load block when `org-protocol' provides). - org-webclipper.el: validate `:url' and `:title' in `cj/org-protocol-webclip'. `:url' must be a non-empty string; `:title' must be a string when provided. Signals `user-error' with the unexpected value instead of silently setting the globals to nil and failing downstream in the capture handler. - mu4e-org-contacts-integration.el: declare `contacts-file' (via `eval-when-compile (defvar ...)') and `cj/get-all-contact-emails' (via `declare-function') near the top of the file. Byte-compile in isolation no longer warns about free variables / unknown functions; the cross-module dependency is explicit at the top. --- todo.org | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'todo.org') diff --git a/todo.org b/todo.org index 3e2194890..1bcab75b8 100644 --- a/todo.org +++ b/todo.org @@ -1594,7 +1594,7 @@ Expected outcome: - Keep startup quiet; only check expensive/external requirements when the relevant command runs. -**** TODO [#B] Guard the org-roam completed-task hook around non-file buffers :bug:refactor: +**** 2026-05-16 Sat @ 03:44:45 -0500 Guarded org-roam completed-task hook with cj/--org-roam-should-copy-completed-task-p =org-roam-config.el= adds a global =org-after-todo-state-change-hook= that copies newly completed tasks to today's org-roam journal. The hook assumes the @@ -1721,7 +1721,7 @@ Recommended improvement: - Link this note from the Org workflow review task and the broader load-graph refactor. -**** TODO [#C] De-duplicate =org-protocol-protocol-alist= registration in =org-webclipper= :cleanup: +**** 2026-05-16 Sat @ 03:44:45 -0500 Removed duplicate org-protocol-protocol-alist registration in cj/webclipper-ensure-initialized The =webclip= protocol handler is registered twice: =modules/org-webclipper.el:72-76= inside =cj/webclipper-ensure-initialized= @@ -1733,7 +1733,7 @@ the alist entry shape ever changes. Pick one site -- the =with-eval-after-load= block is the more robust location -- and remove the other. -**** TODO [#C] Validate =:url= and =:title= in =cj/org-protocol-webclip= :safety: +**** 2026-05-16 Sat @ 03:44:45 -0500 Validated :url and :title in cj/org-protocol-webclip before stashing =modules/org-webclipper.el:124-125= extracts =:url= and =:title= from the incoming protocol plist with no type or nil check. An unexpected @@ -1752,7 +1752,7 @@ corrupt each other's state. Pass the data through a plist on =org-capture-plist=, a per-invocation closure, or a queue, instead of global mutation. -**** TODO [#C] Declare cross-module free variables in =mu4e-org-contacts-integration.el= :cleanup:quick: +**** 2026-05-16 Sat @ 03:44:45 -0500 Declared cross-module free vars in mu4e-org-contacts-integration.el The module reads =contacts-file= (defined in =user-constants.el=) and calls =cj/get-all-contact-emails= (defined in =org-contacts-config.el=) -- cgit v1.2.3