aboutsummaryrefslogtreecommitdiff
path: root/modules/org-capture-config.el
diff options
context:
space:
mode:
authorCraig Jennings <c@cjennings.net>2026-05-24 04:25:24 -0500
committerCraig Jennings <c@cjennings.net>2026-05-24 04:25:24 -0500
commit9c0fc70aa731b016b4805ff701686cebf49ffb96 (patch)
tree3fdc78ab79ad1dcf5ddd9a49a4f82dc9b65a06bc /modules/org-capture-config.el
parentb76c33845e30363187100ee22108946cbeb6a49c (diff)
downloaddotemacs-9c0fc70aa731b016b4805ff701686cebf49ffb96.tar.gz
dotemacs-9c0fc70aa731b016b4805ff701686cebf49ffb96.zip
refactor(org-drill): share one validated drill-file selector
org-capture-config.el and org-drill-config.el each scanned drill-dir with an inline directory-files call, so a missing, empty, or unreadable drill-dir surfaced as a low-level directory-files error or an empty completing-read, depending on which command ran. Added cj/--drill-files-or-error, the single validated entry point: it signals a clear user-error when the directory is missing, unreadable, or has no drill files, and otherwise returns the list. cj/--drill-pick-file and both drill capture templates now route through it. The pure cj/--drill-files-in primitive and its tests are unchanged. Tests cover missing dir, empty dir, a non-org-only dir, and a normal listing.
Diffstat (limited to 'modules/org-capture-config.el')
-rw-r--r--modules/org-capture-config.el13
1 files changed, 3 insertions, 10 deletions
diff --git a/modules/org-capture-config.el b/modules/org-capture-config.el
index 5cd76f0af..39cafe038 100644
--- a/modules/org-capture-config.el
+++ b/modules/org-capture-config.el
@@ -18,6 +18,7 @@
(defvar org-capture-templates)
(defvar org-complex-heading-regexp-format)
+(declare-function cj/--drill-pick-file "org-drill-config")
(declare-function org-at-encrypted-entry-p "org-crypt")
(declare-function org-at-heading-p "org")
(declare-function org-back-to-heading "org")
@@ -230,21 +231,13 @@ Captured On: %U"
:prepend t)
("d" "Drill Question" entry
- (file (lambda ()
- (let ((files (directory-files drill-dir nil "^[^.].*\\.org$")))
- (expand-file-name
- (completing-read "Choose file: " files)
- drill-dir))))
+ (file (lambda () (cj/--drill-pick-file drill-dir)))
"* Item :drill:\n%?
** Answer\n%i\nSource: [[%:link][%:description]]
Captured On: %U" :prepend t)
("f" "Drill Question (from PDF)" entry
- (file (lambda ()
- (let ((files (directory-files drill-dir nil "^[^.].*\\.org$")))
- (expand-file-name
- (completing-read "Choose file: " files)
- drill-dir))))
+ (file (lambda () (cj/--drill-pick-file drill-dir)))
"* Item :drill:\n%?
** Answer\n%(cj/org-capture-pdf-active-region)
Source: [[%L][%(buffer-name (org-capture-get :original-buffer))]]