aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCraig Jennings <c@cjennings.net>2026-06-12 10:12:31 -0500
committerCraig Jennings <c@cjennings.net>2026-06-12 10:13:28 -0500
commit4d9c9fa672ec57551fa8c9d2d25ea60b59dbef52 (patch)
tree65b71a6d920c078a943d72783987b451e2ce1d38
parent4a1ecf647270e49da1a185f4d52c2553e1fedba8 (diff)
downloaddotemacs-4d9c9fa672ec57551fa8c9d2d25ea60b59dbef52.tar.gz
dotemacs-4d9c9fa672ec57551fa8c9d2d25ea60b59dbef52.zip
fix(org-drill): let-bind org-refile-targets and target real drill files
cj/drill-refile used setq, permanently replacing the session-wide org-refile-targets so every refile anywhere offered only drill targets until restart; and its (drill-dir :maxlevel . 1) entry named a bound variable, which org reads as a directory string rather than a file list, so the drill side yielded nothing. Let-bind org-refile-targets and supply (directory-files drill-dir t "\\.org$") as the file list. The stale test (which asserted the buggy drill-dir spec) is rewritten into two: file-list targets and no global clobber.
-rw-r--r--modules/org-drill-config.el7
-rw-r--r--tests/test-org-drill-config-commands.el27
-rw-r--r--todo.org5
3 files changed, 27 insertions, 12 deletions
diff --git a/modules/org-drill-config.el b/modules/org-drill-config.el
index 296b0550..b2d2a509 100644
--- a/modules/org-drill-config.el
+++ b/modules/org-drill-config.el
@@ -95,9 +95,10 @@ With a prefix arg OTHER-DIR, prompt for the directory instead of `drill-dir'."
(defun cj/drill-refile ()
"Refile to a drill file."
(interactive)
- (setq org-refile-targets '((nil :maxlevel . 1)
- (drill-dir :maxlevel . 1)))
- (call-interactively 'org-refile))
+ (let ((org-refile-targets
+ `((nil :maxlevel . 1)
+ (,(directory-files drill-dir t "\\.org$") :maxlevel . 1))))
+ (call-interactively 'org-refile)))
;; ------------------------------- Drill Keymap --------------------------------
diff --git a/tests/test-org-drill-config-commands.el b/tests/test-org-drill-config-commands.el
index 7d197616..37d1f5c4 100644
--- a/tests/test-org-drill-config-commands.el
+++ b/tests/test-org-drill-config-commands.el
@@ -71,21 +71,34 @@
;;; cj/drill-refile
-(ert-deftest test-org-drill-refile-sets-targets-and-delegates ()
- "Normal: drill-refile narrows `org-refile-targets' to current buffer +
-`drill-dir', then dispatches to `org-refile' via `call-interactively'."
+(ert-deftest test-org-drill-refile-delegates-with-file-targets ()
+ "Normal: drill-refile dispatches to `org-refile' with current buffer +
+the list of drill .org files (not the `drill-dir' variable symbol)."
(let (seen-targets called-fn)
- (cl-letf (((symbol-function 'call-interactively)
+ (cl-letf (((symbol-function 'directory-files)
+ (lambda (&rest _) '("/tmp/cj-drill/a.org" "/tmp/cj-drill/b.org")))
+ ((symbol-function 'call-interactively)
(lambda (fn)
(setq called-fn fn
seen-targets org-refile-targets))))
(cj/drill-refile))
(should (eq called-fn 'org-refile))
- (should seen-targets)
- ;; Two entries: (nil :maxlevel . 1) and (drill-dir :maxlevel . 1).
(should (= 2 (length seen-targets)))
(should (assoc nil seen-targets))
- (should (assoc 'drill-dir seen-targets))))
+ ;; The drill entry's car is a real list of .org files, never the
+ ;; `drill-dir' symbol (org reads a bound symbol as the directory string).
+ (let ((files (car (nth 1 seen-targets))))
+ (should (equal files '("/tmp/cj-drill/a.org" "/tmp/cj-drill/b.org")))
+ (should-not (eq files 'drill-dir)))))
+
+(ert-deftest test-org-drill-refile-does-not-clobber-global-targets ()
+ "Error: drill-refile let-binds `org-refile-targets'; the session-wide value
+survives the call instead of being permanently replaced."
+ (let ((org-refile-targets '((sentinel :maxlevel . 9))))
+ (cl-letf (((symbol-function 'directory-files) (lambda (&rest _) nil))
+ ((symbol-function 'call-interactively) (lambda (_fn) nil)))
+ (cj/drill-refile))
+ (should (equal org-refile-targets '((sentinel :maxlevel . 9))))))
(provide 'test-org-drill-config-commands)
;;; test-org-drill-config-commands.el ends here
diff --git a/todo.org b/todo.org
index d1c03ae6..1f565cbb 100644
--- a/todo.org
+++ b/todo.org
@@ -813,8 +813,9 @@ From the 2026-06 config audit, =modules/calendar-sync.el=:
- =:1284= — curl runs without =--fail=: an HTTP 404/500 error page exits 0 and the HTML proceeds into conversion.
- =:1229-1233= — =--parse-ics= returns nil for both garbage and a valid calendar with zero in-window events, so healthy near-empty calendars report "parse failed" in =calendar-sync-status=. Distinguish the cases.
-** TODO [#B] drill-refile clobbers global org-refile-targets with an invalid spec :bug:quick:solo:
-=modules/org-drill-config.el:95-98= — =setq org-refile-targets= replaces the session-wide value, so after one drill refile every org-refile everywhere offers only drill targets until restart; and the =(drill-dir :maxlevel . 1)= spec names a directory-path variable where org expects files, so the drill side yields nothing usable. Let-bind around the call with =((directory-files drill-dir t "\\.org$") :maxlevel . 1)=. From the 2026-06 config audit.
+** DONE [#B] drill-refile clobbers global org-refile-targets with an invalid spec :bug:quick:solo:
+CLOSED: [2026-06-12 Fri]
+Fixed in =modules/org-drill-config.el=: =cj/drill-refile= now =let=-binds =org-refile-targets= (the session-wide value survives) and supplies =(directory-files drill-dir t "\\.org$")= as the file list instead of the bound =drill-dir= symbol (org reads a bound symbol as a directory string, which yielded nothing). Rewrote the stale test (it asserted the buggy =(assoc 'drill-dir ...)=) into two: targets are a real .org file list, and the global is not clobbered. Both red before, green after. Live-reloaded into the daemon.
** TODO [#B] ERC: double mention notifications + tautological server list :bug:quick:solo:
From the 2026-06 config audit, =modules/erc-config.el=: